From 183d17f96ca36c052fddf604ed5897980f120214 Mon Sep 17 00:00:00 2001 From: aHappend <228031504+aHappend@users.noreply.github.com> Date: Thu, 10 Sep 2026 10:31:33 +0000 Subject: [PATCH 1/3] Add optional bilingual CrystalPilot plugins to Argus 0.1.3 --- .gitignore | 3 + .../adapters/agent_cli_backend/_core.py | 18 +- .../adapters/agent_cli_backend/_exec.py | 16 + argus_skill/agent_cli/_acp_routing.py | 4 + argus_skill/agent_cli/_prompt_delivery.py | 7 + argus_skill/agent_cli/_sandbox_commands.py | 33 +- argus_skill/agent_cli/agent_cli_runner.py | 3 + argus_skill/apps/_runtime_execute.py | 55 ++ argus_skill/core/models.py | 3 + argus_skill/core/plugin_manager.py | 620 ++++++++++++++++++ argus_skill/core/plugin_runtime.py | 234 +++++++ argus_skill/core/pricing.py | 5 + argus_skill/core/runner_errors.py | 124 +++- argus_skill/core/session.py | 6 +- argus_skill/core/usage.py | 340 ++++------ argus_skill/core/workbench_plugins.py | 80 +++ argus_skill/plugin_catalog.json | 73 +++ argus_skill/release.py | 21 + argus_skill/release_manifest.json | 4 +- argus_skill/release_tools/build_plugins.py | 93 +++ argus_skill/release_tools/build_release.py | 13 + .../release_tools/verify_plugin_install.py | 65 ++ argus_skill/roles/prompts/manager.py | 3 + argus_skill/verticals/_base.py | 3 +- argus_skill/verticals/_registry.py | 11 +- argus_skill/webapi/daemon_lifecycle.py | 6 +- argus_skill/webapi/manager_bridge.py | 13 + argus_skill/webapi/routes/plugins.py | 101 +++ argus_skill/webapi/server.py | 2 + desktop-tauri/argus_backend.spec | 12 +- docs/ci-examples/plugin-compatibility.yml | 36 + docs/workbench-plugins.md | 37 ++ frontend/core/src/commands.ts | 3 +- frontend/core/src/release.generated.ts | 4 +- frontend/tui/bundle/argus.mjs | 6 +- frontend/tui/src/appSlashDispatch.ts | 3 + frontend/web/dist/assets/MapPanel-BHfjXA2X.js | 12 + .../assets/ResearchWorkbenchPanel-B7craOIV.js | 10 + .../ResearchWorkbenchPanel-BXRghxPt.css | 1 + frontend/web/dist/assets/index-CWCNOzy_.css | 1 + frontend/web/dist/assets/index-CpMiioIG.js | 32 + frontend/web/dist/assets/play-4uDgOsGD.js | 1 + frontend/web/dist/index.html | 4 +- .../web/src/components/PluginEnvironment.tsx | 90 +++ .../web/src/components/PluginLauncher.tsx | 98 +++ frontend/web/src/components/Sidebar.tsx | 2 + frontend/web/src/lib/commandI18n.ts | 1 + frontend/web/src/lib/pluginEnglish.json | 113 ++++ frontend/web/src/lib/pluginText.ts | 25 + frontend/web/src/lib/webCommands.ts | 4 +- frontend/web/src/test/pluginText.test.ts | 16 + frontend/web/src/test/webCommands.test.ts | 6 +- pyproject.toml | 2 + tests/apps/test_runtime_packaged_skills.py | 127 ++++ tests/core/test_codex_startup_billing.py | 62 ++ tests/core/test_external_plugin_release.py | 48 ++ tests/core/test_plugin_manager.py | 135 ++++ tests/core/test_plugin_runtime.py | 129 ++++ tests/core/test_release.py | 15 + uv.lock | 30 + 60 files changed, 2762 insertions(+), 262 deletions(-) create mode 100644 argus_skill/core/plugin_manager.py create mode 100644 argus_skill/core/plugin_runtime.py create mode 100644 argus_skill/core/workbench_plugins.py create mode 100644 argus_skill/plugin_catalog.json create mode 100644 argus_skill/release_tools/build_plugins.py create mode 100644 argus_skill/release_tools/verify_plugin_install.py create mode 100644 argus_skill/webapi/routes/plugins.py create mode 100644 docs/ci-examples/plugin-compatibility.yml create mode 100644 docs/workbench-plugins.md create mode 100644 frontend/web/dist/assets/MapPanel-BHfjXA2X.js create mode 100644 frontend/web/dist/assets/ResearchWorkbenchPanel-B7craOIV.js create mode 100644 frontend/web/dist/assets/ResearchWorkbenchPanel-BXRghxPt.css create mode 100644 frontend/web/dist/assets/index-CWCNOzy_.css create mode 100644 frontend/web/dist/assets/index-CpMiioIG.js create mode 100644 frontend/web/dist/assets/play-4uDgOsGD.js create mode 100644 frontend/web/src/components/PluginEnvironment.tsx create mode 100644 frontend/web/src/components/PluginLauncher.tsx create mode 100644 frontend/web/src/lib/pluginEnglish.json create mode 100644 frontend/web/src/lib/pluginText.ts create mode 100644 frontend/web/src/test/pluginText.test.ts create mode 100644 tests/apps/test_runtime_packaged_skills.py create mode 100644 tests/core/test_codex_startup_billing.py create mode 100644 tests/core/test_external_plugin_release.py create mode 100644 tests/core/test_plugin_manager.py create mode 100644 tests/core/test_plugin_runtime.py diff --git a/.gitignore b/.gitignore index 074820626..3ee41a1a3 100644 --- a/.gitignore +++ b/.gitignore @@ -131,3 +131,6 @@ docs/Argus_BP* # proprietary binary/npm release staging /dist-binary/ /.pyinstaller/ + +# Optional plugin release assets are published separately. +/dist-plugins/ diff --git a/argus_skill/adapters/agent_cli_backend/_core.py b/argus_skill/adapters/agent_cli_backend/_core.py index d61bbf546..869e4892e 100644 --- a/argus_skill/adapters/agent_cli_backend/_core.py +++ b/argus_skill/adapters/agent_cli_backend/_core.py @@ -420,6 +420,14 @@ def _close_io_context(self, call_id: str) -> None: self._io_logger.close(call_id) def _stream_event_callback(self, stream: str, line: str) -> None: + options = getattr(self, "_plugin_execution_options", None) + if options is not None and getattr(options, "extension_env", None): + from ...core.workbench_plugins import observe_plugin_stream + try: + from ...core.secret_guard import redact_secrets_text + observe_plugin_stream(options, stream, redact_secrets_text(line, known_values=self._known_secret_values)) + except Exception: + log.exception("Plugin stream projection failed") self._repeated_tool_call_guard.observe(stream, line) self._io_logger.stream_event_callback( stream, @@ -488,6 +496,9 @@ def _translate_options(self, options: RunnerOptions): watchdog_soft_idle_seconds=soft_idle, watchdog_hard_idle_seconds=hard_idle, ) + for plugin_field in ("trusted_extensions", "trusted_tool_names", "extension_env"): + if plugin_field in option_fields: + kwargs[plugin_field] = getattr(options, plugin_field, None) if "watchdog_stalled_idle_seconds" in option_fields: kwargs["watchdog_stalled_idle_seconds"] = stalled_idle # Forward live_search ONLY when the target RunnerOptions supports it — @@ -565,7 +576,7 @@ def _premium_delta_for_thread( # --- Convenience factory --------------------------------------------------- -def build_agent_cli_backend_from_env() -> AgentCliBackend: +def build_agent_cli_backend_from_env(*, role: str | None = None) -> AgentCliBackend: """Build a AgentCliBackend from environment variables. Honours: @@ -587,9 +598,12 @@ def build_agent_cli_backend_from_env() -> AgentCliBackend: import shlex backend = os.environ.get("ARGUS_SKILL_RUNNER_BACKEND", "").strip() or "codex" + if role: + from ...core.role_config import resolve_role_config + backend = resolve_role_config(role).backend from ...core.knobs import resolve_runner_bin_setting - runner_bin = resolve_runner_bin_setting(backend=backend) or None + runner_bin = resolve_runner_bin_setting(role=role, backend=backend) or None raw_extra = os.environ.get("ARGUS_SKILL_RUNNER_EXTRA_ARGS", "").strip() extra = _strip_legacy_codex_profile_args(shlex.split(raw_extra) if raw_extra else None) return AgentCliBackend( diff --git a/argus_skill/adapters/agent_cli_backend/_exec.py b/argus_skill/adapters/agent_cli_backend/_exec.py index 698321ecb..1e4263f28 100644 --- a/argus_skill/adapters/agent_cli_backend/_exec.py +++ b/argus_skill/adapters/agent_cli_backend/_exec.py @@ -48,6 +48,18 @@ def execute( # The generated command, reservation, and settled usage record therefore # share one model id instead of independently guessing after the call. options = backend._resolve_execution_options(options) + from ...core.workbench_plugins import prepare_plugin_run + prompt, options = prepare_plugin_run(prompt, options, + backend=backend._runner.backend, run_label=run_label) + backend._plugin_execution_options = options + try: + return _execute_prepared(backend, prompt=prompt, options=options, run_label=run_label, resume_thread_id=resume_thread_id) + finally: + from ...core.workbench_plugins import finish_plugin_run + finish_plugin_run(options) + + +def _execute_prepared(backend, *, prompt, options, run_label, resume_thread_id): # Reset per-call: the flag is checked AFTER this call completes, # so stale True from a previous call cannot stick across missions. backend._auth_failure_detected = False @@ -59,6 +71,10 @@ def execute( ) if usage_project_root is None and log_path is not None: usage_project_root = log_path.parent + from ...core.workbench_plugins import plugin_accounting_root + accounting_root = plugin_accounting_root(usage_project_root) + if accounting_root is not None: + usage_global_root = accounting_root io_context = backend._io_logger.start_call( call_id=call_id, run_label=run_label, diff --git a/argus_skill/agent_cli/_acp_routing.py b/argus_skill/agent_cli/_acp_routing.py index 7195dabb4..405167cfc 100644 --- a/argus_skill/agent_cli/_acp_routing.py +++ b/argus_skill/agent_cli/_acp_routing.py @@ -97,6 +97,10 @@ def _acp_enabled( ``ARGUS_SKILL_COPILOT_ACP_LABELS`` overrides the default label set. All engineer/reviewer/planner/mission turns stay on the CLI ``Popen`` path. """ + # Session-bound MCP configurations must start their own CLI process; + # a warm ACP process cannot inherit this turn's scoped capability. + if options is not None and getattr(options, "extension_env", None): + return False if self.backend != BACKEND_COPILOT or not run_label: return False raw_flag = os.environ.get("ARGUS_SKILL_COPILOT_ACP") diff --git a/argus_skill/agent_cli/_prompt_delivery.py b/argus_skill/agent_cli/_prompt_delivery.py index 70df6e8eb..79f5d7cf9 100644 --- a/argus_skill/agent_cli/_prompt_delivery.py +++ b/argus_skill/agent_cli/_prompt_delivery.py @@ -347,6 +347,13 @@ def _child_env( env["GH_CONFIG_DIR"] = str( Path(tempfile.gettempdir()) / "argus-no-gh-auth" ) + plugin_env = getattr(options, "extension_env", None) + if plugin_env and not options.disable_tools: + env = dict(os.environ) if env is None else env + for key, value in plugin_env.items(): + if not key.startswith("ARGUS_PLUGIN_"): + raise ValueError("invalid plugin environment key") + env[key] = str(value) repaired = runner_child_environment( executable or getattr(self, "agent_bin", ""), env=env, diff --git a/argus_skill/agent_cli/_sandbox_commands.py b/argus_skill/agent_cli/_sandbox_commands.py index fe827bbbc..e842c1866 100644 --- a/argus_skill/agent_cli/_sandbox_commands.py +++ b/argus_skill/agent_cli/_sandbox_commands.py @@ -368,6 +368,9 @@ def _build_codex_command( # modified, and later explicit extra args may still opt back in. command.extend(["-c", "notify=[]"]) if options.disable_tools: + import dataclasses + options = dataclasses.replace(options, sandbox_mode="read-only", dangerous_yolo=False, + full_auto=False, skip_git_repo_check=True) # Stateless Manager/Planner control calls need the operator's model # provider and auth, but not interactive plugins, MCP servers, JS # REPL startup or project exec-policy rules. Keeping the base config @@ -382,6 +385,11 @@ def _build_codex_command( "plugins={}", "-c", "features.js_repl=false", + "-c", "features.shell_tool=false", + "-c", "features.apply_patch_freeform=false", + "-c", "features.multi_agent=false", + "-c", "tools.view_image=false", + "-c", "project_doc_max_bytes=0", "-c", 'web_search="disabled"', ]) @@ -551,13 +559,19 @@ def _build_copilot_command( if options.disable_tools: command.append(f"--available-tools={_COPILOT_NO_TOOLS_SENTINEL}") elif options.sandbox_mode == "read-only": - tools = "view,rg,glob" + tools = ",".join(["view", "rg", "glob", *(getattr(options, "trusted_tool_names", None) or [])]) if review_output: tools += ",argus_review-read_review,argus_review-write_review" command.extend([ "--available-tools", tools, "--allow-tool", "view,rg,glob", ]) + if getattr(options, "trusted_tool_names", None): + permissions = [] + for name in options.trusted_tool_names: + server, separator, tool = name.partition("-") + permissions.append(f"{server}({tool})" if separator else name) + command.extend(["--allow-tool", ",".join(permissions)]) if review_output: command.extend(["--allow-tool", "argus_review"]) elif options.dangerous_yolo: @@ -702,6 +716,9 @@ def _build_pi_command( ]) for path in options.skill_paths or []: command.extend(["--skill", path]) + if not options.disable_tools: + for path in getattr(options, "trusted_extensions", None) or []: + command.extend(["--extension", path]) if options.model: command.extend(["--model", _pi_model(options.model)]) if options.reasoning_effort: @@ -709,7 +726,7 @@ def _build_pi_command( if options.disable_tools: command.append("--no-tools") elif options.sandbox_mode == "read-only": - command.extend(["--tools", "read,grep,find,ls"]) + command.extend(["--tools", ",".join(["read", "grep", "find", "ls", *(getattr(options, "trusted_tool_names", None) or [])])]) merged_extra_args = [*self.default_extra_args] if options.extra_args: merged_extra_args.extend(options.extra_args) @@ -720,6 +737,18 @@ def _build_pi_command( ) if merged_extra_args: command.extend(merged_extra_args) + # SELF/other role profiles can append their own --tools allowlist. + # Preserve that builtin policy while retaining the explicitly bound + # plugin tools; otherwise the later flag silently hides the extension. + if not options.disable_tools: + trusted = getattr(options, "trusted_tool_names", None) or [] + for index, argument in enumerate(command): + if argument == "--tools" and index + 1 < len(command): + names = command[index + 1].split(",") + command[index + 1] = ",".join(dict.fromkeys([*names, *trusted])) + elif argument.startswith("--tools="): + names = argument.split("=", 1)[1].split(",") + command[index] = "--tools=" + ",".join(dict.fromkeys([*names, *trusted])) if resume_thread_id: command.extend(["--session", resume_thread_id]) # Pi reads non-TTY stdin into the initial message in JSON mode. Keeping diff --git a/argus_skill/agent_cli/agent_cli_runner.py b/argus_skill/agent_cli/agent_cli_runner.py index 4ba2f1b46..a278352b8 100644 --- a/argus_skill/agent_cli/agent_cli_runner.py +++ b/argus_skill/agent_cli/agent_cli_runner.py @@ -89,6 +89,9 @@ class RunnerOptions: # (the whole daemon) byte-for-byte unchanged; only the Manager chat # front-door sets it, to stream the reply live. on_agent_message: Callable[[str], None] | None = None + trusted_extensions: list[str] | None = None + trusted_tool_names: list[str] | None = None + extension_env: dict[str, str] | None = None class AgentCliRunner( diff --git a/argus_skill/apps/_runtime_execute.py b/argus_skill/apps/_runtime_execute.py index 698b1837b..45c55b913 100644 --- a/argus_skill/apps/_runtime_execute.py +++ b/argus_skill/apps/_runtime_execute.py @@ -15,6 +15,7 @@ import os import shutil import stat +import tempfile import time from pathlib import Path @@ -110,6 +111,44 @@ def _is_unaliased_regular_file(cls, path: Path) -> bool: except OSError: return False + @classmethod + def _detach_packaged_skill_hardlink(cls, path: Path) -> None: + """Give an installed Skill its own inode before establishing the guard. + + uv legitimately hardlinks wheel resources from its cache. Replacing our + directory entry preserves those cached bytes and other environments; + in-place writes or weakening the execution-time alias check would not. + Symlinks, junctions and redirected ancestors remain disallowed. + """ + if cls._is_link_or_reparse_point(path) or cls._has_linked_ancestor(path): + return + before = path.stat() + if not stat.S_ISREG(before.st_mode) or before.st_nlink <= 1: + return + content = path.read_bytes() + fd, filename = tempfile.mkstemp(prefix=".argus-skill-", dir=path.parent) + temporary = Path(filename) + try: + with os.fdopen(fd, "wb") as stream: + stream.write(content) + stream.flush() + os.fsync(stream.fileno()) + temporary.chmod(stat.S_IMODE(before.st_mode)) + if cls._is_link_or_reparse_point(path) or cls._has_linked_ancestor(path): + raise OSError(f"protected Skill path changed while preparing: {path}") + current = path.stat() + identity = lambda value: (value.st_dev, value.st_ino, value.st_size, value.st_mtime_ns) + if identity(current) != identity(before) or path.read_bytes() != content: + # Another startup may already have detached exactly these bytes. + if cls._is_unaliased_regular_file(path) and path.read_bytes() == content: + return + raise OSError(f"protected Skill changed while preparing: {path}") + os.replace(temporary, path) + if not cls._is_unaliased_regular_file(path) or path.read_bytes() != content: + raise OSError(f"protected Skill private copy did not verify: {path}") + finally: + temporary.unlink(missing_ok=True) + @classmethod def _remove_pipeline_state_replacement(cls, path: Path) -> None: if path.is_symlink(): @@ -161,6 +200,11 @@ def _restore_pipeline_state( if snapshot_error: return True, snapshot_error, False try: + # A fresh mission may have neither a pipeline file nor its parent. + # Restoration must not create that parent and then accuse the + # mission of creating formal state that never existed. + if not existed and not os.path.lexists(path.parent): + return False, "", True if cls._has_linked_ancestor(path.parent): raise OSError( f"formal pipeline state ancestor was replaced: {path.parent}" @@ -246,9 +290,14 @@ def _snapshot_playground_skill_files( protected_paths = list(canonical_paths) for parent in dict.fromkeys(path.parent for path in canonical_paths): for sibling in sorted(parent.iterdir()): + # Another mission may be detaching a cache hardlink now; + # its short-lived private copy is not a packaged Skill. + if sibling.name.startswith(".argus-skill-"): + continue if sibling not in protected_paths and sibling.is_file(): protected_paths.append(sibling) for path in protected_paths: + cls._detach_packaged_skill_hardlink(path) if ( cls._is_link_or_reparse_point(path.parent) or not path.parent.is_dir() @@ -944,6 +993,7 @@ def _invoke_execute_loop( expected_playground_path = self._canonical_playground_skill_path( skill_snapshots ) + execution_started = False try: if pipeline_state_snapshot[3]: raise RuntimeError( @@ -962,6 +1012,7 @@ def _invoke_execute_loop( or "canonical Playground Engineer digest is unavailable" ) ) + execution_started = True self._run_bounded_planning( ex_state, sink=sink, @@ -1087,6 +1138,10 @@ def _pre_settlement_guard( if hasattr(ex_state.outcome, "final_message"): ex_state.outcome.final_message = isolation_reason except BaseException as execution_error: + if not execution_started: + # Preflight never ran the planner/engineer. Retain its actual + # error; a failed snapshot is not an execution-time mutation. + raise changed, isolation_reason, restoration_ok = self._restore_playground_boundaries( pipeline_state_snapshot, skill_snapshots, diff --git a/argus_skill/core/models.py b/argus_skill/core/models.py index 36cf76ecc..1cd7fb84f 100644 --- a/argus_skill/core/models.py +++ b/argus_skill/core/models.py @@ -110,6 +110,9 @@ class RunnerOptions: # role turns are entirely unaffected. A callback exception never breaks the # turn (it is swallowed by the runner). on_agent_message: Callable[[str], None] | None = None + trusted_extensions: list[str] | None = None + trusted_tool_names: list[str] | None = None + extension_env: dict[str, str] | None = None @dataclass diff --git a/argus_skill/core/plugin_manager.py b/argus_skill/core/plugin_manager.py new file mode 100644 index 000000000..3a1e7c891 --- /dev/null +++ b/argus_skill/core/plugin_manager.py @@ -0,0 +1,620 @@ +"""Optional workbench installation, isolated packages and atomic activation. + +The catalog is host-owned release metadata. The browser selects an id, never an +arbitrary URL, command or Python package. Research data is not an install payload. +""" + +from __future__ import annotations + +import hashlib +import importlib +import importlib.util +import json +import os +import platform +import re +import shutil +import subprocess +import sys +import threading +import time +import uuid +import zipfile +from pathlib import Path + +import httpx +import portalocker + +from .paths import global_root + +API_VERSION = 1 +UNSUPPORTED = "暂不支持,敬请期待。当前插件支持 Codex、Copilot 和 Pi。" +_NAME = re.compile(r"^[a-z][a-z0-9_]{0,47}$") +_loaded: dict[tuple[str, str, str], object] = {} +_jobs: dict[tuple[str, str], threading.Thread] = {} +_lock = threading.RLock() + + +class PluginError(ValueError): + pass + + +def host_root(root=None): + return Path(root or os.environ.get("ARGUS_WORKBENCH_HOST_ROOT") or global_root()).resolve() + + +def install_root(root=None): + return host_root(root) / "extensions" + + +def read_json(path, default=None): + if not Path(path).exists(): + return {} if default is None else default + return json.loads(Path(path).read_text(encoding="utf-8")) + + +def write_json(path, value): + path = Path(path) + path.parent.mkdir(parents=True, exist_ok=True) + temp = path.with_name(path.name + "." + uuid.uuid4().hex + ".tmp") + temp.write_text(json.dumps(value, ensure_ascii=False, indent=2) + "\n", encoding="utf-8") + os.replace(temp, path) + + +def catalog(): + path = Path( + os.environ.get("ARGUS_PLUGIN_CATALOG") or Path(__file__).parents[1] / "plugin_catalog.json" + ) + data = read_json(path, {"plugins": []}) + result = {} + for entry in data.get("plugins", []): + if not _NAME.fullmatch(str(entry.get("id", ""))): + raise PluginError("Invalid plugin catalog id") + result[entry["id"]] = {**entry, "_catalog_dir": str(path.resolve().parent)} + return result + + +def registry(root=None): + return read_json(install_root(root) / "registry.json") + + +def state_entry(plugin_id, root=None): + return registry(root).get(plugin_id, {}) + + +def installed_digest(row, root): + if row.get("sha256"): + return row["sha256"] + if row.get("release"): + return read_json(_package_path(row, root) / "plugin.json").get("artifact", {}).get("sha256") + return None + + +def compatibility(spec, *, env=None, system=None): + from types import SimpleNamespace + + from ..agent_cli.runner_backend import resolve_available_runner + from .role_config import resolve_all_roles + + system = system or platform.system().lower() + environment = env if env is not None else os.environ + primary = environment.get("ARGUS_SKILL_RUNNER_BACKEND") or "codex" + try: + primary, _ = resolve_available_runner( + primary, environment.get("ARGUS_SKILL_RUNNER_BIN") or None + ) + except ValueError: + pass # Display unsupported configurations instead of breaking discovery. + roles = [SimpleNamespace(role="default", backend=primary), *resolve_all_roles(env=env)] + unsupported = {r.role: r.backend for r in roles if r.backend not in spec.get("backends", [])} + supported = ( + system in spec.get("platforms", []) + and ( + not spec.get("architectures") + or platform.machine().lower() in spec["architectures"].get(system, []) + ) + and not unsupported + and spec.get("host_api") == API_VERSION + ) + return { + "supported": supported, + "backends": {r.role: r.backend for r in roles}, + "unsupported_roles": unsupported, + "platform": system, + "machine": platform.machine().lower(), + "reason": "" + if supported + else UNSUPPORTED + if unsupported + else "当前系统或 Argus 插件接口版本暂不支持此插件。", + } + + +def _package_path(row, root): + path = (install_root(root) / row["release"]).resolve() + if install_root(root) not in path.parents: + raise PluginError("Invalid installed plugin path") + return path + + +def load_plugin(plugin_id, root=None, *, include_disabled=False, _candidate=None): + root = host_root(root) + row = _candidate if _candidate is not None else state_entry(plugin_id, root) + if not row.get("release") or (not include_disabled and not row.get("enabled")): + return None + key = (str(root), plugin_id, row["release"]) + with _lock: + if key in _loaded: + return _loaded[key] + directory = _package_path(row, root) + spec = read_json(directory / "plugin.json") + module_name, factory = spec["factory"].split(":", 1) + package_name, _, submodule = module_name.partition(".") + package = directory / "package" / package_name + alias = "_argus_ext_" + hashlib.sha256("|".join(key).encode()).hexdigest()[:20] + module_spec = importlib.util.spec_from_file_location( + alias, package / "__init__.py", submodule_search_locations=[str(package)] + ) + if not module_spec or not module_spec.loader: + raise PluginError("Plugin package is incomplete") + module = importlib.util.module_from_spec(module_spec) + sys.modules[alias] = module + module_spec.loader.exec_module(module) + plugin = getattr(importlib.import_module(alias + "." + submodule), factory)() + if plugin.api_version != API_VERSION: + raise PluginError("Incompatible plugin interface") + required = ( + "configure_installation", + "manifest", + "mount", + "native_command", + "prepare_run", + "finish_run", + "observe_stream", + "cancel_operations", + "accounting_root", + "vertical_module", + "owns_workdir", + "is_busy", + "shutdown_workers", + ) + if not all(callable(getattr(plugin, name, None)) for name in required): + raise PluginError("Plugin does not implement the required host interface") + plugin.configure_installation(root=root, directory=directory, python=Path(row["python"])) + if plugin.manifest().get("id") != plugin_id: + raise PluginError("Plugin identity does not match its catalog entry") + from .vertical_contract import vertical_contract + + vertical_contract(plugin_id, plugin.vertical_module()) + _loaded[key] = plugin + return plugin + + +def installed(root=None): + return { + name: p + for name, row in registry(root).items() + if row.get("enabled") and (p := load_plugin(name, root)) is not None + } + + +def _busy(plugin_id, root): + plugin = load_plugin(plugin_id, root, include_disabled=True) + if plugin and plugin.is_busy(): + raise PluginError("插件仍有任务运行,请等任务结束或先暂停,再进行此操作。") + + +def plugin_rows(root=None): + root = host_root(root) + rows = [] + for name, spec in catalog().items(): + state = state_entry(name, root) + operation = read_json(install_root(root) / name / "operation.json") + if operation.get("status") == "running" and not _job_alive(root, name, operation): + _recover_setup(operation) + operation.update( + status="failed", error="安装进程已中断;已有可用版本保持不变,可重试。" + ) + write_json(install_root(root) / name / "operation.json", operation) + c = compatibility(spec) + rows.append( + { + **{ + k: v + for k, v in spec.items() + if not k.startswith("_") and k not in {"artifact", "factory"} + }, + **c, + "installed": bool(state.get("release")), + "enabled": bool(state.get("enabled")), + "installed_version": state.get("version"), + "update_available": bool( + state.get("version") + and ( + state.get("version") != spec["version"] + or installed_digest(state, root) != spec.get("artifact", {}).get("sha256") + ) + ), + "operation": operation, + "health": read_json(install_root(root) / name / "resources" / "health.json"), + "available": c["supported"] and bool(state.get("enabled")), + "url": f"/plugins/{name}/", + } + ) + if operation.get("status") == "running": + progress = read_json(install_root(root) / name / "progress.json") + if progress.get("updated", 0) >= operation.get("started", 0): + operation["progress"] = progress.get("progress", operation.get("progress")) + return rows + + +def _job_alive(root, name, operation): + from .process_identity import process_identity_is_running + + thread = _jobs.get((str(root), name)) + if operation.get("pid") == os.getpid(): + return bool(thread and thread.is_alive()) + return process_identity_is_running(operation.get("pid", 0), operation.get("identity")) + + +def _recover_setup(operation): + """Reap only our identified orphan installer before permitting a retry.""" + from .process_identity import process_identity_is_running + + pid = operation.get("installer_pid", 0) + if not process_identity_is_running(pid, operation.get("installer_identity")): + return + import psutil + + try: + parent = psutil.Process(pid) + processes = [*parent.children(recursive=True), parent] + for process in processes: + try: + process.terminate() + except psutil.NoSuchProcess: + pass + _, alive = psutil.wait_procs(processes, timeout=3) + for process in alive: + try: + process.kill() + except psutil.NoSuchProcess: + pass + except psutil.NoSuchProcess: + pass + + +def _python(root=None): + explicit = os.environ.get("ARGUS_PLUGIN_PYTHON") + candidates = [[explicit]] if explicit else [] + if not explicit: + if not getattr(sys, "frozen", False): + candidates.append([sys.executable]) + if os.name == "nt" and shutil.which("py"): + candidates.extend([["py", "-" + version] for version in ("3.11", "3.12", "3.13")]) + candidates.extend( + [ + [p] + for p in ("python3.11", "python3.12", "python3.13", "python3", "python") + if shutil.which(p) + ] + ) + for command in candidates: + try: + result = subprocess.run( + [ + *command, + "-I", + "-c", + "import sys; assert (3,11)<=sys.version_info[:2]<(3,14); print(sys.executable)", + ], + capture_output=True, + text=True, + timeout=15, + check=True, + ) + return result.stdout.strip() + except (OSError, subprocess.SubprocessError): + continue + if root is not None and not explicit: + from .plugin_runtime import portable_python + + return portable_python(install_root(root) / "runtime") + raise PluginError( + "安装科学环境需要 Python 3.11–3.13。请安装 Python 后重试,或设置 ARGUS_PLUGIN_PYTHON。" + ) + + +def _fetch(spec, destination): + artifact = spec.get("artifact") or {} + checksum = artifact.get("sha256", "") + if not re.fullmatch(r"[a-f0-9]{64}", checksum): + raise PluginError("此插件版本尚未提供可校验的发行包。") + local = artifact.get("local") + if local: + source = (Path(spec["_catalog_dir"]) / local).resolve() + shutil.copyfile(source, destination) + else: + url = artifact.get("url", "") + if not url.startswith("https://"): + raise PluginError("插件发行包尚未发布。") + with httpx.stream("GET", url, follow_redirects=True, timeout=90) as response: + response.raise_for_status() + with destination.open("wb") as target: + size = 0 + for part in response.iter_bytes(): + size += len(part) + if size > 256 * 1024 * 1024: + raise PluginError("插件包超过允许大小。") + target.write(part) + if hashlib.sha256(destination.read_bytes()).hexdigest() != checksum: + raise PluginError("插件包校验失败,未安装。") + + +def _extract(wheel, destination): + with zipfile.ZipFile(wheel) as archive: + if sum(i.file_size for i in archive.infolist()) > 512 * 1024 * 1024: + raise PluginError("Plugin package expands beyond its size limit") + for entry in archive.infolist(): + path = (destination / entry.filename).resolve() + if ( + destination.resolve() not in path.parents + or (entry.external_attr >> 16) & 0o170000 == 0o120000 + ): + raise PluginError("Unsafe path in plugin package") + archive.extractall(destination) + + +def _run_setup(name, spec, root, python, action, payload=None): + from .plugin_runtime import clean_env, run + + module = spec.get("setup", {}).get("module") + if not module: + return + directory = install_root(root) / name + env = clean_env() + env["ARGUS_PLUGIN_PROGRESS_FILE"] = str(directory / "progress.json") + + def record(pid): + from .process_identity import capture_process_identity + + path = directory / "operation.json" + state = read_json(path) + state.update(installer_pid=pid, installer_identity=capture_process_identity(pid)) + write_json(path, state) + + output = run( + [python, "-m", module, "--root", directory / "resources", "--action", action], + env=env, + input=json.dumps(payload or {}), + timeout=7200 if action == "repair" else 900, + on_start=record, + ) + # This is our typed installer output, not a shell command containing secrets. + with (directory / "install.log").open("a", encoding="utf-8") as log: + log.write(output + "\n") + + +def _install(name, spec, root, action="install"): + from .process_identity import capture_process_identity + + operation_path = install_root(root) / name / "operation.json" + operation = { + "status": "running", + "action": action, + "progress": "准备安装", + "started": time.time(), + "pid": os.getpid(), + "identity": capture_process_identity(os.getpid()), + } + write_json(operation_path, operation) + release = ( + Path(name) + / "releases" + / (spec["version"] + "-" + spec["artifact"]["sha256"][:12] + "-" + uuid.uuid4().hex[:8]) + ) + target = install_root(root) / release + try: + target.mkdir(parents=True) + operation["progress"] = "获取并校验插件包" + write_json(operation_path, operation) + wheel = target / spec["artifact"]["filename"] + if Path(wheel.name).name != spec["artifact"]["filename"] or not wheel.name.endswith(".whl"): + raise PluginError("Invalid wheel filename") + _fetch(spec, wheel) + _extract(wheel, target / "package") + write_json(target / "plugin.json", spec) + operation["progress"] = "安装独立运行环境(首次可能需要几分钟)" + write_json(operation_path, operation) + executable = _python(root) + science = target / "science" + py = science / ("Scripts/python.exe" if os.name == "nt" else "bin/python") + log = install_root(root) / name / "install.log" + with log.open("ab") as output: + subprocess.run( + [executable, "-m", "venv", str(science)], + check=True, + stdout=output, + stderr=output, + timeout=180, + ) + subprocess.run( + [str(py), "-m", "pip", "install", str(wheel)], + check=True, + stdout=output, + stderr=output, + timeout=900, + ) + subprocess.run( + [str(py), "-m", spec["installer"], "--prefix", str(science)], + check=True, + stdout=output, + stderr=output, + timeout=1800, + ) + subprocess.run( + [str(py), "-m", spec["installer"], "--check"], + check=True, + stdout=output, + stderr=output, + timeout=120, + ) + if spec.get("setup", {}).get("automatic"): + _run_setup(name, spec, root, str(py), "repair") + candidate = { + "version": spec["version"], + "release": str(release), + "python": str(py), + "enabled": True, + "installed": time.time(), + "sha256": spec["artifact"]["sha256"], + } + # Validate import, interface, identity and vertical on the current host + # before changing the active registry or stopping the old worker. + load_plugin(name, root, include_disabled=True, _candidate=candidate) + _busy(name, root) + old = load_plugin(name, root, include_disabled=True) + if old: + old.shutdown_workers() + registry_path = install_root(root) / "registry.json" + with portalocker.Lock(str(registry_path.with_suffix(".lock")), timeout=30): + data = registry(root) + data[name] = candidate + write_json(registry_path, data) + operation.update(status="completed", progress="安装完成", completed=time.time()) + except Exception as exc: + operation.update( + status="failed", + error=f"{type(exc).__name__}: {exc}", + progress="安装未完成,已有版本保持不变", + completed=time.time(), + ) + # Keep the log but discard this unusable version. Never touch research data. + shutil.rmtree(target, ignore_errors=True) + finally: + write_json(operation_path, operation) + + +def _setup_job(name, spec, root, action, payload): + path = install_root(root) / name / "operation.json" + operation = read_json(path) + if action == "repair": + from .plugin_runtime import run + + try: + run( + [ + state_entry(name, root)["python"], + "-I", + "-c", + "import " + spec["setup"]["module"], + ], + timeout=30, + ) + except (OSError, RuntimeError, subprocess.SubprocessError): + # A deleted interpreter or damaged bridge cannot repair itself. + # Recreate its version environment through the normal verified flow. + payload.clear() + _install(name, spec, root, action="repair") + return + try: + row = state_entry(name, root) + if action != "health": + plugin = load_plugin(name, root, include_disabled=True) + if plugin: + _busy(name, root) + plugin.shutdown_workers() + _run_setup(name, spec, root, row["python"], action, payload) + operation.update(status="completed", progress="环境检查完成", completed=time.time()) + except Exception as exc: + error = str(exc) + for secret in (payload.get("username"), payload.get("password")): + if secret: + error = error.replace(secret, "[redacted]") + operation.update(status="failed", error=error[-1600:], completed=time.time()) + finally: + payload.clear() + write_json(path, operation) + + +def _start_job(root, name, action, target, args): + from .process_identity import capture_process_identity + + job = threading.Thread(target=target, args=args, daemon=True, name=f"plugin-{action}-{name}") + _jobs[(str(root), name)] = job + write_json( + install_root(root) / name / "operation.json", + { + "status": "running", + "action": action, + "progress": "正在准备", + "started": time.time(), + "pid": os.getpid(), + "identity": capture_process_identity(os.getpid()), + }, + ) + job.start() + return {"status": "running"} + + +def mutate(name, action, root=None, *, payload=None): + root = host_root(root) + spec = catalog().get(name) + if not spec: + raise PluginError("Unknown plugin") + directory = install_root(root) / name + directory.mkdir(parents=True, exist_ok=True) + with portalocker.Lock(str(directory / "manage.lock"), timeout=5): + operation = read_json(directory / "operation.json") + if operation.get("status") == "running" and _job_alive(root, name, operation): + raise PluginError("此插件已有安装或更新操作正在进行。") + if operation.get("status") == "running": + _recover_setup(operation) + if action != "health": + _busy(name, root) + row = state_entry(name, root) + if action in {"install", "update"}: + c = compatibility(spec) + if not c["supported"]: + raise PluginError(c["reason"]) + if action == "update" and not row.get("release"): + raise PluginError("插件尚未安装") + if row.get("version") == spec["version"] and installed_digest(row, root) == spec.get( + "artifact", {} + ).get("sha256"): + raise PluginError("此版本已安装,可启用插件。") + return _start_job(root, name, action, _install, (name, spec, root, action)) + if action in spec.get("setup", {}).get("actions", []): + if not row.get("release"): + raise PluginError("请先安装插件") + # Invoke the installed module/contract, not a newer catalog's code. + installed_spec = read_json(_package_path(row, root) / "plugin.json") + if action not in installed_spec.get("setup", {}).get("actions", []): + raise PluginError("请先更新插件以使用环境管理功能") + return _start_job( + root, + name, + action, + _setup_job, + (name, installed_spec, root, action, dict(payload or {})), + ) + if action not in {"enable", "disable", "uninstall"}: + raise PluginError("Unknown plugin operation") + if not row.get("release"): + raise PluginError("插件尚未安装") + if action == "enable" and not compatibility(spec)["supported"]: + raise PluginError(compatibility(spec)["reason"]) + plugin = load_plugin(name, root, include_disabled=True) + if action in {"disable", "uninstall"} and plugin: + plugin.shutdown_workers() + registry_path = install_root(root) / "registry.json" + with portalocker.Lock(str(registry_path.with_suffix(".lock")), timeout=30): + data = registry(root) + if action == "uninstall": + data.pop(name, None) + else: + data[name]["enabled"] = action == "enable" + write_json(registry_path, data) + if action == "uninstall": + shutil.rmtree(directory / "releases", ignore_errors=True) + return {"status": "completed", "data_retained": True} diff --git a/argus_skill/core/plugin_runtime.py b/argus_skill/core/plugin_runtime.py new file mode 100644 index 000000000..c30a9f0a9 --- /dev/null +++ b/argus_skill/core/plugin_runtime.py @@ -0,0 +1,234 @@ +"""Portable, user-local runtimes for optional plugins; no shell or global setup. + +This file is also included in standalone plugin wheels. Keep it independent of +Argus imports. Downloads always verify TLS and, where published, SHA-256. +""" + +from __future__ import annotations + +import hashlib +import os +import platform +import shutil +import subprocess +import tarfile +import uuid +from pathlib import Path +from urllib.parse import urlparse + +import httpx + +MAMBA_VERSION = "2.9.0" +MAMBA_HASHES = { + "linux-64": "8761c382127e6363bd9e0a2451aa3ef90d071a79133f736e2f759a3bf13040dd", + "osx-64": "0426ecdc41636d369f57b8fe6acbf4385a69eca45b56d9ee7d3a840a9965d44f", + "osx-arm64": "500f5074feb8d02c4296ef9921c3650ed2874171805a9fbb8fbb53896433646b", + "win-64": "97a336f4ab794bd96a6a4da5e6ed63e75a1d31830414a182419b23d3b36f3fe0", +} + + +def platform_key(system=None, machine=None): + system = (system or platform.system()).lower() + machine = (machine or platform.machine()).lower() + arch = "64" if machine in {"x86_64", "amd64", "x64"} else "arm64" + key = {"windows": "win", "darwin": "osx", "linux": "linux"}.get(system, system) + "-" + arch + if key not in MAMBA_HASHES or machine not in {"x86_64", "amd64", "x64", "arm64", "aarch64"}: + raise ValueError(f"当前处理器平台 {system}/{machine} 尚无完整科学软件发行包。") + return key + + +def sha256(path): + digest = hashlib.sha256() + with Path(path).open("rb") as stream: + for part in iter(lambda: stream.read(1024 * 1024), b""): + digest.update(part) + return digest.hexdigest() + + +def download(url, destination, *, checksum=None, auth=None, context=None, limit=512 * 1024**2): + """Stream to a temporary file. Never forward licensed credentials elsewhere.""" + destination = Path(destination) + destination.parent.mkdir(parents=True, exist_ok=True) + if checksum and destination.is_file() and sha256(destination) == checksum: + return destination + if not url.startswith("https://") or urlparse(url).username: + raise ValueError("下载源必须使用 HTTPS,且不能在 URL 中包含凭据。") + temp = destination.with_name(destination.name + "." + uuid.uuid4().hex + ".part") + try: + with httpx.Client(verify=context or True, timeout=90) as client: + current = url + for _ in range(8): + with client.stream("GET", current, auth=auth) as response: + if response.is_redirect: + redirect = str(response.url.join(response.headers["location"])) + if not redirect.startswith("https://") or ( + auth and urlparse(redirect).netloc != urlparse(url).netloc + ): + raise ValueError("下载站点发生不安全重定向,未发送授权凭据。") + current = redirect + continue + if response.status_code in {401, 403}: + raise ValueError("下载授权未通过,请核对用户名和密码或重新向官方网站申请。") + response.raise_for_status() + size = 0 + with temp.open("wb") as output: + for part in response.iter_bytes(): + size += len(part) + if size > limit: + raise ValueError("下载文件超过大小限制。") + output.write(part) + break + else: + raise ValueError("下载重定向次数过多。") + if checksum and sha256(temp) != checksum: + raise ValueError("下载文件 SHA-256 校验失败;保留已有安装。") + os.replace(temp, destination) + return destination + finally: + temp.unlink(missing_ok=True) + + +def clean_env(): + """No model keys, CLI homes, Python injection, or user conda configuration.""" + keep = { + "PATH", + "HOME", + "SYSTEMROOT", + "WINDIR", + "COMSPEC", + "PATHEXT", + "TEMP", + "TMP", + "USERPROFILE", + "LOCALAPPDATA", + "APPDATA", + "LANG", + "LC_ALL", + "SYSTEMDRIVE", + "HTTP_PROXY", + "HTTPS_PROXY", + "NO_PROXY", + "SSL_CERT_FILE", + "REQUESTS_CA_BUNDLE", + } + env = {k: v for k, v in os.environ.items() if k.upper() in keep} + env.update( + PYTHONUTF8="1", + PYTHONNOUSERSITE="1", + OMP_NUM_THREADS="4", + OPENBLAS_NUM_THREADS="4", + MKL_NUM_THREADS="4", + ) + return env + + +def run(command, *, cwd=None, env=None, timeout=1800, input=None, on_start=None): + """Bounded process tree; a timed out package installer must not keep writing.""" + flags = subprocess.CREATE_NO_WINDOW if os.name == "nt" else 0 + process = subprocess.Popen( + [str(v) for v in command], + cwd=cwd, + env=env or clean_env(), + stdin=subprocess.PIPE if input is not None else subprocess.DEVNULL, + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT, + text=True, + encoding="utf-8", + errors="replace", + creationflags=flags, + start_new_session=os.name != "nt", + ) + try: + if on_start: + on_start(process.pid) + output, _ = process.communicate(input=input, timeout=timeout) + except BaseException: + if os.name == "nt": + subprocess.run(["taskkill", "/PID", str(process.pid), "/T", "/F"], capture_output=True) + else: + import signal + + try: + os.killpg(process.pid, signal.SIGKILL) + except ProcessLookupError: + pass + process.communicate() + raise + if process.returncode: + # Credential payloads are only sent to our installer via stdin, never + # embedded in argv. Callers with credentials suppress untrusted output. + raise RuntimeError( + f"{Path(str(command[0])).name} 执行失败 ({process.returncode})\n{output[-3500:]}" + ) + return output + + +def micromamba(root): + root = Path(root) + key = platform_key() + binary = root / "bootstrap" / ("micromamba.exe" if os.name == "nt" else "micromamba") + marker = binary.with_suffix(".sha256") + if binary.is_file() and marker.is_file() and marker.read_text() == sha256(binary): + return binary + archive = download( + f"https://api.anaconda.org/download/conda-forge/micromamba/{MAMBA_VERSION}/{key}/micromamba-{MAMBA_VERSION}-0.tar.bz2", + root / "cache" / f"micromamba-{key}.tar.bz2", + checksum=MAMBA_HASHES[key], + ) + with tarfile.open(archive) as package: + name = "Library/bin/micromamba.exe" if os.name == "nt" else "bin/micromamba" + member = package.getmember(name) + if not member.isfile() or member.size > 50 * 1024**2: + raise ValueError("Invalid portable runtime package") + binary.parent.mkdir(parents=True, exist_ok=True) + temp = binary.with_suffix(".tmp") + with package.extractfile(member) as source, temp.open("wb") as target: + shutil.copyfileobj(source, target) + temp.chmod(0o700) + os.replace(temp, binary) + marker.write_text(sha256(binary)) + return binary + + +def conda_env(root, prefix, packages, *, timeout=2700): + root, prefix = Path(root), Path(prefix) + binary = micromamba(root) + env = clean_env() + env.update(MAMBA_ROOT_PREFIX=str(root / "mamba"), MAMBA_NO_BANNER="1") + output = run( + [ + binary, + "--no-rc", + "create", + "--yes", + "--prefix", + prefix, + "--override-channels", + "--channel", + "conda-forge", + "--strict-channel-priority", + "--repodata-ttl", + "86400", + *packages, + ], + env=env, + timeout=timeout, + ) + return output + + +def portable_python(root): + root = Path(root) + prefix = root / "python-3.11" + python = prefix / ("python.exe" if os.name == "nt" else "bin/python") + if python.is_file(): + try: + run( + [python, "-I", "-c", "import venv,sys; assert sys.version_info[:2] == (3,11)"], + timeout=20, + ) + return str(python) + except (OSError, RuntimeError): + pass + conda_env(root, prefix, ["python=3.11", "pip"]) + return str(python) diff --git a/argus_skill/core/pricing.py b/argus_skill/core/pricing.py index a615a57bd..197383fe4 100644 --- a/argus_skill/core/pricing.py +++ b/argus_skill/core/pricing.py @@ -31,6 +31,11 @@ class PricingQuote: MODEL_PRICES_USD_PER_MTOK: dict[str, ModelPrice] = { + # Standard public API reference, 2026-09-09. A proxy's actual bill may differ. + # https://developers.openai.com/api/docs/pricing + "gpt-5.6-luna": ModelPrice(0.20, 0.02, 1.20, + long_context_threshold=272_000, long_input_multiplier=2.0, + long_cached_input_multiplier=2.0, long_output_multiplier=1.5), # Official GPT-5.6 Sol API pricing. Requests whose input exceeds 272K # tokens price the full request at 2x input (including cached input) and # 1.5x output. diff --git a/argus_skill/core/runner_errors.py b/argus_skill/core/runner_errors.py index ed3fb6c48..8d6d77ff7 100644 --- a/argus_skill/core/runner_errors.py +++ b/argus_skill/core/runner_errors.py @@ -26,9 +26,7 @@ "copilot could not retrieve the list of available models", "model is not supported when using codex with a chatgpt account", ) -_EXECUTION_HOST_STARTUP_PREFIX = ( - "code mode is unavailable because failed to spawn code-mode host " -) +_EXECUTION_HOST_STARTUP_PREFIX = "code mode is unavailable because failed to spawn code-mode host " def is_execution_host_startup_error(value: object) -> bool: @@ -40,7 +38,7 @@ def is_execution_host_startup_error(value: object) -> bool: """ lowered = str(value or "").strip().casefold() return lowered.startswith(_EXECUTION_HOST_STARTUP_PREFIX) and any( - marker in lowered[len(_EXECUTION_HOST_STARTUP_PREFIX):] + marker in lowered[len(_EXECUTION_HOST_STARTUP_PREFIX) :] for marker in ( "host executable was not found", "startup failure", @@ -132,8 +130,7 @@ def result_has_pre_provider_refusal(result: Any) -> bool: def is_copilot_context_parser_error(value: object) -> bool: """Exact runner-wrapped parser diagnostic; text alone is not authority.""" prefix = ( - "Process exited with code 1 before turn completion.\n" - "error: unknown option '--context'\n" + "Process exited with code 1 before turn completion.\nerror: unknown option '--context'\n" ) suffix = "Try 'copilot --help' for more information." return str(value or "").strip() in ( @@ -143,8 +140,14 @@ def is_copilot_context_parser_error(value: object) -> bool: def is_copilot_context_parser_refusal( - error: object, *, provider: str, call_id: str, run_label: str, - status: str, thread_id: object, source: str, + error: object, + *, + provider: str, + call_id: str, + run_label: str, + status: str, + thread_id: object, + source: str, receipt: dict[str, Any] | None, ) -> bool: """Use only host-generated agent.io.complete, never model/tool JSON. @@ -157,8 +160,11 @@ def is_copilot_context_parser_refusal( return False command = receipt.get("command") return bool( - provider == "copilot" and status == "error" and source == "run_exec" - and not thread_id and call_id + provider == "copilot" + and status == "error" + and source == "run_exec" + and not thread_id + and call_id and receipt.get("type") == "agent.io.complete" and receipt.get("backend") == provider and receipt.get("call_id") == call_id @@ -169,20 +175,98 @@ def is_copilot_context_parser_refusal( and receipt.get("thread_id") is None and receipt.get("fatal_error") == "Process exited with code 1 before turn completion." and receipt.get("tool_activity_observed") is False - and all(receipt.get(key) == 0 for key in ( - "agent_message_count", "stdout_line_count", "json_event_count")) + and all( + receipt.get(key) == 0 + for key in ("agent_message_count", "stdout_line_count", "json_event_count") + ) # Older receipts store zero token placeholders without presence bits. # Nonzero receipt usage still contradicts a missing-usage ledger row; # explicit premium/billing values (including zero) are always evidence. - and all(receipt.get(key) in (None, 0) for key in ( - "input_tokens", "cached_input_tokens", "cache_write_tokens", - "output_tokens", "reasoning_output_tokens")) + and all( + receipt.get(key) in (None, 0) + for key in ( + "input_tokens", + "cached_input_tokens", + "cache_write_tokens", + "output_tokens", + "reasoning_output_tokens", + ) + ) and not receipt.get("premium_requests_present") - and all(receipt.get(key) is None for key in ( - "premium_requests", "total_nano_aiu", "cost_usd", - "provider_cost_usd", "premium_request_cost_usd")) + and all( + receipt.get(key) is None + for key in ( + "premium_requests", + "total_nano_aiu", + "cost_usd", + "provider_cost_usd", + "premium_request_cost_usd", + ) + ) and not receipt.get("model_usage") and isinstance(command, list) - and any(command[i:i+2] == ["--context", "default"] - for i in range(1, len(command)-1)) + and any(command[i : i + 2] == ["--context", "default"] for i in range(1, len(command) - 1)) + ) + + +def is_local_startup_parser_error(value: object) -> bool: + return is_copilot_context_parser_error(value) or str(value or "").strip() == ( + "Process exited with code 1 before turn completion.\n" + "Not inside a trusted directory and --skip-git-repo-check was not specified." + ) + + +def is_local_startup_refusal(error: object, **context) -> bool: + """Only a matching, silent CLI completion proves a zero-provider refusal.""" + if is_copilot_context_parser_refusal(error, **context): + return True + r = context.get("receipt") or {} + command = r.get("command") or [] + return bool( + is_local_startup_parser_error(error) + and not is_copilot_context_parser_error(error) + and context.get("provider") == "codex" + and context.get("status") == "error" + and context.get("source") == "run_exec" + and not context.get("thread_id") + and context.get("call_id") + and r.get("call_id") == context["call_id"] + and r.get("run_label") == context.get("run_label") + and r.get("backend") == "codex" + and r.get("type") == "agent.io.complete" + and r.get("exit_code") == 1 + and r.get("turn_failed") is True + and r.get("turn_completed") is False + and r.get("thread_id") is None + and r.get("tool_activity_observed") is False + and r.get("fatal_error") == "Process exited with code 1 before turn completion." + and all( + r.get(k) == 0 for k in ("agent_message_count", "stdout_line_count", "json_event_count") + ) + and all( + r.get(k) in (None, 0) + for k in ( + "input_tokens", + "cached_input_tokens", + "cache_write_tokens", + "output_tokens", + "reasoning_output_tokens", + ) + ) + and not r.get("premium_requests_present") + and not r.get("model_usage") + and all( + r.get(k) is None + for k in ( + "premium_requests", + "total_nano_aiu", + "cost_usd", + "provider_cost_usd", + "premium_request_cost_usd", + ) + ) + and isinstance(command, list) + and len(command) > 1 + and command[1] == "exec" + and "--skip-git-repo-check" not in command ) diff --git a/argus_skill/core/session.py b/argus_skill/core/session.py index fdbcd55db..e57062ff8 100644 --- a/argus_skill/core/session.py +++ b/argus_skill/core/session.py @@ -38,9 +38,11 @@ _LOCK_PATH_BUDGET = 240 -def new_session_id() -> str: +def new_session_id(namespace: str = "") -> str: """A short, unique, path-safe session id, e.g. ``s-3f9a1c20``.""" - return _SESSION_PREFIX + secrets.token_hex(4) + if namespace and not namespace.replace("_", "").isalnum(): + raise ValueError("invalid session namespace") + return _SESSION_PREFIX + (namespace + "-" if namespace else "") + secrets.token_hex(4) @dataclass diff --git a/argus_skill/core/usage.py b/argus_skill/core/usage.py index d7b9a8ec2..896c009c9 100644 --- a/argus_skill/core/usage.py +++ b/argus_skill/core/usage.py @@ -4,6 +4,7 @@ human-readable timeline, but are never summed for spend because one call can be represented by several overlapping events. """ + from __future__ import annotations import json @@ -27,8 +28,8 @@ from .event_catalog import CALL_SCOPED_EVENT_TYPES, EventType, canonical_event_type from .pricing import PricingQuote, PricingStatus, quote_copilot_usage, quote_token_usage from .runner_errors import ( - is_copilot_context_parser_error, - is_copilot_context_parser_refusal, + is_local_startup_parser_error, + is_local_startup_refusal, is_pre_provider_refusal_error, ) from .token_usage import TokenUsage, extract_token_usage @@ -48,9 +49,7 @@ UsageSource = Literal["run_exec", "legacy.events"] CallStatus = Literal["completed", "error", "denied"] -_THREAD_LOCKS: weakref.WeakValueDictionary[str, threading.Lock] = ( - weakref.WeakValueDictionary() -) +_THREAD_LOCKS: weakref.WeakValueDictionary[str, threading.Lock] = weakref.WeakValueDictionary() _THREAD_LOCKS_GUARD = threading.Lock() _CALL_ID_CACHE: dict[str, tuple[tuple[int, int, int] | None, set[str]]] = {} _CALL_ID_CACHE_LOCK = threading.Lock() @@ -95,32 +94,38 @@ def to_jsonable(self) -> dict[str, Any]: @classmethod def from_jsonable( - cls, row: dict[str, Any], *, startup_receipt: dict[str, Any] | None = None, + cls, + row: dict[str, Any], + *, + startup_receipt: dict[str, Any] | None = None, ) -> "UsageRecord": cost = _optional_float(row.get("cost_usd")) pricing_status = _pricing_status(row.get("pricing_status")) pricing_tier = str(row.get("pricing_tier") or "unknown") error = str(row.get("error") or "") if ( - (is_pre_provider_refusal_error(error) or ( - is_copilot_context_parser_refusal( - error, provider=str(row.get("provider") or ""), - call_id=str(row.get("call_id") or ""), - run_label=str(row.get("run_label") or ""), - status=str(row.get("status") or ""), - thread_id=row.get("thread_id"), - source=str(row.get("source") or ""), receipt=startup_receipt, + ( + is_pre_provider_refusal_error(error) + or ( + is_local_startup_refusal( + error, + provider=str(row.get("provider") or ""), + call_id=str(row.get("call_id") or ""), + run_label=str(row.get("run_label") or ""), + status=str(row.get("status") or ""), + thread_id=row.get("thread_id"), + source=str(row.get("source") or ""), + receipt=startup_receipt, + ) + and row.get("premium_requests") is None + and row.get("premium_request_cost_usd") is None ) - and row.get("premium_requests") is None - and row.get("premium_request_cost_usd") is None - )) + ) and cost is None and row.get("total_nano_aiu") is None and not row.get("model_usage") and not (_optional_float(row.get("premium_requests")) or 0.0) - and not ( - _optional_float(row.get("premium_request_cost_usd")) or 0.0 - ) + and not (_optional_float(row.get("premium_request_cost_usd")) or 0.0) and all( row.get(field) is None for field in ( @@ -157,9 +162,7 @@ def from_jsonable( cached_input_tokens=_optional_int(row.get("cached_input_tokens")), cache_write_tokens=_optional_int(row.get("cache_write_tokens")), output_tokens=_optional_int(row.get("output_tokens")), - reasoning_output_tokens=_optional_int( - row.get("reasoning_output_tokens") - ), + reasoning_output_tokens=_optional_int(row.get("reasoning_output_tokens")), premium_requests=_optional_float(row.get("premium_requests")), pricing_status=pricing_status, pricing_tier=pricing_tier, @@ -173,15 +176,9 @@ def from_jsonable( ), model_usage=_normalize_model_usage(row.get("model_usage")), total_nano_aiu=_optional_int(row.get("total_nano_aiu")), - premium_request_cost_usd=_optional_float( - row.get("premium_request_cost_usd") - ), + premium_request_cost_usd=_optional_float(row.get("premium_request_cost_usd")), error=error, - source=( - "legacy.events" - if row.get("source") == "legacy.events" - else "run_exec" - ), + source=("legacy.events" if row.get("source") == "legacy.events" else "run_exec"), schema_version=max(1, _optional_int(row.get("schema_version")) or 1), ) @@ -229,10 +226,7 @@ def _reconciled_token_quote(record: UsageRecord) -> PricingQuote | None: or record.cost_basis != "token" or record.status == "denied" or record.pricing_status == "not_billed" - or ( - record.cost_usd is not None - and record.pricing_status not in {"partial", "unpriced"} - ) + or (record.cost_usd is not None and record.pricing_status not in {"partial", "unpriced"}) ): return None quote = quote_token_usage( @@ -297,13 +291,22 @@ def build_usage_record( normalized_provider = str(provider or "").strip().lower() premium_quote = quote_copilot_usage(premium_requests) pre_provider_refusal = ( - (is_pre_provider_refusal_error(error) or ( - is_copilot_context_parser_refusal( - error, provider=normalized_provider, call_id=call_id, - run_label=run_label, status=status, thread_id=thread_id, - source=source, receipt=startup_receipt, - ) and premium_requests is None - )) + ( + is_pre_provider_refusal_error(error) + or ( + is_local_startup_refusal( + error, + provider=normalized_provider, + call_id=call_id, + run_label=run_label, + status=status, + thread_id=thread_id, + source=source, + receipt=startup_receipt, + ) + and premium_requests is None + ) + ) and total_nano_aiu is None and provider_cost_usd is None and not normalized_model_usage @@ -338,9 +341,7 @@ def build_usage_record( pricing_status = premium_quote.status pricing_tier = premium_quote.tier cost_usd = premium_quote.cost_usd - cost_basis = ( - "premium_request" if premium_quote.cost_usd is not None else "none" - ) + cost_basis = "premium_request" if premium_quote.cost_usd is not None else "none" elif provider_cost_usd is not None: pricing_status = "priced" pricing_tier = "provider_reported" @@ -351,20 +352,14 @@ def build_usage_record( model, input_tokens=usage.input_tokens if usage.input_tokens_present else None, cached_input_tokens=( - usage.cached_input_tokens - if usage.cached_input_tokens_present - else None + usage.cached_input_tokens if usage.cached_input_tokens_present else None ), cache_write_tokens=( - usage.cache_write_tokens - if usage.cache_write_tokens_present - else None + usage.cache_write_tokens if usage.cache_write_tokens_present else None ), output_tokens=usage.output_tokens if usage.output_tokens_present else None, reasoning_output_tokens=( - usage.reasoning_output_tokens - if usage.reasoning_output_tokens_present - else None + usage.reasoning_output_tokens if usage.reasoning_output_tokens_present else None ), ) pricing_status = quote.status @@ -385,14 +380,10 @@ def build_usage_record( cached_input_tokens=( usage.cached_input_tokens if usage.cached_input_tokens_present else None ), - cache_write_tokens=( - usage.cache_write_tokens if usage.cache_write_tokens_present else None - ), + cache_write_tokens=(usage.cache_write_tokens if usage.cache_write_tokens_present else None), output_tokens=usage.output_tokens if usage.output_tokens_present else None, reasoning_output_tokens=( - usage.reasoning_output_tokens - if usage.reasoning_output_tokens_present - else None + usage.reasoning_output_tokens if usage.reasoning_output_tokens_present else None ), premium_requests=premium_requests, pricing_status=pricing_status, @@ -473,9 +464,7 @@ def __init__(self, project_root: Path | str, *, migrate_legacy: bool = True) -> self.path = self.project_root / USAGE_FILE self.lock_path = self.project_root / USAGE_LOCK_FILE self.migration_path = self.project_root / USAGE_MIGRATION_FILE - self.copilot_reconcile_path = ( - self.project_root / USAGE_COPILOT_RECONCILE_FILE - ) + self.copilot_reconcile_path = self.project_root / USAGE_COPILOT_RECONCILE_FILE self._migrate_legacy = bool(migrate_legacy) def append(self, record: UsageRecord) -> bool: @@ -537,7 +526,7 @@ def records( if not isinstance(row, dict): continue receipt = None - if is_copilot_context_parser_error(row.get("error")): + if is_local_startup_parser_error(row.get("error")): if startup_receipts is None: startup_receipts = _startup_completion_receipts(self.project_root) receipt = startup_receipts.get(str(row.get("call_id") or "")) @@ -556,9 +545,7 @@ def records( def _reconcile_token_pricing(self, records: Iterable[UsageRecord]) -> int: pending = { - record.call_id - for record in records - if _reconciled_token_quote(record) is not None + record.call_id for record in records if _reconciled_token_quote(record) is not None } if not pending: return 0 @@ -581,9 +568,7 @@ def _reconcile_token_pricing(self, records: Iterable[UsageRecord]) -> int: updated += 1 if updated: _rewrite_usage_rows(self.path, rows) - self._cache_call_ids({ - str(row["call_id"]) for row in rows if row.get("call_id") - }) + self._cache_call_ids({str(row["call_id"]) for row in rows if row.get("call_id")}) return updated def summary( @@ -600,14 +585,8 @@ def summary( records = [ record for record in records - if ( - run_labels is None - or record.run_label in run_labels - ) - and ( - not run_label_prefixes - or record.run_label.startswith(run_label_prefixes) - ) + if (run_labels is None or record.run_label in run_labels) + and (not run_label_prefixes or record.run_label.startswith(run_label_prefixes)) and (cost_basis is None or record.cost_basis == cost_basis) ] return summarize_usage(records) @@ -640,9 +619,12 @@ def ensure_copilot_usage_reconciled(self) -> int: store_signature = copilot_usage_store_signature() if signature is None and self.copilot_reconcile_path.exists(): return 0 - if _reconcile_marker_signature( - self.copilot_reconcile_path, store_signature=store_signature - ) == signature: + if ( + _reconcile_marker_signature( + self.copilot_reconcile_path, store_signature=store_signature + ) + == signature + ): return 0 if signature is None: _write_json_atomic( @@ -662,8 +644,7 @@ def ensure_copilot_usage_reconciled(self) -> int: call_threads = ( _legacy_call_threads(self.project_root) if any( - _copilot_usage_needs_reconciliation(row) - and not row.get("thread_id") + _copilot_usage_needs_reconciliation(row) and not row.get("thread_id") for row in rows ) else {} @@ -759,9 +740,7 @@ def ensure_copilot_usage_reconciled(self) -> int: "priced" if usage.cost_usd is not None else "partial" ), "pricing_tier": "copilot_token", - "schema_version": max( - 2, _optional_int(row.get("schema_version")) or 1 - ), + "schema_version": max(2, _optional_int(row.get("schema_version")) or 1), } ) updated += 1 @@ -791,19 +770,11 @@ def ensure_copilot_usage_reconciled(self) -> int: # a definitive charge. Settle that billing unit rather than # leaving the call permanently partial. Missing premium usage # remains fail-closed. - premium_quote = quote_copilot_usage( - _optional_float(row.get("premium_requests")) - ) - existing_pricing_status = str( - row.get("pricing_status") or "" - ).lower() + premium_quote = quote_copilot_usage(_optional_float(row.get("premium_requests"))) + existing_pricing_status = str(row.get("pricing_status") or "").lower() existing_cost = _optional_float(row.get("cost_usd")) - if ( - premium_quote.cost_usd is not None - and ( - existing_cost is None - or existing_pricing_status in {"partial", "unpriced"} - ) + if premium_quote.cost_usd is not None and ( + existing_cost is None or existing_pricing_status in {"partial", "unpriced"} ): row.update( { @@ -812,26 +783,17 @@ def ensure_copilot_usage_reconciled(self) -> int: "cost_basis": "premium_request", "pricing_status": premium_quote.status, "pricing_tier": premium_quote.tier, - "schema_version": max( - 2, _optional_int(row.get("schema_version")) or 1 - ), + "schema_version": max(2, _optional_int(row.get("schema_version")) or 1), } ) updated += 1 if updated: _rewrite_usage_rows(self.path, rows) self._cache_call_ids( - { - str(row.get("call_id")) - for row in rows - if row.get("call_id") - } + {str(row.get("call_id")) for row in rows if row.get("call_id")} ) reconciled_signature = _path_signature(self.path) - pending_token_usage = any( - _copilot_usage_needs_reconciliation(row) - for row in rows - ) + pending_token_usage = any(_copilot_usage_needs_reconciliation(row) for row in rows) _write_json_atomic( self.copilot_reconcile_path, { @@ -941,9 +903,7 @@ def summarize_usage(records: Iterable[UsageRecord]) -> UsageSummary: not_billed = sum(record.pricing_status == "not_billed" for record in rows) contributions = _deduplicated_usage_contributions(rows) known_costs = [ - float(item["cost_usd"]) - for item in contributions - if item.get("cost_usd") is not None + float(item["cost_usd"]) for item in contributions if item.get("cost_usd") is not None ] known_cost = sum(known_costs) if partial: @@ -962,34 +922,22 @@ def summarize_usage(records: Iterable[UsageRecord]) -> UsageSummary: return UsageSummary( call_count=len(rows), known_cost_usd=known_cost, - cost_usd=( - known_cost - if known_costs and not incomplete_without_positive_cost - else None - ), + cost_usd=(known_cost if known_costs and not incomplete_without_positive_cost else None), pricing_status=aggregate_status, priced_calls=priced, partial_calls=partial, unpriced_calls=unpriced, not_billed_calls=not_billed, input_tokens=sum(item.get("input_tokens") or 0 for item in contributions), - cached_input_tokens=sum( - item.get("cached_input_tokens") or 0 for item in contributions - ), + cached_input_tokens=sum(item.get("cached_input_tokens") or 0 for item in contributions), output_tokens=sum(item.get("output_tokens") or 0 for item in contributions), reasoning_output_tokens=sum( item.get("reasoning_output_tokens") or 0 for item in contributions ), premium_requests=sum(record.premium_requests or 0.0 for record in rows), - cache_write_tokens=sum( - item.get("cache_write_tokens") or 0 for item in contributions - ), - total_nano_aiu=sum( - item.get("total_nano_aiu") or 0 for item in contributions - ), - premium_request_cost_usd=sum( - record.premium_request_cost_usd or 0.0 for record in rows - ), + cache_write_tokens=sum(item.get("cache_write_tokens") or 0 for item in contributions), + total_nano_aiu=sum(item.get("total_nano_aiu") or 0 for item in contributions), + premium_request_cost_usd=sum(record.premium_request_cost_usd or 0.0 for record in rows), ) @@ -1000,15 +948,17 @@ def _deduplicated_usage_contributions( seen_copilot_events: set[tuple[str, int]] = set() for record in records: if not record.model_usage: - contributions.append({ - "input_tokens": record.input_tokens, - "cached_input_tokens": record.cached_input_tokens, - "cache_write_tokens": record.cache_write_tokens, - "output_tokens": record.output_tokens, - "reasoning_output_tokens": record.reasoning_output_tokens, - "total_nano_aiu": record.total_nano_aiu, - "cost_usd": record.cost_usd, - }) + contributions.append( + { + "input_tokens": record.input_tokens, + "cached_input_tokens": record.cached_input_tokens, + "cache_write_tokens": record.cache_write_tokens, + "output_tokens": record.output_tokens, + "reasoning_output_tokens": record.reasoning_output_tokens, + "total_nano_aiu": record.total_nano_aiu, + "cost_usd": record.cost_usd, + } + ) continue for item in record.model_usage: session_id = _optional_text(item.get("session_id")) @@ -1154,9 +1104,7 @@ def _legacy_event_records( continue if not isinstance(row, dict): continue - kind = canonical_event_type( - row.get("canonical_type") or row.get("type") - ) + kind = canonical_event_type(row.get("canonical_type") or row.get("type")) if kind == EventType.LIFE_MISSION_STARTED: current_mission = _optional_text(row.get("item_id")) continue @@ -1164,12 +1112,14 @@ def _legacy_event_records( item_id = _optional_text(row.get("item_id")) cost = _optional_float(row.get("cost_usd")) if cost is not None: - legacy_missions.append({ - "item_id": item_id, - "ts": _float(row.get("ts"), 0.0), - "cost_usd": cost, - "status": str(row.get("pricing_status") or "priced"), - }) + legacy_missions.append( + { + "item_id": item_id, + "ts": _float(row.get("ts"), 0.0), + "cost_usd": cost, + "status": str(row.get("pricing_status") or "priced"), + } + ) if item_id is None or item_id == current_mission: current_mission = None continue @@ -1194,17 +1144,9 @@ def _legacy_event_records( call_id=call_id, project_root=project_root, mission_id=mission_id, - provider=str( - row.get("backend") - or started.get("backend") - or "" - ), + provider=str(row.get("backend") or started.get("backend") or ""), model=str(row.get("model") or started.get("model") or ""), - run_label=str( - row.get("run_label") - or started.get("run_label") - or "" - ), + run_label=str(row.get("run_label") or started.get("run_label") or ""), started_at=_float( started.get("ts"), _float(row.get("ts"), 0.0), @@ -1229,17 +1171,9 @@ def _legacy_event_records( call_id=call_id, project_root=project_root, mission_id=mission_id, - provider=str( - row.get("backend") - or started.get("backend") - or "" - ), + provider=str(row.get("backend") or started.get("backend") or ""), model=str(started.get("model") or ""), - run_label=str( - row.get("run_label") - or started.get("run_label") - or "" - ), + run_label=str(row.get("run_label") or started.get("run_label") or ""), started_at=_float( started.get("ts"), _float(row.get("ts"), 0.0), @@ -1327,27 +1261,15 @@ def _legacy_token_usage(row: dict[str, Any]) -> TokenUsage: if extracted.observed: return TokenUsage( input_tokens=_optional_int(row.get("input_tokens")) or 0, - cached_input_tokens=( - _optional_int(row.get("cached_input_tokens")) or 0 - ), - cache_write_tokens=( - _optional_int(row.get("cache_write_tokens")) or 0 - ), + cached_input_tokens=(_optional_int(row.get("cached_input_tokens")) or 0), + cache_write_tokens=(_optional_int(row.get("cache_write_tokens")) or 0), output_tokens=_optional_int(row.get("output_tokens")) or 0, - reasoning_output_tokens=( - _optional_int(row.get("reasoning_output_tokens")) or 0 - ), + reasoning_output_tokens=(_optional_int(row.get("reasoning_output_tokens")) or 0), input_tokens_present=extracted.input_tokens_present, - cached_input_tokens_present=( - extracted.cached_input_tokens_present - ), - cache_write_tokens_present=( - extracted.cache_write_tokens_present - ), + cached_input_tokens_present=(extracted.cached_input_tokens_present), + cache_write_tokens_present=(extracted.cache_write_tokens_present), output_tokens_present=extracted.output_tokens_present, - reasoning_output_tokens_present=( - extracted.reasoning_output_tokens_present - ), + reasoning_output_tokens_present=(extracted.reasoning_output_tokens_present), source="recorded_delta", ) names = ( @@ -1491,10 +1413,7 @@ def _legacy_call_threads(project_root: Path) -> dict[str, str]: row = json.loads(raw) except (json.JSONDecodeError, ValueError): continue - if ( - not isinstance(row, dict) - or row.get("type") != EventType.AGENT_IO_COMPLETE - ): + if not isinstance(row, dict) or row.get("type") != EventType.AGENT_IO_COMPLETE: continue call_id = str(row.get("call_id") or "") thread_id = str(row.get("thread_id") or "") @@ -1566,10 +1485,7 @@ def _reconcile_marker_signature( payload = json.loads(path.read_text(encoding="utf-8")) except (OSError, ValueError, json.JSONDecodeError): return None - if ( - not isinstance(payload, dict) - or payload.get("version") != _COPILOT_RECONCILE_VERSION - ): + if not isinstance(payload, dict) or payload.get("version") != _COPILOT_RECONCILE_VERSION: return None if payload.get("pending_token_usage") and payload.get("store_signature") != store_signature: return None @@ -1647,25 +1563,23 @@ def _normalize_model_usage(value: Any) -> tuple[dict[str, Any], ...]: cost_usd = _optional_float(raw.get("cost_usd")) if cost_usd is None and total_nano_aiu is not None: cost_usd = total_nano_aiu / NANO_AIU_PER_USD - items.append({ - "usage_event_id": usage_event_id, - "session_id": session_id, - "model": str(raw.get("model") or ""), - "turn_index": _optional_int(raw.get("turn_index")), - "input_tokens": _optional_int(raw.get("input_tokens")), - "cached_input_tokens": _optional_int( - raw.get("cached_input_tokens") - ), - "cache_write_tokens": _optional_int(raw.get("cache_write_tokens")), - "output_tokens": _optional_int(raw.get("output_tokens")), - "reasoning_output_tokens": _optional_int( - raw.get("reasoning_output_tokens") - ), - "total_nano_aiu": total_nano_aiu, - "cost_usd": cost_usd, - "request_multiplier": _optional_float(raw.get("request_multiplier")), - "created_at": str(raw.get("created_at") or ""), - }) + items.append( + { + "usage_event_id": usage_event_id, + "session_id": session_id, + "model": str(raw.get("model") or ""), + "turn_index": _optional_int(raw.get("turn_index")), + "input_tokens": _optional_int(raw.get("input_tokens")), + "cached_input_tokens": _optional_int(raw.get("cached_input_tokens")), + "cache_write_tokens": _optional_int(raw.get("cache_write_tokens")), + "output_tokens": _optional_int(raw.get("output_tokens")), + "reasoning_output_tokens": _optional_int(raw.get("reasoning_output_tokens")), + "total_nano_aiu": total_nano_aiu, + "cost_usd": cost_usd, + "request_multiplier": _optional_float(raw.get("request_multiplier")), + "created_at": str(raw.get("created_at") or ""), + } + ) return tuple(items) diff --git a/argus_skill/core/workbench_plugins.py b/argus_skill/core/workbench_plugins.py new file mode 100644 index 000000000..582ee9d18 --- /dev/null +++ b/argus_skill/core/workbench_plugins.py @@ -0,0 +1,80 @@ +"""Runtime hooks for explicitly installed and enabled workbench plugins.""" + +from . import plugin_manager as manager + + +def installed_workbenches(): + return manager.installed() + + +def native_plugin_command(text, *, sid, life_dir, global_root): + command = text.strip().split(maxsplit=1)[0] if text.strip() else "" + for name, spec in manager.catalog().items(): + if command.lower() != spec.get("command"): + continue + plugin = manager.load_plugin(name, global_root) + if plugin is None: + return "请先在 Argus 的“插件”页面安装并启用 " + spec["name"] + "。" + compatible = manager.compatibility(spec) + # Closing an old binding is always allowed; it invokes no model/tools. + if not compatible["supported"] and text.strip().split(maxsplit=1)[-1] not in { + "off", + "关闭", + "status", + "状态", + }: + return compatible["reason"] + return plugin.native_command(text, sid=sid, life_dir=life_dir, global_root=global_root) + return None + + +def prepare_plugin_run(prompt, options, *, backend, run_label): + import portalocker + + for name, plugin in installed_workbenches().items(): + if options is None or not plugin.owns_workdir(options.working_dir): + continue + directory = manager.install_root() / name + with portalocker.Lock(str(directory / "manage.lock"), timeout=10): + # The registry may have switched after the initial discovery. + plugin = manager.load_plugin(name) + if plugin is None: + raise manager.PluginError("插件已停用,请重新启用后再执行。") + operation = manager.read_json(directory / "operation.json") + if ( + operation.get("status") == "running" + and operation.get("action") != "health" + and manager._job_alive(manager.host_root(), name, operation) + ): + # Only block a call actually bound to this plugin. Ordinary + # Argus sessions continue while an optional plugin updates. + if plugin.owns_workdir(options.working_dir): + raise manager.PluginError("插件正在更新,请稍候再开始新的任务。") + continue + prompt, options = plugin.prepare_run( + prompt, options, backend=backend, run_label=run_label + ) + return prompt, options + + +def finish_plugin_run(options): + for plugin in installed_workbenches().values(): + plugin.finish_run(options) + + +def observe_plugin_stream(options, stream, line): + for plugin in installed_workbenches().values(): + plugin.observe_stream(options, stream, line) + + +def cancel_plugin_operations(sid): + for plugin in installed_workbenches().values(): + plugin.cancel_operations(sid) + + +def plugin_accounting_root(project_root): + for plugin in installed_workbenches().values(): + root = plugin.accounting_root(project_root) + if root is not None: + return root + return None diff --git a/argus_skill/plugin_catalog.json b/argus_skill/plugin_catalog.json new file mode 100644 index 000000000..767bf0ad0 --- /dev/null +++ b/argus_skill/plugin_catalog.json @@ -0,0 +1,73 @@ +{ + "plugins": [ + { + "id": "crystalpilot", + "name": "Argus CrystalPilot", + "version": "0.4.0", + "description": "衍射数据处理、结构求解、精修与三维晶体研究工作台", + "command": "/crystalpilot", + "factory": "argus_crystalpilot.host:CrystalPilotPlugin", + "installer": "argus_crystalpilot.installation", + "setup": { + "module": "argus_crystalpilot.dependencies", + "actions": [ + "health", + "repair", + "shelx", + "configure" + ], + "automatic": true, + "license": { + "action": "shelx", + "name": "SHELX", + "url": "https://shelx.uni-goettingen.de/register.php", + "platform_consent": { + "platform": "darwin", + "machines": [ + "arm64", + "aarch64" + ], + "text": "SHELX 官方 Mac 版需要 Rosetta 2。我同意在缺少时自动安装 Rosetta 2,并接受 Apple 的软件许可。", + "url": "https://www.apple.com/legal/sla/" + } + } + }, + "host_api": 1, + "backends": [ + "codex", + "copilot", + "pi" + ], + "platforms": [ + "windows", + "linux", + "darwin" + ], + "architectures": { + "windows": [ + "amd64", + "x86_64", + "x64" + ], + "linux": [ + "amd64", + "x86_64", + "x64" + ], + "darwin": [ + "x86_64", + "arm64", + "aarch64" + ] + }, + "package": "argus_crystalpilot", + "rights_notice": "© 2026 TopoSpace. All rights reserved. Unauthorized commercial use or derivative development is prohibited.", + "rights_notice_zh": "© 2026 TopoSpace 保留所有权利。未经许可,禁止商用或二次开发。", + "artifact": { + "filename": "argus_crystalpilot-0.4.0-py3-none-any.whl", + "sha256": "030f22e7c18cb411db43f42fc4667cba06da1593a8a2054cc1a8e7e1fd12fed2", + "url": "https://crystalpilot-downloads.argusbot.cn/releases/0.4.0/argus_crystalpilot-0.4.0-py3-none-any.whl" + } + } + ] +} diff --git a/argus_skill/release.py b/argus_skill/release.py index 582229cec..0985dac24 100644 --- a/argus_skill/release.py +++ b/argus_skill/release.py @@ -39,6 +39,13 @@ def _source_files(root: Path) -> Iterable[Path]: "argus_skill/**/*.md", "argus_skill/**/*.yaml", "argus_skill/**/*.yml", + "argus_skill/verticals/**/*.mjs", + "argus_skill/verticals/**/*.ts", + "argus_skill/verticals/**/*.tsx", + "argus_skill/verticals/**/*.css", + "argus_skill/verticals/**/*.html", + "argus_skill/verticals/**/*.svg", + "argus_skill/verticals/**/*.toml", "frontend/core/src/**/*", "frontend/tui/src/**/*", "frontend/tui/bin/**/*", @@ -94,6 +101,20 @@ def _source_files(root: Path) -> Iterable[Path]: seen: set[Path] = set() for pattern in patterns: for path in root.glob(pattern): + relative_parts = path.relative_to(root).parts + if len(relative_parts) > 3 and relative_parts[:2] == ("argus_skill", "verticals"): + optional = root / "argus_skill" / "verticals" / relative_parts[2] / "workbench.json" + if optional.is_file(): + continue # Optional packages have their own artifact checksum. + # A bundled workbench is source, but its local dependencies and + # generated assets must not change release identity or differ from + # the installed wheel's digest. + if path.is_relative_to(root / "argus_skill" / "verticals") and any( + part in {"node_modules", "__pycache__", "dist", ".venv", ".pytest_cache"} + or part.endswith(".egg-info") + for part in path.relative_to(root).parts + ): + continue if ( not path.is_file() or path.name == MANIFEST_FILE diff --git a/argus_skill/release_manifest.json b/argus_skill/release_manifest.json index 29f4a0dcd..cbf8587dc 100644 --- a/argus_skill/release_manifest.json +++ b/argus_skill/release_manifest.json @@ -1,6 +1,6 @@ { "package_version": "0.1.3", - "release_id": "0.1.3+8902de6c5e220a94", + "release_id": "0.1.3+c491c972877eb8f2", "schema_version": 1, - "source_digest": "8902de6c5e220a94254d636dded5100ad5c390f96a3f332f25ae98cb99b86510" + "source_digest": "c491c972877eb8f24680e94912e55c00a1be0608b3ad5c0ddf1ae99ee7ee0742" } diff --git a/argus_skill/release_tools/build_plugins.py b/argus_skill/release_tools/build_plugins.py new file mode 100644 index 000000000..0fd300347 --- /dev/null +++ b/argus_skill/release_tools/build_plugins.py @@ -0,0 +1,93 @@ +"""Build optional plugin wheels and their checksum catalog, separately from Argus.""" + +from __future__ import annotations + +import hashlib +import json +import os +import re +import subprocess +import sys +import tomllib +from pathlib import Path + +ROOT = Path(__file__).resolve().parents[2] + + +def main(): + destination = ROOT / "dist-plugins" + destination.mkdir(exist_ok=True) + catalog_path = ROOT / "argus_skill/plugin_catalog.json" + previous = ( + json.loads(catalog_path.read_text(encoding="utf-8")) + if catalog_path.exists() + else {"plugins": []} + ) + # External releases are maintained independently of this checkout. A host + # build must not erase them just because their private source is absent. + catalog = {entry["id"]: entry for entry in previous["plugins"]} + built = set() + for path in sorted((ROOT / "argus_skill/verticals").glob("*/workbench.json")): + spec = json.loads(path.read_text(encoding="utf-8")) + # `build` is a release-only dependency; build isolation supplies the + # plugin's backend. This does not install a plugin on the build host. + subprocess.run( + [ + sys.executable, + "-m", + "build", + "--wheel", + "--outdir", + str(destination), + str(path.parent), + ], + check=True, + ) + wheels = list(destination.glob(f"{spec['package']}-{spec['version']}-*.whl")) + if len(wheels) != 1: + raise RuntimeError("Expected one platform-independent plugin wheel") + wheel = wheels[0] + spec.pop("frontend", None) + version = tomllib.loads((ROOT / "pyproject.toml").read_text(encoding="utf-8"))["project"][ + "version" + ] + repository = os.environ.get("GITHUB_REPOSITORY", "lbx154/Argus") + tag = os.environ.get("GITHUB_REF_NAME", "") + if not tag.startswith("v"): + tag = "v" + version + release_base = os.environ.get( + "ARGUS_PLUGIN_RELEASE_BASE_URL", + f"https://github.com/{repository}/releases/download/{tag}", + ).rstrip("/") + spec["artifact"] = { + "filename": wheel.name, + "sha256": hashlib.sha256(wheel.read_bytes()).hexdigest(), + "url": f"{release_base}/{wheel.name}" if release_base else "", + } + catalog[spec["id"]] = spec + built.add(spec["id"]) + catalog = [catalog[name] for name in sorted(catalog)] + for spec in catalog: + artifact = spec.get("artifact", {}) + artifact.pop("local", None) + if not str(artifact.get("url", "")).startswith("https://") or not re.fullmatch( + r"[a-f0-9]{64}", artifact.get("sha256", "") + ): + raise ValueError(f"Plugin {spec['id']} needs an HTTPS release URL and SHA-256") + # The shipped catalog never embeds paths to the maintainer's computer. + (ROOT / "argus_skill/plugin_catalog.json").write_text( + json.dumps({"plugins": catalog}, ensure_ascii=False, indent=2) + "\n", encoding="utf-8" + ) + for spec in catalog: + if spec["id"] in built: + spec["artifact"]["local"] = spec["artifact"]["filename"] + (destination / "catalog.json").write_text( + json.dumps({"plugins": catalog}, ensure_ascii=False, indent=2) + "\n", encoding="utf-8" + ) + print( + f"Built {len(built)} optional packages; retained {len(catalog) - len(built)} external releases" + ) + + +if __name__ == "__main__": + main() diff --git a/argus_skill/release_tools/build_release.py b/argus_skill/release_tools/build_release.py index 798341896..4b14553f2 100644 --- a/argus_skill/release_tools/build_release.py +++ b/argus_skill/release_tools/build_release.py @@ -44,6 +44,19 @@ def run(*argv: str, cwd: Path = ROOT) -> None: def main() -> int: try: + # Bundled verticals may ship independent workbench frontends. Build each + # before the release digest, keeping domain code out of the host UI. + for manifest_path in sorted((ROOT / "argus_skill" / "verticals").glob("*/workbench.json")): + spec = json.loads(manifest_path.read_text(encoding="utf-8")) + if not spec.get("frontend"): + continue + frontend = (manifest_path.parent / spec["frontend"]).resolve() + if manifest_path.parent.resolve() not in frontend.parents: + raise ValueError("vertical frontend must remain inside its package") + if not (frontend / "node_modules").is_dir(): + run(NPM_COMMAND, "ci", cwd=frontend) + run(NPM_COMMAND, "run", "build", cwd=frontend) + run(sys.executable, "-m", "argus_skill.release_tools.build_plugins") # Generated protocol source participates in the release digest, so it # must be refreshed before computing the manifest. Reversing these two # steps makes a schema change require two builds: the first build updates diff --git a/argus_skill/release_tools/verify_plugin_install.py b/argus_skill/release_tools/verify_plugin_install.py new file mode 100644 index 000000000..758dc098e --- /dev/null +++ b/argus_skill/release_tools/verify_plugin_install.py @@ -0,0 +1,65 @@ +"""Cross-platform optional-package installer smoke; never calls a model.""" + +from __future__ import annotations + +import json +import os +import tempfile +import time +from pathlib import Path + + +def main(): + from ..core import plugin_manager as manager + from .build_plugins import ROOT + + with tempfile.TemporaryDirectory(prefix="argus-plugin-install-") as directory: + root = Path(directory) + os.environ["ARGUS_SKILL_HOME"] = str(root) + os.environ["ARGUS_WORKBENCH_HOST_ROOT"] = str(root) + if not os.environ.get("ARGUS_PLUGIN_CATALOG"): + os.environ["ARGUS_PLUGIN_CATALOG"] = str(ROOT / "argus_skill/plugin_catalog.json") + os.environ["ARGUS_SKILL_RUNNER_BACKEND"] = "pi" + for role in ("MANAGER", "PLANNER", "ENGINEER", "REVIEWER"): + os.environ["ARGUS_SKILL_" + role + "_BACKEND"] = "pi" + assert not manager.installed(root) + manager.mutate("crystalpilot", "install", root) + deadline = time.monotonic() + 10800 + while time.monotonic() < deadline: + row = manager.plugin_rows(root)[0] + if row["operation"].get("status") == "failed": + raise RuntimeError(row["operation"]["error"]) + if row["installed"] and row["operation"].get("status") == "completed": + break + time.sleep(1) + else: + raise TimeoutError("Plugin installation did not complete") + plugin = manager.load_plugin("crystalpilot", root) + assert plugin and plugin.vertical_module().ARGUS_VERTICAL_API_VERSION == 1 + health = row["health"] + assert all(r["status"] == "ready" for r in health["components"] if r["automatic"]), health + assert all( + r["status"] == "missing" for r in health["components"] if r["license_required"] + ), health + software = root / "extensions/crystalpilot/resources/software.json" + assert software.is_file() + sentinel = root / "plugins/crystalpilot/retained.json" + sentinel.parent.mkdir(parents=True, exist_ok=True) + sentinel.write_text("{}") + manager.mutate("crystalpilot", "uninstall", root) + assert not manager.installed(root) and sentinel.exists() and software.exists() + print( + json.dumps( + { + "platform": os.name, + "installation": True, + "uninstall_preserves_data": True, + "free_software_verified": True, + "license_not_bundled": True, + } + ) + ) + + +if __name__ == "__main__": + main() diff --git a/argus_skill/roles/prompts/manager.py b/argus_skill/roles/prompts/manager.py index b074ed292..45c848c30 100644 --- a/argus_skill/roles/prompts/manager.py +++ b/argus_skill/roles/prompts/manager.py @@ -248,6 +248,9 @@ def build_front_door_prompt(text: str, *, active_mission: bool = False) -> str: "IMPLEMENT=local implementation+tests; DEBUG=diagnosis/fix+tests; " "REVIEW=local review report; SYNTHESIZE=synthesis " "from supplied sources. Prefer DEBUG for fixes/regressions; TEAM=NONE. " + "A request to actually inspect data, call tools, calculate or change state is execution work, " + "including a bounded test or acceptance check: do not choose SELF_MODE=REPLY for it. " + "REPLY answers a question from available context; it must not merely describe how you classified a requested action. " "REPLY is the complete human-facing answer for SELF/REPLY, " "in the operator's language: lead with the answer in ordinary words; " "never expose route, control, lifetime, or role-protocol labels.\n\n" diff --git a/argus_skill/verticals/_base.py b/argus_skill/verticals/_base.py index 01b20db64..bb73af0dc 100644 --- a/argus_skill/verticals/_base.py +++ b/argus_skill/verticals/_base.py @@ -49,7 +49,8 @@ def load_vertical(name: object, project_root: object = None) -> VerticalDefiniti stages_path = os.path.join( os.path.dirname(__file__), *import_name.split("."), "stages.py" ) - if os.path.isfile(stages_path): + optional = Path(stages_path).with_name("workbench.json").is_file() + if os.path.isfile(stages_path) and not optional: try: return importlib.import_module(module_name) except Exception as exc: # noqa: BLE001 diff --git a/argus_skill/verticals/_registry.py b/argus_skill/verticals/_registry.py index 0ff1fdbdb..2b2c98ede 100644 --- a/argus_skill/verticals/_registry.py +++ b/argus_skill/verticals/_registry.py @@ -4,7 +4,6 @@ import logging import re from dataclasses import dataclass -from functools import lru_cache from importlib.metadata import entry_points from pathlib import Path from types import ModuleType @@ -33,7 +32,6 @@ def _skills_root(module: ModuleType) -> Any: return value -@lru_cache(maxsize=1) def vertical_plugins() -> dict[str, VerticalPlugin]: """Load valid plugins once. Invalid registrations are not advertised.""" try: @@ -41,9 +39,16 @@ def vertical_plugins() -> dict[str, VerticalPlugin]: except Exception: # noqa: BLE001 log.warning("vertical entry-point discovery failed", exc_info=True) return {} + from ..core import plugin_manager plugins: dict[str, VerticalPlugin] = {} + for name, plugin in plugin_manager.installed().items(): + module = plugin.vertical_module() + plugins[name] = VerticalPlugin(name, module.VERTICAL_PURPOSE, module, _skills_root(module)) + managed_names = set(plugin_manager.catalog()) for entry in sorted(discovered, key=lambda row: (row.name, row.value)): name = str(entry.name or "").strip().lower() + if name in managed_names: + continue if not _NAME.fullmatch(name) or name in plugins: log.warning("ignoring invalid or duplicate vertical entry point %r", name) continue @@ -80,7 +85,7 @@ def vertical_plugin(name: object) -> VerticalPlugin | None: def refresh_vertical_plugins() -> None: - vertical_plugins.cache_clear() + pass # Managed activation is read on every discovery; installed modules are cached. __all__ = [ diff --git a/argus_skill/webapi/daemon_lifecycle.py b/argus_skill/webapi/daemon_lifecycle.py index 0c5e3113d..faafde126 100644 --- a/argus_skill/webapi/daemon_lifecycle.py +++ b/argus_skill/webapi/daemon_lifecycle.py @@ -523,7 +523,7 @@ def replace_project_daemon( def create_daemon( - objective: str = "", *, name: str = "", + objective: str = "", *, name: str = "", session_namespace: str = "", launch_cwd: str = "", workdir: str = "", global_root: Path | str | None = None, @@ -549,7 +549,7 @@ def create_daemon( from ..core.session import new_session_id root = _global_root(global_root) - sid = new_session_id() + sid = new_session_id(session_namespace) if session_namespace else new_session_id() now = _time.time() requested_objective = (objective or "").strip() life_dir = core_paths.session_state_root(sid, root=root) @@ -760,6 +760,8 @@ def stop_project_daemon( ) -> dict[str, Any] | None: """Stop this project's daemon. Blocking (waits up to the drain timeout) — call from a threadpool in the async endpoint.""" + from ..core.workbench_plugins import cancel_plugin_operations + cancel_plugin_operations(sid) life_dir = project_life_dir(sid, global_root=global_root) if life_dir is None: return None diff --git a/argus_skill/webapi/manager_bridge.py b/argus_skill/webapi/manager_bridge.py index 749310902..d6f63b71b 100644 --- a/argus_skill/webapi/manager_bridge.py +++ b/argus_skill/webapi/manager_bridge.py @@ -251,6 +251,19 @@ def _after_reply(reply: str) -> None: "reply": "project no longer exists; the message was not processed", } + # Native domain commands stay on this session and do not run a classifier. + from ..core.workbench_plugins import native_plugin_command + with _lock_for(sid): + plugin_reply = native_plugin_command(operator_text, sid=sid, + life_dir=life_dir, global_root=mem.global_root) + if plugin_reply is not None: + append_turn(life_dir, "operator", body) + append_turn(life_dir, "argus", plugin_reply) + _emit_ui_turn(life_dir, "operator", body, message_id=f"{turn_id}-operator") + _emit_ui_turn(life_dir, "argus", plugin_reply, message_id=f"{turn_id}-argus") + _fragment("delta", {"text": plugin_reply}) + return {"kind": "chat", "reply": plugin_reply} + # Atlas card references: replace each ``[[Argus引用 {...}]]`` marker line # with a readable inline line in the persisted operator text, and carry the # bounded context block separately so only the model-facing bodies (triage diff --git a/argus_skill/webapi/routes/plugins.py b/argus_skill/webapi/routes/plugins.py new file mode 100644 index 000000000..9abcfc8a7 --- /dev/null +++ b/argus_skill/webapi/routes/plugins.py @@ -0,0 +1,101 @@ +"""Optional plugin center plus dynamically activated, authenticated workbenches.""" + +from fastapi import Body, Depends, FastAPI, HTTPException, Request +from fastapi.responses import JSONResponse + +from ...core import plugin_manager as manager + + +class PluginSurface: + def __init__(self, ctx): + self.ctx = ctx + self.apps = {} + + async def __call__(self, scope, receive, send): + name = scope["path_params"]["plugin_id"] + spec = manager.catalog().get(name) + plugin = manager.load_plugin(name, self.ctx.global_root) if spec else None + if plugin is None: + response = JSONResponse( + {"detail": "插件未安装或未启用,请前往插件中心。"}, status_code=404 + ) + return await response(scope, receive, send) + compatible = manager.compatibility(spec) + if not compatible["supported"]: + response = JSONResponse({"detail": compatible["reason"]}, status_code=409) + return await response(scope, receive, send) + operation = manager.read_json( + manager.install_root(self.ctx.global_root) / name / "operation.json" + ) + if ( + scope.get("method") not in {"GET", "HEAD", "OPTIONS"} + and operation.get("status") == "running" + and operation.get("action") != "health" + ): + response = JSONResponse({"detail": "插件正在更新,请稍候再执行操作。"}, status_code=409) + return await response(scope, receive, send) + key = id(plugin) + if key not in self.apps: + host = FastAPI() + plugin.mount(host, self.ctx) + self.apps[key] = host + await self.apps[key](scope, receive, send) + + +def register_plugin_routes(app, ctx): + @app.get("/api/plugins", dependencies=[Depends(ctx.require_auth)]) + def list_plugins(): + return {"plugins": manager.plugin_rows(ctx.global_root)} + + @app.post("/api/plugins/{plugin_id}/manage/{action}", dependencies=[Depends(ctx.require_auth)]) + def manage( + plugin_id: str, action: str, request: Request, payload: dict = Body(default_factory=dict) + ): + origin = request.headers.get("origin") + from urllib.parse import urlparse + + if origin and urlparse(origin).netloc != request.headers.get("host"): + raise HTTPException(403, "Cross-origin plugin management refused") + try: + if set(payload) - {"username", "password", "paths", "accept_platform_license"}: + raise ValueError("Unknown plugin setup field") + if "accept_platform_license" in payload and not isinstance( + payload["accept_platform_license"], bool + ): + raise ValueError("Invalid platform consent") + if any( + not isinstance(payload.get(key, ""), str) or len(payload.get(key, "")) > 500 + for key in ("username", "password") + ): + raise ValueError("Invalid credential format") + return manager.mutate(plugin_id, action, ctx.global_root, payload=payload) + except (manager.PluginError, ValueError) as exc: + raise HTTPException(409, str(exc)) from exc + + @app.post("/api/plugins/{plugin_id}/launch", dependencies=[Depends(ctx.require_auth)]) + def launch_plugin(plugin_id: str, request: Request): + spec = manager.catalog().get(plugin_id) + if not spec or not manager.load_plugin(plugin_id, ctx.global_root): + raise HTTPException(404, "plugin is not installed or enabled") + compatible = manager.compatibility(spec) + if not compatible["supported"]: + raise HTTPException(409, compatible["reason"]) + response = JSONResponse({"url": f"/plugins/{plugin_id}/"}) + if ctx.token: + response.set_cookie( + "argus_plugin_access", + ctx.token, + httponly=True, + samesite="strict", + secure=request.url.scheme == "https", + path=f"/api/plugins/{plugin_id}", + ) + return response + + # Route an installed version on demand, so install/update/uninstall take + # effect without restarting Argus or disrupting unrelated sessions. + surface = PluginSurface(ctx) + methods = ["GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS", "HEAD"] + app.router.add_route("/api/plugins/{plugin_id}/{rest:path}", surface, methods=methods) + app.router.add_route("/plugins/{plugin_id}/{rest:path}", surface, methods=methods) + app.router.add_route("/plugins/{plugin_id}", surface, methods=methods) diff --git a/argus_skill/webapi/server.py b/argus_skill/webapi/server.py index cd709ca55..51e40a9a2 100644 --- a/argus_skill/webapi/server.py +++ b/argus_skill/webapi/server.py @@ -687,6 +687,8 @@ def _shutdown_warm_manager_clients() -> None: from .routes.map_notes import register_map_note_routes register_map_note_routes(app, ctx) + from .routes.plugins import register_plugin_routes + register_plugin_routes(app, ctx) # ── static web UI (optional) ────────────────────────────────────────── # When the React frontend has been built (`npm run build` in frontend/web), diff --git a/desktop-tauri/argus_backend.spec b/desktop-tauri/argus_backend.spec index f4d880749..61b1a469a 100644 --- a/desktop-tauri/argus_backend.spec +++ b/desktop-tauri/argus_backend.spec @@ -18,7 +18,13 @@ ROOT = TAURI_ROOT.parent # optional scientific/quant dependency at build time. Modules reached by the # product runtime are still analyzed normally; dynamic providers remain exact # hidden imports below. -datas = collect_data_files("argus_skill", include_py_files=True) +optional_roots = [p.parent for p in (ROOT / "argus_skill/verticals").glob("*/workbench.json")] +def optional_source(path): + path = Path(path).resolve() + return any(path == root or root in path.parents for root in optional_roots) + +datas = [(source, target) for source, target in collect_data_files("argus_skill", include_py_files=True) + if not optional_source(source)] # Windows does not ship an IANA timezone database. Keep named ZoneInfo keys # available to the frozen Python-compatible runtime and extension tools. datas += collect_data_files("tzdata") @@ -35,6 +41,8 @@ def collect_in_tree_modules(package_root, package): """List every shipped Python module without importing optional subpackages.""" modules = [] for path in sorted(package_root.rglob("*.py")): + if optional_source(path): + continue relative = path.relative_to(package_root) parts = list(relative.with_suffix("").parts) if parts[-1] == "__init__": @@ -98,7 +106,7 @@ a = Analysis( hookspath=[], hooksconfig={}, runtime_hooks=[], - excludes=[], + excludes=["argus_skill.verticals." + p.name for p in optional_roots], noarchive=False, ) diff --git a/docs/ci-examples/plugin-compatibility.yml b/docs/ci-examples/plugin-compatibility.yml new file mode 100644 index 000000000..ffc72d14f --- /dev/null +++ b/docs/ci-examples/plugin-compatibility.yml @@ -0,0 +1,36 @@ +name: optional-plugin-compatibility +on: + workflow_dispatch: + pull_request: + paths: + - 'argus_skill/core/plugin_manager.py' + - 'argus_skill/core/plugin_runtime.py' + - 'argus_skill/core/workbench_plugins.py' + - 'argus_skill/plugin_catalog.json' + - 'argus_skill/release_tools/build_plugins.py' + - 'tests/core/test_*plugin*.py' + - 'argus_skill/agent_cli/**' + - 'argus_skill/webapi/routes/plugins.py' + - '.github/workflows/plugin-compatibility.yml' +permissions: + contents: read +jobs: + plugins: + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, windows-latest, macos-latest, macos-15-intel] + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: '3.11' + - uses: actions/setup-node@v4 + with: + node-version: '22' + - run: python -m pip install -e . pytest build + - name: Host contracts (no private checkout or model calls) + run: python -m pytest tests/core/test_plugin_manager.py tests/core/test_plugin_runtime.py tests/core/test_external_plugin_release.py tests/apps/test_runtime_packaged_skills.py tests/skills/test_vertical_plugins.py + - name: Clean install from public HTTPS source (no licensed binaries or model calls) + run: python -m argus_skill.release_tools.verify_plugin_install diff --git a/docs/workbench-plugins.md b/docs/workbench-plugins.md new file mode 100644 index 000000000..995d75bd8 --- /dev/null +++ b/docs/workbench-plugins.md @@ -0,0 +1,37 @@ +# Optional workbench plugins + +Argus provides the plugin center and lifecycle API. CrystalPilot is distributed independently: its scientific core, workbench frontend and installer source are not in this public repository or the host installation. The default installation has no enabled workbench plugins. + +## Install and use + +Open **Plugins → Argus CrystalPilot → Install**. Argus downloads the wheel specified by its bundled `argus_skill/plugin_catalog.json`, verifies SHA-256, creates an isolated Python environment, installs the plugin and scientific dependencies, and activates it only after its core and host interface validate. + +The public distribution page is https://crystalpilot-downloads.argusbot.cn/. Immutable wheel and source archives are under `/releases//`. Argus installs the wheel; it never clones a private repository. The source ZIP is for inspection and independent builds. Upstream scientific binaries, model credentials and research datasets are not included in these artifacts. + +The host checks its default and per-role execution backends. CrystalPilot supports Codex, Copilot and Pi, including mixed supported roles. Unsupported backends block workbench access with “暂不支持,敬请期待”. Provider credentials and model choices remain owned by Argus. + +After installation, `/crystalpilot` in a native Argus session enables scientific tools in that interface. Opening CrystalPilot from Plugins uses its own workbench. The surfaces retain separate conversations, ownership and project bindings. + +## Environment and lifecycle + +The plugin prepares its private scientific environment and automatically attempts free dependency installation. Missing optional/licensed components remain visible in its health report and can be repaired or configured later. For SHELX, users register with the upstream author and enter their licensed download credentials in the local administration form. Credentials are not passed through models. + +Installations live under `ARGUS_SKILL_HOME/extensions//releases`. Research state and reusable scientific programs live separately. Updates are manual, staged in a new directory and activated atomically; failure retains the previous version. Active session, CLI and scientific work blocks update, disable, uninstall and environment repair. Uninstall removes release environments while preserving research data, conversations and reusable software. + +The plugin center uses Argus's authenticated local administration interface. It is not a multi-tenant marketplace. Browsers submit a catalog id and action, not arbitrary installer URLs or commands. Dynamic ASGI routing activates installed plugins without restarting unrelated Argus sessions. + +## Release maintenance + +The catalog is curated and pinned to reviewed HTTPS artifacts and SHA-256 digests. New plugin releases require a catalog update; this implementation does not automatically trust an online latest manifest. The public catalog at the distribution source helps maintainers inspect releases but does not override a user's bundled trust configuration. + +Host release builds preserve external entries even when no plugin source exists in the checkout. They neither download nor rebuild CrystalPilot. Host contracts can run in public Argus CI without access to the private repository. A four-platform installer workflow example is provided in `docs/ci-examples/plugin-compatibility.yml`; it is not active until a maintainer with workflow permission copies it into `.github/workflows/`. Existing repository CI remains unchanged. An example is not evidence of a successful platform run. + +Optional in-tree plugins can still use `python -m argus_skill.release_tools.build_plugins`. That command merges generated entries with the externally maintained catalog; its developer catalog adds local wheel paths only for packages actually built in that checkout. `ARGUS_PLUGIN_CATALOG` is a host-side override for a curated local file. Release maintainers must publish every referenced artifact before updating the host catalog. + +## CrystalPilot licensing + +© 2026 TopoSpace. All rights reserved. Unauthorized commercial use or derivative development of Argus CrystalPilot is prohibited. The plugin is proprietary; the public source archive does not grant commercial or derivative-development rights. Third-party components retain their respective licenses. These terms apply to the TopoSpace-owned plugin, not to Argus itself or the MIT-licensed host integration. + +CrystalPilot includes Chinese and English workbench modes. The sidebar language button and Settings → Appearance share a plugin-owned preference. Changing language preserves drafts and running tasks; new user-facing replies and titles follow that default. Raw scientific records and user-authored names remain intact. + +The submitting OAuth session does not have GitHub's `workflow` scope. The four-platform installer matrix is intentionally supplied as an inactive example, not a newly active workflow. Maintainers can review and enable it separately without blocking the plugin-center implementation. diff --git a/frontend/core/src/commands.ts b/frontend/core/src/commands.ts index b065848b7..85b9bb295 100644 --- a/frontend/core/src/commands.ts +++ b/frontend/core/src/commands.ts @@ -3,7 +3,7 @@ import { EVENT_VIEW_FILTERS, type EventViewFilter } from './events.js'; export type CommandKind = 'panel' | 'action' | 'local'; export type CommandId = - | 'status' | 'roles' | 'journal' | 'backlog' | 'artifacts' | 'artifact' + | 'crystalpilot' | 'status' | 'roles' | 'journal' | 'backlog' | 'artifacts' | 'artifact' | 'events' | 'find' | 'cancel' | 'ask' | 'task' | 'plan' | 'rewrite' | 'nudge' | 'abort' | 'note' | 'done' | 'skip' | 'stop' | 'item' | 'run' | 'new' | 'daemons' | 'resume' | 'attach' | 'rename' | 'doctor' | 'backend' | 'config' @@ -31,6 +31,7 @@ export const COMMANDS: SlashCommand[] = [ { id: 'find', name: '/find', arg: '', argument: 'required', desc: 'search the current event buffer', group: 'Everyday', kind: 'panel' }, { id: 'cancel', name: '/cancel', argument: 'none', desc: 'stop waiting for the current Manager reply', group: 'Everyday', kind: 'local' }, { id: 'ask', name: '/ask', arg: '', argument: 'required', desc: 'answer inline — no task queued, no Planner/Engineer/Reviewer', aliases: ['/chat'], group: 'Everyday', kind: 'action' }, + { id: 'crystalpilot', name: '/crystalpilot', arg: '[status|off|use ]', argument: 'optional', desc: 'enable crystallography tools in this Argus conversation', group: 'Everyday', kind: 'action' }, { id: 'task', name: '/task', arg: '', argument: 'required', desc: 'queue work directly', aliases: ['/add'], group: 'Task management', kind: 'action' }, { id: 'plan', name: '/plan', arg: '', argument: 'required', desc: 'preview a Planner-authored execution plan', group: 'Task management', kind: 'action' }, { id: 'rewrite', name: '/rewrite', arg: '[text]', argument: 'optional', desc: 'let the Manager rewrite your prompt before sending', aliases: ['/refine'], group: 'Task management', kind: 'action' }, diff --git a/frontend/core/src/release.generated.ts b/frontend/core/src/release.generated.ts index fced57da4..bd7d209b6 100644 --- a/frontend/core/src/release.generated.ts +++ b/frontend/core/src/release.generated.ts @@ -1,3 +1,3 @@ // Generated by argus_skill.release_tools.generate_manifest. Do not edit. -export const RELEASE_ID = "0.1.3+8902de6c5e220a94"; -export const RELEASE_SOURCE_DIGEST = "8902de6c5e220a94254d636dded5100ad5c390f96a3f332f25ae98cb99b86510"; +export const RELEASE_ID = "0.1.3+c491c972877eb8f2"; +export const RELEASE_SOURCE_DIGEST = "c491c972877eb8f24680e94912e55c00a1be0608b3ad5c0ddf1ae99ee7ee0742"; diff --git a/frontend/tui/bundle/argus.mjs b/frontend/tui/bundle/argus.mjs index d0848aa7a..018445d45 100644 --- a/frontend/tui/bundle/argus.mjs +++ b/frontend/tui/bundle/argus.mjs @@ -121,7 +121,7 @@ Read about how to prevent this error on https://github.com/vadimdemedes/ink/#isr Read about how to prevent this error on https://github.com/vadimdemedes/ink/#israwmodesupported`);if(r.setEncoding("utf8"),t){this.rawModeEnabledCount===0&&(r.ref(),r.setRawMode(!0),r.addListener("readable",this.handleReadable)),this.rawModeEnabledCount++;return}--this.rawModeEnabledCount===0&&(r.setRawMode(!1),r.removeListener("readable",this.handleReadable),r.unref())};handleReadable=()=>{let t;for(;(t=this.props.stdin.read())!==null;)this.handleInput(t),this.internal_eventEmitter.emit("input",t)};handleInput=t=>{t===""&&this.props.exitOnCtrlC&&this.handleExit(),t===ab&&this.state.activeFocusId&&this.setState({activeFocusId:void 0}),this.state.isFocusEnabled&&this.state.focusables.length>0&&(t===ib&&this.focusNext(),t===sb&&this.focusPrevious())};handleExit=t=>{this.isRawModeSupported()&&this.handleSetRawMode(!1),this.props.onExit(t)};enableFocus=()=>{this.setState({isFocusEnabled:!0})};disableFocus=()=>{this.setState({isFocusEnabled:!1})};focus=t=>{this.setState(r=>r.focusables.some(s=>s?.id===t)?{activeFocusId:t}:r)};focusNext=()=>{this.setState(t=>{let r=t.focusables.find(s=>s.isActive)?.id;return{activeFocusId:this.findNextFocusable(t)??r}})};focusPrevious=()=>{this.setState(t=>{let r=t.focusables.findLast(s=>s.isActive)?.id;return{activeFocusId:this.findPreviousFocusable(t)??r}})};addFocusable=(t,{autoFocus:r})=>{this.setState(i=>{let s=i.activeFocusId;return!s&&r&&(s=t),{activeFocusId:s,focusables:[...i.focusables,{id:t,isActive:!0}]}})};removeFocusable=t=>{this.setState(r=>({activeFocusId:r.activeFocusId===t?void 0:r.activeFocusId,focusables:r.focusables.filter(i=>i.id!==t)}))};activateFocusable=t=>{this.setState(r=>({focusables:r.focusables.map(i=>i.id!==t?i:{id:t,isActive:!0})}))};deactivateFocusable=t=>{this.setState(r=>({activeFocusId:r.activeFocusId===t?void 0:r.activeFocusId,focusables:r.focusables.map(i=>i.id!==t?i:{id:t,isActive:!1})}))};findNextFocusable=t=>{let r=t.focusables.findIndex(i=>i.id===t.activeFocusId);for(let i=r+1;i{let r=t.focusables.findIndex(i=>i.id===t.activeFocusId);for(let i=r-1;i>=0;i--){let s=t.focusables[i];if(s?.isActive)return s.id}}};var hy=()=>{},xf=class{options;log;throttledLog;isUnmounted;lastOutput;container;rootNode;fullStaticOutput;exitPromise;restoreConsole;unsubscribeResize;constructor(t){FE(this),this.options=t,this.rootNode=Id("ink-root"),this.rootNode.onComputeLayout=this.calculateLayout,this.rootNode.onRender=t.debug?this.onRender:Zg(this.onRender,32,{leading:!0,trailing:!0}),this.rootNode.onImmediateRender=this.onRender,this.log=zD.create(t.stdout),this.throttledLog=t.debug?this.log:Zg(this.log,void 0,{leading:!0,trailing:!0}),this.isUnmounted=!1,this.lastOutput="",this.fullStaticOutput="",this.container=ZA.createContainer(this.rootNode,0,null,!1,null,"id",()=>{},null),this.unsubscribeExit=(0,By.default)(this.unmount,{alwaysLast:!1}),Ab.env.DEV==="true"&&ZA.injectIntoDevTools({bundleType:0,version:"16.13.1",rendererPackageName:"ink"}),t.patchConsole&&this.patchConsole(),HA||(t.stdout.on("resize",this.resized),this.unsubscribeResize=()=>{t.stdout.off("resize",this.resized)})}resized=()=>{this.calculateLayout(),this.onRender()};resolveExitPromise=()=>{};rejectExitPromise=()=>{};unsubscribeExit=()=>{};calculateLayout=()=>{let t=this.options.stdout.columns||80;this.rootNode.yogaNode.setWidth(t),this.rootNode.yogaNode.calculateLayout(void 0,void 0,it.DIRECTION_LTR)};onRender=()=>{if(this.isUnmounted)return;let{output:t,outputHeight:r,staticOutput:i}=GD(this.rootNode),s=i&&i!==` `;if(this.options.debug){s&&(this.fullStaticOutput+=i),this.options.stdout.write(this.fullStaticOutput+t);return}if(HA){s&&this.options.stdout.write(i),this.lastOutput=t;return}if(s&&(this.fullStaticOutput+=i),r>=this.options.stdout.rows){this.options.stdout.write(Mo.clearTerminal+this.fullStaticOutput+t),this.lastOutput=t;return}s&&(this.log.clear(),this.options.stdout.write(i),this.log(t)),!s&&t!==this.lastOutput&&this.throttledLog(t),this.lastOutput=t};render(t){let r=Cy.default.createElement(kf,{stdin:this.options.stdin,stdout:this.options.stdout,stderr:this.options.stderr,writeToStdout:this.writeToStdout,writeToStderr:this.writeToStderr,exitOnCtrlC:this.options.exitOnCtrlC,onExit:this.unmount},t);ZA.updateContainer(r,this.container,null,hy)}writeToStdout(t){if(!this.isUnmounted){if(this.options.debug){this.options.stdout.write(t+this.fullStaticOutput+this.lastOutput);return}if(HA){this.options.stdout.write(t);return}this.log.clear(),this.options.stdout.write(t),this.log(this.lastOutput)}}writeToStderr(t){if(!this.isUnmounted){if(this.options.debug){this.options.stderr.write(t),this.options.stdout.write(this.fullStaticOutput+this.lastOutput);return}if(HA){this.options.stderr.write(t);return}this.log.clear(),this.options.stderr.write(t),this.log(this.lastOutput)}}unmount(t){this.isUnmounted||(this.calculateLayout(),this.onRender(),this.unsubscribeExit(),typeof this.restoreConsole=="function"&&this.restoreConsole(),typeof this.unsubscribeResize=="function"&&this.unsubscribeResize(),HA?this.options.stdout.write(this.lastOutput+` `):this.options.debug||this.log.done(),this.isUnmounted=!0,ZA.updateContainer(null,this.container,null,hy),Tu.delete(this.options.stdout),t instanceof Error?this.rejectExitPromise(t):this.resolveExitPromise())}async waitUntilExit(){return this.exitPromise||=new Promise((t,r)=>{this.resolveExitPromise=t,this.rejectExitPromise=r}),this.exitPromise}clear(){!HA&&!this.options.debug&&this.log.clear()}patchConsole(){this.options.debug||(this.restoreConsole=aC((t,r)=>{t==="stdout"&&this.writeToStdout(r),t==="stderr"&&(r.startsWith("The above error occurred")||this.writeToStderr(r))}))}};var ub=(e,t)=>{let r={stdout:Zd.stdout,stdin:Zd.stdin,stderr:Zd.stderr,debug:!1,exitOnCtrlC:!0,patchConsole:!0,...cb(t)},i=fb(r.stdout,()=>new xf(r));return i.render(e),{rerender:i.render,unmount(){i.unmount()},waitUntilExit:i.waitUntilExit,cleanup:()=>Tu.delete(r.stdout),clear:i.clear}},Zm=ub,cb=(e={})=>e instanceof lb?{stdout:e,stdin:Zd.stdin}:e,fb=(e,t)=>{let r=Tu.get(e);return r||(r=t(),Tu.set(e,r)),r};var fa=Le($t(),1);function Nf(e){let{items:t,children:r,style:i}=e,[s,a]=(0,fa.useState)(0),u=(0,fa.useMemo)(()=>t.slice(s),[t,s]);(0,fa.useLayoutEffect)(()=>{a(t.length)},[t.length]);let E=u.map((h,y)=>r(h,s+y)),m=(0,fa.useMemo)(()=>({position:"absolute",flexDirection:"column",...i}),[i]);return fa.default.createElement("ink-box",{internal_static:!0,style:m},E)}var gb=Le($t(),1);var db=Le($t(),1);var pb=Le($t(),1);var eI=Le($t(),1);import{Buffer as Eb}from"node:buffer";var mb=/^(?:\x1b)([a-zA-Z0-9])$/,Ib=/^(?:\x1b+)(O|N|\[|\[\[)(?:(\d+)(?:;(\d+))?([~^$])|(?:1;)?(\d+)?([a-zA-Z]))/,Dy={OP:"f1",OQ:"f2",OR:"f3",OS:"f4","[11~":"f1","[12~":"f2","[13~":"f3","[14~":"f4","[[A":"f1","[[B":"f2","[[C":"f3","[[D":"f4","[[E":"f5","[15~":"f5","[17~":"f6","[18~":"f7","[19~":"f8","[20~":"f9","[21~":"f10","[23~":"f11","[24~":"f12","[A":"up","[B":"down","[C":"right","[D":"left","[E":"clear","[F":"end","[H":"home",OA:"up",OB:"down",OC:"right",OD:"left",OE:"clear",OF:"end",OH:"home","[1~":"home","[2~":"insert","[3~":"delete","[4~":"end","[5~":"pageup","[6~":"pagedown","[[5~":"pageup","[[6~":"pagedown","[7~":"home","[8~":"end","[a":"up","[b":"down","[c":"right","[d":"left","[e":"clear","[2$":"insert","[3$":"delete","[5$":"pageup","[6$":"pagedown","[7$":"home","[8$":"end",Oa:"up",Ob:"down",Oc:"right",Od:"left",Oe:"clear","[2^":"insert","[3^":"delete","[5^":"pageup","[6^":"pagedown","[7^":"home","[8^":"end","[Z":"tab"},yy=[...Object.values(Dy),"backspace"],hb=e=>["[a","[b","[c","[d","[e","[2$","[3$","[5$","[6$","[7$","[8$","[Z"].includes(e),Cb=e=>["Oa","Ob","Oc","Od","Oe","[2^","[3^","[5^","[6^","[7^","[8^"].includes(e),Bb=(e="")=>{let t;Eb.isBuffer(e)?e[0]>127&&e[1]===void 0?(e[0]-=128,e="\x1B"+String(e)):e=String(e):e!==void 0&&typeof e!="string"?e=String(e):e||(e="");let r={name:"",ctrl:!1,meta:!1,shift:!1,option:!1,sequence:e,raw:e};if(r.sequence=r.sequence||e||r.name,e==="\r")r.raw=void 0,r.name="return";else if(e===` -`)r.name="enter";else if(e===" ")r.name="tab";else if(e==="\b"||e==="\x1B\b")r.name="backspace",r.meta=e.charAt(0)==="\x1B";else if(e==="\x7F"||e==="\x1B\x7F")r.name="delete",r.meta=e.charAt(0)==="\x1B";else if(e==="\x1B"||e==="\x1B\x1B")r.name="escape",r.meta=e.length===2;else if(e===" "||e==="\x1B ")r.name="space",r.meta=e.length===2;else if(e.length===1&&e<="")r.name=String.fromCharCode(e.charCodeAt(0)+97-1),r.ctrl=!0;else if(e.length===1&&e>="0"&&e<="9")r.name="number";else if(e.length===1&&e>="a"&&e<="z")r.name=e;else if(e.length===1&&e>="A"&&e<="Z")r.name=e.toLowerCase(),r.shift=!0;else if(t=mb.exec(e))r.meta=!0,r.shift=/^[A-Z]$/.test(t[1]);else if(t=Ib.exec(e)){let i=[...e];i[0]==="\x1B"&&i[1]==="\x1B"&&(r.option=!0);let s=[t[1],t[2],t[4],t[6]].filter(Boolean).join(""),a=(t[3]||t[5]||1)-1;r.ctrl=!!(a&4),r.meta=!!(a&10),r.shift=!!(a&1),r.code=s,r.name=Dy[s],r.shift=hb(s)||r.shift,r.ctrl=Cb(s)||r.ctrl}return r},Qy=Bb;var wy=Le($t(),1);var Db=()=>(0,wy.useContext)(Vd),ep=Db;var yb=(e,t={})=>{let{stdin:r,setRawMode:i,internal_exitOnCtrlC:s,internal_eventEmitter:a}=ep();(0,eI.useEffect)(()=>{if(t.isActive!==!1)return i(!0),()=>{i(!1)}},[t.isActive,i]),(0,eI.useEffect)(()=>{if(t.isActive===!1)return;let u=E=>{let m=Qy(E),h={upArrow:m.name==="up",downArrow:m.name==="down",leftArrow:m.name==="left",rightArrow:m.name==="right",pageDown:m.name==="pagedown",pageUp:m.name==="pageup",return:m.name==="return",escape:m.name==="escape",ctrl:m.ctrl,shift:m.shift,tab:m.name==="tab",backspace:m.name==="backspace",delete:m.name==="delete",meta:m.meta||m.name==="escape"||m.option},y=m.ctrl?m.name:m.sequence;yy.includes(m.name)&&(y=""),y.startsWith("\x1B")&&(y=y.slice(1)),y.length===1&&typeof y[0]=="string"&&/[A-Z]/.test(y[0])&&(h.shift=!0),(!(y==="c"&&h.ctrl)||!s)&&ZA.batchedUpdates(()=>{e(y,h)})};return a?.on("input",u),()=>{a?.removeListener("input",u)}},[t.isActive,r,s,e])},ls=yb;var vy=Le($t(),1);var Qb=()=>(0,vy.useContext)(Yd),ga=Qb;var Sy=Le($t(),1);var wb=()=>(0,Sy.useContext)(qd),da=wb;var vb=Le($t(),1);var tI=Le($t(),1);var Sb=Le($t(),1);bm();import{randomUUID as np}from"node:crypto";import{homedir as Lb}from"node:os";import{posix as Mb,win32 as aI}from"node:path";var rI=class extends Error{status;method;path;constructor(t,r,i,s){super(t),this.name="ApiError",this.status=r,this.method=i,this.path=s}};function _b(e){let t=e.replace(/\s+/g," ").trim();if(!t)return"";try{let r=JSON.parse(e);for(let i of["detail","error","message"]){let s=r[i];if(typeof s=="string"&&s.trim())return s.trim();if(Array.isArray(s)){let a=s.map(u=>u&&typeof u=="object"?String(u.msg??""):"").filter(Boolean);if(a.length)return a.join("; ")}}}catch{}return t.startsWith("typeof D=="string"):[],u=nI(i?.major),E=nI(i?.minor);if(!r||!i||!s)return{compatible:!1,reason:"malformed /api/meta response"};if(typeof s.source_root!="string"||nI(s.pid)===null||typeof s.package_version!="string"||typeof s.release_id!="string")return{compatible:!1,reason:"malformed /api/meta runtime identity"};if(r.service!==bb)return{compatible:!1,reason:`unexpected service ${String(r.service||"unknown")}`};let m=e;if(i.name!==Ou.name||u!==Ou.major)return{compatible:!1,reason:`protocol ${String(i.name||"unknown")}/${String(u)} is incompatible with client ${Ou.name}/${Ou.major}`,meta:m};if(E===null||E!a.includes(D));if(h.length>0)return{compatible:!1,reason:`missing capabilities: ${h.join(", ")}`,meta:m};if(s.source_root_matches_config===!1)return{compatible:!1,reason:"backend is running from a different installation than configured",meta:m};if(s.release_id!==t.releaseId)return{compatible:!1,reason:"backend and client installations are out of sync; restart or reinstall Argus",meta:m};if(t.sourceDigest){if(typeof s.runtime_source_digest!="string"||!s.runtime_source_digest)return{compatible:!1,reason:"backend cannot verify this local installation; restart it from the current checkout",meta:m};if(s.runtime_source_digest!==t.sourceDigest)return{compatible:!1,reason:"backend is running code from a different local installation; restart it",meta:m}}return{compatible:!0,reason:"",warning:s.release_matches_source===!1?oI:void 0,meta:m}}function Ry(e,t){let r=iI(e);if(!r.compatible||!r.meta)throw new Error(`incompatible Argus API: ${r.reason}`);return r.warning&&t?.(r.warning),r.meta}function by(e){let t=Tf(e),r=Tf(t?.daemon);if(!t||t.schema_version!==rp)throw new Error(`incompatible snapshot schema: expected ${rp}, got ${String(t?.schema_version??"missing")}`);if(!r)throw new Error("invalid snapshot: daemon section is missing");let s=["global_daily_cap_usd","read_status","read_error","protocol_compatible","protocol_error"].filter(E=>!Object.hasOwn(r,E));if(s.length>0)throw new Error(`invalid snapshot: daemon fields missing: ${s.join(", ")}`);let u=["spend_usd","spend_status","usage_summary","request_usage","cost_control","daemon_commands","observability","mission_view","partial","diagnostics"].filter(E=>!Object.hasOwn(t,E));if(u.length>0)throw new Error(`invalid snapshot: fields missing: ${u.join(", ")}`);if(!Array.isArray(t.diagnostics))throw new Error("invalid snapshot: diagnostics must be an array");return e}function sI(e){let t=typeof e=="string"||e instanceof URL?String(e):e.url;try{let r=new URL(t);return r.username="",r.password="",r.searchParams.has("token")&&r.searchParams.set("token","[redacted]"),r.toString()}catch{return t}}function el(e,t){return typeof e=="object"&&e!==null?e[t]:void 0}function kb(e){let t=el(e,"cause"),r=new Set;for(;el(t,"cause")&&!r.has(t);)r.add(t),t=el(t,"cause");return t??e}function xb(e,t,r="GET"){let i=kb(e),s=String(el(i,"code")??"").trim(),a=String(el(i,"address")??"").trim(),u=String(el(i,"port")??"").trim(),E=a&&u?`${a}:${u}`:a,m=i instanceof Error?i.message.trim():String(i??"").trim(),h=e instanceof Error?e.message.trim():String(e??"").trim(),y;return s==="ECONNREFUSED"?y=`connection refused${E?` by ${E}`:""}`:s==="ECONNRESET"?y="connection reset by the local service":s==="ETIMEDOUT"?y="connection timed out":s==="ENOTFOUND"?y="host name could not be resolved":m&&m!==h?y=m:y=h||"network request failed",`${r.toUpperCase()} ${sI(t)} failed: ${y}${s?` (${s})`:""}`}function Fy(e){return e%1e3===0?`${e/1e3}s`:`${e}ms`}async function Nb(e,t,r,i,s){let a=Number.isFinite(r)&&r>0?Math.max(1,Math.trunc(r)):1,u=new AbortController,E=t.signal,m=!1,h=!1,y=()=>u.abort(E?.reason);E?.aborted?y():E?.addEventListener("abort",y,{once:!0});let D=(async()=>{let G=await fetch(e,{...t,signal:u.signal});return h=!0,await s(G)})(),_,O=new Promise((G,re)=>{_=setTimeout(()=>{m=!0;let ne=new Error(`request timed out after ${Fy(a)}`);u.abort(ne),re(ne)},a)});try{return await Promise.race([D,O])}catch(G){throw m?new Error(`${i.toUpperCase()} ${sI(e)} timed out after ${Fy(a)}; the local Argus service did not respond`,{cause:G}):E?.aborted?E.reason instanceof Error?E.reason:new Error(`${i.toUpperCase()} ${sI(e)} was aborted`,{cause:G}):h&&el(G,"cause")===void 0?G:new Error(xb(G,e,i),{cause:G})}finally{_&&clearTimeout(_),E?.removeEventListener("abort",y)}}function pa(e,t,r,i,s=t.method??"GET"){return Nb(e,t,r,s,i)}function Pb(e,t=Lb()){let r=E=>E.includes("\\")||/^[A-Za-z]:[\\/]/.test(E),i=r(e)?aI:Mb,s=i.resolve(e),a=E=>i===aI?E.toLowerCase():E,u=r(t)===(i===aI)?a(i.resolve(t)):"";if(!(a(s)===u||a(s)===a(i.parse(s).root)))return s}function Ub(e,t=""){let r=t.trim();return e===4401?{code:e,reason:r||"event stream authentication was rejected",retryable:!1}:e===4404?{code:e,reason:r||"the selected project no longer exists",retryable:!1}:{code:e,reason:r,retryable:!0}}function AI(e){let t=e.item?.title||"new mission";return e.daemon?.admission_required?`\u2192 queued: choose one running session to park before starting ${t}`:e.daemon&&e.daemon.rc!==0?`\u2192 queued but not running: ${e.daemon.error||"background executor failed to start"}`:`\u2192 dispatched to the team: ${t}`}function ky(e){let t=[],r;for(;(r=e.indexOf(` +`)r.name="enter";else if(e===" ")r.name="tab";else if(e==="\b"||e==="\x1B\b")r.name="backspace",r.meta=e.charAt(0)==="\x1B";else if(e==="\x7F"||e==="\x1B\x7F")r.name="delete",r.meta=e.charAt(0)==="\x1B";else if(e==="\x1B"||e==="\x1B\x1B")r.name="escape",r.meta=e.length===2;else if(e===" "||e==="\x1B ")r.name="space",r.meta=e.length===2;else if(e.length===1&&e<="")r.name=String.fromCharCode(e.charCodeAt(0)+97-1),r.ctrl=!0;else if(e.length===1&&e>="0"&&e<="9")r.name="number";else if(e.length===1&&e>="a"&&e<="z")r.name=e;else if(e.length===1&&e>="A"&&e<="Z")r.name=e.toLowerCase(),r.shift=!0;else if(t=mb.exec(e))r.meta=!0,r.shift=/^[A-Z]$/.test(t[1]);else if(t=Ib.exec(e)){let i=[...e];i[0]==="\x1B"&&i[1]==="\x1B"&&(r.option=!0);let s=[t[1],t[2],t[4],t[6]].filter(Boolean).join(""),a=(t[3]||t[5]||1)-1;r.ctrl=!!(a&4),r.meta=!!(a&10),r.shift=!!(a&1),r.code=s,r.name=Dy[s],r.shift=hb(s)||r.shift,r.ctrl=Cb(s)||r.ctrl}return r},Qy=Bb;var wy=Le($t(),1);var Db=()=>(0,wy.useContext)(Vd),ep=Db;var yb=(e,t={})=>{let{stdin:r,setRawMode:i,internal_exitOnCtrlC:s,internal_eventEmitter:a}=ep();(0,eI.useEffect)(()=>{if(t.isActive!==!1)return i(!0),()=>{i(!1)}},[t.isActive,i]),(0,eI.useEffect)(()=>{if(t.isActive===!1)return;let u=E=>{let m=Qy(E),h={upArrow:m.name==="up",downArrow:m.name==="down",leftArrow:m.name==="left",rightArrow:m.name==="right",pageDown:m.name==="pagedown",pageUp:m.name==="pageup",return:m.name==="return",escape:m.name==="escape",ctrl:m.ctrl,shift:m.shift,tab:m.name==="tab",backspace:m.name==="backspace",delete:m.name==="delete",meta:m.meta||m.name==="escape"||m.option},y=m.ctrl?m.name:m.sequence;yy.includes(m.name)&&(y=""),y.startsWith("\x1B")&&(y=y.slice(1)),y.length===1&&typeof y[0]=="string"&&/[A-Z]/.test(y[0])&&(h.shift=!0),(!(y==="c"&&h.ctrl)||!s)&&ZA.batchedUpdates(()=>{e(y,h)})};return a?.on("input",u),()=>{a?.removeListener("input",u)}},[t.isActive,r,s,e])},ls=yb;var vy=Le($t(),1);var Qb=()=>(0,vy.useContext)(Yd),ga=Qb;var Sy=Le($t(),1);var wb=()=>(0,Sy.useContext)(qd),da=wb;var vb=Le($t(),1);var tI=Le($t(),1);var Sb=Le($t(),1);bm();import{randomUUID as np}from"node:crypto";import{homedir as Lb}from"node:os";import{posix as Mb,win32 as aI}from"node:path";var rI=class extends Error{status;method;path;constructor(t,r,i,s){super(t),this.name="ApiError",this.status=r,this.method=i,this.path=s}};function _b(e){let t=e.replace(/\s+/g," ").trim();if(!t)return"";try{let r=JSON.parse(e);for(let i of["detail","error","message"]){let s=r[i];if(typeof s=="string"&&s.trim())return s.trim();if(Array.isArray(s)){let a=s.map(u=>u&&typeof u=="object"?String(u.msg??""):"").filter(Boolean);if(a.length)return a.join("; ")}}}catch{}return t.startsWith("typeof D=="string"):[],u=nI(i?.major),E=nI(i?.minor);if(!r||!i||!s)return{compatible:!1,reason:"malformed /api/meta response"};if(typeof s.source_root!="string"||nI(s.pid)===null||typeof s.package_version!="string"||typeof s.release_id!="string")return{compatible:!1,reason:"malformed /api/meta runtime identity"};if(r.service!==bb)return{compatible:!1,reason:`unexpected service ${String(r.service||"unknown")}`};let m=e;if(i.name!==Ou.name||u!==Ou.major)return{compatible:!1,reason:`protocol ${String(i.name||"unknown")}/${String(u)} is incompatible with client ${Ou.name}/${Ou.major}`,meta:m};if(E===null||E!a.includes(D));if(h.length>0)return{compatible:!1,reason:`missing capabilities: ${h.join(", ")}`,meta:m};if(s.source_root_matches_config===!1)return{compatible:!1,reason:"backend is running from a different installation than configured",meta:m};if(s.release_id!==t.releaseId)return{compatible:!1,reason:"backend and client installations are out of sync; restart or reinstall Argus",meta:m};if(t.sourceDigest){if(typeof s.runtime_source_digest!="string"||!s.runtime_source_digest)return{compatible:!1,reason:"backend cannot verify this local installation; restart it from the current checkout",meta:m};if(s.runtime_source_digest!==t.sourceDigest)return{compatible:!1,reason:"backend is running code from a different local installation; restart it",meta:m}}return{compatible:!0,reason:"",warning:s.release_matches_source===!1?oI:void 0,meta:m}}function Ry(e,t){let r=iI(e);if(!r.compatible||!r.meta)throw new Error(`incompatible Argus API: ${r.reason}`);return r.warning&&t?.(r.warning),r.meta}function by(e){let t=Tf(e),r=Tf(t?.daemon);if(!t||t.schema_version!==rp)throw new Error(`incompatible snapshot schema: expected ${rp}, got ${String(t?.schema_version??"missing")}`);if(!r)throw new Error("invalid snapshot: daemon section is missing");let s=["global_daily_cap_usd","read_status","read_error","protocol_compatible","protocol_error"].filter(E=>!Object.hasOwn(r,E));if(s.length>0)throw new Error(`invalid snapshot: daemon fields missing: ${s.join(", ")}`);let u=["spend_usd","spend_status","usage_summary","request_usage","cost_control","daemon_commands","observability","mission_view","partial","diagnostics"].filter(E=>!Object.hasOwn(t,E));if(u.length>0)throw new Error(`invalid snapshot: fields missing: ${u.join(", ")}`);if(!Array.isArray(t.diagnostics))throw new Error("invalid snapshot: diagnostics must be an array");return e}function sI(e){let t=typeof e=="string"||e instanceof URL?String(e):e.url;try{let r=new URL(t);return r.username="",r.password="",r.searchParams.has("token")&&r.searchParams.set("token","[redacted]"),r.toString()}catch{return t}}function el(e,t){return typeof e=="object"&&e!==null?e[t]:void 0}function kb(e){let t=el(e,"cause"),r=new Set;for(;el(t,"cause")&&!r.has(t);)r.add(t),t=el(t,"cause");return t??e}function xb(e,t,r="GET"){let i=kb(e),s=String(el(i,"code")??"").trim(),a=String(el(i,"address")??"").trim(),u=String(el(i,"port")??"").trim(),E=a&&u?`${a}:${u}`:a,m=i instanceof Error?i.message.trim():String(i??"").trim(),h=e instanceof Error?e.message.trim():String(e??"").trim(),y;return s==="ECONNREFUSED"?y=`connection refused${E?` by ${E}`:""}`:s==="ECONNRESET"?y="connection reset by the local service":s==="ETIMEDOUT"?y="connection timed out":s==="ENOTFOUND"?y="host name could not be resolved":m&&m!==h?y=m:y=h||"network request failed",`${r.toUpperCase()} ${sI(t)} failed: ${y}${s?` (${s})`:""}`}function Fy(e){return e%1e3===0?`${e/1e3}s`:`${e}ms`}async function Nb(e,t,r,i,s){let a=Number.isFinite(r)&&r>0?Math.max(1,Math.trunc(r)):1,u=new AbortController,E=t.signal,m=!1,h=!1,y=()=>u.abort(E?.reason);E?.aborted?y():E?.addEventListener("abort",y,{once:!0});let D=(async()=>{let G=await fetch(e,{...t,signal:u.signal});return h=!0,await s(G)})(),_,O=new Promise((G,re)=>{_=setTimeout(()=>{m=!0;let ne=new Error(`request timed out after ${Fy(a)}`);u.abort(ne),re(ne)},a)});try{return await Promise.race([D,O])}catch(G){throw m?new Error(`${i.toUpperCase()} ${sI(e)} timed out after ${Fy(a)}; the local Argus service did not respond`,{cause:G}):E?.aborted?E.reason instanceof Error?E.reason:new Error(`${i.toUpperCase()} ${sI(e)} was aborted`,{cause:G}):h&&el(G,"cause")===void 0?G:new Error(xb(G,e,i),{cause:G})}finally{_&&clearTimeout(_),E?.removeEventListener("abort",y)}}function pa(e,t,r,i,s=t.method??"GET"){return Nb(e,t,r,s,i)}function Pb(e,t=Lb()){let r=E=>E.includes("\\")||/^[A-Za-z]:[\\/]/.test(E),i=r(e)?aI:Mb,s=i.resolve(e),a=E=>i===aI?E.toLowerCase():E,u=r(t)===(i===aI)?a(i.resolve(t)):"";if(!(a(s)===u||a(s)===a(i.parse(s).root)))return s}function Ub(e,t=""){let r=t.trim();return e===4401?{code:e,reason:r||"event stream authentication was rejected",retryable:!1}:e===4404?{code:e,reason:r||"the selected project no longer exists",retryable:!1}:{code:e,reason:r,retryable:!0}}function AI(e){let t=e.item?.title||"new mission";return e.daemon?.admission_required?`\u2192 queued: choose one running session to park before starting ${t}`:e.daemon&&e.daemon.rc!==0?`\u2192 queued but not running: ${e.daemon.error||"background executor failed to start"}`:`\u2192 dispatched to the team: ${t}`}function ky(e){let t=[],r;for(;(r=e.indexOf(` `))>=0;){let i=e.slice(0,r);e=e.slice(r+2);for(let s of i.split(` `)){let a=s.trim();if(a.startsWith("data:"))try{t.push(JSON.parse(a.slice(5).trim()))}catch{}}}return{frames:t,rest:e}}var us=class{httpBase;wsBase;project;token;onCompatibilityWarning;metaTimeoutMs;readTimeoutMs;metaPromise;constructor(t){this.httpBase=`http://${t.host}:${t.port}`,this.wsBase=`ws://${t.host}:${t.port}`,this.project=t.project,this.token=t.token,this.onCompatibilityWarning=t.onCompatibilityWarning,this.metaTimeoutMs=t.metaTimeoutMs??8e3,this.readTimeoutMs=t.readTimeoutMs??12e3}authHeaders(){return this.token?{Authorization:`Bearer ${this.token}`}:{}}p(t){return`${this.httpBase}/api/projects/${encodeURIComponent(this.project)}${t}`}meta(){if(!this.metaPromise){let t="/api/meta",r=pa(`${this.httpBase}${t}`,{headers:this.authHeaders()},this.metaTimeoutMs,async i=>{if(i.status===404)throw new Error("incompatible Argus API: service does not expose /api/meta");return await io(i,"GET",t),Ry(await i.json(),this.onCompatibilityWarning)});this.metaPromise=r,r.catch(()=>{this.metaPromise===r&&(this.metaPromise=void 0)})}return this.metaPromise}async listProjects(){return await this.meta(),pa(`${this.httpBase}/api/projects`,{headers:this.authHeaders()},this.readTimeoutMs,async t=>(await io(t,"GET","/api/projects"),(await t.json()).projects))}async createDaemon(t="",r="",i=process.cwd(),s,a=np()){let u="/api/daemons",E=Pb(i),m={objective:t,name:r,launch_cwd:i,command_id:a,expected_revision:s};E&&(m.workdir=E);let h=JSON.stringify(m),y=()=>fetch(`${this.httpBase}${u}`,{method:"POST",headers:{"Content-Type":"application/json",Connection:"close",...this.authHeaders()},body:h}),D=await y();return D.status===400&&/Invalid HTTP request received/i.test(await D.clone().text())&&(D=await y()),await io(D,"POST",u),await D.json()}async replaceDaemon(t,r=!1,i,s=np()){return await this.post("/daemon/replace",{victim_sid:t,resume_continuous:r,command_id:s,expected_revision:i})}async scheduleDaemonUpgrade(t,r,i=np()){let s=`/api/projects/${encodeURIComponent(t)}/daemon/upgrade-schedule`,a=await fetch(`${this.httpBase}${s}`,{method:"POST",headers:{"Content-Type":"application/json",...this.authHeaders()},body:JSON.stringify({command_id:i,expected_revision:r})});return await io(a,"POST",s),await a.json()}stopDaemon(t=np()){let r="/daemon/stop";return pa(this.p(r),{method:"POST",headers:{"Content-Type":"application/json",...this.authHeaders()},body:JSON.stringify({force:!1,drain:!1,command_id:t})},this.readTimeoutMs,async i=>{await io(i,"POST",r);let s=await i.json(),a=Number(s.rc??0);if(!Number.isFinite(a)||![0,1].includes(a)){let u=String(s.error??s.message??`rc=${String(s.rc??"unknown")}`);throw new Error(`executor did not stop cleanly: ${u}`)}return s})}async setProjectLaunchCwd(t,r){let i=`/api/projects/${encodeURIComponent(t)}/launch-cwd`,s=await fetch(`${this.httpBase}${i}`,{method:"POST",headers:{"Content-Type":"application/json",...this.authHeaders()},body:JSON.stringify({launch_cwd:r})});await io(s,"POST",i)}async setProjectWorkdir(t,r){let i=`/api/projects/${encodeURIComponent(t)}/workdir`,s=await fetch(`${this.httpBase}${i}`,{method:"POST",headers:{"Content-Type":"application/json",...this.authHeaders()},body:JSON.stringify({workdir:r})});await io(s,"POST",i)}async renameProject(t){let r=this.p(""),i=await fetch(r,{method:"PATCH",headers:{"Content-Type":"application/json",...this.authHeaders()},body:JSON.stringify({name:t})});return await io(i,"PATCH",r),await i.json()}async snapshot(t=1,r,i=!1){return await this.meta(),pa(this.p(`/snapshot?compact=true&events_limit=${t}`+(i?"&prewarm=true":"")),{headers:this.authHeaders(),signal:r},this.readTimeoutMs,async s=>(await io(s,"GET","/snapshot"),by(await s.json())))}async postTask(t){let r=await fetch(this.p("/tasks"),{method:"POST",headers:{"Content-Type":"application/json",...this.authHeaders()},body:JSON.stringify({text:t})});return await io(r,"POST","/tasks"),(await r.json()).item}async postNudge(t){let r=await fetch(this.p("/nudge"),{method:"POST",headers:{"Content-Type":"application/json",...this.authHeaders()},body:JSON.stringify({text:t})});await io(r,"POST","/nudge")}async message(t,r){let i=await fetch(this.p("/message"),{method:"POST",headers:{"Content-Type":"application/json",...this.authHeaders()},body:JSON.stringify({text:t}),signal:r});return await io(i,"POST","/message"),await i.json()}async messageStream(t,r,i){let s=await fetch(this.p("/message/stream"),{method:"POST",headers:{"Content-Type":"application/json",...this.authHeaders()},body:JSON.stringify({text:t}),signal:i});if(await io(s,"POST","/message/stream"),!s.body)throw new Error("Manager stream returned no response body");let a=h=>{if(!i?.aborted)if(h.type==="phase"){let y=Number(h.quiet_s??0);r.onPhase?.(String(h.label??""),String(h.role??"manager"),{heartbeat:h.heartbeat===!0,quietS:Number.isFinite(y)?y:0,kind:String(h.kind??""),detail:String(h.detail??"")})}else h.type==="delta"?r.onDelta?.(String(h.text??""),String(h.message_id??""),String(h.fragment_mode??"auto")):h.type==="done"?r.onDone?.(h.result??{}):h.type==="error"&&r.onError?.(new Error(String(h.error??"stream error")))},u=s.body.getReader(),E=new TextDecoder,m="";for(;;){let{done:h,value:y}=await u.read();if(h)break;m+=E.decode(y,{stream:!0});let D=ky(m);m=D.rest,D.frames.forEach(a)}i?.aborted||ky(m+` @@ -129,7 +129,7 @@ Read about how to prevent this error on https://github.com/vadimdemedes/ink/#isr `).frames.forEach(a)}async getJson(t){return pa(this.p(t),{headers:this.authHeaders()},this.readTimeoutMs,async r=>(await io(r,"GET",t),await r.json()))}async post(t,r){let i=await fetch(this.p(t),{method:"POST",headers:{"Content-Type":"application/json",...this.authHeaders()},body:r===void 0?void 0:JSON.stringify(r)});return await io(i,"POST",t),await i.json()}getStatus(){return this.getJson("/status")}getResources(){let t="/api/system/resources";return pa(`${this.httpBase}${t}`,{headers:this.authHeaders()},this.readTimeoutMs,async r=>(await io(r,"GET",t),await r.json()))}async getJournal(t=10){return(await this.getJson(`/journal?n=${t}`)).journal}getDoctor(){return this.getJson("/doctor")}getConfig(){return this.getJson("/config")}async getIdentity(){return(await this.getJson("/identity")).identity}async getTranscript(t=20){return(await this.getJson(`/transcript?n=${t}`)).turns}async getArtifacts(){return(await this.getJson("/artifacts")).artifacts}async getBacklogItem(t){return(await this.getJson(`/backlog/${encodeURIComponent(t)}`)).item}answerPending(t,r){return this.post(`/backlog/${encodeURIComponent(t)}/answer`,{text:r})}resolveDecision(t,r,i){return this.post(`/decisions/${encodeURIComponent(t)}/resolve`,{option_id:r,note:i})}getArtifact(t){let r=new URLSearchParams({path:t});return this.getJson(`/artifact?${r}`)}async postNote(t){await this.post("/note",{text:t})}async previewPlan(t){return await this.post("/plan",{text:t})}async rewritePrompt(t){return await this.post("/prompt/rewrite",{text:t})}async setConfig(t,r){return this.post("/config/set",{name:t,value:r})}async setIdentity(t){await this.post("/identity",{text:t})}async resetManager(){await this.post("/reset")}async skills(t="ls"){return String((await this.post("/skills",{args:t})).text??"")}async disposeBacklog(t,r){return(await this.post(`/backlog/${encodeURIComponent(t)}/dispose`,{op:r})).item}async stopBacklog(t){return(await this.post(`/backlog/${encodeURIComponent(t)}/stop`)).item}async abortMission(t=""){return await this.post("/mission/abort",{reason:t})}connectStream(t){let r=new URLSearchParams;t.replay!=null&&r.set("replay",String(t.replay)),this.token&&r.set("token",this.token);let i=`${this.wsBase}/api/projects/${encodeURIComponent(this.project)}/stream?${r}`,s=new Td(i);return s.on("open",()=>t.onOpen?.()),s.on("message",a=>{try{let u=JSON.parse(String(a));u&&typeof u=="object"&&t.onEvent(u)}catch{}}),s.on("close",(a,u)=>t.onClose?.(Ub(a,u.toString("utf8")))),s.on("error",a=>t.onError?.(a)),s}};var Ir=Le($t(),1);var Ea={value:"",cursor:0},Po=e=>Array.from(e);function cs(e,t){let r=Math.max(0,Math.min(t,e.length));return{value:e.join(""),cursor:r}}function ma(e,t=Array.from(e).length){return cs(Po(e),t)}function Ia(e,t){if(!t)return e;let r=Po(e.value),i=Po(t);return r.splice(e.cursor,0,...i),cs(r,e.cursor+i.length)}function Lu(e){if(e.cursor<=0)return e;let t=Po(e.value);return t.splice(e.cursor-1,1),cs(t,e.cursor-1)}function Ny(e){let t=Po(e.value);return e.cursor>=t.length?e:(t.splice(e.cursor,1),cs(t,e.cursor))}function tl(e){return e.cursor<=0?e:cs(Po(e.value),e.cursor-1)}function rl(e){let t=Po(e.value).length;return e.cursor>=t?e:cs(Po(e.value),e.cursor+1)}function op(e){return cs(Po(e.value),0)}function ip(e){let t=Po(e.value);return cs(t,t.length)}function xy(e){return/\S/.test(e)}function Mu(e){let t=Po(e.value),r=e.cursor;for(;r>0&&!xy(t[r-1]);)r--;for(;r>0&&xy(t[r-1]);)r--;return r===e.cursor?e:(t.splice(r,e.cursor-r),cs(t,r))}function Pu(e){if(e.cursor<=0)return e;let t=Po(e.value);return t.splice(0,e.cursor),cs(t,0)}function Uu(e){let t=Po(e.value);return e.cursor>=t.length?e:(t.splice(e.cursor),cs(t,e.cursor))}function Ty(e){let t=Po(e.value);return{before:t.slice(0,e.cursor).join(""),at:t[e.cursor]??"",after:t.slice(e.cursor+1).join("")}}var Oy={entries:[],pos:0,draft:""};function lI(e,t){let r=t.trim();return r?{entries:e.entries[e.entries.length-1]===r?e.entries:[...e.entries,r],pos:0,draft:""}:{entries:e.entries,pos:0,draft:""}}function Ly(e,t){if(e.entries.length===0)return{h:e,value:t};let r=e.pos===0?t:e.draft,i=Math.min(e.pos+1,e.entries.length),s=i===0?r:e.entries[e.entries.length-i];return{h:{...e,pos:i,draft:r},value:s}}function My(e){let t=Math.max(e.pos-1,0),r=t===0?e.draft:e.entries[e.entries.length-t];return{h:{...e,pos:t},value:r}}var te={AGENT_IO_START:"agent.io.start",AGENT_IO_STREAM:"agent.io.stream",AGENT_IO_COMPLETE:"agent.io.complete",AGENT_IO_ERROR:"agent.io.error",USAGE_RECORDED:"usage.recorded",PROVIDER_REQUEST_STARTED:"provider.request.started",PROVIDER_REQUEST_COMPLETED:"provider.request.completed",PROVIDER_REQUEST_DENIED:"provider.request.denied",CODEX_UTIL_COMPLETED:"codex.util.completed",SKILL_COST_COMPLETED:"skill.cost.completed",BUDGET_RESERVATION_CREATED:"budget.reservation.created",BUDGET_RESERVATION_DENIED:"budget.reservation.denied",BUDGET_RESERVATION_SETTLED:"budget.reservation.settled",BUDGET_RESERVATION_RELEASED:"budget.reservation.released",BUDGET_UNPRICED_BLOCKED:"budget.unpriced.blocked",LOOP_START:"loop.start",LOOP_DONE:"loop.done",ROUND_START:"round.start",ROUND_MAIN_COMPLETED:"round.main.completed",ROUND_REVIEW_STARTED:"round.review.started",ROUND_REVIEW_DEFERRED:"round.review.deferred",ROUND_REVIEW_COMPLETED:"round.review.completed",ROUND_CHECKPOINT_RECORDED:"round.checkpoint.recorded",ROUND_CHECKPOINT_FAILED:"round.checkpoint.failed",ROUND_SECRET_REDACTED:"round.secret_redacted",ROUND_ESCALATED:"round.escalated",ROUND_STALL:"round.stall",ROUND_REVIEWER_BACKEND_FAILURE:"round.reviewer_backend_failure",ROLE_SESSION_TURN:"role.session.turn",ENGINEER_PROGRESS:"engineer.progress",ENGINEER_SKILL_MAINTENANCE_COMPLETED:"engineer.skill_maintenance.completed",LIFE_STATUS:"life.status",LIFE_PHASE_STARTED:"life.phase.started",LIFE_MISSION_STARTED:"life.mission.started",LIFE_MISSION_COMPLETED:"life.mission.completed",LIFE_MISSION_FAILED:"life.mission.failed",LIFE_MISSION_SKIPPED:"life.mission.skipped",LIFE_MISSION_ORPHANED:"life.mission.orphaned",LIFE_MISSION_REQUEUED:"life.mission.requeued",LIFE_MANAGER_INTENT_STARTED:"life.manager.intent.started",LIFE_MANAGER_INTENT_COMPLETED:"life.manager.intent.completed",LIFE_MANAGER_INTENT_FAILED:"life.manager.intent.failed",LIFE_MANAGER_STAGE_DECISION:"life.manager.stage_decision",LIFE_MANAGER_PLAN_CHALLENGE_DECIDED:"life.manager.plan_challenge.decided",LIFE_VERTICAL_RESOLVED:"life.vertical.resolved",LIFE_MANAGER_BACKEND_RESOLVED:"life.manager.backend_resolved",LIFE_PLANNER_BACKEND_RESOLVED:"life.planner.backend_resolved",LIFE_ENGINEER_BACKEND_RESOLVED:"life.engineer.backend_resolved",LIFE_REVIEWER_BACKEND_RESOLVED:"life.reviewer.backend_resolved",LIFE_CURATOR_BACKEND_RESOLVED:"life.curator.backend_resolved",LIFE_PLANNER_START:"life.planner.start",LIFE_PLANNER_NORMALIZED:"life.planner.normalized",LIFE_PLANNER_TASK_ADDED:"life.planner.task_added",LIFE_PLANNER_TASK_SKIPPED:"life.planner.task_skipped",LIFE_PLANNER_VERDICT:"life.planner.verdict",LIFE_PLANNER_WAITING:"life.planner.waiting",LIFE_PLANNER_WAITING_WOKEN:"life.planner.waiting_woken",LIFE_PLANNER_TERMINAL_IDLE:"life.planner.terminal_idle",LIFE_PLANNER_VERIFICATION_PROBE:"life.planner.verification_probe",LIFE_PLANNER_STALL_ESCALATION:"life.planner.stall_escalation",LIFE_PLANNER_DEPENDENCY_DROPPED:"life.planner.dependency_dropped",LIFE_PLANNER_PARALLEL_DROPPED:"life.planner.parallel_dropped",LIFE_PLANNER_ERROR:"life.planner.error",LIFE_RUNTIME_FAILURE_CIRCUIT_OPENED:"life.runtime_failure.circuit_opened",LIFE_RUNTIME_FAILURE_CIRCUIT_BLOCKED:"life.runtime_failure.circuit_blocked",LIFE_RUNTIME_FAILURE_CANARY_PASSED:"life.runtime_failure.canary_passed",LIFE_PLAN_REVISION_PROPOSED:"life.plan.revision.proposed",LIFE_PLAN_REVISION_REJECTED:"life.plan.revision.rejected",LIFE_PLAN_REVISION_COMMITTED:"life.plan.revision.committed",LIFE_PLAN_NODE_SUPERSEDED:"life.plan.node.superseded",LIFE_RESEARCH_SECOND_READING:"life.research.second_reading",LIFE_LETTER_WRITTEN:"life.letter.written",LIFE_BUDGET_PAUSE:"life.budget.pause",LIFE_LIFECYCLE_BLOCK:"life.lifecycle.block",LIFE_LIFECYCLE_TRANSITION:"life.lifecycle.transition",LIFE_INBOX_QUEUED:"life.inbox.queued",LIFE_INBOX_DRAINED:"life.inbox.drained",LIFE_OPERATOR_QUESTION_PENDING:"life.operator_question.pending",LIFE_OPERATOR_QUESTION_ANSWERED:"life.operator_question.answered",LIFE_DAEMON_IDLE_TIMEOUT:"life.daemon.idle_timeout",PROJECT_COMPLETED:"project.completed",PROJECT_COMPLETION_REFUSED:"project.completion_refused",DAEMON_PARKED:"daemon.parked",DAEMON_COMMAND_SUBMITTED:"daemon.command.submitted",DAEMON_COMMAND_COMPLETED:"daemon.command.completed",DAEMON_COMMAND_REJECTED:"daemon.command.rejected",IDEA_SEARCH_STARTED:"idea.search.started",IDEA_SEARCH_COMPLETED:"idea.search.completed",IDEA_SEARCH_SKIPPED:"idea.search.skipped",VENUE_RESEARCH_STARTED:"venue.research.started",VENUE_RESEARCH_COMPLETED:"venue.research.completed",RESEARCH_ACHIEVEMENT_CERTIFIED:"research.achievement.certified",SKILL_LIBRARY_AVAILABLE:"skill.library.available",SKILL_CREATED:"skill.created",SKILL_UPDATED:"skill.updated",SKILL_ARCHIVED:"skill.archived",SKILL_TIDIED:"skill.tidied",SKILL_HISTORY_COMPRESSED:"skill.history.compressed",SKILL_EVOLUTION_COMPLETED:"skill.evolution.completed",WIKI_INITIALIZED:"wiki.initialized",WIKI_HOOK_WARNING:"wiki.hook.warning",WIKI_CREATED:"wiki.created",WIKI_UPDATED:"wiki.updated",WIKI_RETIRED:"wiki.retired",WIKI_PROMOTION_PROMOTED:"wiki.promotion.promoted",WIKI_PROMOTION_DEMOTED:"wiki.promotion.demoted",WIKI_RETIRED_COMPRESSED:"wiki.retired.compressed",WIKI_EVOLUTION_COMPLETED:"wiki.evolution.completed",OPERATOR_ALERT:"operator_alert"},Gb={"loop.started":te.LOOP_START,"loop.completed":te.LOOP_DONE,"round.started":te.ROUND_START,"mission.started":te.LIFE_MISSION_STARTED,"mission.completed":te.LIFE_MISSION_COMPLETED,"mission.error":te.LIFE_MISSION_FAILED},lM=new Set([te.LIFE_MANAGER_BACKEND_RESOLVED,te.LIFE_PLANNER_BACKEND_RESOLVED,te.LIFE_ENGINEER_BACKEND_RESOLVED,te.LIFE_REVIEWER_BACKEND_RESOLVED,te.LIFE_CURATOR_BACKEND_RESOLVED,te.LOOP_START,te.LOOP_DONE,te.ROUND_START,te.ROUND_MAIN_COMPLETED,te.ROUND_REVIEW_DEFERRED,te.ROUND_REVIEW_COMPLETED,te.ROUND_CHECKPOINT_RECORDED,te.ROUND_CHECKPOINT_FAILED,te.ROUND_SECRET_REDACTED,te.ROUND_ESCALATED,te.ROUND_STALL,te.ROUND_REVIEWER_BACKEND_FAILURE,te.ENGINEER_SKILL_MAINTENANCE_COMPLETED,te.SKILL_LIBRARY_AVAILABLE,te.SKILL_CREATED,te.SKILL_UPDATED,te.SKILL_ARCHIVED,te.SKILL_TIDIED,te.SKILL_HISTORY_COMPRESSED,te.SKILL_EVOLUTION_COMPLETED,te.WIKI_INITIALIZED,te.WIKI_HOOK_WARNING,te.WIKI_CREATED,te.WIKI_UPDATED,te.WIKI_RETIRED,te.WIKI_PROMOTION_PROMOTED,te.WIKI_PROMOTION_DEMOTED,te.WIKI_RETIRED_COMPRESSED,te.WIKI_EVOLUTION_COMPLETED,te.LIFE_MISSION_STARTED,te.LIFE_MISSION_COMPLETED,te.LIFE_MANAGER_INTENT_STARTED,te.LIFE_MANAGER_INTENT_COMPLETED,te.LIFE_MANAGER_INTENT_FAILED,te.LIFE_MANAGER_STAGE_DECISION,te.LIFE_MANAGER_PLAN_CHALLENGE_DECIDED,te.LIFE_VERTICAL_RESOLVED,te.LIFE_PLANNER_START,te.LIFE_PLANNER_TASK_ADDED,te.LIFE_PLANNER_TASK_SKIPPED,te.LIFE_PLANNER_DEPENDENCY_DROPPED,te.LIFE_PLANNER_PARALLEL_DROPPED,te.LIFE_PLANNER_VERDICT,te.LIFE_PLANNER_WAITING,te.LIFE_PLANNER_WAITING_WOKEN,te.LIFE_PLANNER_TERMINAL_IDLE,te.LIFE_PLANNER_VERIFICATION_PROBE,te.LIFE_PLANNER_STALL_ESCALATION,te.LIFE_RUNTIME_FAILURE_CIRCUIT_OPENED,te.LIFE_RUNTIME_FAILURE_CIRCUIT_BLOCKED,te.LIFE_RUNTIME_FAILURE_CANARY_PASSED,te.LIFE_PLAN_REVISION_PROPOSED,te.LIFE_PLAN_REVISION_REJECTED,te.LIFE_PLAN_REVISION_COMMITTED,te.LIFE_PLAN_NODE_SUPERSEDED,te.LIFE_RESEARCH_SECOND_READING,te.LIFE_LETTER_WRITTEN,te.LIFE_BUDGET_PAUSE,te.BUDGET_RESERVATION_DENIED,te.BUDGET_UNPRICED_BLOCKED,te.LIFE_LIFECYCLE_BLOCK,te.LIFE_LIFECYCLE_TRANSITION,te.PROVIDER_REQUEST_STARTED,te.PROVIDER_REQUEST_COMPLETED,te.PROVIDER_REQUEST_DENIED,te.LIFE_INBOX_QUEUED,te.LIFE_INBOX_DRAINED,te.LIFE_DAEMON_IDLE_TIMEOUT,te.PROJECT_COMPLETED,te.PROJECT_COMPLETION_REFUSED,te.DAEMON_PARKED,te.DAEMON_COMMAND_COMPLETED,te.DAEMON_COMMAND_REJECTED,te.IDEA_SEARCH_STARTED,te.IDEA_SEARCH_COMPLETED,te.IDEA_SEARCH_SKIPPED,te.VENUE_RESEARCH_STARTED,te.VENUE_RESEARCH_COMPLETED,te.RESEARCH_ACHIEVEMENT_CERTIFIED,te.OPERATOR_ALERT]),uM=new Set([te.AGENT_IO_START,te.AGENT_IO_COMPLETE,te.AGENT_IO_ERROR,te.PROVIDER_REQUEST_STARTED,te.PROVIDER_REQUEST_COMPLETED,te.PROVIDER_REQUEST_DENIED,te.USAGE_RECORDED]);function iA(e){let t=String(e??"").trim();return Gb[t]??t}function uI(e){if(e===null||typeof e!="object")return JSON.stringify(e);if(Array.isArray(e))return`[${e.map(uI).join(",")}]`;let t=e;return`{${Object.keys(t).sort().map(r=>`${JSON.stringify(r)}:${uI(t[r])}`).join(",")}}`}function Hb(e){let t=2166136261;for(let r=0;r>>0).toString(36)}function sA(e){let t=e.event_id??e.id??e.seq??e._offset,r=String(e.type??"event");if(t!=null&&t!=="")return`${r}-${String(t)}`;let i=String(e.ts??e.time??"");return`${r}-${i}-${Hb(uI(e))}`}function cI(e){return e.type===te.ENGINEER_PROGRESS&&e.kind==="reasoning"}function Gu(e){if(e.type!==te.ENGINEER_PROGRESS||!["assistant_message","agent_message","message"].includes(String(e.kind??"")))return!1;let t=String(e.agent_layer??e.actor??"");return String(e.text??"").trimStart().startsWith("{")?t==="reviewer"||t==="planner":!1}var Wb=/^(?:[-*+]\s*)?[`*_]*(?:ARGUS_)?(?:MILESTONE_STATUS|NEXT_OWNER|OPERATOR_QUESTION|OPERATOR_OPTIONS|ROLE_DECISION)[`*_]*\s*[:=]|^(?:final\s+)?decision\s*:\s*$/i;function sp(e){return String(e??"").split(/\r?\n/).filter(t=>!Wb.test(t.trim())).join(` `).trim()}function Of(e){let t=String(e.fragment_mode??"");return t==="append"||t==="snapshot"?t:e.replace===!0?"snapshot":"auto"}function jb(e,t){let r=Math.min(e.length,t.length);for(let i=r;i>=8;i-=1)if(e.endsWith(t.slice(0,i)))return i;return 0}function fI(e,t,r="auto"){let i=(e||"").trim(),s=(t||"").trim();if(!i)return s;if(!s)return i;if(r==="snapshot")return s;if(i.includes(s))return i;if(r==="append")return`${i} ${s}`;if(s.includes(i))return s;let a=jb(i,s);return a?`${i}${s.slice(a)}`:`${i} -${s}`}var Py=["all","attention","milestones","messages"],Jb=new Set([te.LIFE_MISSION_STARTED,te.LIFE_MISSION_COMPLETED,te.LIFE_MISSION_FAILED,te.LOOP_START,te.LOOP_DONE,te.LIFE_PLANNER_VERDICT,"final.report.ready","pptx.report.ready","plan.completed",te.LIFE_BUDGET_PAUSE,te.LIFE_LIFECYCLE_BLOCK]);function Uy(e,t,r="all",i=""){let s=iA(e.canonical_type??e.type),a=String(e.kind??"");if(r==="attention"&&!["warn","err"].includes(String(t.tone??""))&&e.operator_alert!==!0||r==="milestones"&&!(t.rule&&!s.startsWith("ui."))&&!Jb.has(s)||r==="messages"&&t.tone!=="bright"&&!["assistant_message","agent_message","message"].includes(a)&&!["ui.operator","ui.argus"].includes(s))return!1;let u=i.trim().toLocaleLowerCase();return u?[s,a,t.role,t.label,t.text,e.title,e.objective,e.text,e.summary,e.reason,e.error,e.status,e.action_summary,e.command,e.path,Array.isArray(e.tags)?e.tags.join(" "):e.tags].some(m=>String(m??"").toLocaleLowerCase().includes(u)):!0}var Lf=[{id:"status",name:"/status",argument:"none",desc:"roles, queued work, journal, and health",group:"Everyday",kind:"panel"},{id:"roles",name:"/roles",argument:"none",desc:"per-role backend / model / effort + live activity",group:"Everyday",kind:"panel"},{id:"journal",name:"/journal",arg:"[N]",argument:"optional",desc:"recent journal entries (default 10)",group:"Everyday",kind:"panel"},{id:"backlog",name:"/backlog",arg:"[all]",argument:"optional",desc:"pending tasks (all = incl. done/skipped)",group:"Everyday",kind:"panel"},{id:"artifacts",name:"/artifacts",argument:"none",desc:"result files the Reviewer has checked (Enter previews)",group:"Everyday",kind:"panel"},{id:"artifact",name:"/artifact",arg:"",argument:"required",desc:"preview one reviewed result file",group:"Everyday",kind:"panel"},{id:"events",name:"/events",arg:"[filter] [query]",argument:"optional",desc:"search feed: all / watch / milestones / messages",group:"Everyday",kind:"panel"},{id:"find",name:"/find",arg:"",argument:"required",desc:"search the current event buffer",group:"Everyday",kind:"panel"},{id:"cancel",name:"/cancel",argument:"none",desc:"stop waiting for the current Manager reply",group:"Everyday",kind:"local"},{id:"ask",name:"/ask",arg:"",argument:"required",desc:"answer inline \u2014 no task queued, no Planner/Engineer/Reviewer",aliases:["/chat"],group:"Everyday",kind:"action"},{id:"task",name:"/task",arg:"",argument:"required",desc:"queue work directly",aliases:["/add"],group:"Task management",kind:"action"},{id:"plan",name:"/plan",arg:"",argument:"required",desc:"preview a Planner-authored execution plan",group:"Task management",kind:"action"},{id:"rewrite",name:"/rewrite",arg:"[text]",argument:"optional",desc:"let the Manager rewrite your prompt before sending",aliases:["/refine"],group:"Task management",kind:"action"},{id:"nudge",name:"/nudge",arg:"",argument:"required",desc:"inject guidance into the running mission",aliases:["/inject","/notify"],group:"Task management",kind:"action"},{id:"abort",name:"/abort",argument:"none",desc:"immediately stop the running mission",group:"Task management",kind:"action"},{id:"note",name:"/note",arg:"",argument:"required",desc:"append a manual note to the timeline",group:"Task management",kind:"action"},{id:"done",name:"/done",arg:"",argument:"required",desc:"mark a task done",group:"Task management",kind:"action"},{id:"skip",name:"/skip",arg:"",argument:"required",desc:"skip a task",aliases:["/rm"],group:"Task management",kind:"action"},{id:"stop",name:"/stop",arg:"",argument:"required",desc:"stop a task's auto-iteration",group:"Task management",kind:"action"},{id:"item",name:"/item",arg:"",argument:"required",desc:"inspect a full task contract",group:"Task management",kind:"panel"},{id:"run",name:"/run",argument:"none",desc:"return to the always-live mission feed",group:"Task management",kind:"local"},{id:"new",name:"/new",arg:"[objective]",argument:"optional",desc:"review, create, and switch to a fresh conversation",group:"Sessions & diagnostics",kind:"action"},{id:"daemons",name:"/daemons",arg:"[query]",argument:"optional",desc:"find every session + switch or create",group:"Sessions & diagnostics",kind:"panel"},{id:"resume",name:"/resume",arg:"[list|]",argument:"optional",desc:"switch to another project/session",group:"Sessions & diagnostics",kind:"action"},{id:"attach",name:"/attach",arg:"",argument:"required",desc:"follow another project (read the stream)",group:"Sessions & diagnostics",kind:"action"},{id:"rename",name:"/rename",arg:"",argument:"required",desc:"rename the current conversation",group:"Sessions & diagnostics",kind:"action"},{id:"doctor",name:"/doctor",argument:"none",desc:"diagnose 'why isn't anything running'",group:"Sessions & diagnostics",kind:"panel"},{id:"backend",name:"/backend",arg:"[codex|claude|copilot|cursor|opencode|pi|grok|qoder|dsh]",argument:"optional",desc:"view or change the shared runner backend",group:"Configuration",kind:"action"},{id:"config",name:"/config",arg:"[key=value \u2026]",argument:"optional",desc:"view or change runtime settings",group:"Configuration",kind:"panel"},{id:"identity",name:"/identity",arg:"[set ]",argument:"optional",desc:"view or replace the operator identity card",group:"Configuration",kind:"panel"},{id:"reset",name:"/reset",argument:"none",desc:"drop the warm Manager conversation context",group:"Configuration",kind:"action"},{id:"skills",name:"/skills",arg:"[ls|promote ]",argument:"optional",desc:"inspect or promote runtime skills",group:"Configuration",kind:"action"},{id:"clear",name:"/clear",argument:"none",desc:"clear the event feed view",group:"Other",kind:"local"},{id:"reconnect",name:"/reconnect",argument:"none",desc:"reconnect the live event stream",group:"Other",kind:"local"},{id:"help",name:"/help",argument:"none",desc:"keys + full command reference",aliases:["/?","/commands"],group:"Other",kind:"local"},{id:"quit",name:"/quit",argument:"none",desc:"leave the cockpit (background work keeps running)",aliases:["/exit","/q"],group:"Other",kind:"local"}],pM=new Map(Lf.map(e=>[e.id,e])),ap=new Map;for(let e of Lf)for(let t of[e.name,...e.aliases??[]])ap.set(t.toLowerCase(),e);var Kb=/^\/[A-Za-z0-9_-]+$/;function Mf(e){if(!e.startsWith("/"))return!1;let t=e.indexOf(" "),r=t===-1?e:e.slice(0,t);return Kb.test(r)}function Yb(e){return e.startsWith("/")&&!e.includes(" ")&&!e.slice(1).includes("/")}function Ap(e){if(!Yb(e))return[];let t=e.toLowerCase(),r=new Set,i=[];for(let s of Lf)[s.name,...s.aliases??[]].some(u=>u.toLowerCase().startsWith(t))&&!r.has(s.name)&&(r.add(s.name),i.push(s));return i.sort((s,a)=>Number(Gy(a,t))-Number(Gy(s,t)))}function Gy(e,t){return[e.name,...e.aliases??[]].some(r=>r.toLowerCase()===t)}function lp(e){return e.arg?`${e.name} `:e.name}function gI(e){let t=e.trim();return!t||t.toLowerCase()==="list"?{kind:"list"}:{kind:"project",query:t}}function dI(e){let t=e.trim();if(!t)return{filter:"all",query:""};let[r,...i]=t.split(/\s+/);return r.toLowerCase()==="watch"?{filter:"attention",query:i.join(" ")}:Py.includes(r.toLowerCase())?{filter:r.toLowerCase(),query:i.join(" ")}:{filter:"all",query:t}}function pI(e){if(!Mf(e))return null;let t=e.indexOf(" "),r=(t===-1?e:e.slice(0,t)).toLowerCase(),i=t===-1?"":e.slice(t+1).trim(),s=ap.get(r)??null;return{cmd:s,name:s?s.name:r,rest:i}}function EI(e){let t=e.toLowerCase(),r=null,i=0;for(let s of ap.keys()){let a=Vb(t,s);a>i&&(i=a,r=ap.get(s).name)}return i>=.6?r:null}function Vb(e,t){let r=qb(e,t),i=Math.max(e.length,t.length)||1;return 1-r/i}function qb(e,t){let r=e.length,i=t.length,s=Array.from({length:r+1},(a,u)=>[u,...Array(i).fill(0)]);for(let a=0;a<=i;a+=1)s[0][a]=a;for(let a=1;a<=r;a+=1)for(let u=1;u<=i;u+=1)s[a][u]=Math.min(s[a-1][u]+1,s[a][u-1]+1,s[a-1][u-1]+(e[a-1]===t[u-1]?0:1));return s[r][i]}function mI(){let e=["Everyday","Task management","Sessions & diagnostics","Configuration","Other"],t=new Map;for(let r of Lf){let i=r.aliases?.length?` (= ${r.aliases.join(", ")})`:"",s=`${r.name}${r.arg?` ${r.arg}`:""}${i}`;t.has(r.group)||t.set(r.group,[]),t.get(r.group).push({label:s,desc:r.desc})}return e.filter(r=>t.has(r)).map(r=>({group:r,rows:t.get(r)}))}var pe={accent:"#e6b450",border:"#8a93a6",success:"#3aa76a",error:"#d15c6a",warning:"#d0a850",info:"#5a9beb",role:{manager:"blue",planner:"magenta",engineer:"green",reviewer:"yellow"}},Hu=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"],Hy=["#3b6fd4","#4d86e0","#5f9deb","#72b4f0","#89dceb"],II="#48506b",Wy="#f4e0a8",jy="#6c7086";function Jy(e){switch(e){case"medium":return pe.info;case"high":return pe.warning;case"xhigh":return pe.accent;case"max":return pe.error;default:return"gray"}}var ha=Le(Gt(),1),qy="argus";function Ca({d:e="solid",lit:t=qy.length,sh:r=-1}){let i=e==="ghost"?II:pe.accent;return(0,ha.jsxs)(k,{children:[(0,ha.jsx)(k,{color:i,bold:e==="solid",dimColor:e==="flick",children:"\u25C9"}),t>=0?(0,ha.jsxs)(ha.Fragment,{children:[(0,ha.jsx)(k,{children:" "}),[...qy].map((s,a)=>{let u=a===r,E=u?Wy:ae.length<=t?e:`${e.slice(0,Math.max(1,t-1))}\u2026`;function zy({width:e,health:t="",vertical:r=""}){return(0,nl.jsxs)(De,{flexDirection:"column",children:[(0,nl.jsxs)(De,{children:[(0,nl.jsx)(Ca,{}),(0,nl.jsx)(k,{dimColor:!0,children:r==="research"?" \xB7 Autonomous Research Lab":" \xB7 Autonomous Work Lab"})]}),t?(0,nl.jsx)(k,{color:pe.warning,children:` ! ${rF(t,Math.max(12,e-6))}`}):null]})}var sl=Le($t(),1);var nF=new Set(["done","success","completed"]),oF=new Set(["research_incomplete","paused_no_breakthrough","exhausted_current_methods"]),iF=new Set(["no_progress","max_rounds"]),sF=new Set(["blocked","infra_blocked"]),aF=new Set(["error","failed","supervisor_error"]),AF={completed:{glyph:"\u{1F389}",tone:"ok",missionStatus:"complete"},incomplete:{glyph:"\u25CC",tone:"warn",missionStatus:"incomplete"},stalled:{glyph:"\u23F8",tone:"warn",missionStatus:"stalled"},blocked:{glyph:"\u26D4",tone:"err",missionStatus:"blocked"},failed:{glyph:"\u{1F4A5}",tone:"err",missionStatus:"failed"},ended:{glyph:"\u25A0",tone:"info",missionStatus:"ended"}},lF={completed:"Task completed",incomplete:"Mission incomplete",stalled:"Mission stalled",blocked:"Mission blocked",failed:"Mission failed",ended:"Mission ended"};function ol(e){return String(e??"").trim().toLowerCase()}function uF(e){let t=ol(e);switch(t){case"completed":case"incomplete":case"stalled":case"blocked":case"failed":case"ended":return t;default:return null}}function hI(e){let t=ol(e.status);return e.success===!0||nF.has(t)?"completed":oF.has(t)?"incomplete":iF.has(t)?"stalled":sF.has(t)?"blocked":aF.has(t)?"failed":"ended"}function CI(e){let t=e.outcome;if(t&&typeof t=="object"&&!Array.isArray(t)){let r=t;return{execution_status:ol(r.execution_status)||hI(e),review_status:ol(r.review_status)||"not_assessed",stage_certification:ol(r.stage_certification)||"not_assessed",interruption_kind:ol(r.interruption_kind)||"none",resumable:r.resumable===!0}}return{execution_status:hI(e),review_status:"not_assessed",stage_certification:"not_assessed",interruption_kind:ol(e.stop_kind)||"none",resumable:e.resumable===!0}}function cp(e){if(!e?.execution_status)return[];let t={certified:"Stage approved",not_certified:"Stage not approved",revoked:"Stage approval revoked",intentionally_skipped:"Stage decision not needed",deferred:"Stage decision pending",not_assessed:""};return[`execution=${e.execution_status}`,e.review_status&&e.review_status!=="not_assessed"?`review=${e.review_status}`:"",e.stage_certification?t[e.stage_certification]:"",e.interruption_kind&&e.interruption_kind!=="none"?`interrupt=${e.interruption_kind}`:"",e.resumable?"resumable=yes":""].filter(Boolean)}function il(e){if(e.success===!0&&e.campaign_continues===!0)return{outcomeClass:"completed",label:"Task continued",glyph:"\u21BB",tone:"info",missionStatus:"continued"};let t=uF(e.outcome_class)??hI(e),r=String(e.status??"").trim(),i=AF[t],s=t==="completed"&&e.final_submission_certified===!0?"Submission certified":t==="ended"&&r?`Mission ended \xB7 ${r}`:lF[t];return{outcomeClass:t,label:s,glyph:i.glyph,tone:i.tone,missionStatus:i.missionStatus}}var fp=["manager","planner","engineer","reviewer"],$y=new Set(["planner","engineer","reviewer"]),cF=new Set(["running","in_progress","claimed"]),Qe=(e,t)=>String(e[t]??"").trim(),ks=(e,t)=>{let r=Number(e[t]);return Number.isFinite(r)?r:null};function Wu(e){let t=[e.route?e.route.toUpperCase():"",e.vertical,e.workflow_mode?e.workflow_mode.toUpperCase():""].filter(Boolean);return e.lifetime==="standing"?t.push("STANDING \xB7 OPEN-ENDED"):e.lifetime==="bounded_increment"?t.push("BOUNDED INCREMENT"):e.lifetime==="bounded"&&e.continuous?t.push("BOUNDED \xB7 FINITE CONTINUOUS"):e.lifetime&&t.push(e.lifetime.toUpperCase()),t.join(" \xB7 ")}function fF(e){return JSON.parse(JSON.stringify(e))}function BI(){return{schema_version:6,bootstrapped:!1,mission:{id:"",title:"",objective:"",summary:"",final_output:"",status:"idle",started_at:null,completed_at:null,elapsed_seconds:0,campaign_started_at:null,campaign_elapsed_seconds:0},stage:{id:"",label:""},routing:{route:"",vertical:"",workflow_mode:"",lifetime:"",continuous:!1,open_ended:!1},round:{current:0,max:0},active_role:"",roles:fp.map(e=>({role:e,status:"waiting",label:"Waiting",updated_at:0})),role_work:[],dag:[],timeline:[],artifacts:[],learned_skills:[],learned_wiki_pages:[],storage:{project_skill_dir:"",global_skill_dir:"",project_skill_count:0,global_skill_count:0,skill_history_compressed:0,wiki_retired_compressed:0,skill_history_bytes_saved:0,wiki_retired_bytes_saved:0,wiki_paths:[]},achievement:null,review:{status:"",reason:"",rejected_attempts:0},frontier:{change:"",summary:"",updated_at:0},delivery:null,outcome:{},last_event_ts:0,updated_at:0}}function Ba(e,t,r,i){if(r==null||r==="")return;let s=e.findIndex(a=>a[t]===r);s>=0?e[s]={...e[s],...i}:e.push(i)}function Cn(e,t,r,i,s){if(!fp.includes(t))return;r==="active"&&$y.has(t)&&e.roles.forEach(u=>{$y.has(u.role)&&u.role!==t&&u.status==="active"&&Object.assign(u,{status:"done",label:"Handed off",updated_at:s})});let a={role:t,status:r,label:i,updated_at:s};Ba(e.roles,"role",t,a),r==="active"?e.active_role=t:e.active_role===t&&(e.active_role="")}function Kn(e,t,r,i,s="",a="neutral"){let u=sA(t);if(e.timeline.some(m=>m.id===u))return;let E={id:u,ts:Number(t.ts??Date.now()/1e3),type:iA(t.type),role:r,title:i.slice(0,180),detail:s.slice(0,500),tone:a};["item_id","branch_id"].forEach(m=>{let h=Qe(t,m);h&&(E[m]=h)}),e.timeline=[...e.timeline,E].slice(-120)}function Uo(e,t,r,i,s,a="",u=""){if(!fp.includes(r))return;let E=Qe(t,"message_id"),m=E?`${r}:${E}`:sA(t),h=e.role_work.find(G=>G.id===m),y=h&&h.detail.length>a.length?h.detail:a,D={id:m,ts:Number(t.ts??Date.now()/1e3),role:r,kind:i,title:s.slice(0,240),detail:y.slice(0,4e3),status:u,item_id:Qe(t,"item_id"),mission_id:e.mission.id,mission_title:e.mission.title.slice(0,240),round_index:ks(t,"round_index")},_=e.role_work.findIndex(G=>G.id===m);_>=0?e.role_work[_]=D:e.role_work.push(D);let O=new Set;fp.forEach(G=>{e.role_work.filter(re=>re.role===G).slice(-40).forEach(re=>O.add(re.id))}),e.role_work=e.role_work.filter(G=>O.has(G.id))}function gF(e){return e==="ok"?"success":e==="err"?"error":"info"}var dF={agent_message:"Reporting progress",assistant_message:"Reporting progress",command_execution:"Running a command",reasoning:"Reasoning",tool_use:"Using a tool",tool_result:"Inspecting tool output",codex_idle:"Waiting for model output"};function Xy(e,t){let r=iA(t.type),i=Number(t.ts??Date.now()/1e3);if(e.last_event_ts=Math.max(e.last_event_ts,i),r===te.LIFE_MANAGER_INTENT_STARTED)e.mission.id=Qe(t,"item_id")||Qe(t,"intent_id"),e.mission.title=Qe(t,"objective").slice(0,240),e.mission.objective=Qe(t,"objective"),e.mission.summary="",e.mission.final_output="",e.mission.started_at=null,e.mission.completed_at=null,e.mission.status="grounding",Cn(e,"manager","active","Grounding project",i),Kn(e,t,"manager","Project grounding started",Qe(t,"objective")),Uo(e,t,"manager","grounding","Grounding project",Qe(t,"objective"),"active");else if(r===te.LIFE_MANAGER_INTENT_COMPLETED){e.mission.id=Qe(t,"item_id"),e.mission.title=Qe(t,"objective").slice(0,240),e.mission.objective=Qe(t,"objective"),e.mission.summary="",e.mission.final_output="",e.mission.started_at=null,e.mission.completed_at=null,e.mission.status="framed",e.routing.route=Qe(t,"route")||e.routing.route||"team",e.routing.vertical=Qe(t,"vertical")||e.routing.vertical,e.routing.workflow_mode=Qe(t,"workflow_mode")||e.routing.workflow_mode,e.routing.lifetime=Qe(t,"lifetime")||e.routing.lifetime,"continuous"in t&&(e.routing.continuous=t.continuous===!0),"open_ended"in t&&(e.routing.open_ended=t.open_ended===!0);let s=Qe(t,"current_stage"),a=Array.isArray(t.stages)?t.stages:[];if(s)e.stage={id:s,label:s.replaceAll("_"," ")};else if(!e.stage.id&&a[0]){let u=String(a[0]);e.stage={id:u,label:u.replaceAll("_"," ")}}Cn(e,"manager","done","Goal framed",i),Kn(e,t,"manager","Goal framed",Qe(t,"reason"),"success"),Uo(e,t,"manager","decision","Goal framed",Qe(t,"reason")||Qe(t,"execution_task"),"done")}else if(r===te.LIFE_MANAGER_INTENT_FAILED)e.mission.status="failed",Cn(e,"manager","error","Manager routing failed",i),Kn(e,t,"manager","Manager routing failed",Qe(t,"error")||Qe(t,"reason"),"error"),Uo(e,t,"manager","grounding","Manager routing failed",Qe(t,"error")||Qe(t,"reason"),"error");else if(r===te.LIFE_MANAGER_STAGE_DECISION){let s=Qe(t,"target_stage")||Qe(t,"stage")||Qe(t,"current_stage");s&&(e.stage={id:s,label:s.replaceAll("_"," ")}),Cn(e,"manager","done",s?`Stage \xB7 ${s}`:"Stage reviewed",i),Kn(e,t,"manager",s?`Stage \u2192 ${s}`:"Stage reviewed",Qe(t,"reason")),Uo(e,t,"manager","stage_decision",s?`Stage \u2192 ${s}`:"Stage reviewed",Qe(t,"reason"),Qe(t,"action"))}else if(r===te.LIFE_PLANNER_START)Cn(e,"planner","active","Planning next work",i),Uo(e,t,"planner","planning","Planning next work",Qe(t,"objective"),"active");else if(r===te.LIFE_PLANNER_TASK_ADDED){let s=Qe(t,"item_id"),a={id:s,title:Qe(t,"title"),objective:Qe(t,"objective"),status:"pending",deps:Array.isArray(t.deps)?t.deps.map(String):[],branch_id:Qe(t,"branch_id")||s,parent_branch_id:Qe(t,"parent_branch_id")||null};Ba(e.dag,"id",s,a);let u=e.routing.vertical==="research"?"Research branch added":"Task added";Cn(e,"planner","done",u,i),Kn(e,t,"planner",u,a.title,"info"),Uo(e,t,"planner","task",a.title||"Task added",a.objective,"pending")}else if(r===te.LIFE_PLANNER_VERDICT){let s=!!t.project_done,a=s&&t.delivery&&typeof t.delivery=="object"&&!Array.isArray(t.delivery)?JSON.parse(JSON.stringify(t.delivery)):null,u=a?"Task completed":s?"Project reviewed":"Planning complete";a&&(e.delivery=a,e.mission.status="complete",e.mission.summary=a.summary||"",e.mission.completed_at=i),Cn(e,"planner","done",u,i),Kn(e,t,"planner",u,Qe(t,"reason"),s?"success":"neutral"),Uo(e,t,"planner","verdict",u,Qe(t,"reason"),s?"done":"planned")}else if(r===te.LIFE_PLANNER_WAITING){Cn(e,"planner","waiting","Waiting on external work",i);let s=Qe(t,"reason")||Qe(t,"waiting_reason");Kn(e,t,"planner","Planner waiting",s),Uo(e,t,"planner","waiting","Planner waiting",s,"waiting")}else if(r===te.LIFE_MISSION_STARTED)e.review={status:"",reason:"",rejected_attempts:0},e.delivery=null,e.mission.campaign_started_at??=i,e.mission={...e.mission,id:Qe(t,"item_id"),title:Qe(t,"title"),objective:Qe(t,"objective"),summary:"",final_output:"",status:"working",started_at:i,completed_at:null},Cn(e,"reviewer","waiting","Waiting for the Engineer to finish",i),Cn(e,"engineer","active","Starting mission",i),Kn(e,t,"engineer","Mission started",Qe(t,"title"),"info"),Uo(e,t,"engineer","task",Qe(t,"title")||"Mission started",Qe(t,"objective"),"active");else if(r===te.ROUND_START)e.round={current:ks(t,"round_index")??0,max:ks(t,"round_max")??e.round.max},Cn(e,"engineer","active",`Running round ${e.round.current}`,i),Kn(e,t,"engineer",`Round ${e.round.current} started`);else if(r===te.ENGINEER_PROGRESS){let s=Qe(t,"agent_layer")||Qe(t,"actor")||"engineer",a=s==="main"?"engineer":s,u=Qe(t,"kind"),E=dF[u]??"Working";Cn(e,a,"active",E,i),a==="engineer"&&["assistant_message","agent_message","message"].includes(u)&&t.final_delivery===!0&&e.mission.started_at!=null&&e.mission.completed_at==null&&i>=e.mission.started_at&&(!t.item_id||Qe(t,"item_id")===e.mission.id)&&(e.mission.final_output=sp(t.text));let m=Qe(t,"action_summary")||Qe(t,"text");m&&!cI(t)&&!Gu(t)&&Uo(e,t,a,u||"progress",E,m,"active"),["reasoning","assistant_message","agent_message"].includes(u)||Kn(e,t,a,E,Qe(t,"action_summary")||Qe(t,"text"))}else if(r===te.ROUND_MAIN_COMPLETED)Cn(e,"engineer","done","Work ready for review",i),Uo(e,t,"engineer","handoff","Work ready for review",Qe(t,"text")||Qe(t,"summary"),"done");else if(r===te.ROUND_REVIEW_STARTED)e.review={status:"",reason:"",rejected_attempts:e.review.rejected_attempts},Cn(e,"reviewer","active","Reviewing benchmark evidence",i),Uo(e,t,"reviewer","review","Review started","","active");else if(r===te.ROUND_REVIEW_DEFERRED){let s=Qe(t,"next_step");Cn(e,"engineer","active","Continuing before review",i),Cn(e,"reviewer","waiting","Review deferred for one round",i),Kn(e,t,"engineer","Continued before review",s,"info")}else if(r===te.ROUND_REVIEW_COMPLETED){let s=t.review_skipped===!0,a=s?"skipped":Qe(t,"status"),u=Qe(t,"reason");e.review={status:a,reason:u,rejected_attempts:e.review.rejected_attempts+(["continue","blocked"].includes(a)?1:0)};let E=Qe(t,"frontier_change");E&&(e.frontier={change:E,summary:Qe(t,"frontier_summary"),updated_at:i});let m=s?"Review not performed":a==="done"?"Evidence accepted":"Attempt rejected";Cn(e,"reviewer",s?"waiting":a==="done"?"done":"rejected",s?m:a==="done"?"Accepted evidence":"Requested another attempt",i),Kn(e,t,"reviewer",m,u,s?"info":a==="done"?"success":"error");let h=Qe(t,"next_action");Uo(e,t,"reviewer",s?"review":"verdict",m,h?`${u} +${s}`}var Py=["all","attention","milestones","messages"],Jb=new Set([te.LIFE_MISSION_STARTED,te.LIFE_MISSION_COMPLETED,te.LIFE_MISSION_FAILED,te.LOOP_START,te.LOOP_DONE,te.LIFE_PLANNER_VERDICT,"final.report.ready","pptx.report.ready","plan.completed",te.LIFE_BUDGET_PAUSE,te.LIFE_LIFECYCLE_BLOCK]);function Uy(e,t,r="all",i=""){let s=iA(e.canonical_type??e.type),a=String(e.kind??"");if(r==="attention"&&!["warn","err"].includes(String(t.tone??""))&&e.operator_alert!==!0||r==="milestones"&&!(t.rule&&!s.startsWith("ui."))&&!Jb.has(s)||r==="messages"&&t.tone!=="bright"&&!["assistant_message","agent_message","message"].includes(a)&&!["ui.operator","ui.argus"].includes(s))return!1;let u=i.trim().toLocaleLowerCase();return u?[s,a,t.role,t.label,t.text,e.title,e.objective,e.text,e.summary,e.reason,e.error,e.status,e.action_summary,e.command,e.path,Array.isArray(e.tags)?e.tags.join(" "):e.tags].some(m=>String(m??"").toLocaleLowerCase().includes(u)):!0}var Lf=[{id:"status",name:"/status",argument:"none",desc:"roles, queued work, journal, and health",group:"Everyday",kind:"panel"},{id:"roles",name:"/roles",argument:"none",desc:"per-role backend / model / effort + live activity",group:"Everyday",kind:"panel"},{id:"journal",name:"/journal",arg:"[N]",argument:"optional",desc:"recent journal entries (default 10)",group:"Everyday",kind:"panel"},{id:"backlog",name:"/backlog",arg:"[all]",argument:"optional",desc:"pending tasks (all = incl. done/skipped)",group:"Everyday",kind:"panel"},{id:"artifacts",name:"/artifacts",argument:"none",desc:"result files the Reviewer has checked (Enter previews)",group:"Everyday",kind:"panel"},{id:"artifact",name:"/artifact",arg:"",argument:"required",desc:"preview one reviewed result file",group:"Everyday",kind:"panel"},{id:"events",name:"/events",arg:"[filter] [query]",argument:"optional",desc:"search feed: all / watch / milestones / messages",group:"Everyday",kind:"panel"},{id:"find",name:"/find",arg:"",argument:"required",desc:"search the current event buffer",group:"Everyday",kind:"panel"},{id:"cancel",name:"/cancel",argument:"none",desc:"stop waiting for the current Manager reply",group:"Everyday",kind:"local"},{id:"ask",name:"/ask",arg:"",argument:"required",desc:"answer inline \u2014 no task queued, no Planner/Engineer/Reviewer",aliases:["/chat"],group:"Everyday",kind:"action"},{id:"crystalpilot",name:"/crystalpilot",arg:"[status|off|use ]",argument:"optional",desc:"enable crystallography tools in this Argus conversation",group:"Everyday",kind:"action"},{id:"task",name:"/task",arg:"",argument:"required",desc:"queue work directly",aliases:["/add"],group:"Task management",kind:"action"},{id:"plan",name:"/plan",arg:"",argument:"required",desc:"preview a Planner-authored execution plan",group:"Task management",kind:"action"},{id:"rewrite",name:"/rewrite",arg:"[text]",argument:"optional",desc:"let the Manager rewrite your prompt before sending",aliases:["/refine"],group:"Task management",kind:"action"},{id:"nudge",name:"/nudge",arg:"",argument:"required",desc:"inject guidance into the running mission",aliases:["/inject","/notify"],group:"Task management",kind:"action"},{id:"abort",name:"/abort",argument:"none",desc:"immediately stop the running mission",group:"Task management",kind:"action"},{id:"note",name:"/note",arg:"",argument:"required",desc:"append a manual note to the timeline",group:"Task management",kind:"action"},{id:"done",name:"/done",arg:"",argument:"required",desc:"mark a task done",group:"Task management",kind:"action"},{id:"skip",name:"/skip",arg:"",argument:"required",desc:"skip a task",aliases:["/rm"],group:"Task management",kind:"action"},{id:"stop",name:"/stop",arg:"",argument:"required",desc:"stop a task's auto-iteration",group:"Task management",kind:"action"},{id:"item",name:"/item",arg:"",argument:"required",desc:"inspect a full task contract",group:"Task management",kind:"panel"},{id:"run",name:"/run",argument:"none",desc:"return to the always-live mission feed",group:"Task management",kind:"local"},{id:"new",name:"/new",arg:"[objective]",argument:"optional",desc:"review, create, and switch to a fresh conversation",group:"Sessions & diagnostics",kind:"action"},{id:"daemons",name:"/daemons",arg:"[query]",argument:"optional",desc:"find every session + switch or create",group:"Sessions & diagnostics",kind:"panel"},{id:"resume",name:"/resume",arg:"[list|]",argument:"optional",desc:"switch to another project/session",group:"Sessions & diagnostics",kind:"action"},{id:"attach",name:"/attach",arg:"",argument:"required",desc:"follow another project (read the stream)",group:"Sessions & diagnostics",kind:"action"},{id:"rename",name:"/rename",arg:"",argument:"required",desc:"rename the current conversation",group:"Sessions & diagnostics",kind:"action"},{id:"doctor",name:"/doctor",argument:"none",desc:"diagnose 'why isn't anything running'",group:"Sessions & diagnostics",kind:"panel"},{id:"backend",name:"/backend",arg:"[codex|claude|copilot|cursor|opencode|pi|grok|qoder|dsh]",argument:"optional",desc:"view or change the shared runner backend",group:"Configuration",kind:"action"},{id:"config",name:"/config",arg:"[key=value \u2026]",argument:"optional",desc:"view or change runtime settings",group:"Configuration",kind:"panel"},{id:"identity",name:"/identity",arg:"[set ]",argument:"optional",desc:"view or replace the operator identity card",group:"Configuration",kind:"panel"},{id:"reset",name:"/reset",argument:"none",desc:"drop the warm Manager conversation context",group:"Configuration",kind:"action"},{id:"skills",name:"/skills",arg:"[ls|promote ]",argument:"optional",desc:"inspect or promote runtime skills",group:"Configuration",kind:"action"},{id:"clear",name:"/clear",argument:"none",desc:"clear the event feed view",group:"Other",kind:"local"},{id:"reconnect",name:"/reconnect",argument:"none",desc:"reconnect the live event stream",group:"Other",kind:"local"},{id:"help",name:"/help",argument:"none",desc:"keys + full command reference",aliases:["/?","/commands"],group:"Other",kind:"local"},{id:"quit",name:"/quit",argument:"none",desc:"leave the cockpit (background work keeps running)",aliases:["/exit","/q"],group:"Other",kind:"local"}],pM=new Map(Lf.map(e=>[e.id,e])),ap=new Map;for(let e of Lf)for(let t of[e.name,...e.aliases??[]])ap.set(t.toLowerCase(),e);var Kb=/^\/[A-Za-z0-9_-]+$/;function Mf(e){if(!e.startsWith("/"))return!1;let t=e.indexOf(" "),r=t===-1?e:e.slice(0,t);return Kb.test(r)}function Yb(e){return e.startsWith("/")&&!e.includes(" ")&&!e.slice(1).includes("/")}function Ap(e){if(!Yb(e))return[];let t=e.toLowerCase(),r=new Set,i=[];for(let s of Lf)[s.name,...s.aliases??[]].some(u=>u.toLowerCase().startsWith(t))&&!r.has(s.name)&&(r.add(s.name),i.push(s));return i.sort((s,a)=>Number(Gy(a,t))-Number(Gy(s,t)))}function Gy(e,t){return[e.name,...e.aliases??[]].some(r=>r.toLowerCase()===t)}function lp(e){return e.arg?`${e.name} `:e.name}function gI(e){let t=e.trim();return!t||t.toLowerCase()==="list"?{kind:"list"}:{kind:"project",query:t}}function dI(e){let t=e.trim();if(!t)return{filter:"all",query:""};let[r,...i]=t.split(/\s+/);return r.toLowerCase()==="watch"?{filter:"attention",query:i.join(" ")}:Py.includes(r.toLowerCase())?{filter:r.toLowerCase(),query:i.join(" ")}:{filter:"all",query:t}}function pI(e){if(!Mf(e))return null;let t=e.indexOf(" "),r=(t===-1?e:e.slice(0,t)).toLowerCase(),i=t===-1?"":e.slice(t+1).trim(),s=ap.get(r)??null;return{cmd:s,name:s?s.name:r,rest:i}}function EI(e){let t=e.toLowerCase(),r=null,i=0;for(let s of ap.keys()){let a=Vb(t,s);a>i&&(i=a,r=ap.get(s).name)}return i>=.6?r:null}function Vb(e,t){let r=qb(e,t),i=Math.max(e.length,t.length)||1;return 1-r/i}function qb(e,t){let r=e.length,i=t.length,s=Array.from({length:r+1},(a,u)=>[u,...Array(i).fill(0)]);for(let a=0;a<=i;a+=1)s[0][a]=a;for(let a=1;a<=r;a+=1)for(let u=1;u<=i;u+=1)s[a][u]=Math.min(s[a-1][u]+1,s[a][u-1]+1,s[a-1][u-1]+(e[a-1]===t[u-1]?0:1));return s[r][i]}function mI(){let e=["Everyday","Task management","Sessions & diagnostics","Configuration","Other"],t=new Map;for(let r of Lf){let i=r.aliases?.length?` (= ${r.aliases.join(", ")})`:"",s=`${r.name}${r.arg?` ${r.arg}`:""}${i}`;t.has(r.group)||t.set(r.group,[]),t.get(r.group).push({label:s,desc:r.desc})}return e.filter(r=>t.has(r)).map(r=>({group:r,rows:t.get(r)}))}var pe={accent:"#e6b450",border:"#8a93a6",success:"#3aa76a",error:"#d15c6a",warning:"#d0a850",info:"#5a9beb",role:{manager:"blue",planner:"magenta",engineer:"green",reviewer:"yellow"}},Hu=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"],Hy=["#3b6fd4","#4d86e0","#5f9deb","#72b4f0","#89dceb"],II="#48506b",Wy="#f4e0a8",jy="#6c7086";function Jy(e){switch(e){case"medium":return pe.info;case"high":return pe.warning;case"xhigh":return pe.accent;case"max":return pe.error;default:return"gray"}}var ha=Le(Gt(),1),qy="argus";function Ca({d:e="solid",lit:t=qy.length,sh:r=-1}){let i=e==="ghost"?II:pe.accent;return(0,ha.jsxs)(k,{children:[(0,ha.jsx)(k,{color:i,bold:e==="solid",dimColor:e==="flick",children:"\u25C9"}),t>=0?(0,ha.jsxs)(ha.Fragment,{children:[(0,ha.jsx)(k,{children:" "}),[...qy].map((s,a)=>{let u=a===r,E=u?Wy:ae.length<=t?e:`${e.slice(0,Math.max(1,t-1))}\u2026`;function zy({width:e,health:t="",vertical:r=""}){return(0,nl.jsxs)(De,{flexDirection:"column",children:[(0,nl.jsxs)(De,{children:[(0,nl.jsx)(Ca,{}),(0,nl.jsx)(k,{dimColor:!0,children:r==="research"?" \xB7 Autonomous Research Lab":" \xB7 Autonomous Work Lab"})]}),t?(0,nl.jsx)(k,{color:pe.warning,children:` ! ${rF(t,Math.max(12,e-6))}`}):null]})}var sl=Le($t(),1);var nF=new Set(["done","success","completed"]),oF=new Set(["research_incomplete","paused_no_breakthrough","exhausted_current_methods"]),iF=new Set(["no_progress","max_rounds"]),sF=new Set(["blocked","infra_blocked"]),aF=new Set(["error","failed","supervisor_error"]),AF={completed:{glyph:"\u{1F389}",tone:"ok",missionStatus:"complete"},incomplete:{glyph:"\u25CC",tone:"warn",missionStatus:"incomplete"},stalled:{glyph:"\u23F8",tone:"warn",missionStatus:"stalled"},blocked:{glyph:"\u26D4",tone:"err",missionStatus:"blocked"},failed:{glyph:"\u{1F4A5}",tone:"err",missionStatus:"failed"},ended:{glyph:"\u25A0",tone:"info",missionStatus:"ended"}},lF={completed:"Task completed",incomplete:"Mission incomplete",stalled:"Mission stalled",blocked:"Mission blocked",failed:"Mission failed",ended:"Mission ended"};function ol(e){return String(e??"").trim().toLowerCase()}function uF(e){let t=ol(e);switch(t){case"completed":case"incomplete":case"stalled":case"blocked":case"failed":case"ended":return t;default:return null}}function hI(e){let t=ol(e.status);return e.success===!0||nF.has(t)?"completed":oF.has(t)?"incomplete":iF.has(t)?"stalled":sF.has(t)?"blocked":aF.has(t)?"failed":"ended"}function CI(e){let t=e.outcome;if(t&&typeof t=="object"&&!Array.isArray(t)){let r=t;return{execution_status:ol(r.execution_status)||hI(e),review_status:ol(r.review_status)||"not_assessed",stage_certification:ol(r.stage_certification)||"not_assessed",interruption_kind:ol(r.interruption_kind)||"none",resumable:r.resumable===!0}}return{execution_status:hI(e),review_status:"not_assessed",stage_certification:"not_assessed",interruption_kind:ol(e.stop_kind)||"none",resumable:e.resumable===!0}}function cp(e){if(!e?.execution_status)return[];let t={certified:"Stage approved",not_certified:"Stage not approved",revoked:"Stage approval revoked",intentionally_skipped:"Stage decision not needed",deferred:"Stage decision pending",not_assessed:""};return[`execution=${e.execution_status}`,e.review_status&&e.review_status!=="not_assessed"?`review=${e.review_status}`:"",e.stage_certification?t[e.stage_certification]:"",e.interruption_kind&&e.interruption_kind!=="none"?`interrupt=${e.interruption_kind}`:"",e.resumable?"resumable=yes":""].filter(Boolean)}function il(e){if(e.success===!0&&e.campaign_continues===!0)return{outcomeClass:"completed",label:"Task continued",glyph:"\u21BB",tone:"info",missionStatus:"continued"};let t=uF(e.outcome_class)??hI(e),r=String(e.status??"").trim(),i=AF[t],s=t==="completed"&&e.final_submission_certified===!0?"Submission certified":t==="ended"&&r?`Mission ended \xB7 ${r}`:lF[t];return{outcomeClass:t,label:s,glyph:i.glyph,tone:i.tone,missionStatus:i.missionStatus}}var fp=["manager","planner","engineer","reviewer"],$y=new Set(["planner","engineer","reviewer"]),cF=new Set(["running","in_progress","claimed"]),Qe=(e,t)=>String(e[t]??"").trim(),ks=(e,t)=>{let r=Number(e[t]);return Number.isFinite(r)?r:null};function Wu(e){let t=[e.route?e.route.toUpperCase():"",e.vertical,e.workflow_mode?e.workflow_mode.toUpperCase():""].filter(Boolean);return e.lifetime==="standing"?t.push("STANDING \xB7 OPEN-ENDED"):e.lifetime==="bounded_increment"?t.push("BOUNDED INCREMENT"):e.lifetime==="bounded"&&e.continuous?t.push("BOUNDED \xB7 FINITE CONTINUOUS"):e.lifetime&&t.push(e.lifetime.toUpperCase()),t.join(" \xB7 ")}function fF(e){return JSON.parse(JSON.stringify(e))}function BI(){return{schema_version:6,bootstrapped:!1,mission:{id:"",title:"",objective:"",summary:"",final_output:"",status:"idle",started_at:null,completed_at:null,elapsed_seconds:0,campaign_started_at:null,campaign_elapsed_seconds:0},stage:{id:"",label:""},routing:{route:"",vertical:"",workflow_mode:"",lifetime:"",continuous:!1,open_ended:!1},round:{current:0,max:0},active_role:"",roles:fp.map(e=>({role:e,status:"waiting",label:"Waiting",updated_at:0})),role_work:[],dag:[],timeline:[],artifacts:[],learned_skills:[],learned_wiki_pages:[],storage:{project_skill_dir:"",global_skill_dir:"",project_skill_count:0,global_skill_count:0,skill_history_compressed:0,wiki_retired_compressed:0,skill_history_bytes_saved:0,wiki_retired_bytes_saved:0,wiki_paths:[]},achievement:null,review:{status:"",reason:"",rejected_attempts:0},frontier:{change:"",summary:"",updated_at:0},delivery:null,outcome:{},last_event_ts:0,updated_at:0}}function Ba(e,t,r,i){if(r==null||r==="")return;let s=e.findIndex(a=>a[t]===r);s>=0?e[s]={...e[s],...i}:e.push(i)}function Cn(e,t,r,i,s){if(!fp.includes(t))return;r==="active"&&$y.has(t)&&e.roles.forEach(u=>{$y.has(u.role)&&u.role!==t&&u.status==="active"&&Object.assign(u,{status:"done",label:"Handed off",updated_at:s})});let a={role:t,status:r,label:i,updated_at:s};Ba(e.roles,"role",t,a),r==="active"?e.active_role=t:e.active_role===t&&(e.active_role="")}function Kn(e,t,r,i,s="",a="neutral"){let u=sA(t);if(e.timeline.some(m=>m.id===u))return;let E={id:u,ts:Number(t.ts??Date.now()/1e3),type:iA(t.type),role:r,title:i.slice(0,180),detail:s.slice(0,500),tone:a};["item_id","branch_id"].forEach(m=>{let h=Qe(t,m);h&&(E[m]=h)}),e.timeline=[...e.timeline,E].slice(-120)}function Uo(e,t,r,i,s,a="",u=""){if(!fp.includes(r))return;let E=Qe(t,"message_id"),m=E?`${r}:${E}`:sA(t),h=e.role_work.find(G=>G.id===m),y=h&&h.detail.length>a.length?h.detail:a,D={id:m,ts:Number(t.ts??Date.now()/1e3),role:r,kind:i,title:s.slice(0,240),detail:y.slice(0,4e3),status:u,item_id:Qe(t,"item_id"),mission_id:e.mission.id,mission_title:e.mission.title.slice(0,240),round_index:ks(t,"round_index")},_=e.role_work.findIndex(G=>G.id===m);_>=0?e.role_work[_]=D:e.role_work.push(D);let O=new Set;fp.forEach(G=>{e.role_work.filter(re=>re.role===G).slice(-40).forEach(re=>O.add(re.id))}),e.role_work=e.role_work.filter(G=>O.has(G.id))}function gF(e){return e==="ok"?"success":e==="err"?"error":"info"}var dF={agent_message:"Reporting progress",assistant_message:"Reporting progress",command_execution:"Running a command",reasoning:"Reasoning",tool_use:"Using a tool",tool_result:"Inspecting tool output",codex_idle:"Waiting for model output"};function Xy(e,t){let r=iA(t.type),i=Number(t.ts??Date.now()/1e3);if(e.last_event_ts=Math.max(e.last_event_ts,i),r===te.LIFE_MANAGER_INTENT_STARTED)e.mission.id=Qe(t,"item_id")||Qe(t,"intent_id"),e.mission.title=Qe(t,"objective").slice(0,240),e.mission.objective=Qe(t,"objective"),e.mission.summary="",e.mission.final_output="",e.mission.started_at=null,e.mission.completed_at=null,e.mission.status="grounding",Cn(e,"manager","active","Grounding project",i),Kn(e,t,"manager","Project grounding started",Qe(t,"objective")),Uo(e,t,"manager","grounding","Grounding project",Qe(t,"objective"),"active");else if(r===te.LIFE_MANAGER_INTENT_COMPLETED){e.mission.id=Qe(t,"item_id"),e.mission.title=Qe(t,"objective").slice(0,240),e.mission.objective=Qe(t,"objective"),e.mission.summary="",e.mission.final_output="",e.mission.started_at=null,e.mission.completed_at=null,e.mission.status="framed",e.routing.route=Qe(t,"route")||e.routing.route||"team",e.routing.vertical=Qe(t,"vertical")||e.routing.vertical,e.routing.workflow_mode=Qe(t,"workflow_mode")||e.routing.workflow_mode,e.routing.lifetime=Qe(t,"lifetime")||e.routing.lifetime,"continuous"in t&&(e.routing.continuous=t.continuous===!0),"open_ended"in t&&(e.routing.open_ended=t.open_ended===!0);let s=Qe(t,"current_stage"),a=Array.isArray(t.stages)?t.stages:[];if(s)e.stage={id:s,label:s.replaceAll("_"," ")};else if(!e.stage.id&&a[0]){let u=String(a[0]);e.stage={id:u,label:u.replaceAll("_"," ")}}Cn(e,"manager","done","Goal framed",i),Kn(e,t,"manager","Goal framed",Qe(t,"reason"),"success"),Uo(e,t,"manager","decision","Goal framed",Qe(t,"reason")||Qe(t,"execution_task"),"done")}else if(r===te.LIFE_MANAGER_INTENT_FAILED)e.mission.status="failed",Cn(e,"manager","error","Manager routing failed",i),Kn(e,t,"manager","Manager routing failed",Qe(t,"error")||Qe(t,"reason"),"error"),Uo(e,t,"manager","grounding","Manager routing failed",Qe(t,"error")||Qe(t,"reason"),"error");else if(r===te.LIFE_MANAGER_STAGE_DECISION){let s=Qe(t,"target_stage")||Qe(t,"stage")||Qe(t,"current_stage");s&&(e.stage={id:s,label:s.replaceAll("_"," ")}),Cn(e,"manager","done",s?`Stage \xB7 ${s}`:"Stage reviewed",i),Kn(e,t,"manager",s?`Stage \u2192 ${s}`:"Stage reviewed",Qe(t,"reason")),Uo(e,t,"manager","stage_decision",s?`Stage \u2192 ${s}`:"Stage reviewed",Qe(t,"reason"),Qe(t,"action"))}else if(r===te.LIFE_PLANNER_START)Cn(e,"planner","active","Planning next work",i),Uo(e,t,"planner","planning","Planning next work",Qe(t,"objective"),"active");else if(r===te.LIFE_PLANNER_TASK_ADDED){let s=Qe(t,"item_id"),a={id:s,title:Qe(t,"title"),objective:Qe(t,"objective"),status:"pending",deps:Array.isArray(t.deps)?t.deps.map(String):[],branch_id:Qe(t,"branch_id")||s,parent_branch_id:Qe(t,"parent_branch_id")||null};Ba(e.dag,"id",s,a);let u=e.routing.vertical==="research"?"Research branch added":"Task added";Cn(e,"planner","done",u,i),Kn(e,t,"planner",u,a.title,"info"),Uo(e,t,"planner","task",a.title||"Task added",a.objective,"pending")}else if(r===te.LIFE_PLANNER_VERDICT){let s=!!t.project_done,a=s&&t.delivery&&typeof t.delivery=="object"&&!Array.isArray(t.delivery)?JSON.parse(JSON.stringify(t.delivery)):null,u=a?"Task completed":s?"Project reviewed":"Planning complete";a&&(e.delivery=a,e.mission.status="complete",e.mission.summary=a.summary||"",e.mission.completed_at=i),Cn(e,"planner","done",u,i),Kn(e,t,"planner",u,Qe(t,"reason"),s?"success":"neutral"),Uo(e,t,"planner","verdict",u,Qe(t,"reason"),s?"done":"planned")}else if(r===te.LIFE_PLANNER_WAITING){Cn(e,"planner","waiting","Waiting on external work",i);let s=Qe(t,"reason")||Qe(t,"waiting_reason");Kn(e,t,"planner","Planner waiting",s),Uo(e,t,"planner","waiting","Planner waiting",s,"waiting")}else if(r===te.LIFE_MISSION_STARTED)e.review={status:"",reason:"",rejected_attempts:0},e.delivery=null,e.mission.campaign_started_at??=i,e.mission={...e.mission,id:Qe(t,"item_id"),title:Qe(t,"title"),objective:Qe(t,"objective"),summary:"",final_output:"",status:"working",started_at:i,completed_at:null},Cn(e,"reviewer","waiting","Waiting for the Engineer to finish",i),Cn(e,"engineer","active","Starting mission",i),Kn(e,t,"engineer","Mission started",Qe(t,"title"),"info"),Uo(e,t,"engineer","task",Qe(t,"title")||"Mission started",Qe(t,"objective"),"active");else if(r===te.ROUND_START)e.round={current:ks(t,"round_index")??0,max:ks(t,"round_max")??e.round.max},Cn(e,"engineer","active",`Running round ${e.round.current}`,i),Kn(e,t,"engineer",`Round ${e.round.current} started`);else if(r===te.ENGINEER_PROGRESS){let s=Qe(t,"agent_layer")||Qe(t,"actor")||"engineer",a=s==="main"?"engineer":s,u=Qe(t,"kind"),E=dF[u]??"Working";Cn(e,a,"active",E,i),a==="engineer"&&["assistant_message","agent_message","message"].includes(u)&&t.final_delivery===!0&&e.mission.started_at!=null&&e.mission.completed_at==null&&i>=e.mission.started_at&&(!t.item_id||Qe(t,"item_id")===e.mission.id)&&(e.mission.final_output=sp(t.text));let m=Qe(t,"action_summary")||Qe(t,"text");m&&!cI(t)&&!Gu(t)&&Uo(e,t,a,u||"progress",E,m,"active"),["reasoning","assistant_message","agent_message"].includes(u)||Kn(e,t,a,E,Qe(t,"action_summary")||Qe(t,"text"))}else if(r===te.ROUND_MAIN_COMPLETED)Cn(e,"engineer","done","Work ready for review",i),Uo(e,t,"engineer","handoff","Work ready for review",Qe(t,"text")||Qe(t,"summary"),"done");else if(r===te.ROUND_REVIEW_STARTED)e.review={status:"",reason:"",rejected_attempts:e.review.rejected_attempts},Cn(e,"reviewer","active","Reviewing benchmark evidence",i),Uo(e,t,"reviewer","review","Review started","","active");else if(r===te.ROUND_REVIEW_DEFERRED){let s=Qe(t,"next_step");Cn(e,"engineer","active","Continuing before review",i),Cn(e,"reviewer","waiting","Review deferred for one round",i),Kn(e,t,"engineer","Continued before review",s,"info")}else if(r===te.ROUND_REVIEW_COMPLETED){let s=t.review_skipped===!0,a=s?"skipped":Qe(t,"status"),u=Qe(t,"reason");e.review={status:a,reason:u,rejected_attempts:e.review.rejected_attempts+(["continue","blocked"].includes(a)?1:0)};let E=Qe(t,"frontier_change");E&&(e.frontier={change:E,summary:Qe(t,"frontier_summary"),updated_at:i});let m=s?"Review not performed":a==="done"?"Evidence accepted":"Attempt rejected";Cn(e,"reviewer",s?"waiting":a==="done"?"done":"rejected",s?m:a==="done"?"Accepted evidence":"Requested another attempt",i),Kn(e,t,"reviewer",m,u,s?"info":a==="done"?"success":"error");let h=Qe(t,"next_action");Uo(e,t,"reviewer",s?"review":"verdict",m,h?`${u} Next action: ${h}`:u,a)}else if([te.SKILL_CREATED,te.SKILL_UPDATED].includes(r)){let s=Qe(t,"skill_id")||Qe(t,"name");s&&(Ba(e.learned_skills,"id",s,{id:s,name:Qe(t,"name"),version:ks(t,"version")??1,scope:Qe(t,"scope"),path:Qe(t,"path"),status:"active",updated_at:i,mission_id:e.mission.id,mission_title:e.mission.title}),Kn(e,t,"reviewer",r===te.SKILL_CREATED?"Capability unlocked":"Capability upgraded",Qe(t,"name"),"skill"))}else if(r===te.SKILL_EVOLUTION_COMPLETED)e.storage.project_skill_dir=Qe(t,"project_skill_dir")||e.storage.project_skill_dir,e.storage.global_skill_dir=Qe(t,"global_skill_dir")||e.storage.global_skill_dir,e.storage.project_skill_count=ks(t,"project_skill_count")??e.storage.project_skill_count,e.storage.global_skill_count=ks(t,"global_skill_count")??e.storage.global_skill_count;else if(r===te.SKILL_HISTORY_COMPRESSED)e.storage.skill_history_compressed+=ks(t,"count")??0,e.storage.skill_history_bytes_saved+=ks(t,"bytes_saved")??0;else if(r===te.SKILL_TIDIED){let s=Qe(t,"name");if(s){let a=e.learned_skills.find(E=>E.name===s),u={source_path:Qe(t,"path"),source_placement:Qe(t,"placement"),source_vertical:Qe(t,"vertical"),updated_at:i};a?Object.assign(a,u):Ba(e.learned_skills,"id",s,{id:s,name:s,version:1,scope:"",path:"",status:"active",...u}),Kn(e,t,"manager","Capability promoted to source",s,"skill")}}else if([te.WIKI_INITIALIZED,te.WIKI_EVOLUTION_COMPLETED].includes(r)){let s=[...(Array.isArray(t.paths)?t.paths:[]).map(a=>String(a)),Qe(t,"path")].filter(Boolean);e.storage.wiki_paths=[...new Set([...e.storage.wiki_paths,...s])]}else if(r===te.WIKI_RETIRED_COMPRESSED)e.storage.wiki_retired_compressed+=ks(t,"count")??0,e.storage.wiki_retired_bytes_saved+=ks(t,"bytes_saved")??0;else if([te.WIKI_CREATED,te.WIKI_UPDATED].includes(r)){let s=Qe(t,"page_id");s&&(Ba(e.learned_wiki_pages,"id",s,{id:s,title:Qe(t,"title")||s,card_type:Qe(t,"card_type"),status:Qe(t,"status")||"scratch",path:Qe(t,"path"),updated_at:i}),Kn(e,t,"reviewer",r===te.WIKI_CREATED?"Knowledge captured":"Knowledge refined",Qe(t,"title")||s,"skill"))}else if(r===te.WIKI_RETIRED){let s=Qe(t,"page_id");if(s){let a=e.learned_wiki_pages.find(u=>u.id===s);a?Object.assign(a,{status:"retired",updated_at:i}):Ba(e.learned_wiki_pages,"id",s,{id:s,title:s,card_type:Qe(t,"card_type"),status:"retired",path:"",updated_at:i}),Kn(e,t,"reviewer","Knowledge retired",s,"error")}}else if([te.WIKI_PROMOTION_PROMOTED,te.WIKI_PROMOTION_DEMOTED].includes(r)){let s=Qe(t,"page_id");if(s){let a=e.learned_wiki_pages.find(E=>E.id===s);a?Object.assign(a,{status:Qe(t,"to_status"),updated_at:i}):Ba(e.learned_wiki_pages,"id",s,{id:s,title:s,card_type:Qe(t,"card_type"),status:Qe(t,"to_status"),path:"",updated_at:i});let u=r===te.WIKI_PROMOTION_PROMOTED;Kn(e,t,"reviewer",u?"Knowledge promoted":"Knowledge demoted",`${s} \u2192 ${Qe(t,"to_status")}`,u?"success":"neutral")}}else if(r===te.RESEARCH_ACHIEVEMENT_CERTIFIED)e.achievement={id:Qe(t,"achievement_id"),title:Qe(t,"title"),goal:Qe(t,"goal"),summary:Qe(t,"summary"),rejected_attempts:e.review.rejected_attempts,skills_learned:e.learned_skills.filter(s=>s.status==="active").length,artifacts:e.artifacts.length,elapsed_seconds:e.mission.elapsed_seconds,evidence:Array.isArray(t.evidence)?t.evidence.map(String):[],reviewer_certified:!0,certified_at:i};else if([te.LIFE_MISSION_COMPLETED,te.LIFE_MISSION_FAILED].includes(r)){let s=r===te.LIFE_MISSION_FAILED?il({...t,outcome_class:"failed",status:Qe(t,"status")||"failed",success:!1}):il(t),a="final_output"in t?Qe(t,"final_output"):Qe(t,"item_id")===e.mission.id&&e.mission.started_at!=null&&(e.mission.completed_at==null||e.mission.completed_at===i)&&e.mission.final_output||"";e.mission.id=Qe(t,"item_id")||e.mission.id,e.mission.title=Qe(t,"title")||e.mission.title,e.mission.objective=Qe(t,"objective")||e.mission.objective,e.mission.summary=Qe(t,"summary"),e.mission.final_output=a,e.mission.status=s.missionStatus,e.mission.completed_at=i;let u=t.delivery;t.success===!0&&u&&typeof u=="object"&&!Array.isArray(u)?e.delivery=JSON.parse(JSON.stringify(u)):t.success!==!0&&(e.delivery=null),e.outcome=CI(t),Cn(e,"engineer",s.missionStatus==="complete"?"done":s.missionStatus,s.label,i),Kn(e,t,"engineer",s.label,Qe(t,"summary")||Qe(t,"title")||Qe(t,"status"),gF(s.tone)),Uo(e,t,"engineer","completion",s.label,Qe(t,"summary")||Qe(t,"title")||Qe(t,"status"),s.missionStatus)}return e.updated_at=Date.now()/1e3,e}function pF(e,t,r){let i=t.backlog.find(D=>cF.has(D.status)),s=t.backlog.find(D=>D.status==="pending"),a=t.backlog.find(D=>D.id===e.mission.id),u=i??a,E=!!(i||s||t.continuous?.enabled||t.continuous?.done_reason||t.continuous?.done_at||e.mission.id||!["","idle"].includes(e.mission.status));t.continuous?.enabled&&(e.routing.route=e.routing.route||"team",e.routing.continuous=!0,e.routing.open_ended=t.continuous.open_ended===!0,e.routing.lifetime=e.routing.open_ended?"standing":e.routing.lifetime||"bounded");let m=u?.objective||u?.title||(t.continuous?.enabled?t.continuous.objective:"")||t.session.objective||(e.mission.id?"":s?.objective)||(e.mission.id?"":s?.title)||e.mission.objective;m&&(e.mission.objective=m,u?e.mission.title=(u.title||m.split(` `)[0]).slice(0,240):e.mission.title||(e.mission.title=m.split(` @@ -151,7 +151,7 @@ Next action: ${h}`:u,a)}else if([te.SKILL_CREATED,te.SKILL_UPDATED].includes(r)) `).replace(/\r/g,` `).replace(/[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f]/g,"")}function q0(e,t){let r=/(?:\u001b)?\[200~/.test(e),i=/(?:\u001b)?\[201~/.test(e),s=Array.from(e).length>1;if(!(t||r||i||s))return{handled:!1,active:t,text:e,pasted:!1};let u=E1(e);return t&&!e&&(u=` `),{handled:!0,active:i?!1:t||r,text:u,pasted:r||i||t||s}}var ao=Le(Gt(),1);function $0(e,t,r){return r.ctrl&&(t==="c"||t==="d")?"exit":r.escape?"dismiss":e.busy?null:r.downArrow||t==="j"?"next":r.upArrow||t==="k"?"previous":r.return?"replace":null}var z0=(e,t)=>e.length<=t?e:`${e.slice(0,Math.max(1,t-1))}\u2026`;function X0({state:e,width:t}){let r=Math.max(20,t-12);return(0,ao.jsxs)(De,{flexDirection:"column",borderStyle:"round",borderColor:pe.warning,paddingX:2,marginTop:1,children:[(0,ao.jsx)(k,{bold:!0,color:pe.warning,children:`Concurrent work limit reached \xB7 ${e.activeCount}/${e.limit}`}),(0,ao.jsx)(k,{dimColor:!0,children:"Choose one running session to park. Its files, backlog, checkpoints, skills, and wiki stay saved."}),(0,ao.jsx)(De,{flexDirection:"column",marginTop:1,children:e.running.map((i,s)=>{let a=s===e.selection,u=i.label||i.display_name||i.id,E=i.activity||i.current_task||i.continuous_objective||"standing by";return(0,ao.jsxs)(De,{flexDirection:"column",children:[(0,ao.jsxs)(De,{children:[(0,ao.jsx)(k,{color:a?pe.accent:"gray",children:a?"\u203A ":" "}),(0,ao.jsx)(k,{color:i.daemon_alive?pe.success:"gray",children:i.daemon_alive?"\u25CF ":"\u25CB "}),(0,ao.jsx)(k,{bold:a,color:a?pe.accent:void 0,children:z0(u,Math.max(12,r-24))}),(0,ao.jsx)(k,{dimColor:!0,children:` ${i.id} pid ${i.daemon_pid??"\u2014"}`})]}),(0,ao.jsx)(k,{dimColor:!0,children:` ${z0(E,r)}`})]},i.id)})}),(0,ao.jsx)(De,{marginTop:1,children:e.error?(0,ao.jsx)(k,{color:pe.error,children:e.error}):e.busy?(0,ao.jsx)(k,{color:pe.accent,children:"Parking selected session and starting queued work\u2026"}):(0,ao.jsx)(k,{dimColor:!0,children:"\u2191/\u2193 select \xB7 Enter park & replace \xB7 Esc leave new work queued"})})]})}function Z0(e,t=!1,r=!1){return(t||r)&&e.toLowerCase()==="r"}var Yn=e=>String(e??"").trim(),m1=/^[a-z][a-z -]+ requires an operator-owned decision before continuing\.?$/i,I1=e=>{let t=Yn(e);return m1.test(t)?"":t},eQ=(e,t)=>{let r=/[\u3400-\u9fff]/.test(`${e} -${t}`);return{id:"custom",label:r?"\u81EA\u5DF1\u8F93\u5165":"Write my own answer",description:r?"\u76F4\u63A5\u544A\u8BC9 Argus \u4F60\u7684\u51B3\u5B9A\u3002":"Tell Argus your decision directly.",requires_note:!0}};function tQ(e,t){let r=[...e,...t],i=[],s=new Set;for(let a of r){let u=Yn(a.id),E=a.operator_decision;if(E&&typeof E=="object"&&!Array.isArray(E)){let y=E,D=Yn(y.id);if(!D||s.has(D)||Yn(y.status)!=="pending")continue;s.add(D);let O=Yn(y.options_source)==="agent"&&Array.isArray(y.options)?y.options.filter(G=>!!Yn(G?.id)&&!!Yn(G?.label)).map(G=>({...G,requires_note:G.requires_note===!0})):[];O.push(eQ(Yn(y.title),Yn(y.question))),i.push({id:D,item_id:Yn(y.item_id)||u,revision:Number(y.revision??1),status:"pending",title:Yn(y.title)||Yn(a.title)||"Decision required",reason:I1(y.reason),question:Yn(y.question)||Yn(a.pending_question),evidence:Array.isArray(y.evidence)?y.evidence.filter(G=>Yn(G?.label)!=="Acceptance check"):[],options:O,options_source:O.length?"agent":"none",selected_option:"",note:""});continue}let m=Yn(a.pending_question??a.question??a.text);if(!u||!m)continue;let h=`legacy-${u}`;s.has(h)||(s.add(h),i.push({id:h,item_id:u,revision:1,status:"pending",title:Yn(a.title??a.objective)||"Blocked task",reason:"",question:m,evidence:[],options:[eQ(Yn(a.title??a.objective),m)],options_source:"none",selected_option:"",note:"",legacy:!0}))}return i}var Wo=Le($t(),1);function h1(e){return String(e.message_id??"").startsWith("mission-result-")}function C1(e){let t=[];for(let r of e){if(h1(r))continue;let i=String(r.text??"").trim();if(!i)continue;let s=r.role==="operator"?"ui.operator":r.role==="argus"?"ui.argus":"";s&&t.push({type:s,text:i,...typeof r.ts=="number"?{ts:r.ts}:{},...r.message_id?{message_id:r.message_id}:{}})}return t}function rQ(e,t,r=400){let i=C1(t),s=new Map;for(let E of e){let m=String(E.type??"");if(m!=="ui.operator"&&m!=="ui.argus")continue;let h=`${m}\0${String(E.text??"")}`;s.set(h,(s.get(h)??0)+1)}let a=new Array(i.length).fill(!0);for(let E=i.length-1;E>=0;E-=1){let m=i[E],h=`${String(m.type??"")}\0${String(m.text??"")}`,y=s.get(h)??0;y>0&&(a[E]=!1,s.set(h,y-1))}let u=i.filter((E,m)=>a[m]).reduce((E,m)=>Cp(E,m,Number.MAX_SAFE_INTEGER),[...e]).sort((E,m)=>Number(E.ts??0)-Number(m.ts??0));return u.length>r?u.slice(u.length-r):u}var MI=400,B1=50;function nQ(e,t){let[r,i]=(0,Wo.useState)(null),[s,a]=(0,Wo.useState)([]),[u,E]=(0,Wo.useState)(!1),[m,h]=(0,Wo.useState)(""),[y,D]=(0,Wo.useState)(""),_=(0,Wo.useRef)(null),O=(0,Wo.useRef)(!0);(0,Wo.useEffect)(()=>{a([]),i(null),E(!1),h(""),D("")},[t]),(0,Wo.useEffect)(()=>{O.current=!0;let ne=!0,z,ce=1e3,J,$=[],fe=()=>{if(J=void 0,!ne||$.length===0)return;let Se=$;$=[],a(de=>Se.reduce((gt,Ve)=>Cp(gt,Ve,MI),de))},Ie=Se=>{ne&&($.push(Se),J||(J=setTimeout(fe,B1)))},se=()=>{!ne||!O.current||(_.current=e.connectStream({replay:60,onOpen:()=>{ne&&(ce=1e3,E(!0),D(""))},onEvent:Ie,onClose:Se=>{if(ne){if(fe(),E(!1),!Se.retryable){D(`event stream closed (${Se.code}): ${Se.reason}`);return}O.current&&(z=setTimeout(se,ce),ce=Math.min(ce*2,1e4))}},onError:Se=>{ne&&D(Se.message||"event stream unavailable")}}))};return se(),()=>{ne=!1,z&&clearTimeout(z),J&&clearTimeout(J),$=[],_.current?.close()}},[e]),(0,Wo.useEffect)(()=>{let ne=!0;return e.getTranscript(MI).then(z=>{ne&&a(ce=>rQ(ce,z,MI))},()=>{}),()=>{ne=!1}},[e]),(0,Wo.useEffect)(()=>{let ne=!0,z=!1,ce=!0,J,$=async()=>{if(z)return;z=!0;let Ie=new AbortController;J=Ie;try{let se=await e.snapshot(1,Ie.signal,ce);ce=!1,ne&&(i(Se=>Se&&JSON.stringify(Se)===JSON.stringify(se)?Se:se),h(""))}catch(se){ne&&h(se.message||"snapshot refresh failed")}finally{z=!1,J===Ie&&(J=void 0)}};$();let fe=setInterval($,5e3);return()=>{ne=!1,J?.abort(),clearInterval(fe)}},[e]);let G=()=>{_.current?.close()};return{snap:r,setSnap:i,events:s,setEvents:a,connected:u,snapshotError:m,streamError:y,wsRef:_,closeStream:G,shutdown:()=>{O.current=!1,G()}}}var jo=Le($t(),1);var D1=1e3;function oQ({api:e,projectRef:t,setEvents:r,setNotice:i,captureAdmission:s}){let[a,u]=(0,jo.useState)(!1),[E,m]=(0,jo.useState)(""),[h,y]=(0,jo.useState)(!1),[D,_]=(0,jo.useState)(0),[O,G]=(0,jo.useState)([]),[re,ne]=(0,jo.useState)(0),[z,ce]=(0,jo.useState)(0),J=(0,jo.useRef)(null),$=(0,jo.useRef)(0),fe=()=>{let Se=!!J.current;return $.current+=1,J.current?.controller.abort(),J.current=null,u(!1),m(""),y(!1),_(0),G([]),ne(0),Se},Ie=()=>{fe()?i("stopped waiting \xB7 server-side work may still finish in the project timeline"):i("no Manager reply is currently in flight")};return(0,jo.useEffect)(()=>()=>{$.current+=1,J.current?.controller.abort(),J.current=null},[]),(0,jo.useEffect)(()=>{if(!a)return;let Se=setInterval(()=>ce(de=>de+1),D1);return()=>clearInterval(Se)},[a]),{pending:a,phase:E,phaseHeartbeat:h,phaseQuietS:D,steps:O,startedAt:re,tick:z,managerRequestRef:J,cancelManagerTurn:fe,stopWaiting:Ie,submitFreeText:async Se=>{if(J.current){i("Argus is still working \xB7 wait or switch daemons to cancel");return}let de=t.current,gt=++$.current,Ve=new AbortController;J.current={id:gt,project:de,controller:Ve,messageId:""};let ve=()=>{let Oe=J.current;return!!(Oe&&Oe.id===gt&&Oe.project===de&&t.current===de&&!Ve.signal.aborted)},oe=`argus-${Date.now()}`;r(Oe=>[...Oe,{type:"ui.operator",text:Se,ts:Date.now()/1e3,event_id:`local-${de}-${gt}-operator`,message_id:`local-${gt}-operator`,local_request_id:gt,local_optimistic:!0}]),m(""),G([]),ne(Date.now()),ce(0),u(!0),i("");let N=(Oe,dt=oe,lt="auto")=>{ve()&&r(We=>ve()?[...We,{type:"ui.argus",text:Oe,message_id:dt,fragment_mode:lt,ts:Date.now()/1e3}]:We)},H=[],ie=!1,ge=()=>{if(ie||!ve())return;ie=!0;let Oe=_0(v0(H));Oe&&r(dt=>ve()?[...dt,{type:"ui.activity",text:Oe,ts:Date.now()/1e3}]:dt)},me=!1,tt=null;try{try{await e.messageStream(Se,{onPhase:(Oe,dt,lt)=>{ve()&&(m(Oe),y(lt.heartbeat),_(lt.quietS),H=w0(H,{label:Oe,role:dt,kind:lt.kind,detail:lt.detail,heartbeat:lt.heartbeat,quietS:lt.quietS}),G(H))},onDelta:(Oe,dt,lt)=>{if(!ve())return;me=!0,ge(),m(""),y(!1),_(0);let We=dt||oe,st=J.current;st?.id===gt&&(st.messageId=We),N(Oe,We,lt==="append"||lt==="snapshot"?lt:"auto")},onDone:Oe=>{ve()&&(ge(),Oe.kind==="task"?(s(Oe.daemon,de,!!Oe.continuous),me||N(AI(Oe))):me||N(Oe.reply||"[Manager reply unavailable] No task was dispatched."))},onError:Oe=>{ve()&&(tt=Oe)}},Ve.signal)}catch(Oe){ve()&&(tt=Oe)}if(!ve())return;if(tt&&!me)try{let Oe=await e.message(Se,Ve.signal);if(!ve())return;Oe.kind==="chat"&&Oe.reply?N(Oe.reply):Oe.kind==="task"?(s(Oe.daemon,de,!!Oe.continuous),N(AI(Oe))):N(Oe.reply||"(no response)")}catch(Oe){ve()&&N(`(couldn\u2019t reach Argus: ${Oe.message})`)}}finally{J.current?.id===gt&&(ge(),J.current=null,u(!1),y(!1),_(0),G([]))}}}}var iQ=Le($t(),1);function sQ(e,t){let[r,i]=(0,iQ.useState)(null);return{panel:r,setPanel:i,openPanel:(a,u={})=>{let E=!["help","backlog","events"].includes(a);if(i({kind:a,page:0,...u,loading:E}),!E)return;let h={status:()=>Promise.all([e.getStatus(),e.getResources()]),doctor:()=>e.getDoctor(),journal:()=>e.getJournal(20),config:()=>e.getConfig(),identity:()=>e.getIdentity(),daemons:()=>e.listProjects(),artifacts:()=>e.getArtifacts(),artifact:()=>e.getArtifact(String(u.path??"")),task:()=>e.getBacklogItem(String(u.itemId??""))}[a];h&&h().then(y=>i(D=>{if(!D||D.kind!==a)return D;let _=D.selection??0;if(a==="daemons"){let G=al(fs(y),String(u.query??"")).findIndex(re=>re.id===t);_=G>=0?G:0}return{...D,loading:!1,data:y,selection:_}}),y=>i(D=>D&&D.kind===a?{...D,loading:!1,error:y.message}:D))}}}function aQ(e,t){let r=pI(e);if(!r)return;if(!r.cmd){let E=EI(r.name);t.setNotice(E?`unknown ${r.name} \u2014 did you mean ${E}?`:`unknown command ${r.name} \u2014 /help`);return}let i=E=>()=>t.setNotice(E),s=E=>t.setNotice(`error: ${E.message}`),a=E=>t.setNotice(`usage: ${E}`),u=E=>t.setEvents(m=>[...m,{type:"ui.argus",text:E,message_id:`local-${Date.now()}`,ts:Date.now()/1e3}]);switch(r.cmd.name){case"/help":t.openPanel("help");break;case"/status":t.openPanel("status");break;case"/roles":t.openPanel("config");break;case"/doctor":t.openPanel("doctor");break;case"/identity":if(!r.rest)t.openPanel("identity");else if(r.rest.toLowerCase().startsWith("set ")){let E=r.rest.slice(4).trim();E?t.api.setIdentity(E).then(i("identity updated"),s):a("/identity set ")}else a("/identity [set ]");break;case"/journal":t.openPanel("journal");break;case"/backlog":t.openPanel("backlog",{all:r.rest.trim()==="all",selection:0});break;case"/daemons":t.openPanel("daemons",{query:r.rest});break;case"/artifacts":t.openPanel("artifacts");break;case"/artifact":r.rest?t.openPanel("artifact",{path:r.rest}):a("/artifact ");break;case"/events":t.openPanel("events",{...dI(r.rest)});break;case"/find":r.rest?t.openPanel("events",{filter:"all",query:r.rest}):a("/find ");break;case"/item":r.rest?t.openPanel("task",{itemId:r.rest}):a("/item ");break;case"/resume":case"/attach":t.switchProject(r.rest);break;case"/rename":if(!r.rest){a("/rename ");break}t.api.renameProject(r.rest).then(E=>{t.setSnap(m=>m&&m.session.id===E.sid?{...m,session:{...m.session,display_name:E.name}}:m),t.projectRef.current===E.sid&&t.setNotice(`renamed conversation to ${E.name}`)},s);break;case"/clear":t.setEvents([]),t.setNotice("feed cleared");break;case"/run":t.setPanel(null),t.setNotice("already following the live daemon feed");break;case"/reconnect":t.setNotice("reconnecting\u2026"),t.closeStream();break;case"/cancel":t.stopWaiting();break;case"/abort":t.api.abortMission("operator used /abort").then(E=>t.setNotice(E.message),s);break;case"/quit":t.quit();break;case"/task":r.rest?t.api.postTask(r.rest).then(E=>t.setNotice(`queued ${E.id}`),s):a("/task ");break;case"/plan":r.rest?t.api.previewPlan(r.rest).then(E=>{if(E.error){u(`Planner could not draft a plan: ${E.error}`);return}let m=["Planner preview (nothing queued):"];E.steps.forEach((h,y)=>{m.push(`${y+1}. ${h.title}${h.detail?` \u2014 ${h.detail}`:""}`)}),E.notes.length&&m.push(`Notes: ${E.notes.join("; ")}`),m.push("Use /task to queue it."),u(m.join(` +${t}`);return{id:"custom",label:r?"\u81EA\u5DF1\u8F93\u5165":"Write my own answer",description:r?"\u76F4\u63A5\u544A\u8BC9 Argus \u4F60\u7684\u51B3\u5B9A\u3002":"Tell Argus your decision directly.",requires_note:!0}};function tQ(e,t){let r=[...e,...t],i=[],s=new Set;for(let a of r){let u=Yn(a.id),E=a.operator_decision;if(E&&typeof E=="object"&&!Array.isArray(E)){let y=E,D=Yn(y.id);if(!D||s.has(D)||Yn(y.status)!=="pending")continue;s.add(D);let O=Yn(y.options_source)==="agent"&&Array.isArray(y.options)?y.options.filter(G=>!!Yn(G?.id)&&!!Yn(G?.label)).map(G=>({...G,requires_note:G.requires_note===!0})):[];O.push(eQ(Yn(y.title),Yn(y.question))),i.push({id:D,item_id:Yn(y.item_id)||u,revision:Number(y.revision??1),status:"pending",title:Yn(y.title)||Yn(a.title)||"Decision required",reason:I1(y.reason),question:Yn(y.question)||Yn(a.pending_question),evidence:Array.isArray(y.evidence)?y.evidence.filter(G=>Yn(G?.label)!=="Acceptance check"):[],options:O,options_source:O.length?"agent":"none",selected_option:"",note:""});continue}let m=Yn(a.pending_question??a.question??a.text);if(!u||!m)continue;let h=`legacy-${u}`;s.has(h)||(s.add(h),i.push({id:h,item_id:u,revision:1,status:"pending",title:Yn(a.title??a.objective)||"Blocked task",reason:"",question:m,evidence:[],options:[eQ(Yn(a.title??a.objective),m)],options_source:"none",selected_option:"",note:"",legacy:!0}))}return i}var Wo=Le($t(),1);function h1(e){return String(e.message_id??"").startsWith("mission-result-")}function C1(e){let t=[];for(let r of e){if(h1(r))continue;let i=String(r.text??"").trim();if(!i)continue;let s=r.role==="operator"?"ui.operator":r.role==="argus"?"ui.argus":"";s&&t.push({type:s,text:i,...typeof r.ts=="number"?{ts:r.ts}:{},...r.message_id?{message_id:r.message_id}:{}})}return t}function rQ(e,t,r=400){let i=C1(t),s=new Map;for(let E of e){let m=String(E.type??"");if(m!=="ui.operator"&&m!=="ui.argus")continue;let h=`${m}\0${String(E.text??"")}`;s.set(h,(s.get(h)??0)+1)}let a=new Array(i.length).fill(!0);for(let E=i.length-1;E>=0;E-=1){let m=i[E],h=`${String(m.type??"")}\0${String(m.text??"")}`,y=s.get(h)??0;y>0&&(a[E]=!1,s.set(h,y-1))}let u=i.filter((E,m)=>a[m]).reduce((E,m)=>Cp(E,m,Number.MAX_SAFE_INTEGER),[...e]).sort((E,m)=>Number(E.ts??0)-Number(m.ts??0));return u.length>r?u.slice(u.length-r):u}var MI=400,B1=50;function nQ(e,t){let[r,i]=(0,Wo.useState)(null),[s,a]=(0,Wo.useState)([]),[u,E]=(0,Wo.useState)(!1),[m,h]=(0,Wo.useState)(""),[y,D]=(0,Wo.useState)(""),_=(0,Wo.useRef)(null),O=(0,Wo.useRef)(!0);(0,Wo.useEffect)(()=>{a([]),i(null),E(!1),h(""),D("")},[t]),(0,Wo.useEffect)(()=>{O.current=!0;let ne=!0,z,ce=1e3,J,$=[],fe=()=>{if(J=void 0,!ne||$.length===0)return;let Se=$;$=[],a(de=>Se.reduce((gt,Ve)=>Cp(gt,Ve,MI),de))},Ie=Se=>{ne&&($.push(Se),J||(J=setTimeout(fe,B1)))},se=()=>{!ne||!O.current||(_.current=e.connectStream({replay:60,onOpen:()=>{ne&&(ce=1e3,E(!0),D(""))},onEvent:Ie,onClose:Se=>{if(ne){if(fe(),E(!1),!Se.retryable){D(`event stream closed (${Se.code}): ${Se.reason}`);return}O.current&&(z=setTimeout(se,ce),ce=Math.min(ce*2,1e4))}},onError:Se=>{ne&&D(Se.message||"event stream unavailable")}}))};return se(),()=>{ne=!1,z&&clearTimeout(z),J&&clearTimeout(J),$=[],_.current?.close()}},[e]),(0,Wo.useEffect)(()=>{let ne=!0;return e.getTranscript(MI).then(z=>{ne&&a(ce=>rQ(ce,z,MI))},()=>{}),()=>{ne=!1}},[e]),(0,Wo.useEffect)(()=>{let ne=!0,z=!1,ce=!0,J,$=async()=>{if(z)return;z=!0;let Ie=new AbortController;J=Ie;try{let se=await e.snapshot(1,Ie.signal,ce);ce=!1,ne&&(i(Se=>Se&&JSON.stringify(Se)===JSON.stringify(se)?Se:se),h(""))}catch(se){ne&&h(se.message||"snapshot refresh failed")}finally{z=!1,J===Ie&&(J=void 0)}};$();let fe=setInterval($,5e3);return()=>{ne=!1,J?.abort(),clearInterval(fe)}},[e]);let G=()=>{_.current?.close()};return{snap:r,setSnap:i,events:s,setEvents:a,connected:u,snapshotError:m,streamError:y,wsRef:_,closeStream:G,shutdown:()=>{O.current=!1,G()}}}var jo=Le($t(),1);var D1=1e3;function oQ({api:e,projectRef:t,setEvents:r,setNotice:i,captureAdmission:s}){let[a,u]=(0,jo.useState)(!1),[E,m]=(0,jo.useState)(""),[h,y]=(0,jo.useState)(!1),[D,_]=(0,jo.useState)(0),[O,G]=(0,jo.useState)([]),[re,ne]=(0,jo.useState)(0),[z,ce]=(0,jo.useState)(0),J=(0,jo.useRef)(null),$=(0,jo.useRef)(0),fe=()=>{let Se=!!J.current;return $.current+=1,J.current?.controller.abort(),J.current=null,u(!1),m(""),y(!1),_(0),G([]),ne(0),Se},Ie=()=>{fe()?i("stopped waiting \xB7 server-side work may still finish in the project timeline"):i("no Manager reply is currently in flight")};return(0,jo.useEffect)(()=>()=>{$.current+=1,J.current?.controller.abort(),J.current=null},[]),(0,jo.useEffect)(()=>{if(!a)return;let Se=setInterval(()=>ce(de=>de+1),D1);return()=>clearInterval(Se)},[a]),{pending:a,phase:E,phaseHeartbeat:h,phaseQuietS:D,steps:O,startedAt:re,tick:z,managerRequestRef:J,cancelManagerTurn:fe,stopWaiting:Ie,submitFreeText:async Se=>{if(J.current){i("Argus is still working \xB7 wait or switch daemons to cancel");return}let de=t.current,gt=++$.current,Ve=new AbortController;J.current={id:gt,project:de,controller:Ve,messageId:""};let ve=()=>{let Oe=J.current;return!!(Oe&&Oe.id===gt&&Oe.project===de&&t.current===de&&!Ve.signal.aborted)},oe=`argus-${Date.now()}`;r(Oe=>[...Oe,{type:"ui.operator",text:Se,ts:Date.now()/1e3,event_id:`local-${de}-${gt}-operator`,message_id:`local-${gt}-operator`,local_request_id:gt,local_optimistic:!0}]),m(""),G([]),ne(Date.now()),ce(0),u(!0),i("");let N=(Oe,dt=oe,lt="auto")=>{ve()&&r(We=>ve()?[...We,{type:"ui.argus",text:Oe,message_id:dt,fragment_mode:lt,ts:Date.now()/1e3}]:We)},H=[],ie=!1,ge=()=>{if(ie||!ve())return;ie=!0;let Oe=_0(v0(H));Oe&&r(dt=>ve()?[...dt,{type:"ui.activity",text:Oe,ts:Date.now()/1e3}]:dt)},me=!1,tt=null;try{try{await e.messageStream(Se,{onPhase:(Oe,dt,lt)=>{ve()&&(m(Oe),y(lt.heartbeat),_(lt.quietS),H=w0(H,{label:Oe,role:dt,kind:lt.kind,detail:lt.detail,heartbeat:lt.heartbeat,quietS:lt.quietS}),G(H))},onDelta:(Oe,dt,lt)=>{if(!ve())return;me=!0,ge(),m(""),y(!1),_(0);let We=dt||oe,st=J.current;st?.id===gt&&(st.messageId=We),N(Oe,We,lt==="append"||lt==="snapshot"?lt:"auto")},onDone:Oe=>{ve()&&(ge(),Oe.kind==="task"?(s(Oe.daemon,de,!!Oe.continuous),me||N(AI(Oe))):me||N(Oe.reply||"[Manager reply unavailable] No task was dispatched."))},onError:Oe=>{ve()&&(tt=Oe)}},Ve.signal)}catch(Oe){ve()&&(tt=Oe)}if(!ve())return;if(tt&&!me)try{let Oe=await e.message(Se,Ve.signal);if(!ve())return;Oe.kind==="chat"&&Oe.reply?N(Oe.reply):Oe.kind==="task"?(s(Oe.daemon,de,!!Oe.continuous),N(AI(Oe))):N(Oe.reply||"(no response)")}catch(Oe){ve()&&N(`(couldn\u2019t reach Argus: ${Oe.message})`)}}finally{J.current?.id===gt&&(ge(),J.current=null,u(!1),y(!1),_(0),G([]))}}}}var iQ=Le($t(),1);function sQ(e,t){let[r,i]=(0,iQ.useState)(null);return{panel:r,setPanel:i,openPanel:(a,u={})=>{let E=!["help","backlog","events"].includes(a);if(i({kind:a,page:0,...u,loading:E}),!E)return;let h={status:()=>Promise.all([e.getStatus(),e.getResources()]),doctor:()=>e.getDoctor(),journal:()=>e.getJournal(20),config:()=>e.getConfig(),identity:()=>e.getIdentity(),daemons:()=>e.listProjects(),artifacts:()=>e.getArtifacts(),artifact:()=>e.getArtifact(String(u.path??"")),task:()=>e.getBacklogItem(String(u.itemId??""))}[a];h&&h().then(y=>i(D=>{if(!D||D.kind!==a)return D;let _=D.selection??0;if(a==="daemons"){let G=al(fs(y),String(u.query??"")).findIndex(re=>re.id===t);_=G>=0?G:0}return{...D,loading:!1,data:y,selection:_}}),y=>i(D=>D&&D.kind===a?{...D,loading:!1,error:y.message}:D))}}}function aQ(e,t){let r=pI(e);if(!r)return;if(!r.cmd){let E=EI(r.name);t.setNotice(E?`unknown ${r.name} \u2014 did you mean ${E}?`:`unknown command ${r.name} \u2014 /help`);return}let i=E=>()=>t.setNotice(E),s=E=>t.setNotice(`error: ${E.message}`),a=E=>t.setNotice(`usage: ${E}`),u=E=>t.setEvents(m=>[...m,{type:"ui.argus",text:E,message_id:`local-${Date.now()}`,ts:Date.now()/1e3}]);switch(r.cmd.name){case"/crystalpilot":t.api.message(e).then(E=>t.setNotice(E.reply||"CrystalPilot command handled"),s);break;case"/help":t.openPanel("help");break;case"/status":t.openPanel("status");break;case"/roles":t.openPanel("config");break;case"/doctor":t.openPanel("doctor");break;case"/identity":if(!r.rest)t.openPanel("identity");else if(r.rest.toLowerCase().startsWith("set ")){let E=r.rest.slice(4).trim();E?t.api.setIdentity(E).then(i("identity updated"),s):a("/identity set ")}else a("/identity [set ]");break;case"/journal":t.openPanel("journal");break;case"/backlog":t.openPanel("backlog",{all:r.rest.trim()==="all",selection:0});break;case"/daemons":t.openPanel("daemons",{query:r.rest});break;case"/artifacts":t.openPanel("artifacts");break;case"/artifact":r.rest?t.openPanel("artifact",{path:r.rest}):a("/artifact ");break;case"/events":t.openPanel("events",{...dI(r.rest)});break;case"/find":r.rest?t.openPanel("events",{filter:"all",query:r.rest}):a("/find ");break;case"/item":r.rest?t.openPanel("task",{itemId:r.rest}):a("/item ");break;case"/resume":case"/attach":t.switchProject(r.rest);break;case"/rename":if(!r.rest){a("/rename ");break}t.api.renameProject(r.rest).then(E=>{t.setSnap(m=>m&&m.session.id===E.sid?{...m,session:{...m.session,display_name:E.name}}:m),t.projectRef.current===E.sid&&t.setNotice(`renamed conversation to ${E.name}`)},s);break;case"/clear":t.setEvents([]),t.setNotice("feed cleared");break;case"/run":t.setPanel(null),t.setNotice("already following the live daemon feed");break;case"/reconnect":t.setNotice("reconnecting\u2026"),t.closeStream();break;case"/cancel":t.stopWaiting();break;case"/abort":t.api.abortMission("operator used /abort").then(E=>t.setNotice(E.message),s);break;case"/quit":t.quit();break;case"/task":r.rest?t.api.postTask(r.rest).then(E=>t.setNotice(`queued ${E.id}`),s):a("/task ");break;case"/plan":r.rest?t.api.previewPlan(r.rest).then(E=>{if(E.error){u(`Planner could not draft a plan: ${E.error}`);return}let m=["Planner preview (nothing queued):"];E.steps.forEach((h,y)=>{m.push(`${y+1}. ${h.title}${h.detail?` \u2014 ${h.detail}`:""}`)}),E.notes.length&&m.push(`Notes: ${E.notes.join("; ")}`),m.push("Use /task to queue it."),u(m.join(` `))},s):a("/plan ");break;case"/nudge":r.rest?t.api.postNudge(r.rest).then(i("nudge sent"),s):a("/nudge ");break;case"/rewrite":r.rest?t.rewriteDraft(r.rest):a("/rewrite \u2014 or press Ctrl+R to rewrite what you already typed");break;case"/note":r.rest?t.api.postNote(r.rest).then(i("note added"),s):a("/note ");break;case"/done":r.rest?t.api.disposeBacklog(r.rest,"done").then(i(`done ${r.rest}`),s):a("/done ");break;case"/skip":r.rest?t.api.disposeBacklog(r.rest,"skip").then(i(`skipped ${r.rest}`),s):a("/skip ");break;case"/stop":r.rest?t.api.stopBacklog(r.rest).then(i(`stopped ${r.rest}`),s):a("/stop ");break;case"/new":t.openNewDaemon(r.rest);break;case"/backend":r.rest?t.api.setConfig("backend",r.rest).then(()=>t.setNotice(`backend set to ${r.rest}`),s):t.openPanel("config");break;case"/config":{if(!r.rest){t.openPanel("config");break}let E=r.rest.split(/\s+/).filter(Boolean),m=E.find(y=>{let D=y.indexOf("=");return D<=0||D===y.length-1});if(m){t.setNotice(`expected key=value, got ${m}`);break}let h=E.map(y=>{let D=y.indexOf("=");return t.api.setConfig(y.slice(0,D),y.slice(D+1))});Promise.all(h).then(()=>t.setNotice(`updated ${h.length} setting(s)`),s);break}case"/reset":t.api.resetManager().then(i("Manager context reset"),s);break;case"/skills":t.api.skills(r.rest||"ls").then(u,s);break;default:t.setNotice(`${r.cmd.name} not yet wired`)}}var Ro=Le(Gt(),1);function AQ({card:e,selection:t,note:r,busy:i,error:s}){let a=e.options[t],u=e.options.length===0;return(0,Ro.jsxs)(De,{flexDirection:"column",borderStyle:"round",borderColor:pe.warning,paddingX:1,marginTop:1,children:[(0,Ro.jsx)(k,{color:pe.warning,bold:!0,children:"ACTION REQUIRED"}),(0,Ro.jsx)(k,{bold:!0,wrap:"wrap",children:e.title}),(0,Ro.jsx)(De,{marginTop:1,children:(0,Ro.jsx)(k,{wrap:"wrap",children:e.question})}),e.options.length?(0,Ro.jsx)(De,{flexDirection:"column",marginTop:1,children:e.options.map((E,m)=>(0,Ro.jsxs)(k,{color:m===t?pe.accent:void 0,wrap:"wrap",children:[m===t?"\u203A ":" ",m+1,". ",E.label,E.description&&E.description!==e.question?` \u2014 ${E.description}`:""]},E.id))}):null,u||a?.requires_note?(0,Ro.jsxs)(De,{marginTop:1,children:[(0,Ro.jsx)(k,{color:pe.accent,children:"Your response \u203A "}),(0,Ro.jsx)(k,{children:r.value}),i?null:(0,Ro.jsx)(k,{inverse:!0,children:" "})]}):null,s?(0,Ro.jsx)(k,{color:pe.error,wrap:"wrap",children:s}):null,(0,Ro.jsx)(k,{dimColor:!0,children:i?"Sending your answer\u2026":u?"Type your answer \xB7 Enter send":"\u2191/\u2193 or number select \xB7 Enter confirm \xB7 typing selects an option that accepts guidance"})]})}var Bn=Le(Gt(),1);function yp(e,t,r){return!e?.admission_required||!e.running_daemons?.length?null:{targetProject:t,running:e.running_daemons,limit:e.limit??e.running_daemons.length,activeCount:e.active_count??e.running_daemons.length,selection:0,resumeContinuous:r,busy:!1,error:""}}function lQ({host:e,port:t,token:r,project:i,initialNotice:s="",initialAdmission:a,initialResumeContinuous:u=!1,exitPolicy:E="detach",onProjectChange:m,trackDaemonCreation:h=y=>y}){let{exit:y}=ga(),{stdout:D}=da(),_=Yu(),[O,G]=(0,Ir.useState)(i),re=(0,Ir.useRef)(O);re.current=O;let ne=(0,Ir.useMemo)(()=>new us({host:e,port:t,project:O,token:r}),[e,t,O,r]),{snap:z,setSnap:ce,events:J,setEvents:$,connected:fe,snapshotError:Ie,streamError:se,closeStream:Se,shutdown:de}=nQ(ne,O),[gt,Ve]=(0,Ir.useState)(Ea),[ve,oe]=(0,Ir.useState)(Oy),[N,H]=(0,Ir.useState)(0),[ie,ge]=(0,Ir.useState)(s),{panel:me,setPanel:tt,openPanel:Oe}=sQ(ne,O),[dt,lt]=(0,Ir.useState)(null),[We,st]=(0,Ir.useState)(()=>yp(a,i,u)),[K,ue]=(0,Ir.useState)(!1),[Ce]=(0,Ir.useState)(J0),et=(0,Ir.useMemo)(()=>tQ(z?.pending_questions??[],(z?.backlog??[]).map(_e=>({..._e})))[0]??null,[z?.backlog,z?.pending_questions]),[Ke,wt]=(0,Ir.useState)(0),[ft,It]=(0,Ir.useState)(Ea),[vt,Ye]=(0,Ir.useState)(!1),[vr,cr]=(0,Ir.useState)("");(0,Ir.useEffect)(()=>{H(0)},[gt.value]),(0,Ir.useEffect)(()=>{wt(0),It(Ea),Ye(!1),cr("")},[et?.id]);let _r=(0,Ir.useRef)(!1),Jr=(0,Ir.useRef)(!0),j=(0,Ir.useRef)(0),Ae=(0,Ir.useRef)(!1),rt=(0,Ir.useRef)(!1);(0,Ir.useEffect)(()=>(Jr.current=!0,()=>{Jr.current=!1}),[]),(0,Ir.useEffect)(()=>{if(D.isTTY)return D.write("\x1B[?2004h"),()=>{D.write("\x1B[?2004l")}},[D]);let Et=(_e,Ne,$e)=>{let Ht=yp(_e,Ne,$e);Ht&&(j.current=0,st(Ht))};(0,Ir.useEffect)(()=>{let _e=z?.daemon_admission;We||!_e||_e.requested_at<=j.current||st(yp(_e,_e.target_sid||O,_e.resume_continuous))},[O,We,z?.daemon_admission]);let kt=async()=>{if(!We||We.busy)return;let _e=We.running[We.selection];if(_e){st(Ne=>Ne&&{...Ne,busy:!0,error:""});try{let $e=await new us({host:e,port:t,project:We.targetProject,token:r}).replaceDaemon(_e.id,We.resumeContinuous,z?.daemon_commands?.revision);if($e.rc!==0){let Ht=yp($e,We.targetProject,We.resumeContinuous);st(Ht??{...We,busy:!1,error:$e.error||"could not replace the selected session"});return}j.current=Date.now()/1e3,st(null),ge(`parked ${_e.label||_e.id} \xB7 queued work started`)}catch(Ne){st($e=>$e&&{...$e,busy:!1,error:Ne.message})}}},{pending:bt,phase:rr,phaseHeartbeat:Ar,phaseQuietS:lr,steps:an,startedAt:Ns,tick:Jo,managerRequestRef:Vn,cancelManagerTurn:Ln,stopWaiting:gi,submitFreeText:di}=oQ({api:ne,projectRef:re,setEvents:$,setNotice:ge,captureAdmission:Et}),Ko=_e=>_e===re.current?!1:(Ln(),re.current=_e,G(_e),m?.(_e),st(null),j.current=0,!0),Mn=()=>{Jr.current=!1,Ln(),de(),y()},pi=async _e=>{let Ne=gI(_e);if(Ne.kind==="list"){Oe("daemons");return}let $e=Ne.query;try{let Ht=await ne.listProjects(),hr=Ht.find(ut=>ut.id===$e)||Ht.find(ut=>ut.id.startsWith($e))||Ht.find(ut=>(ut.label||"").toLowerCase().includes($e.toLowerCase()))||al(Ht,$e)[0];if(!hr){ge(`no project matching "${$e}" \u2014 /daemons to list`);return}if(hr.id===O){ge(`already on ${hr.id}`);return}Ko(hr.id),ge(`switched to ${hr.label||hr.id}`)}catch(Ht){ge(`error: ${Ht.message}`)}},nn=_e=>{if(tt(null),_e.id===O){ge(`already on ${_e.label||_e.id}`);return}Ko(_e.id),ge(`switched to ${_e.label||_e.id}`)},ds=(_e="")=>{tt(null),ue(!1),ge(""),lt(Uf(_e))},Ao=async()=>{if(!dt||dt.busy)return;if(_r.current){lt($e=>$e&&{...$e,error:"a daemon is already being created"});return}let{objective:_e,name:Ne}=Ku(dt);_r.current=!0,lt($e=>$e&&{...$e,busy:!0,error:""});try{let $e=await h(ne.createDaemon(_e,Ne));if(!Jr.current)return;tt(null),lt(null),Ko($e.sid),Et($e.start,$e.sid,!!_e),ge($e.start?.admission_required?`created ${$e.sid} \xB7 choose running work to park`:$e.spawned?`created ${$e.sid} \xB7 campaign started`:`created ${$e.sid} \xB7 message Argus when ready`)}catch($e){if(!Jr.current)return;lt(Ht=>Ht&&{...Ht,busy:!1,error:$e.message||"daemon creation failed"})}finally{_r.current=!1}},ps=_e=>{let Ne=(_e||"").trim();if(!Ne){ge("nothing to rewrite \xB7 type a prompt first");return}rt.current||(rt.current=!0,ge("Manager is rewriting your prompt\u2026"),ne.rewritePrompt(Ne).then($e=>{if(rt.current=!1,$e.error||!$e.rewritten.trim()){ge(`rewrite failed \xB7 ${$e.error||"empty rewrite"} \xB7 your prompt is unchanged`);return}Ve(ma($e.rewritten));let Ht=["Rewrote your prompt (not sent \u2014 edit it, then Enter):","",`was: ${Ne}`];$e.changes.length&&Ht.push("","made explicit:",...$e.changes.map(hr=>` - ${hr}`)),$e.questions.length&&Ht.push("","Manager asks (answer these, or they stay unspecified):",...$e.questions.map(hr=>` ? ${hr}`)),$(hr=>[...hr,{type:"ui.activity",text:Ht.join(` `),ts:Date.now()/1e3}]),ge("prompt rewritten \xB7 review it, then Enter to send")},$e=>{rt.current=!1,ge(`rewrite failed \xB7 ${$e.message} \xB7 your prompt is unchanged`)}))},Co=_e=>{aQ(_e,{api:ne,openPanel:Oe,setPanel:tt,setEvents:$,setNotice:ge,setSnap:ce,projectRef:re,closeStream:Se,stopWaiting:gi,quit:Mn,switchProject:pi,openNewDaemon:ds,rewriteDraft:ps})},Ts=()=>{let _e=gt.value.trim();if(_e){if(!Mf(_e)&&Vn.current){ge("Argus is still working \xB7 wait or switch daemons to cancel");return}Ve(Ea),H(0),oe(Ne=>lI(Ne,_e)),Mf(_e)?Co(_e):di(_e)}},Ei=async()=>{if(!et||vt)return;let _e=et.options.length===0,Ne=et.options[Ke],$e=ft.value.trim();if((_e||Ne?.requires_note)&&!$e){cr("Type the requested answer before confirming.");return}if(!(!_e&&!Ne)){Ye(!0),cr("");try{let Ht=et.legacy?await ne.answerPending(et.item_id,$e):await ne.resolveDecision(et.id,_e?"custom":Ne.id,$e);if(Ht.resolved===!1){cr(String(Ht.reply||"A more specific answer is required."));return}ge(String(Ht.reply||"Your answer was delivered to the team.")),ce(await ne.snapshot())}catch(Ht){cr(Ht.message)}finally{Ye(!1)}}};ls((_e,Ne)=>{let $e=q0(_e,Ae.current);if($e.handled){if(Ae.current=$e.active,et&&$e.text){let ut=et.options.length===0,Er=et.options[Ke]?.requires_note?Ke:et.options.findIndex(Wt=>Wt.id==="custom");(ut||Er>=0)&&(Er>=0&&wt(Er),It(Wt=>Ia(Wt,$e.text)));return}if($e.text&&!me){if(We)return;if(dt){let ut=Gf(dt,$e.text,{});lt(ut.draft)}else Ve(ut=>Ia(ut,$e.text)),oe(ut=>ut.pos===0?ut:{...ut,pos:0});$e.pasted&&$e.text.length>20&&ge(`pasted ${Array.from($e.text).length} chars \xB7 Enter to send`)}return}if(et){if(Ne.ctrl&&(_e==="c"||_e==="d")){Mn();return}if(vt)return;if(et.options.length===0){Ne.return?Ei():Ne.leftArrow?It(tl):Ne.rightArrow?It(rl):Ne.backspace||Ne.delete?It(Lu):Ne.ctrl&&_e==="w"?It(Mu):Ne.ctrl&&_e==="u"?It(Pu):Ne.ctrl&&_e==="k"?It(Uu):_e&&!Ne.ctrl&&!Ne.meta&&It(Er=>Ia(Er,_e)),cr("");return}if(Ne.downArrow){wt(Er=>ll(Er,et.options.length,1));return}if(Ne.upArrow){wt(Er=>ll(Er,et.options.length,-1));return}if(Ne.return){Ei();return}if(et.options[Ke]?.requires_note){Ne.leftArrow?It(tl):Ne.rightArrow?It(rl):Ne.backspace||Ne.delete?It(Lu):Ne.ctrl&&_e==="w"?It(Mu):Ne.ctrl&&_e==="u"?It(Pu):Ne.ctrl&&_e==="k"?It(Uu):_e&&!Ne.ctrl&&!Ne.meta&&It(Er=>Ia(Er,_e)),cr("");return}if(/^[1-9]$/.test(_e)){let Er=Number(_e)-1;ErWt.id==="custom");Er>=0&&(wt(Er),It(Wt=>Ia(Wt,_e)),cr(""))}return}if(We){let ut=$0(We,_e,Ne);ut==="exit"?Mn():ut==="dismiss"?(j.current=Date.now()/1e3,st(null),ge("new work remains queued")):ut==="next"?st(fr=>fr&&{...fr,selection:ll(fr.selection,fr.running.length,1)}):ut==="previous"?st(fr=>fr&&{...fr,selection:ll(fr.selection,fr.running.length,-1)}):ut==="replace"&&kt();return}if(dt){if(Ne.ctrl&&_e==="d"){Mn();return}if(Ne.ctrl&&_e==="c"){dt.busy||lt(null);return}let ut=Gf(dt,_e,Ne);ut.intent==="submit"?Ao():ut.intent==="cancel"?lt(null):ut.draft!==dt&<(ut.draft);return}if(Ne.ctrl&&_e==="c"){if(K){Mn();return}ue(!0),ge(`Ctrl-C again to exit \xB7 Ctrl-D also quits \xB7 ${E==="stop-all"?"current executor and this launch's owned API will stop gracefully":E==="stop-api"?"executor keeps running; this launch's owned API will stop":"terminal UI exits; local API and executor keep running"}`);return}if(Ne.ctrl&&_e==="d"){Mn();return}if(Z0(_e,Ne.ctrl,Ne.meta)){ps(gt.value);return}if(K&&ue(!1),me){let ut=me.kind==="daemons"||me.kind==="artifacts"||me.kind==="backlog",fr=me.kind==="daemons"?al(fs(me.data??[]),me.query??""):[],Er=me.kind==="backlog"?me.all?z?.backlog??[]:hp(z?.backlog??[],!1):[];if(Ne.escape||_e==="q")tt(null);else if(me.kind==="daemons"&&_e==="n")tt(null),ds();else if(me.kind==="daemons"&&_e==="/")tt(null),Ve(ma("/daemons ")),H(0);else if(ut&&(Ne.downArrow||_e==="j")){let Wt=me.kind==="daemons"?fr.length:me.kind==="backlog"?Er.length:Array.isArray(me.data)?me.data.length:0;tt(An=>An&&{...An,selection:ll(An.selection??0,Wt,1)})}else if(ut&&(Ne.upArrow||_e==="k")){let Wt=me.kind==="daemons"?fr.length:me.kind==="backlog"?Er.length:Array.isArray(me.data)?me.data.length:0;tt(An=>An&&{...An,selection:ll(An.selection??0,Wt,-1)})}else if(ut&&Ne.return)if(me.kind==="daemons"){let Wt=fr[me.selection??0];Wt&&nn(Wt)}else if(me.kind==="artifacts"){let An=(me.data??[])[me.selection??0];An?.exists?Oe("artifact",{path:An.path}):An&&(tt(null),ge(`artifact is declared but missing: ${An.path}`))}else{let Wt=Er[me.selection??0];Wt&&Oe("task",{itemId:Wt.id})}else Ne.return?tt(null):Ne.downArrow||_e==="j"?tt(Wt=>Wt&&{...Wt,page:(Wt.page??0)+1}):(Ne.upArrow||_e==="k")&&tt(Wt=>Wt&&{...Wt,page:Math.max(0,(Wt.page??0)-1)});return}let Ht=Ap(gt.value),hr=Ht.length>0;if(Ne.escape&&Vn.current&&!hr){gi();return}if(Ne.escape){hr&&Ve(Ea);return}if(hr){if(Ne.upArrow){H(fr=>(fr-1+Ht.length)%Ht.length);return}if(Ne.downArrow){H(fr=>(fr+1)%Ht.length);return}let ut=Ht[Math.min(N,Ht.length-1)];if(Ne.tab){Ve(ma(lp(ut))),H(0);return}if(Ne.return){let fr=gt.value.trim(),Er=fr.toLowerCase()===ut.name.toLowerCase()||(ut.aliases??[]).some(Wt=>Wt.toLowerCase()===fr.toLowerCase());if(!Er&&ut.arg)Ve(ma(lp(ut))),H(0);else{let Wt=Er?fr:ut.name;Ve(Ea),H(0),oe(An=>lI(An,Wt)),Co(Wt)}return}}if(Ne.return){Ts();return}if(Ne.leftArrow){Ve(tl);return}if(Ne.rightArrow){Ve(rl);return}if(Ne.upArrow){let ut=Ly(ve,gt.value);oe(ut.h),Ve(ma(ut.value));return}if(Ne.downArrow){let ut=My(ve);oe(ut.h),Ve(ma(ut.value));return}if(Ne.ctrl&&_e==="a"){Ve(op);return}if(Ne.ctrl&&_e==="e"){Ve(ip);return}if(Ne.ctrl&&_e==="b"){Ve(tl);return}if(Ne.ctrl&&_e==="f"){Ve(rl);return}if(Ne.ctrl&&_e==="w"){Ve(Mu);return}if(Ne.ctrl&&_e==="u"){Ve(Pu);return}if(Ne.ctrl&&_e==="k"){Ve(Uu);return}if(Ne.backspace||Ne.delete){Ve(Lu),oe(ut=>ut.pos===0?ut:{...ut,pos:0});return}if(_e==="?"&>.value===""){Oe("help");return}_e&&!Ne.ctrl&&!Ne.meta&&(Ve(ut=>Ia(ut,_e)),oe(ut=>ut.pos===0?ut:{...ut,pos:0}))});let Li=Ap(gt.value),bo=Li.length>0&&!We&&!dt&&!me,wa=bt?["manager"]:[],Es=M0(z?.roles??[],J),Yo=(rr||"handling your message").replace(/^Manager\s*·\s*/i,"").replace(/[.…]+$/u,""),Pn=bt?P0(Es,"manager",Yo,Math.max(0,(Date.now()-Ns)/1e3)):Es,Bo=z?Zy({...z,roles:Pn},J):null,Os=z?.partial?(z.diagnostics??[]).map(_e=>`${_e.section}: ${_e.message}`).join(" \xB7 "):"",Fr=z?.observability?.slo.status==="degraded"?z.observability.slo.violations.join(" \xB7 "):"",ms=Ie?`snapshot refresh failed \xB7 ${Ie}`:z?.partial?`snapshot partial \xB7 ${Os||"backend reported incomplete state"}`:Fr?`SLO degraded \xB7 ${Fr}`:se&&!fe?`event stream reconnecting \xB7 ${se}`:"";return(0,Bn.jsxs)(De,{flexDirection:"column",paddingX:1,children:[(0,Bn.jsx)(zy,{width:_.columns,vertical:Bo?.routing.vertical}),bo?null:(0,Bn.jsx)(b0,{alert:OI(J)}),et?(0,Bn.jsx)(AQ,{card:et,selection:Ke,note:ft,busy:vt,error:vr}):We?(0,Bn.jsx)(X0,{state:We,width:_.columns}):dt?(0,Bn.jsx)(mp,{draft:dt}):(0,Bn.jsxs)(Bn.Fragment,{children:[Bo&&!bo&&!me?(0,Bn.jsx)(V0,{view:Bo,width:_.columns,height:_.rows,busy:bt,spentUsd:z?.global_spend_usd,spendStatus:z?.global_spend_status,globalDailyCapUsd:z?.daemon.global_daily_cap_usd,requestUsage:z?.request_usage}):null,(0,Bn.jsx)(u0,{events:J,width:_.columns,mode:"all",liveMessageId:Vn.current?.messageId,collapsed:bo||!!me,showIdle:!Bo,showReasoning:Ce}),me?(0,Bn.jsx)(j0,{panel:me,snap:z,events:J,viewportRows:_.rows,viewportColumns:_.columns,activeProject:O}):(0,Bn.jsxs)(Bn.Fragment,{children:[bt&&!bo&&(0,Bn.jsx)(R0,{tick:Jo,phase:rr,heartbeat:Ar,quietS:lr,steps:an,width:_.columns,elapsedS:Math.max(0,Math.floor((Date.now()-Ns)/1e3))}),(0,Bn.jsxs)(De,{flexDirection:"column",flexShrink:0,children:[(0,Bn.jsx)(B0,{items:Li,selected:Math.min(N,Li.length-1),maxVisible:C0(_.rows)}),(0,Bn.jsx)(I0,{edit:gt,width:_.columns,rowsBelow:bo?0:1})]}),bo?null:(0,Bn.jsx)(D0,{notice:ie,health:ms,width:_.columns})]})]})]})}import{execFile as fQ}from"node:child_process";import{mkdir as y1,readFile as gQ,writeFile as Q1,rename as w1,unlink as vU}from"node:fs/promises";import{homedir as v1}from"node:os";import{dirname as S1,join as uQ,resolve as _1}from"node:path";function Qa(e){let t=e.trim().toLowerCase();if(t==="localhost"||t==="::1")return!0;let r=t.split(".").map(Number);return r.length===4&&r[0]===127&&r.every(i=>Number.isInteger(i)&&i>=0&&i<=255)}function HI(e,t,r=process.env){if(!Qa(e))return;let i=r.ARGUS_SKILL_HOME?.trim(),s=r.HOME?.trim()||v1(),a=i?_1(i):uQ(s,".argus-skill"),u=e.toLowerCase().replace(/[^a-z0-9._-]+/g,"_");return uQ(a,"runtime",`webapi-${u}-${t}.owner.json`)}async function R1(e){let t=!1;try{process.kill(e,0),t=!0}catch{return{alive:!1,argv:[]}}try{let i=(await gQ(`/proc/${e}/cmdline`)).toString("utf8").split("\0").filter(Boolean);return{alive:t,argv:i}}catch{return{alive:!1,argv:[]}}}async function b1(e){try{process.kill(e,0)}catch{return{alive:!1,argv:[]}}return new Promise(t=>{fQ("/bin/ps",["-ww","-p",String(e),"-o","command="],{encoding:"utf-8"},(r,i)=>{let s=r?"":i.trim();t({alive:!!s,argv:[],commandLine:s||void 0})})})}async function F1(e){try{process.kill(e,0)}catch{return{alive:!1,argv:[]}}let t=["$ErrorActionPreference = 'Stop'","[Console]::OutputEncoding = [System.Text.UTF8Encoding]::new($false)",`$process = Get-CimInstance Win32_Process -Filter "ProcessId = ${e}"`,"if ($null -eq $process) { exit 3 }","[PSCustomObject]@{ commandLine = [string]$process.CommandLine } | ConvertTo-Json -Compress"].join("; ");return new Promise(r=>{fQ("powershell.exe",["-NoProfile","-NonInteractive","-Command",t],{encoding:"utf-8",windowsHide:!0},(i,s)=>{if(i){r({alive:!1,argv:[]});return}try{let a=JSON.parse(s.trim()),u=typeof a.commandLine=="string"?a.commandLine.trim():"";r({alive:!!u,argv:[],commandLine:u||void 0})}catch{r({alive:!1,argv:[]})}})})}function dQ(e,t=process.platform){return t==="win32"?F1(e):t==="darwin"?b1(e):R1(e)}function UI(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function PI(e,t,r){return new RegExp(`(?:^|\\s)["']?${UI(t)}["']?(?=\\s|$)`,r?"i":"").test(e)}function cQ(e,t,r,i){return new RegExp(`(?:^|\\s)${UI(t)}\\s+["']?${UI(r)}["']?(?=\\s|$)`,i?"i":"").test(e)}async function Qp(e,t){await y1(S1(e),{recursive:!0,mode:448});let r=`${e}.tmp.${process.pid}`;await Q1(r,JSON.stringify(t),{encoding:"utf-8",mode:384}),await w1(r,e)}async function GI(e){let{pid:t,host:r,port:i,backendBin:s}=e,a=e.platform??process.platform,u=e.inspect??(_=>dQ(_,a)),E=a==="win32",m=(_,O)=>E?_.toLowerCase()===O.toLowerCase():_===O;if(!Number.isInteger(t)||t<=0)return!1;let{alive:h,argv:y,commandLine:D}=await u(t);if(!h)return!1;if(y.length>0){let _=re=>y.findIndex(ne=>m(ne,re));if(_(s)===-1||_("--web")===-1)return!1;let O=_("--web-port");if(O===-1||!m(y[O+1]??"",String(i)))return!1;let G=_("--web-host");return!(G!==-1&&!m(y[G+1]??"",r))}return!(!D||!PI(D,s,E)||!PI(D,"--web",E)||!cQ(D,"--web-port",String(i),E)||PI(D,"--web-host",E)&&!cQ(D,"--web-host",r,E))}async function WI(e){return await GI({pid:e.pid,host:e.host,port:e.port,backendBin:e.backendBin,inspect:e.inspect,platform:e.platform})?(await Qp(e.path,{schema:1,pid:e.pid,...e.rootPid===void 0?{}:{rootPid:e.rootPid},host:e.host,port:e.port,backendBin:e.backendBin,startedAt:e.startedAt}),!0):!1}async function Vu(e){let{path:t,host:r,port:i,backendBin:s}=e,a=e.platform??process.platform,u=e.inspect??(E=>dQ(E,a));try{let E=await gQ(t,"utf-8"),m=JSON.parse(E);if(m.schema!==1)return null;let h=m.pid;if(typeof h!="number"||!Number.isInteger(h)||h<=0||m.rootPid!==void 0&&(typeof m.rootPid!="number"||!Number.isInteger(m.rootPid)||m.rootPid<=0)||m.host!==r||m.port!==i||m.backendBin!==s||!await GI({pid:h,host:r,port:i,backendBin:s,inspect:u,platform:a}))return null;if(m.rootPid!==void 0&&m.rootPid!==h&&!await GI({pid:m.rootPid,host:r,port:i,backendBin:s,inspect:u,platform:a})){let{rootPid:y,...D}=m;return D}return m}catch{return null}}function pQ(e,t){let r=e?.trim()||"detach";if(r==="detach"||r==="stop-api"||r==="stop-all")return r;throw new Error(`${t} must be detach, stop-api, or stop-all; got ${r}`)}function ul(e,t,r){let i=e[t+1];if(!i||i.startsWith("-"))throw new Error(`${r} requires a value`);return i}function EQ(e,t={}){let r=t.env??process.env,i=t.platform??process.platform,s=r.ARGUS_TUI_PORT,a=r.ARGUS_TUI_API_OWNER_FILE?.trim(),u={host:r.ARGUS_TUI_HOST??"127.0.0.1",port:Number(s??8799),portExplicit:s!==void 0,project:r.ARGUS_TUI_PROJECT,resume:!1,resumeAll:!1,token:r.ARGUS_SKILL_WEB_TOKEN,ownerFile:void 0,once:!1,json:!1,count:5,help:!1,web:!1,openWebWithCli:i==="win32",noOpen:!1,objective:"",forceNew:!1,exitPolicy:pQ(r.ARGUS_TUI_EXIT_POLICY,"ARGUS_TUI_EXIT_POLICY"),ownerFileExplicit:!!a};for(let E=0;E65535)throw new Error(`--port must be between 1 and 65535; got ${u.port}`);if(!Number.isInteger(u.count)||u.count<1)throw new Error(`--count must be a positive integer; got ${u.count}`);return u.ownerFile=a||HI(u.host,u.port),u}function mQ(e,t){return{...e,port:t,ownerFile:e.ownerFileExplicit?e.ownerFile:HI(e.host,t)}}var IQ=`argus \u2014 the terminal cockpit for the argus-skill autonomous-research daemon diff --git a/frontend/tui/src/appSlashDispatch.ts b/frontend/tui/src/appSlashDispatch.ts index c05a8d8e4..ea08b115a 100644 --- a/frontend/tui/src/appSlashDispatch.ts +++ b/frontend/tui/src/appSlashDispatch.ts @@ -41,6 +41,9 @@ export function dispatchSlashCommand(line: string, deps: SlashDispatchDeps): voi ]); switch (parsed.cmd.name) { + case '/crystalpilot': + void deps.api.message(line).then(result => deps.setNotice(result.reply || 'CrystalPilot command handled'), err); + break; case '/help': deps.openPanel('help'); break; diff --git a/frontend/web/dist/assets/MapPanel-BHfjXA2X.js b/frontend/web/dist/assets/MapPanel-BHfjXA2X.js new file mode 100644 index 000000000..a03796102 --- /dev/null +++ b/frontend/web/dist/assets/MapPanel-BHfjXA2X.js @@ -0,0 +1,12 @@ +import{r as e,t}from"./rolldown-runtime-hePW80VL.js";import{A as n,k as r}from"./icons-2gFhc0pq.js";import{g as i,i as a,n as o}from"./query-CGMsBv4s.js";import{i as s,r as c}from"./markdown-BtnlLdzu.js";import{n as l,r as u,t as d}from"./play-4uDgOsGD.js";import{A as f,B as p,E as m,F as h,G as g,I as _,L as v,M as y,N as b,O as x,P as S,R as C,S as w,T,_ as E,a as D,b as O,c as k,d as A,f as j,g as M,j as N,k as P,l as F,m as I,n as L,o as R,p as z,r as B,s as V,t as ee,u as te,v as H,w as U,x as W,z as G}from"./index-CpMiioIG.js";var K=x(`ArrowLeft`,[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]),ne=x(`ChevronLeft`,[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]),re=x(`Compass`,[[`path`,{d:`m16.24 7.76-1.804 5.411a2 2 0 0 1-1.265 1.265L7.76 16.24l1.804-5.411a2 2 0 0 1 1.265-1.265z`,key:`9ktpf1`}],[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),ie=x(`CornerDownLeft`,[[`polyline`,{points:`9 10 4 15 9 20`,key:`r3jprv`}],[`path`,{d:`M20 4v7a4 4 0 0 1-4 4H4`,key:`6o5b7l`}]]),ae=x(`Ellipsis`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`19`,cy:`12`,r:`1`,key:`1wjl8i`}],[`circle`,{cx:`5`,cy:`12`,r:`1`,key:`1pcz8c`}]]),oe=x(`ListChecks`,[[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`path`,{d:`m3 7 2 2 4-4`,key:`1obspn`}],[`path`,{d:`M13 6h8`,key:`15sg57`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 18h8`,key:`oe0vm4`}]]),se=x(`LocateFixed`,[[`line`,{x1:`2`,x2:`5`,y1:`12`,y2:`12`,key:`bvdh0s`}],[`line`,{x1:`19`,x2:`22`,y1:`12`,y2:`12`,key:`1tbv5k`}],[`line`,{x1:`12`,x2:`12`,y1:`2`,y2:`5`,key:`11lu5j`}],[`line`,{x1:`12`,x2:`12`,y1:`19`,y2:`22`,key:`x3vr5v`}],[`circle`,{cx:`12`,cy:`12`,r:`7`,key:`fim9np`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),ce=x(`MessageCircle`,[[`path`,{d:`M7.9 20A9 9 0 1 0 4 16.1L2 22Z`,key:`vv11sd`}]]),le=x(`RotateCcw`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}]]),q=x(`Route`,[[`circle`,{cx:`6`,cy:`19`,r:`3`,key:`1kj8tv`}],[`path`,{d:`M9 19h8.5a3.5 3.5 0 0 0 0-7h-11a3.5 3.5 0 0 1 0-7H15`,key:`1d8sl`}],[`circle`,{cx:`18`,cy:`5`,r:`3`,key:`gq8acd`}]]),ue=x(`Search`,[[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}],[`path`,{d:`m21 21-4.3-4.3`,key:`1qie3q`}]]),de=x(`Settings2`,[[`path`,{d:`M20 7h-9`,key:`3s1dr2`}],[`path`,{d:`M14 17H5`,key:`gfn3mx`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}],[`circle`,{cx:`7`,cy:`7`,r:`3`,key:`dfmy0x`}]]),J=r();function fe({events:e,connected:t,pending:n,artifacts:r,zh:i,onClose:a,onOpenArtifact:o,onOpenDelivery:s}){let c=e.filter(e=>e.type===`ui.operator`||e.type===`ui.argus`);return(0,J.jsxs)(`aside`,{className:`map-conversation nowheel nodrag nopan`,"aria-label":i?`地图对话`:`Map conversation`,children:[(0,J.jsxs)(`header`,{children:[(0,J.jsx)(ce,{size:16}),(0,J.jsx)(`strong`,{children:i?`与 Argus 对话`:`Talk to Argus`}),(0,J.jsx)(`button`,{type:`button`,onClick:a,"aria-label":i?`关闭对话`:`Close conversation`,children:(0,J.jsx)(j,{size:18})})]}),c.length?(0,J.jsx)(S,{events:c,connected:t,showReasoning:!1,onToggleReasoning:()=>{},embedded:!0,showHeader:!1,artifacts:r,onOpenArtifact:o,onOpenDelivery:s}):(0,J.jsx)(`p`,{className:`map-conversation-empty`,children:i?`在下方发送目标或问题,回复会保留在这里。`:`Send a goal or question below. Your conversation stays here.`}),n&&(0,J.jsx)(`p`,{className:`map-conversation-pending`,role:`status`,children:i?`Argus 正在回复…`:`Argus is replying…`})]})}var Y=e(n(),1),pe=g(),me=(e,t,n)=>e+(t-e)*n,X=e=>e*e*(3-2*e),he=(e,t,n)=>Math.max(t,Math.min(n,e));function ge(e,t,n){let r=Math.hypot(t.x-e.x,t.y-e.y),i=Math.min(140,Math.max(54,r*.22))*(t.x>=e.x?-1:1),a=Math.min(120,r*.3),o={x:he(e.x+i,28,n-28),y:e.y-a},s={x:he(t.x+i*.6,28,n-28),y:t.y+a};return n=>{let r=1-n;return{x:r**3*e.x+3*r**2*n*o.x+3*r*n**2*s.x+n**3*t.x,y:r**3*e.y+3*r**2*n*o.y+3*r*n**2*s.y+n**3*t.y}}}function _e({flight:e,canvas:t,zh:n,historical:r=!1,onReveal:i,onLand:a,onFinish:o}){let s=(0,Y.useRef)(null),c=(0,Y.useRef)(null),l=(0,Y.useRef)(null),u=(0,Y.useRef)(null),d=`dispatch-wake-${(0,Y.useId)().replace(/:/g,``)}`,f=(0,Y.useRef)({onReveal:i,onLand:a,onFinish:o});f.current={onReveal:i,onLand:a,onFinish:o};let p=e.result?.type===`task`&&!r;return(0,Y.useEffect)(()=>{if(!e.result)return;let n=0,i,a,o=()=>f.current.onFinish(e.id);if(e.result.type!==`task`||r)return i=setTimeout(o,2200),()=>clearTimeout(i);let d=s.current;if(!d)return;let p=e.result.taskId,m=window.matchMedia(`(prefers-reduced-motion: reduce)`).matches,h=t.current,g=()=>{cancelAnimationFrame(n),clearTimeout(i),f.current.onLand(e.id),o()};h?.addEventListener(`pointerdown`,g,{once:!0}),h?.addEventListener(`wheel`,g,{once:!0,passive:!0});let _=performance.now(),v=0,y=!1,b=0,x,S=r=>{if(r-_>6e3){o();return}let s=t.current?.querySelector(`.map-macro[data-task-id="${CSS.escape(p)}"]`);if(!s||s.getBoundingClientRect().width<8){r-v>600&&(f.current.onReveal(p),v=r),n=requestAnimationFrame(S);return}if(m){f.current.onLand(e.id),i=setTimeout(o,1200);return}y||(f.current.onReveal(p),y=!0,v=r);let h=s.getBoundingClientRect();if((!x||Math.abs(x.x-h.x)+Math.abs(x.y-h.y)+Math.abs(x.width-h.width)>.7)&&(b=r),x=h,r-v<360||r-b<100){n=requestAnimationFrame(S);return}let g=t.current?.querySelector(`.map-composer`)?.getBoundingClientRect(),C=g?{x:g.left,y:g.top,width:g.width,height:g.height}:e.origin,w={x:C.x+C.width/2,y:C.y+C.height/2},T={x:w.x,y:w.y-26},E={x:h.left+h.width/2,y:h.top+h.height/2},D=ge(T,E,innerWidth),O=Math.min(320,C.width),k=Math.min(68,C.height),A=performance.now(),j=!1,M=t=>{if(!s.isConnected){o();return}let r=Math.min(1,(t-A)/1050),p=X(Math.min(1,r/.22)),m=X(he((r-.22)/.6,0,1)),h=X(he((r-.82)/.18,0,1)),g=r<.22?{x:w.x,y:me(w.y,T.y,p)}:D(m),_=me(52,22,h),v=me(O,_,p),y=me(k,_,p);if(d.style.width=`${v}px`,d.style.height=`${y}px`,d.style.transform=`translate3d(${g.x-v/2}px,${g.y-y/2}px,0)`,d.style.opacity=String(Math.min(1,r/.045)*(1-h)),d.style.setProperty(`--dispatch-copy`,String(1-X(Math.min(1,r/.12)))),d.style.setProperty(`--dispatch-mark`,String(me(1,.7,h))),d.dataset.phase=r<.22?`compress`:r<.82?`travel`:`arrive`,c.current&&l.current&&r>.22){let e=Math.max(0,m-.16),t=Array.from({length:13},(t,n)=>D(me(e,m,n/12)));c.current.setAttribute(`d`,t.map((e,t)=>`${t?`L`:`M`} ${e.x} ${e.y}`).join(` `)),c.current.style.opacity=String(.7*(1-h)),l.current.setAttribute(`x1`,String(t[0].x)),l.current.setAttribute(`y1`,String(t[0].y)),l.current.setAttribute(`x2`,String(g.x)),l.current.setAttribute(`y2`,String(g.y))}r>=.82&&!j&&(j=!0,f.current.onLand(e.id),u.current&&(u.current.style.left=`${E.x}px`,u.current.style.top=`${E.y}px`,a=u.current.animate([{transform:`translate(-50%,-50%) scale(.65)`,opacity:.65},{transform:`translate(-50%,-50%) scale(2.8)`,opacity:0}],{duration:650,easing:`cubic-bezier(.16,1,.3,1)`,fill:`both`}))),r<1?n=requestAnimationFrame(M):i=setTimeout(o,550)};n=requestAnimationFrame(M)};return n=requestAnimationFrame(S),()=>{cancelAnimationFrame(n),clearTimeout(i),a?.cancel(),h?.removeEventListener(`pointerdown`,g),h?.removeEventListener(`wheel`,g)}},[e.id,e.result,t,r]),p?(0,pe.createPortal)((0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`svg`,{className:`map-dispatch-trail`,"aria-hidden":`true`,children:[(0,J.jsx)(`defs`,{children:(0,J.jsxs)(`linearGradient`,{ref:l,id:d,gradientUnits:`userSpaceOnUse`,children:[(0,J.jsx)(`stop`,{stopColor:`#6fbcce`,stopOpacity:`0`}),(0,J.jsx)(`stop`,{offset:`1`,stopColor:`#87d9cf`})]})}),(0,J.jsx)(`path`,{ref:c,fill:`none`,stroke:`url(#${d})`,strokeWidth:`2.5`,strokeLinecap:`round`})]}),(0,J.jsxs)(`div`,{ref:s,className:`map-dispatch-flight`,"data-testid":`map-dispatch-flight`,"data-state":`task`,"data-task-id":e.result?.type===`task`?e.result.taskId:void 0,"aria-hidden":`true`,children:[(0,J.jsx)(`div`,{className:`map-dispatch-symbol`,children:(0,J.jsx)(h,{size:25})}),(0,J.jsxs)(`div`,{className:`map-dispatch-copy`,children:[(0,J.jsx)(`strong`,{children:e.text}),(0,J.jsx)(`span`,{children:n?`进入任务地图`:`Into your task map`})]})]}),(0,J.jsx)(`div`,{ref:u,className:`map-dispatch-halo`,"aria-hidden":`true`})]}),document.body):null}var ve=()=>({revision:0,cards:{},steps:{},links:{}}),ye=(e,t)=>`${e}\u0000${t}`,be=class{initialized=!1;seen=new Set;revision=0;loadingHistory=!1;observe(e,t=!1){let n=ve(),r=0;for(let t of e.cards){this.seen.has(`card:${t.id}`)||(n.cards[t.id]=Math.min(r++*100,400)),this.seen.add(`card:${t.id}`);let i=e.layouts[t.id],a=0;for(let e of i.steps){let r=ye(t.id,e.id);this.seen.has(`step:${r}`)||(n.steps[r]=160+Math.min(a++*120,720)),this.seen.add(`step:${r}`)}for(let e of i.links){let r=ye(t.id,e.id);this.seen.has(`link:${r}`)||(n.links[r]=Math.max(0,(n.steps[ye(t.id,e.target)]??160)-160)),this.seen.add(`link:${r}`)}}for(let t of e.links)this.seen.has(`outer:${t.id}`)||(n.links[t.id]=0),this.seen.add(`outer:${t.id}`);let i=!this.initialized||t||this.loadingHistory;return this.loadingHistory=t,this.initialized=!0,i||![n.cards,n.steps,n.links].some(e=>Object.keys(e).length)?null:{...n,revision:++this.revision}}};function xe(e,t=!1){let n=(0,Y.useRef)(new be),r=(0,Y.useRef)(new Set),[i,a]=(0,Y.useState)(ve);return(0,Y.useEffect)(()=>{let i=n.current.observe(e,t);if(t)r.current.forEach(clearTimeout),r.current.clear(),a(ve());else if(i){a(e=>({revision:i.revision,cards:{...e.cards,...i.cards},steps:{...e.steps,...i.steps},links:{...e.links,...i.links}}));let e=setTimeout(()=>{r.current.delete(e),a(e=>({revision:e.revision,cards:Object.fromEntries(Object.entries(e.cards).filter(([e])=>!(e in i.cards))),steps:Object.fromEntries(Object.entries(e.steps).filter(([e])=>!(e in i.steps))),links:Object.fromEntries(Object.entries(e.links).filter(([e])=>!(e in i.links)))}))},2e3);r.current.add(e)}},[e,t]),(0,Y.useEffect)(()=>()=>{r.current.forEach(clearTimeout),r.current.clear()},[]),i}function Se(e){if(typeof e==`string`||typeof e==`number`)return``+e;let t=``;if(Array.isArray(e))for(let n=0,r;n{}};function we(){for(var e=0,t=arguments.length,n={},r;e=0&&(n=e.slice(r+1),e=e.slice(0,r)),e&&!t.hasOwnProperty(e))throw Error(`unknown type: `+e);return{type:e,name:n}})}Te.prototype=we.prototype={constructor:Te,on:function(e,t){var n=this._,r=Ee(e+``,n),i,a=-1,o=r.length;if(arguments.length<2){for(;++a0)for(var n=Array(i),r=0,i,a;r=0&&(t=e.slice(0,n))!==`xmlns`&&(e=e.slice(n+1)),ke.hasOwnProperty(t)?{space:ke[t],local:e}:e}function je(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===`http://www.w3.org/1999/xhtml`&&t.documentElement.namespaceURI===`http://www.w3.org/1999/xhtml`?t.createElement(e):t.createElementNS(n,e)}}function Me(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Ne(e){var t=Ae(e);return(t.local?Me:je)(t)}function Pe(){}function Fe(e){return e==null?Pe:function(){return this.querySelector(e)}}function Ie(e){typeof e!=`function`&&(e=Fe(e));for(var t=this._groups,n=t.length,r=Array(n),i=0;i=v&&(v=_+1);!(b=g[v])&&++v=0;)(o=r[i])&&(a&&o.compareDocumentPosition(a)^4&&a.parentNode.insertBefore(o,a),a=o);return this}function ft(e){e||=pt;function t(t,n){return t&&n?e(t.__data__,n.__data__):!t-!n}for(var n=this._groups,r=n.length,i=Array(r),a=0;at?1:e>=t?0:NaN}function mt(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function ht(){return Array.from(this)}function gt(){for(var e=this._groups,t=0,n=e.length;t1?this.each((t==null?Ot:typeof t==`function`?At:kt)(e,t,n??``)):Mt(this.node(),e)}function Mt(e,t){return e.style.getPropertyValue(t)||Dt(e).getComputedStyle(e,null).getPropertyValue(t)}function Nt(e){return function(){delete this[e]}}function Pt(e,t){return function(){this[e]=t}}function Ft(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function It(e,t){return arguments.length>1?this.each((t==null?Nt:typeof t==`function`?Ft:Pt)(e,t)):this.node()[e]}function Lt(e){return e.trim().split(/^|\s+/)}function Rt(e){return e.classList||new zt(e)}function zt(e){this._node=e,this._names=Lt(e.getAttribute(`class`)||``)}zt.prototype={add:function(e){this._names.indexOf(e)<0&&(this._names.push(e),this._node.setAttribute(`class`,this._names.join(` `)))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute(`class`,this._names.join(` `)))},contains:function(e){return this._names.indexOf(e)>=0}};function Bt(e,t){for(var n=Rt(e),r=-1,i=t.length;++r=0&&(t=e.slice(n+1),e=e.slice(0,n)),{type:e,name:t}})}function gn(e){return function(){var t=this.__on;if(t){for(var n=0,r=-1,i=t.length,a;n()=>e;function Rn(e,{sourceEvent:t,subject:n,target:r,identifier:i,active:a,x:o,y:s,dx:c,dy:l,dispatch:u}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},identifier:{value:i,enumerable:!0,configurable:!0},active:{value:a,enumerable:!0,configurable:!0},x:{value:o,enumerable:!0,configurable:!0},y:{value:s,enumerable:!0,configurable:!0},dx:{value:c,enumerable:!0,configurable:!0},dy:{value:l,enumerable:!0,configurable:!0},_:{value:u}})}Rn.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function zn(e){return!e.ctrlKey&&!e.button}function Bn(){return this.parentNode}function Vn(e,t){return t??{x:e.x,y:e.y}}function Hn(){return navigator.maxTouchPoints||`ontouchstart`in this}function Un(){var e=zn,t=Bn,n=Vn,r=Hn,i={},a=we(`start`,`drag`,`end`),o=0,s,c,l,u,d=0;function f(e){e.on(`mousedown.drag`,p).filter(r).on(`touchstart.drag`,g).on(`touchmove.drag`,_,jn).on(`touchend.drag touchcancel.drag`,v).style(`touch-action`,`none`).style(`-webkit-tap-highlight-color`,`rgba(0,0,0,0)`)}function p(n,r){if(!(u||!e.call(this,n,r))){var i=y(this,t.call(this,n,r),n,r,`mouse`);i&&(On(n.view).on(`mousemove.drag`,m,Mn).on(`mouseup.drag`,h,Mn),Fn(n.view),Nn(n),l=!1,s=n.clientX,c=n.clientY,i(`start`,n))}}function m(e){if(Pn(e),!l){var t=e.clientX-s,n=e.clientY-c;l=t*t+n*n>d}i.mouse(`drag`,e)}function h(e){On(e.view).on(`mousemove.drag mouseup.drag`,null),In(e.view,l),Pn(e),i.mouse(`end`,e)}function g(n,r){if(e.call(this,n,r)){var i=n.changedTouches,a=t.call(this,n,r),o=i.length,s,c;for(s=0;s>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?fr(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?fr(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=$n.exec(e))?new hr(t[1],t[2],t[3],1):(t=er.exec(e))?new hr(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=tr.exec(e))?fr(t[1],t[2],t[3],t[4]):(t=nr.exec(e))?fr(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=rr.exec(e))?Sr(t[1],t[2]/100,t[3]/100,1):(t=ir.exec(e))?Sr(t[1],t[2]/100,t[3]/100,t[4]):ar.hasOwnProperty(e)?dr(ar[e]):e===`transparent`?new hr(NaN,NaN,NaN,0):null}function dr(e){return new hr(e>>16&255,e>>8&255,e&255,1)}function fr(e,t,n,r){return r<=0&&(e=t=n=NaN),new hr(e,t,n,r)}function pr(e){return e instanceof Kn||(e=ur(e)),e?(e=e.rgb(),new hr(e.r,e.g,e.b,e.opacity)):new hr}function mr(e,t,n,r){return arguments.length===1?pr(e):new hr(e,t,n,r??1)}function hr(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}Wn(hr,mr,Gn(Kn,{brighter(e){return e=e==null?Jn:Jn**+e,new hr(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?qn:qn**+e,new hr(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new hr(br(this.r),br(this.g),br(this.b),yr(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:gr,formatHex:gr,formatHex8:_r,formatRgb:vr,toString:vr}));function gr(){return`#${xr(this.r)}${xr(this.g)}${xr(this.b)}`}function _r(){return`#${xr(this.r)}${xr(this.g)}${xr(this.b)}${xr((isNaN(this.opacity)?1:this.opacity)*255)}`}function vr(){let e=yr(this.opacity);return`${e===1?`rgb(`:`rgba(`}${br(this.r)}, ${br(this.g)}, ${br(this.b)}${e===1?`)`:`, ${e})`}`}function yr(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function br(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function xr(e){return e=br(e),(e<16?`0`:``)+e.toString(16)}function Sr(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new Tr(e,t,n,r)}function Cr(e){if(e instanceof Tr)return new Tr(e.h,e.s,e.l,e.opacity);if(e instanceof Kn||(e=ur(e)),!e)return new Tr;if(e instanceof Tr)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,i=Math.min(t,n,r),a=Math.max(t,n,r),o=NaN,s=a-i,c=(a+i)/2;return s?(o=t===a?(n-r)/s+(n0&&c<1?0:o,new Tr(o,s,c,e.opacity)}function wr(e,t,n,r){return arguments.length===1?Cr(e):new Tr(e,t,n,r??1)}function Tr(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}Wn(Tr,wr,Gn(Kn,{brighter(e){return e=e==null?Jn:Jn**+e,new Tr(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?qn:qn**+e,new Tr(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,r=n+(n<.5?n:1-n)*t,i=2*n-r;return new hr(Or(e>=240?e-240:e+120,i,r),Or(e,i,r),Or(e<120?e+240:e-120,i,r),this.opacity)},clamp(){return new Tr(Er(this.h),Dr(this.s),Dr(this.l),yr(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(){let e=yr(this.opacity);return`${e===1?`hsl(`:`hsla(`}${Er(this.h)}, ${Dr(this.s)*100}%, ${Dr(this.l)*100}%${e===1?`)`:`, ${e})`}`}}));function Er(e){return e=(e||0)%360,e<0?e+360:e}function Dr(e){return Math.max(0,Math.min(1,e||0))}function Or(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}var kr=e=>()=>e;function Ar(e,t){return function(n){return e+n*t}}function jr(e,t,n){return e**=+n,t=t**+n-e,n=1/n,function(r){return(e+r*t)**+n}}function Mr(e){return(e=+e)==1?Nr:function(t,n){return n-t?jr(t,n,e):kr(isNaN(t)?n:t)}}function Nr(e,t){var n=t-e;return n?Ar(e,n):kr(isNaN(e)?t:e)}var Pr=(function e(t){var n=Mr(t);function r(e,t){var r=n((e=mr(e)).r,(t=mr(t)).r),i=n(e.g,t.g),a=n(e.b,t.b),o=Nr(e.opacity,t.opacity);return function(t){return e.r=r(t),e.g=i(t),e.b=a(t),e.opacity=o(t),e+``}}return r.gamma=e,r})(1);function Fr(e,t){t||=[];var n=e?Math.min(t.length,e.length):0,r=t.slice(),i;return function(a){for(i=0;in&&(a=t.slice(n,a),s[o]?s[o]+=a:s[++o]=a),(r=r[0])===(i=i[0])?s[o]?s[o]+=i:s[++o]=i:(s[++o]=null,c.push({i:o,x:zr(r,i)})),n=Hr.lastIndex;return n180?t+=360:t-e>180&&(e+=360),a.push({i:n.push(i(n)+`rotate(`,null,r)-2,x:zr(e,t)}))}function s(e,t,n,a){e===t?t&&n.push(i(n)+`skewX(`+t+r):a.push({i:n.push(i(n)+`skewX(`,null,r)-2,x:zr(e,t)})}function c(e,t,n,r,a,o){if(e!==n||t!==r){var s=a.push(i(a)+`scale(`,null,`,`,null,`)`);o.push({i:s-4,x:zr(e,n)},{i:s-2,x:zr(t,r)})}else(n!==1||r!==1)&&a.push(i(a)+`scale(`+n+`,`+r+`)`)}return function(t,n){var r=[],i=[];return t=e(t),n=e(n),a(t.translateX,t.translateY,n.translateX,n.translateY,r,i),o(t.rotate,n.rotate,r,i),s(t.skewX,n.skewX,r,i),c(t.scaleX,t.scaleY,n.scaleX,n.scaleY,r,i),t=n=null,function(e){for(var t=-1,n=i.length,a;++t=0&&e._call.call(void 0,t),e=e._next;--si}function Ci(){mi=(pi=gi.now())+hi,si=ci=0;try{Si()}finally{si=0,Ti(),mi=0}}function wi(){var e=gi.now(),t=e-pi;t>ui&&(hi-=t,pi=e)}function Ti(){for(var e,t=di,n,r=1/0;t;)t._call?(r>t._time&&(r=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:di=n);fi=e,Ei(r)}function Ei(e){si||(ci&&=clearTimeout(ci),e-mi>24?(e<1/0&&(ci=setTimeout(Ci,e-gi.now()-hi)),li&&=clearInterval(li)):(li||=(pi=gi.now(),setInterval(wi,ui)),si=1,_i(Ci)))}function Di(e,t,n){var r=new bi;return t=t==null?0:+t,r.restart(n=>{r.stop(),e(n+t)},t,n),r}var Oi=we(`start`,`end`,`cancel`,`interrupt`),ki=[];function Ai(e,t,n,r,i,a){var o=e.__transition;if(!o)e.__transition={};else if(n in o)return;Pi(e,n,{name:t,index:r,group:i,on:Oi,tween:ki,time:a.time,delay:a.delay,duration:a.duration,ease:a.ease,timer:null,state:0})}function ji(e,t){var n=Ni(e,t);if(n.state>0)throw Error(`too late; already scheduled`);return n}function Mi(e,t){var n=Ni(e,t);if(n.state>3)throw Error(`too late; already running`);return n}function Ni(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw Error(`transition not found`);return n}function Pi(e,t,n){var r=e.__transition,i;r[t]=n,n.timer=xi(a,0,n.time);function a(e){n.state=1,n.timer.restart(o,n.delay,n.time),n.delay<=e&&o(e-n.delay)}function o(a){var l,u,d,f;if(n.state!==1)return c();for(l in r)if(f=r[l],f.name===n.name){if(f.state===3)return Di(o);f.state===4?(f.state=6,f.timer.stop(),f.on.call(`interrupt`,e,e.__data__,f.index,f.group),delete r[l]):+l2&&r.state<5,r.state=6,r.timer.stop(),r.on.call(i?`interrupt`:`cancel`,e,e.__data__,r.index,r.group),delete n[o]}a&&delete e.__transition}}function Ii(e){return this.each(function(){Fi(this,e)})}function Li(e,t){var n,r;return function(){var i=Mi(this,e),a=i.tween;if(a!==n){r=n=a;for(var o=0,s=r.length;o=0&&(e=e.slice(0,t)),!e||e===`start`})}function pa(e,t,n){var r,i,a=fa(t)?ji:Mi;return function(){var o=a(this,e),s=o.on;s!==r&&(i=(r=s).copy()).on(t,n),o.on=i}}function ma(e,t){var n=this._id;return arguments.length<2?Ni(this.node(),n).on.on(e):this.each(pa(n,e,t))}function ha(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function ga(){return this.on(`end.remove`,ha(this._id))}function _a(e){var t=this._name,n=this._id;typeof e!=`function`&&(e=Fe(e));for(var r=this._groups,i=r.length,a=Array(i),o=0;o()=>e;function qa(e,{sourceEvent:t,target:n,transform:r,dispatch:i}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:r,enumerable:!0,configurable:!0},_:{value:i}})}function Ja(e,t,n){this.k=e,this.x=t,this.y=n}Ja.prototype={constructor:Ja,scale:function(e){return e===1?this:new Ja(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new Ja(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return`translate(`+this.x+`,`+this.y+`) scale(`+this.k+`)`}};var Ya=new Ja(1,0,0);Xa.prototype=Ja.prototype;function Xa(e){for(;!e.__zoom;)if(!(e=e.parentNode))return Ya;return e.__zoom}function Za(e){e.stopImmediatePropagation()}function Qa(e){e.preventDefault(),e.stopImmediatePropagation()}function $a(e){return(!e.ctrlKey||e.type===`wheel`)&&!e.button}function eo(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e,e.hasAttribute(`viewBox`)?(e=e.viewBox.baseVal,[[e.x,e.y],[e.x+e.width,e.y+e.height]]):[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]):[[0,0],[e.clientWidth,e.clientHeight]]}function to(){return this.__zoom||Ya}function no(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function ro(){return navigator.maxTouchPoints||`ontouchstart`in this}function io(e,t,n){var r=e.invertX(t[0][0])-n[0][0],i=e.invertX(t[1][0])-n[1][0],a=e.invertY(t[0][1])-n[0][1],o=e.invertY(t[1][1])-n[1][1];return e.translate(i>r?(r+i)/2:Math.min(0,r)||Math.max(0,i),o>a?(a+o)/2:Math.min(0,a)||Math.max(0,o))}function ao(){var e=$a,t=eo,n=io,r=no,i=ro,a=[0,1/0],o=[[-1/0,-1/0],[1/0,1/0]],s=250,c=oi,l=we(`start`,`zoom`,`end`),u,d,f,p=500,m=150,h=0,g=10;function _(e){e.property(`__zoom`,to).on(`wheel.zoom`,w,{passive:!1}).on(`mousedown.zoom`,T).on(`dblclick.zoom`,E).filter(i).on(`touchstart.zoom`,D).on(`touchmove.zoom`,O).on(`touchend.zoom touchcancel.zoom`,k).style(`-webkit-tap-highlight-color`,`rgba(0,0,0,0)`)}_.transform=function(e,t,n,r){var i=e.selection?e.selection():e;i.property(`__zoom`,to),e===i?i.interrupt().each(function(){S(this,arguments).event(r).start().zoom(null,typeof t==`function`?t.apply(this,arguments):t).end()}):x(e,t,n,r)},_.scaleBy=function(e,t,n,r){_.scaleTo(e,function(){return this.__zoom.k*(typeof t==`function`?t.apply(this,arguments):t)},n,r)},_.scaleTo=function(e,r,i,a){_.transform(e,function(){var e=t.apply(this,arguments),a=this.__zoom,s=i==null?b(e):typeof i==`function`?i.apply(this,arguments):i,c=a.invert(s),l=typeof r==`function`?r.apply(this,arguments):r;return n(y(v(a,l),s,c),e,o)},i,a)},_.translateBy=function(e,r,i,a){_.transform(e,function(){return n(this.__zoom.translate(typeof r==`function`?r.apply(this,arguments):r,typeof i==`function`?i.apply(this,arguments):i),t.apply(this,arguments),o)},null,a)},_.translateTo=function(e,r,i,a,s){_.transform(e,function(){var e=t.apply(this,arguments),s=this.__zoom,c=a==null?b(e):typeof a==`function`?a.apply(this,arguments):a;return n(Ya.translate(c[0],c[1]).scale(s.k).translate(typeof r==`function`?-r.apply(this,arguments):-r,typeof i==`function`?-i.apply(this,arguments):-i),e,o)},a,s)};function v(e,t){return t=Math.max(a[0],Math.min(a[1],t)),t===e.k?e:new Ja(t,e.x,e.y)}function y(e,t,n){var r=t[0]-n[0]*e.k,i=t[1]-n[1]*e.k;return r===e.x&&i===e.y?e:new Ja(e.k,r,i)}function b(e){return[(+e[0][0]+ +e[1][0])/2,(+e[0][1]+ +e[1][1])/2]}function x(e,n,r,i){e.on(`start.zoom`,function(){S(this,arguments).event(i).start()}).on(`interrupt.zoom end.zoom`,function(){S(this,arguments).event(i).end()}).tween(`zoom`,function(){var e=this,a=arguments,o=S(e,a).event(i),s=t.apply(e,a),l=r==null?b(s):typeof r==`function`?r.apply(e,a):r,u=Math.max(s[1][0]-s[0][0],s[1][1]-s[0][1]),d=e.__zoom,f=typeof n==`function`?n.apply(e,a):n,p=c(d.invert(l).concat(u/d.k),f.invert(l).concat(u/f.k));return function(e){if(e===1)e=f;else{var t=p(e),n=u/t[2];e=new Ja(n,l[0]-t[0]*n,l[1]-t[1]*n)}o.zoom(null,e)}})}function S(e,t,n){return!n&&e.__zooming||new C(e,t)}function C(e,n){this.that=e,this.args=n,this.active=0,this.sourceEvent=null,this.extent=t.apply(e,n),this.taps=0}C.prototype={event:function(e){return e&&(this.sourceEvent=e),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit(`start`)),this},zoom:function(e,t){return this.mouse&&e!==`mouse`&&(this.mouse[1]=t.invert(this.mouse[0])),this.touch0&&e!==`touch`&&(this.touch0[1]=t.invert(this.touch0[0])),this.touch1&&e!==`touch`&&(this.touch1[1]=t.invert(this.touch1[0])),this.that.__zoom=t,this.emit(`zoom`),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit(`end`)),this},emit:function(e){var t=On(this.that).datum();l.call(e,this.that,new qa(e,{sourceEvent:this.sourceEvent,target:_,type:e,transform:this.that.__zoom,dispatch:l}),t)}};function w(t,...i){if(!e.apply(this,arguments))return;var s=S(this,i).event(t),c=this.__zoom,l=Math.max(a[0],Math.min(a[1],c.k*2**r.apply(this,arguments))),u=An(t);if(s.wheel)(s.mouse[0][0]!==u[0]||s.mouse[0][1]!==u[1])&&(s.mouse[1]=c.invert(s.mouse[0]=u)),clearTimeout(s.wheel);else if(c.k===l)return;else s.mouse=[u,c.invert(u)],Fi(this),s.start();Qa(t),s.wheel=setTimeout(d,m),s.zoom(`mouse`,n(y(v(c,l),s.mouse[0],s.mouse[1]),s.extent,o));function d(){s.wheel=null,s.end()}}function T(t,...r){if(f||!e.apply(this,arguments))return;var i=t.currentTarget,a=S(this,r,!0).event(t),s=On(t.view).on(`mousemove.zoom`,d,!0).on(`mouseup.zoom`,p,!0),c=An(t,i),l=t.clientX,u=t.clientY;Fn(t.view),Za(t),a.mouse=[c,this.__zoom.invert(c)],Fi(this),a.start();function d(e){if(Qa(e),!a.moved){var t=e.clientX-l,r=e.clientY-u;a.moved=t*t+r*r>h}a.event(e).zoom(`mouse`,n(y(a.that.__zoom,a.mouse[0]=An(e,i),a.mouse[1]),a.extent,o))}function p(e){s.on(`mousemove.zoom mouseup.zoom`,null),In(e.view,a.moved),Qa(e),a.event(e).end()}}function E(r,...i){if(e.apply(this,arguments)){var a=this.__zoom,c=An(r.changedTouches?r.changedTouches[0]:r,this),l=a.invert(c),u=a.k*(r.shiftKey?.5:2),d=n(y(v(a,u),c,l),t.apply(this,i),o);Qa(r),s>0?On(this).transition().duration(s).call(x,d,c,r):On(this).call(_.transform,d,c,r)}}function D(t,...n){if(e.apply(this,arguments)){var r=t.touches,i=r.length,a=S(this,n,t.changedTouches.length===i).event(t),o,s,c,l;for(Za(t),s=0;s`Seems like you have not used ${e===`svelte`?`SvelteFlowProvider`:`ReactFlowProvider`} as an ancestor. Help: https://${e}flow.dev/error#001`,error002:()=>`It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.`,error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>`The parent container needs a width and a height to render the graph.`,error005:()=>`Only child nodes can use a parent extent.`,error006:()=>`Can't create edge. An edge needs a source and a target.`,error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,{id:t,sourceHandle:n,targetHandle:r})=>`Couldn't create edge for ${e} handle id: "${e===`source`?n:r}", edge id: ${t}.`,error010:()=>`Handle: No node id found. Make sure to only use a Handle inside a custom Node.`,error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(e=`react`)=>`It seems that you haven't loaded the styles. Please import '@xyflow/${e}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>`useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.`,error015:()=>`It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs.`,error016:e=>`Edge with id "${e}" does not exist, it may have been removed. This can happen when an edge is deleted before the "onEdgeClick" handler is called.`},so=[[-1/0,-1/0],[1/0,1/0]],co=[`Enter`,` `,`Escape`],lo={"node.a11yDescription.default":`Press enter or space to select a node. Press delete to remove it and escape to cancel.`,"node.a11yDescription.keyboardDisabled":`Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.`,"node.a11yDescription.ariaLiveMessage":({direction:e,x:t,y:n})=>`Moved selected node ${e}. New position, x: ${t}, y: ${n}`,"edge.a11yDescription.default":`Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.`,"controls.ariaLabel":`Control Panel`,"controls.zoomIn.ariaLabel":`Zoom In`,"controls.zoomOut.ariaLabel":`Zoom Out`,"controls.fitView.ariaLabel":`Fit View`,"controls.interactive.ariaLabel":`Toggle Interactivity`,"minimap.ariaLabel":`Mini Map`,"handle.ariaLabel":`Handle`},uo;(function(e){e.Strict=`strict`,e.Loose=`loose`})(uo||={});var fo;(function(e){e.Free=`free`,e.Vertical=`vertical`,e.Horizontal=`horizontal`})(fo||={});var po;(function(e){e.Partial=`partial`,e.Full=`full`})(po||={});var mo={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null},ho;(function(e){e.Bezier=`default`,e.Straight=`straight`,e.Step=`step`,e.SmoothStep=`smoothstep`,e.SimpleBezier=`simplebezier`})(ho||={});var go;(function(e){e.Arrow=`arrow`,e.ArrowClosed=`arrowclosed`})(go||={});var Z;(function(e){e.Left=`left`,e.Top=`top`,e.Right=`right`,e.Bottom=`bottom`})(Z||={});var _o={[Z.Left]:Z.Right,[Z.Right]:Z.Left,[Z.Top]:Z.Bottom,[Z.Bottom]:Z.Top};function vo(e){return e===null?null:e?`valid`:`invalid`}var yo=e=>`id`in e&&`source`in e&&`target`in e,bo=e=>`id`in e&&`position`in e&&!(`source`in e)&&!(`target`in e),xo=e=>`id`in e&&`internals`in e&&!(`source`in e)&&!(`target`in e),So=(e,t=[0,0])=>{let{width:n,height:r}=ns(e),i=e.origin??t,a=n*i[0],o=r*i[1];return{x:e.position.x-a,y:e.position.y-o}},Co=(e,t={nodeOrigin:[0,0]})=>e.length===0?{x:0,y:0,width:0,height:0}:Ro(e.reduce((e,n)=>{let r=typeof n==`string`,i=!t.nodeLookup&&!r?n:void 0;return t.nodeLookup&&(i=r?t.nodeLookup.get(n):xo(n)?n:t.nodeLookup.get(n.id)),Io(e,i?Bo(i,t.nodeOrigin):{x:0,y:0,x2:0,y2:0})},{x:1/0,y:1/0,x2:-1/0,y2:-1/0})),wo=(e,t={})=>{let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0},r=!1;return e.forEach(e=>{(t.filter===void 0||t.filter(e))&&(n=Io(n,Bo(e)),r=!0)}),r?Ro(n):{x:0,y:0,width:0,height:0}},To=(e,t,[n,r,i]=[0,0,1],a=!1,o=!1)=>{let s=(t.x-n)/i,c=(t.y-r)/i,l=t.width/i,u=t.height/i,d=[];for(let t of e.values()){let{measured:e,selectable:n=!0,hidden:r=!1}=t;if(o&&!n||r)continue;let i=e.width??t.width??t.initialWidth??0,f=e.height??t.height??t.initialHeight??0,{x:p,y:m}=t.internals.positionAbsolute,h=Ho(s,c,l,u,p,m,i,f),g=i*f,_=a&&h>0;(!t.internals.handleBounds||_||h>=g||t.dragging)&&d.push(t)}return d},Eo=(e,t)=>{let n=new Set;return e.forEach(e=>{n.add(e.id)}),t.filter(e=>n.has(e.source)||n.has(e.target))};function Do(e,t){let n=new Map,r=t?.nodes?new Set(t.nodes.map(e=>e.id)):null;return e.forEach(e=>{e.measured.width&&e.measured.height&&(t?.includeHiddenNodes||!e.hidden)&&(!r||r.has(e.id))&&n.set(e.id,e)}),n}async function Oo({nodes:e,width:t,height:n,panZoom:r,minZoom:i,maxZoom:a},o){if(e.size===0)return!0;let s=$o(wo(Do(e,o)),t,n,o?.minZoom??i,o?.maxZoom??a,o?.padding??.1);return await r.setViewport(s,{duration:o?.duration,ease:o?.ease,interpolate:o?.interpolate}),!0}function ko({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:r=[0,0],nodeExtent:i,onError:a}){let o=n.get(e),s=o.parentId?n.get(o.parentId):void 0,{x:c,y:l}=s?s.internals.positionAbsolute:{x:0,y:0},u=o.origin??r,d=o.extent||i;if(o.extent===`parent`&&!o.expandParent){if(!s)a?.(`005`,oo.error005());else{let e=s.measured.width,t=s.measured.height;e&&t&&(d=[[c,l],[c+e,l+t]])}}else s&&ts(o.extent)&&(d=[[o.extent[0][0]+c,o.extent[0][1]+l],[o.extent[1][0]+c,o.extent[1][1]+l]]);let f=ts(d)?Mo(t,d,o.measured):t;return(o.measured.width===void 0||o.measured.height===void 0)&&a?.(`015`,oo.error015()),{position:{x:f.x-c+(o.measured.width??0)*u[0],y:f.y-l+(o.measured.height??0)*u[1]},positionAbsolute:f}}async function Ao({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:r,onBeforeDelete:i}){let a=new Set(e.map(e=>e.id)),o=[];for(let e of n){if(e.deletable===!1)continue;let t=a.has(e.id),n=!t&&e.parentId&&o.find(t=>t.id===e.parentId);(t||n)&&o.push(e)}let s=new Set(t.map(e=>e.id)),c=r.filter(e=>e.deletable!==!1),l=Eo(o,c);for(let e of c)s.has(e.id)&&!l.find(t=>t.id===e.id)&&l.push(e);if(!i)return{edges:l,nodes:o};let u=await i({nodes:o,edges:l});return typeof u==`boolean`?u?{edges:l,nodes:o}:{edges:[],nodes:[]}:u}var jo=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),Mo=(e={x:0,y:0},t,n)=>({x:jo(e.x,t[0][0],t[1][0]-(n?.width??0)),y:jo(e.y,t[0][1],t[1][1]-(n?.height??0))});function No(e,t,n){let{width:r,height:i}=ns(n),{x:a,y:o}=n.internals.positionAbsolute;return Mo(e,[[a,o],[a+r,o+i]],t)}var Po=(e,t,n)=>en?-jo(Math.abs(e-n),1,t)/t:0,Fo=(e,t,n=15,r=40)=>[Po(e.x,r,t.width-r)*n,Po(e.y,r,t.height-r)*n],Io=(e,t)=>({x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x2,t.x2),y2:Math.max(e.y2,t.y2)}),Lo=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),Ro=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),zo=(e,t=[0,0])=>{let{x:n,y:r}=xo(e)?e.internals.positionAbsolute:So(e,t);return{x:n,y:r,width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}},Bo=(e,t=[0,0])=>{let{x:n,y:r}=xo(e)?e.internals.positionAbsolute:So(e,t);return{x:n,y:r,x2:n+(e.measured?.width??e.width??e.initialWidth??0),y2:r+(e.measured?.height??e.height??e.initialHeight??0)}},Vo=(e,t)=>Ro(Io(Lo(e),Lo(t))),Ho=(e,t,n,r,i,a,o,s)=>{let c=Math.max(0,Math.min(e+n,i+o)-Math.max(e,i)),l=Math.max(0,Math.min(t+r,a+s)-Math.max(t,a));return Math.ceil(c*l)},Uo=(e,t)=>Ho(e.x,e.y,e.width,e.height,t.x,t.y,t.width,t.height),Wo=e=>Go(e.width)&&Go(e.height)&&Go(e.x)&&Go(e.y),Go=e=>!isNaN(e)&&isFinite(e),Ko=(e,t)=>(e,t)=>{},qo=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),Jo=({x:e,y:t},[n,r,i],a=!1,o=[1,1])=>{let s={x:(e-n)/i,y:(t-r)/i};return a?qo(s,o):s},Yo=({x:e,y:t},[n,r,i])=>({x:e*i+n,y:t*i+r});function Xo(e,t){if(typeof e==`number`)return Math.floor((t-t/(1+e))*.5);if(typeof e==`string`&&e.endsWith(`px`)){let t=parseFloat(e);if(!Number.isNaN(t))return Math.floor(t)}if(typeof e==`string`&&e.endsWith(`%`)){let n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(t*n*.01)}return console.error(`The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function Zo(e,t,n){if(typeof e==`string`||typeof e==`number`){let r=Xo(e,n),i=Xo(e,t);return{top:r,right:i,bottom:r,left:i,x:i*2,y:r*2}}if(typeof e==`object`){let r=Xo(e.top??e.y??0,n),i=Xo(e.bottom??e.y??0,n),a=Xo(e.left??e.x??0,t),o=Xo(e.right??e.x??0,t);return{top:r,right:o,bottom:i,left:a,x:a+o,y:r+i}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function Qo(e,t,n,r,i,a){let{x:o,y:s}=Yo(e,[t,n,r]),{x:c,y:l}=Yo({x:e.x+e.width,y:e.y+e.height},[t,n,r]),u=i-c,d=a-l;return{left:Math.floor(o),top:Math.floor(s),right:Math.floor(u),bottom:Math.floor(d)}}var $o=(e,t,n,r,i,a)=>{let o=Zo(a,t,n),s=(t-o.x)/e.width,c=(n-o.y)/e.height,l=jo(Math.min(s,c),r,i),u=e.x+e.width/2,d=e.y+e.height/2,f=t/2-u*l,p=n/2-d*l,m=Qo(e,f,p,l,t,n),h={left:Math.min(m.left-o.left,0),top:Math.min(m.top-o.top,0),right:Math.min(m.right-o.right,0),bottom:Math.min(m.bottom-o.bottom,0)};return{x:f-h.left+h.right,y:p-h.top+h.bottom,zoom:l}},es=()=>typeof navigator<`u`&&navigator?.userAgent?.indexOf(`Mac`)>=0;function ts(e){return e!=null&&e!==`parent`}function ns(e){return{width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}}function rs(e){return(e.measured?.width??e.width??e.initialWidth)!==void 0&&(e.measured?.height??e.height??e.initialHeight)!==void 0}function is(e,t={width:0,height:0},n,r,i){let a={...e},o=r.get(n);if(o){let e=o.origin||i;a.x+=o.internals.positionAbsolute.x-(t.width??0)*e[0],a.y+=o.internals.positionAbsolute.y-(t.height??0)*e[1]}return a}function as(e,t){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}function os(){let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}function ss(e){return{...lo,...e||{}}}function cs(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:r,containerBounds:i}){let{x:a,y:o}=ms(e),s=Jo({x:a-(i?.left??0),y:o-(i?.top??0)},r),{x:c,y:l}=n?qo(s,t):s;return{xSnapped:c,ySnapped:l,...s}}var ls=e=>({width:e.offsetWidth,height:e.offsetHeight}),us=e=>e?.getRootNode?.()||window?.document,ds=[`INPUT`,`SELECT`,`TEXTAREA`];function fs(e){let t=e.composedPath?.()?.[0]||e.target;return t?.nodeType===1?ds.includes(t.nodeName)||t.hasAttribute(`contenteditable`)||!!t.closest(`.nokey`):!1}var ps=e=>`clientX`in e,ms=(e,t)=>{let n=ps(e),r=n?e.clientX:e.touches?.[0].clientX,i=n?e.clientY:e.touches?.[0].clientY;return{x:r-(t?.left??0),y:i-(t?.top??0)}},hs=(e,t,n,r,i)=>{let a=t.querySelectorAll(`.${e}`);return!a||!a.length?null:Array.from(a).map(t=>{let a=t.getBoundingClientRect();return{id:t.getAttribute(`data-handleid`),type:e,nodeId:i,position:t.getAttribute(`data-handlepos`),x:(a.left-n.left)/r,y:(a.top-n.top)/r,...ls(t)}})};function gs({sourceX:e,sourceY:t,targetX:n,targetY:r,sourceControlX:i,sourceControlY:a,targetControlX:o,targetControlY:s}){let c=e*.125+i*.375+o*.375+n*.125,l=t*.125+a*.375+s*.375+r*.125;return[c,l,Math.abs(c-e),Math.abs(l-t)]}function _s(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function vs({pos:e,x1:t,y1:n,x2:r,y2:i,c:a}){switch(e){case Z.Left:return[t-_s(t-r,a),n];case Z.Right:return[t+_s(r-t,a),n];case Z.Top:return[t,n-_s(n-i,a)];case Z.Bottom:return[t,n+_s(i-n,a)]}}function ys({sourceX:e,sourceY:t,sourcePosition:n=Z.Bottom,targetX:r,targetY:i,targetPosition:a=Z.Top,curvature:o=.25}){let[s,c]=vs({pos:n,x1:e,y1:t,x2:r,y2:i,c:o}),[l,u]=vs({pos:a,x1:r,y1:i,x2:e,y2:t,c:o}),[d,f,p,m]=gs({sourceX:e,sourceY:t,targetX:r,targetY:i,sourceControlX:s,sourceControlY:c,targetControlX:l,targetControlY:u});return[`M${e},${t} C${s},${c} ${l},${u} ${r},${i}`,d,f,p,m]}function bs({sourceX:e,sourceY:t,targetX:n,targetY:r}){let i=Math.abs(n-e)/2,a=n0}var Cs=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`xy-edge__${e}${t||``}-${n}${r||``}`,ws=(e,t)=>t.some(t=>t.source===e.source&&t.target===e.target&&(t.sourceHandle===e.sourceHandle||!t.sourceHandle&&!e.sourceHandle)&&(t.targetHandle===e.targetHandle||!t.targetHandle&&!e.targetHandle)),Ts=(e,t,n={})=>{if(!e.source||!e.target)return n.onError?.(`006`,oo.error006()),t;let r=n.getEdgeId||Cs,i;return i=yo(e)?{...e}:{...e,id:r(e)},ws(i,t)?t:(i.sourceHandle===null&&delete i.sourceHandle,i.targetHandle===null&&delete i.targetHandle,t.concat(i))};function Es({sourceX:e,sourceY:t,targetX:n,targetY:r}){let[i,a,o,s]=bs({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,i,a,o,s]}var Ds={[Z.Left]:{x:-1,y:0},[Z.Right]:{x:1,y:0},[Z.Top]:{x:0,y:-1},[Z.Bottom]:{x:0,y:1}},Os=({source:e,sourcePosition:t=Z.Bottom,target:n})=>t===Z.Left||t===Z.Right?e.xMath.sqrt((t.x-e.x)**2+(t.y-e.y)**2);function As({source:e,sourcePosition:t=Z.Bottom,target:n,targetPosition:r=Z.Top,center:i,offset:a,stepPosition:o}){let s=Ds[t],c=Ds[r],l={x:e.x+s.x*a,y:e.y+s.y*a},u={x:n.x+c.x*a,y:n.y+c.y*a},d=Os({source:l,sourcePosition:t,target:u}),f=d.x===0?`y`:`x`,p=d[f],m=[],h,g,_={x:0,y:0},v={x:0,y:0},[,,y,b]=bs({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(s[f]*c[f]===-1){f===`x`?(h=i.x??l.x+(u.x-l.x)*o,g=i.y??(l.y+u.y)/2):(h=i.x??(l.x+u.x)/2,g=i.y??l.y+(u.y-l.y)*o);let e=[{x:h,y:l.y},{x:h,y:u.y}],t=[{x:l.x,y:g},{x:u.x,y:g}];m=s[f]===p?f===`x`?e:t:f===`x`?t:e}else{let i=[{x:l.x,y:u.y}],o=[{x:u.x,y:l.y}];if(m=f===`x`?s.x===p?o:i:s.y===p?i:o,t===r){let t=Math.abs(e[f]-n[f]);if(t<=a){let r=Math.min(a-1,a-t);s[f]===p?_[f]=(l[f]>e[f]?-1:1)*r:v[f]=(u[f]>n[f]?-1:1)*r}}if(t!==r){let e=f===`x`?`y`:`x`,t=s[f]===c[e],n=l[e]>u[e],r=l[e]=Math.max(Math.abs(d.y-m[0].y),Math.abs(y.y-m[0].y))?(h=(d.x+y.x)/2,g=m[0].y):(h=m[0].x,g=(d.y+y.y)/2)}let x={x:l.x+_.x,y:l.y+_.y},S={x:u.x+v.x,y:u.y+v.y};return[[e,...x.x!==m[0].x||x.y!==m[0].y?[x]:[],...m,...S.x!==m[m.length-1].x||S.y!==m[m.length-1].y?[S]:[],n],h,g,y,b]}function js(e,t,n,r){let i=Math.min(ks(e,t)/2,ks(t,n)/2,r),{x:a,y:o}=t;if(e.x===a&&a===n.x||e.y===o&&o===n.y)return`L${a} ${o}`;if(e.y===o){let t=e.xe.id===t):e[0])||null}function Rs(e,t){return e?typeof e==`string`?e:`${t?`${t}__`:``}${Object.keys(e).sort().map(t=>`${t}=${e[t]}`).join(`&`)}`:``}function zs(e,{id:t,defaultColor:n,defaultMarkerStart:r,defaultMarkerEnd:i}){let a=new Set;return e.reduce((e,o)=>([o.markerStart||r,o.markerEnd||i].forEach(r=>{if(r&&typeof r==`object`){let i=Rs(r,t);a.has(i)||(e.push({id:i,color:r.color||n,...r}),a.add(i))}}),e),[]).sort((e,t)=>e.id.localeCompare(t.id))}var Bs=1e3,Vs=10,Hs={nodeOrigin:[0,0],nodeExtent:so,elevateNodesOnSelect:!0,zIndexMode:`basic`,defaults:{}},Us={...Hs,checkEquality:!0};function Ws(e,t){let n={...e};for(let e in t)t[e]!==void 0&&(n[e]=t[e]);return n}function Gs(e,t,n){let r=Ws(Hs,n);for(let n of e.values())if(n.parentId)Xs(n,e,t,r);else{let e=Mo(So(n,r.nodeOrigin),ts(n.extent)?n.extent:r.nodeExtent,ns(n));n.internals.positionAbsolute=e}}function Ks(e,t){if(!e.handles)return e.measured?t?.internals.handleBounds:void 0;let n=[],r=[];for(let t of e.handles){let i={id:t.id,width:t.width??1,height:t.height??1,nodeId:e.id,x:t.x,y:t.y,position:t.position,type:t.type};t.type===`source`?n.push(i):t.type===`target`&&r.push(i)}return{source:n,target:r}}function qs(e){return e===`manual`}function Js(e,t,n,r={}){let i=Ws(Us,r),a={i:0},o=new Map(t),s=i?.elevateNodesOnSelect&&!qs(i.zIndexMode)?Bs:0,c=e.length>0,l=!1;t.clear(),n.clear();for(let u of e){let e=o.get(u.id);if(i.checkEquality&&u===e?.internals.userNode)t.set(u.id,e);else{let n=Mo(So(u,i.nodeOrigin),ts(u.extent)?u.extent:i.nodeExtent,ns(u));e={...i.defaults,...u,measured:{width:u.measured?.width,height:u.measured?.height},internals:{positionAbsolute:n,handleBounds:Ks(u,e),z:Zs(u,s,i.zIndexMode),userNode:u}},t.set(u.id,e)}(e.measured===void 0||e.measured.width===void 0||e.measured.height===void 0)&&!e.hidden&&(c=!1),u.parentId&&Xs(e,t,n,r,a),l||=u.selected??!1}return{nodesInitialized:c,hasSelectedNodes:l}}function Ys(e,t){if(!e.parentId)return;let n=t.get(e.parentId);n?n.set(e.id,e):t.set(e.parentId,new Map([[e.id,e]]))}function Xs(e,t,n,r,i){let{elevateNodesOnSelect:a,nodeOrigin:o,nodeExtent:s,zIndexMode:c}=Ws(Hs,r),l=e.parentId,u=t.get(l);if(!u){console.warn(`Parent node ${l} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}Ys(e,n),i&&!u.parentId&&u.internals.rootParentIndex===void 0&&c===`auto`&&(u.internals.rootParentIndex=++i.i,u.internals.z=u.internals.z+i.i*Vs),i&&u.internals.rootParentIndex!==void 0&&(i.i=u.internals.rootParentIndex);let{x:d,y:f,z:p}=Qs(e,u,o,s,a&&!qs(c)?Bs:0,c),{positionAbsolute:m}=e.internals,h=d!==m.x||f!==m.y;(h||p!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:h?{x:d,y:f}:m,z:p}})}function Zs(e,t,n){let r=Go(e.zIndex)?e.zIndex:0;return qs(n)?r:r+(e.selected?t:0)}function Qs(e,t,n,r,i,a){let{x:o,y:s}=t.internals.positionAbsolute,c=ns(e),l=So(e,n),u=ts(e.extent)?Mo(l,e.extent,c):l,d=Mo({x:o+u.x,y:s+u.y},r,c);e.extent===`parent`&&(d=No(d,c,t));let f=Zs(e,i,a),p=t.internals.z??0;return{x:d.x,y:d.y,z:p>=f?p+1:f}}function $s(e,t,n,r=[0,0]){let i=[],a=new Map;for(let n of e){let e=t.get(n.parentId);if(!e)continue;let r=Vo(a.get(n.parentId)?.expandedRect??zo(e),n.rect);a.set(n.parentId,{expandedRect:r,parent:e})}return a.size>0&&a.forEach(({expandedRect:t,parent:a},o)=>{let s=a.internals.positionAbsolute,c=ns(a),l=a.origin??r,u=t.x0||d>0||m||h)&&(i.push({id:o,type:`position`,position:{x:a.position.x-u+m,y:a.position.y-d+h}}),n.get(o)?.forEach(t=>{e.some(e=>e.id===t.id)||i.push({id:t.id,type:`position`,position:{x:t.position.x+u,y:t.position.y+d}})})),(c.width0){let e=$s(f,t,n,i);l.push(...e)}return{changes:l,updatedInternals:c}}async function tc({delta:e,panZoom:t,transform:n,translateExtent:r,width:i,height:a}){if(!t||!e.x&&!e.y)return!1;let o=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[i,a]],r);return!!o&&(o.x!==n[0]||o.y!==n[1]||o.k!==n[2])}function nc(e,t,n,r,i,a){let o=i,s=r.get(o)||new Map;r.set(o,s.set(n,t)),o=`${i}-${e}`;let c=r.get(o)||new Map;if(r.set(o,c.set(n,t)),a){o=`${i}-${e}-${a}`;let s=r.get(o)||new Map;r.set(o,s.set(n,t))}}function rc(e,t,n){e.clear(),t.clear();for(let r of n){let{source:n,target:i,sourceHandle:a=null,targetHandle:o=null}=r,s={edgeId:r.id,source:n,target:i,sourceHandle:a,targetHandle:o},c=`${n}-${a}--${i}-${o}`;nc(`source`,s,`${i}-${o}--${n}-${a}`,e,n,a),nc(`target`,s,c,e,i,o),t.set(r.id,r)}}function ic(e,t){if(!e.parentId)return!1;let n=t.get(e.parentId);return n?n.selected?!0:ic(n,t):!1}function ac(e,t,n){let r=e;do{if(r?.matches?.(t))return!0;if(r===n)return!1;r=r?.parentElement}while(r);return!1}function oc(e,t,n,r){let i=new Map;for(let[a,o]of e)if((o.selected||o.id===r)&&(!o.parentId||!ic(o,e))&&(o.draggable||t&&o.draggable===void 0)){let t=e.get(a);t&&i.set(a,{id:a,position:t.position||{x:0,y:0},distance:{x:n.x-t.internals.positionAbsolute.x,y:n.y-t.internals.positionAbsolute.y},extent:t.extent,parentId:t.parentId,origin:t.origin,expandParent:t.expandParent,internals:{positionAbsolute:t.internals.positionAbsolute||{x:0,y:0}},measured:{width:t.measured.width??0,height:t.measured.height??0}})}return i}function sc({nodeId:e,dragItems:t,nodeLookup:n,dragging:r=!0}){let i=[];for(let[e,a]of t){let t=n.get(e)?.internals.userNode;t&&i.push({...t,position:a.position,dragging:r})}if(!e)return[i[0],i];let a=n.get(e)?.internals.userNode;return[a?{...a,position:t.get(e)?.position||a.position,dragging:r}:i[0],i]}function cc({dragItems:e,snapGrid:t,x:n,y:r}){let i=e.values().next().value;if(!i)return null;let a={x:n-i.distance.x,y:r-i.distance.y},o=qo(a,t);return{x:o.x-a.x,y:o.y-a.y}}function lc({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:r,onDragStop:i}){let a={x:null,y:null},o=0,s=new Map,c=!1,l={x:0,y:0},u=null,d=!1,f=null,p=!1,m=!1,h=null;function g({noDragClassName:g,handleSelector:_,domNode:v,isSelectable:y,nodeId:b,nodeClickDistance:x=0}){f=On(v);function S({x:e,y:n}){let{nodeLookup:i,nodeExtent:o,snapGrid:c,snapToGrid:l,nodeOrigin:u,onNodeDrag:d,onSelectionDrag:f,onError:p,updateNodePositions:g}=t();a={x:e,y:n};let _=!1,v=s.size>1,y=v&&o?Lo(wo(s)):null,x=v&&l?cc({dragItems:s,snapGrid:c,x:e,y:n}):null;for(let[t,r]of s){if(!i.has(t))continue;let a={x:e-r.distance.x,y:n-r.distance.y};l&&(a=x?{x:Math.round(a.x+x.x),y:Math.round(a.y+x.y)}:qo(a,c));let s=null;if(v&&o&&!r.extent&&y){let{positionAbsolute:e}=r.internals,t=e.x-y.x+o[0][0],n=e.x+r.measured.width-y.x2+o[1][0],i=e.y-y.y+o[0][1],a=e.y+r.measured.height-y.y2+o[1][1];s=[[t,i],[n,a]]}let{position:d,positionAbsolute:f}=ko({nodeId:t,nextPosition:a,nodeLookup:i,nodeExtent:s||o,nodeOrigin:u,onError:p});_=_||r.position.x!==d.x||r.position.y!==d.y,r.position=d,r.internals.positionAbsolute=f}if(m||=_,_&&(g(s,!0),h&&(r||d||!b&&f))){let[e,t]=sc({nodeId:b,dragItems:s,nodeLookup:i});r?.(h,s,e,t),d?.(h,e,t),b||f?.(h,t)}}async function C(){if(!u)return;let{transform:e,panBy:n,autoPanSpeed:r,autoPanOnNodeDrag:i}=t();if(!i){c=!1,cancelAnimationFrame(o);return}let[s,d]=Fo(l,u,r);(s!==0||d!==0)&&(a.x=(a.x??0)-s/e[2],a.y=(a.y??0)-d/e[2],await n({x:s,y:d})&&S(a)),o=requestAnimationFrame(C)}function w(r){let{nodeLookup:i,multiSelectionActive:o,nodesDraggable:c,transform:l,snapGrid:f,snapToGrid:p,selectNodesOnDrag:m,onNodeDragStart:h,onSelectionDragStart:g,unselectNodesAndEdges:_}=t();d=!0,(!m||!y)&&!o&&b&&(i.get(b)?.selected||_()),y&&m&&b&&e?.(b);let v=cs(r.sourceEvent,{transform:l,snapGrid:f,snapToGrid:p,containerBounds:u});if(a=v,s=oc(i,c,v,b),s.size>0&&(n||h||!b&&g)){let[e,t]=sc({nodeId:b,dragItems:s,nodeLookup:i});n?.(r.sourceEvent,s,e,t),h?.(r.sourceEvent,e,t),b||g?.(r.sourceEvent,t)}}let T=Un().clickDistance(x).on(`start`,e=>{let{domNode:n,nodeDragThreshold:r,transform:i,snapGrid:o,snapToGrid:s}=t();u=n?.getBoundingClientRect()||null,p=!1,m=!1,h=e.sourceEvent,r===0&&w(e),a=cs(e.sourceEvent,{transform:i,snapGrid:o,snapToGrid:s,containerBounds:u}),l=ms(e.sourceEvent,u)}).on(`drag`,e=>{let{autoPanOnNodeDrag:n,transform:r,snapGrid:i,snapToGrid:o,nodeDragThreshold:f,nodeLookup:m}=t(),g=cs(e.sourceEvent,{transform:r,snapGrid:i,snapToGrid:o,containerBounds:u});if(h=e.sourceEvent,(e.sourceEvent.type===`touchmove`&&e.sourceEvent.touches.length>1||b&&!m.has(b))&&(p=!0),!p){if(!c&&n&&d&&(c=!0,C()),!d){let t=ms(e.sourceEvent,u),n=t.x-l.x,r=t.y-l.y;Math.sqrt(n*n+r*r)>f&&w(e)}(a.x!==g.xSnapped||a.y!==g.ySnapped)&&s&&d&&(l=ms(e.sourceEvent,u),S(g))}}).on(`end`,e=>{if(!d||p){p&&s.size>0&&t().updateNodePositions(s,!1);return}if(c=!1,d=!1,cancelAnimationFrame(o),s.size>0){let{nodeLookup:n,updateNodePositions:r,onNodeDragStop:a,onSelectionDragStop:o}=t();if(m&&=(r(s,!1),!1),i||a||!b&&o){let[t,r]=sc({nodeId:b,dragItems:s,nodeLookup:n,dragging:!1});i?.(e.sourceEvent,s,t,r),a?.(e.sourceEvent,t,r),b||o?.(e.sourceEvent,r)}}}).filter(e=>{let t=e.target;return!e.button&&(!g||!ac(t,`.${g}`,v))&&(!_||ac(t,_,v))});f.call(T)}function _(){f?.on(`.drag`,null)}return{update:g,destroy:_}}function uc(e,t,n){let r=[],i={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(let e of t.values())Uo(i,zo(e))>0&&r.push(e);return r}var dc=250;function fc(e,t,n,r){let i=[],a=1/0,o=uc(e,n,t+dc);for(let n of o){let o=[...n.internals.handleBounds?.source??[],...n.internals.handleBounds?.target??[]];for(let s of o){if(r.nodeId===s.nodeId&&r.type===s.type&&r.id===s.id)continue;let{x:o,y:c}=Is(n,s,s.position,!0),l=Math.sqrt((o-e.x)**2+(c-e.y)**2);l>t||(l1){let e=r.type===`source`?`target`:`source`;return i.find(t=>t.type===e)??i[0]}return i[0]}function pc(e,t,n,r,i,a=!1){let o=r.get(e);if(!o)return null;let s=i===`strict`?o.internals.handleBounds?.[t]:[...o.internals.handleBounds?.source??[],...o.internals.handleBounds?.target??[]],c=(n?s?.find(e=>e.id===n):s?.[0])??null;return c&&a?{...c,...Is(o,c,c.position,!0)}:c}function mc(e,t){return e||(t?.classList.contains(`target`)?`target`:t?.classList.contains(`source`)?`source`:null)}function hc(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}var gc=()=>!0;function _c(e,{connectionMode:t,connectionRadius:n,handleId:r,nodeId:i,edgeUpdaterType:a,isTarget:o,domNode:s,nodeLookup:c,lib:l,autoPanOnConnect:u,flowId:d,panBy:f,cancelConnection:p,onConnectStart:m,onConnect:h,onConnectEnd:g,isValidConnection:_=gc,onReconnectEnd:v,updateConnection:y,getTransform:b,getFromHandle:x,autoPanSpeed:S,dragThreshold:C=1,handleDomNode:w}){let T=us(e.target),E=0,D,{x:O,y:k}=ms(e),A=mc(a,w),j=s?.getBoundingClientRect(),M=!1;if(!j||!A)return;let N=pc(i,A,r,c,t);if(!N)return;let P=ms(e,j),F=!1,I=null,L=!1,R=null;function z(){if(!u||!j)return;let[e,t]=Fo(P,j,S);f({x:e,y:t}),E=requestAnimationFrame(z)}let B={...N,nodeId:i,type:A,position:N.position},V=c.get(i),ee={inProgress:!0,isValid:null,from:Is(V,B,Z.Left,!0),fromHandle:B,fromPosition:B.position,fromNode:V,to:P,toHandle:null,toPosition:_o[B.position],toNode:null,pointer:P};function te(){M=!0,y(ee),m?.(e,{nodeId:i,handleId:r,handleType:A})}C===0&&te();function H(e){if(!M){let{x:t,y:n}=ms(e),r=t-O,i=n-k;if(!(r*r+i*i>C*C))return;te()}if(!x()||!B){U(e);return}let a=b();P=ms(e,j),D=fc(Jo(P,a,!1,[1,1]),n,c,B),F||=(z(),!0);let s=vc(e,{handle:D,connectionMode:t,fromNodeId:i,fromHandleId:r,fromType:o?`target`:`source`,isValidConnection:_,doc:T,lib:l,flowId:d,nodeLookup:c});R=s.handleDomNode,I=s.connection,L=hc(!!D,s.isValid);let u=c.get(i),f=u?Is(u,B,Z.Left,!0):ee.from,p={...ee,from:f,isValid:L,to:s.toHandle&&L?Yo({x:s.toHandle.x,y:s.toHandle.y},a):P,toHandle:s.toHandle,toPosition:L&&s.toHandle?s.toHandle.position:_o[B.position],toNode:s.toHandle?c.get(s.toHandle.nodeId):null,pointer:P};y(p),ee=p}function U(e){if(!(`touches`in e&&e.touches.length>0)){if(M){(D||R)&&I&&L&&h?.(I);let{inProgress:t,...n}=ee,r={...n,toPosition:ee.toHandle?ee.toPosition:null};g?.(e,r),a&&v?.(e,r)}p(),cancelAnimationFrame(E),F=!1,L=!1,I=null,R=null,T.removeEventListener(`mousemove`,H),T.removeEventListener(`mouseup`,U),T.removeEventListener(`touchmove`,H),T.removeEventListener(`touchend`,U)}}T.addEventListener(`mousemove`,H),T.addEventListener(`mouseup`,U),T.addEventListener(`touchmove`,H),T.addEventListener(`touchend`,U)}function vc(e,{handle:t,connectionMode:n,fromNodeId:r,fromHandleId:i,fromType:a,doc:o,lib:s,flowId:c,isValidConnection:l=gc,nodeLookup:u}){let d=a===`target`,f=t?o.querySelector(`.${s}-flow__handle[data-id="${c}-${t?.nodeId}-${t?.id}-${t?.type}"]`):null,{x:p,y:m}=ms(e),h=o.elementFromPoint(p,m),g=h?.classList.contains(`${s}-flow__handle`)?h:f,_={handleDomNode:g,isValid:!1,connection:null,toHandle:null};if(g){let e=mc(void 0,g),t=g.getAttribute(`data-nodeid`),a=g.getAttribute(`data-handleid`),o=g.classList.contains(`connectable`),s=g.classList.contains(`connectableend`);if(!t||!e)return _;let c={source:d?t:r,sourceHandle:d?a:i,target:d?r:t,targetHandle:d?i:a};_.connection=c,_.isValid=o&&s&&(n===uo.Strict?d&&e===`source`||!d&&e===`target`:t!==r||a!==i)&&l(c),_.toHandle=pc(t,e,a,u,n,!0)}return _}var yc={onPointerDown:_c,isValid:vc};function bc({domNode:e,panZoom:t,getTransform:n,getViewScale:r}){let i=On(e);function a({translateExtent:e,width:a,height:o,zoomStep:s=1,pannable:c=!0,zoomable:l=!0,inversePan:u=!1}){let d=e=>{if(e.sourceEvent.type!==`wheel`||!t)return;let r=n(),i=e.sourceEvent.ctrlKey&&es()?10:1,a=-e.sourceEvent.deltaY*(e.sourceEvent.deltaMode===1?.05:e.sourceEvent.deltaMode?1:.002)*s,o=r[2]*2**(a*i);t.scaleTo(o)},f=[0,0],p=ao().on(`start`,e=>{(e.sourceEvent.type===`mousedown`||e.sourceEvent.type===`touchstart`)&&(f=[e.sourceEvent.clientX??e.sourceEvent.touches[0].clientX,e.sourceEvent.clientY??e.sourceEvent.touches[0].clientY])}).on(`zoom`,c?i=>{let s=n();if(i.sourceEvent.type!==`mousemove`&&i.sourceEvent.type!==`touchmove`||!t)return;let c=[i.sourceEvent.clientX??i.sourceEvent.touches[0].clientX,i.sourceEvent.clientY??i.sourceEvent.touches[0].clientY],l=[c[0]-f[0],c[1]-f[1]];f=c;let d=r()*Math.max(s[2],Math.log(s[2]))*(u?-1:1),p={x:s[0]-l[0]*d,y:s[1]-l[1]*d},m=[[0,0],[a,o]];t.setViewportConstrained({x:p.x,y:p.y,zoom:s[2]},m,e)}:null).on(`zoom.wheel`,l?d:null);i.call(p,{})}function o(){i.on(`zoom`,null)}return{update:a,destroy:o,pointer:An}}var xc=e=>({x:e.x,y:e.y,zoom:e.k}),Sc=({x:e,y:t,zoom:n})=>Ya.translate(e,t).scale(n),Cc=(e,t)=>e.target.closest(`.${t}`),wc=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),Tc=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,Ec=(e,t=0,n=Tc,r=()=>{})=>{let i=typeof t==`number`&&t>0;return i||r(),i?e.transition().duration(t).ease(n).on(`end`,r):e},Dc=e=>{let t=e.ctrlKey&&es()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function Oc({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:r,panOnScrollMode:i,panOnScrollSpeed:a,zoomOnPinch:o,onPanZoomStart:s,onPanZoom:c,onPanZoomEnd:l}){return u=>{if(Cc(u,t))return u.ctrlKey&&u.preventDefault(),!1;u.preventDefault(),u.stopImmediatePropagation();let d=n.property(`__zoom`).k||1;if(u.ctrlKey&&o){let e=An(u),t=d*2**Dc(u);r.scaleTo(n,t,e,u);return}let f=u.deltaMode===1?20:1,p=i===fo.Vertical?0:u.deltaX*f,m=i===fo.Horizontal?0:u.deltaY*f;!es()&&u.shiftKey&&i!==fo.Vertical&&(p=u.deltaY*f,m=0),r.translateBy(n,-(p/d)*a,-(m/d)*a,{internal:!0});let h=xc(n.property(`__zoom`));clearTimeout(e.panScrollTimeout),e.isPanScrolling?(c?.(u,h),e.panScrollTimeout=setTimeout(()=>{l?.(u,h),e.isPanScrolling=!1},150)):(e.isPanScrolling=!0,s?.(u,h))}}function kc({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(r,i){let a=r.type===`wheel`,o=!t&&a&&!r.ctrlKey,s=Cc(r,e);if(r.ctrlKey&&a&&s&&r.preventDefault(),o||s)return null;r.preventDefault(),n.call(this,r,i)}}function Ac({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return r=>{if(r.sourceEvent?.internal)return;let i=xc(r.transform);e.mouseButton=r.sourceEvent?.button||0,e.isZoomingOrPanning=!0,e.prevViewport=i,r.sourceEvent?.type===`mousedown`&&t(!0),n&&n?.(r.sourceEvent,i)}}function jc({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:r,onPanZoom:i}){return a=>{e.usedRightMouseButton=!!(n&&wc(t,e.mouseButton??0)),a.sourceEvent?.sync||r([a.transform.x,a.transform.y,a.transform.k]),i&&!a.sourceEvent?.internal&&i?.(a.sourceEvent,xc(a.transform))}}function Mc({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:r,onPanZoomEnd:i,onPaneContextMenu:a}){return o=>{if(!o.sourceEvent?.internal&&(e.isZoomingOrPanning=!1,a&&wc(t,e.mouseButton??0)&&!e.usedRightMouseButton&&o.sourceEvent&&a(o.sourceEvent),e.usedRightMouseButton=!1,r(!1),i)){let t=xc(o.transform);e.prevViewport=t,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{i?.(o.sourceEvent,t)},n?150:0)}}}function Nc({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:n,panOnDrag:r,panOnScroll:i,zoomOnDoubleClick:a,userSelectionActive:o,noWheelClassName:s,noPanClassName:c,lib:l,connectionInProgress:u}){return d=>{let f=e||t,p=n&&d.ctrlKey,m=d.type===`wheel`;if(d.button===1&&d.type===`mousedown`&&(Cc(d,`${l}-flow__node`)||Cc(d,`${l}-flow__edge`)))return!0;if(!r&&!f&&!i&&!a&&!n||o||u&&!m||Cc(d,s)&&m||Cc(d,c)&&(!m||i&&m&&!e)||!n&&d.ctrlKey&&m)return!1;if(!n&&d.type===`touchstart`&&d.touches?.length>1)return d.preventDefault(),!1;if(!f&&!i&&!p&&m||!r&&(d.type===`mousedown`||d.type===`touchstart`)||Array.isArray(r)&&!r.includes(d.button)&&d.type===`mousedown`)return!1;let h=Array.isArray(r)&&r.includes(d.button)||!d.button||d.button<=1;return(!d.ctrlKey||m)&&h}}function Pc({domNode:e,minZoom:t,maxZoom:n,translateExtent:r,viewport:i,onPanZoom:a,onPanZoomStart:o,onPanZoomEnd:s,onDraggingChange:c}){let l={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},u=e.getBoundingClientRect(),d=ao().scaleExtent([t,n]).translateExtent(r),f=On(e).call(d);v({x:i.x,y:i.y,zoom:jo(i.zoom,t,n)},[[0,0],[u.width,u.height]],r);let p=f.on(`wheel.zoom`),m=f.on(`dblclick.zoom`);d.wheelDelta(Dc);async function h(e,t){return f?new Promise(n=>{d?.interpolate(t?.interpolate===`linear`?Kr:oi).transform(Ec(f,t?.duration,t?.ease,()=>n(!0)),e)}):!1}function g({noWheelClassName:e,noPanClassName:t,onPaneContextMenu:n,userSelectionActive:r,panOnScroll:i,panOnDrag:u,panOnScrollMode:h,panOnScrollSpeed:g,preventScrolling:v,zoomOnPinch:y,zoomOnScroll:b,zoomOnDoubleClick:x,zoomActivationKeyPressed:S,lib:C,onTransformChange:w,connectionInProgress:T,paneClickDistance:E,selectionOnDrag:D}){r&&!l.isZoomingOrPanning&&_();let O=i&&!S&&!r;d.clickDistance(D?1/0:!Go(E)||E<0?0:E);let k=O?Oc({zoomPanValues:l,noWheelClassName:e,d3Selection:f,d3Zoom:d,panOnScrollMode:h,panOnScrollSpeed:g,zoomOnPinch:y,onPanZoomStart:o,onPanZoom:a,onPanZoomEnd:s}):kc({noWheelClassName:e,preventScrolling:v,d3ZoomHandler:p});f.on(`wheel.zoom`,k,{passive:!1});let A=Ac({zoomPanValues:l,onDraggingChange:c,onPanZoomStart:o});d.on(`start`,A);let j=jc({zoomPanValues:l,panOnDrag:u,onPaneContextMenu:!!n,onPanZoom:a,onTransformChange:w});d.on(`zoom`,j);let M=Mc({zoomPanValues:l,panOnDrag:u,panOnScroll:i,onPaneContextMenu:n,onPanZoomEnd:s,onDraggingChange:c});d.on(`end`,M);let N=Nc({zoomActivationKeyPressed:S,panOnDrag:u,zoomOnScroll:b,panOnScroll:i,zoomOnDoubleClick:x,zoomOnPinch:y,userSelectionActive:r,noPanClassName:t,noWheelClassName:e,lib:C,connectionInProgress:T});d.filter(N),x?f.on(`dblclick.zoom`,m):f.on(`dblclick.zoom`,null)}function _(){d.on(`zoom`,null)}async function v(e,t,n){let r=Sc(e),i=d?.constrain()(r,t,n);return i&&await h(i),i}async function y(e,t){let n=Sc(e);return await h(n,t),n}function b(e){if(f){let t=Sc(e),n=f.property(`__zoom`);(n.k!==e.zoom||n.x!==e.x||n.y!==e.y)&&d?.transform(f,t,null,{sync:!0})}}function x(){let e=f?Xa(f.node()):{x:0,y:0,k:1};return{x:e.x,y:e.y,zoom:e.k}}async function S(e,t){return f?new Promise(n=>{d?.interpolate(t?.interpolate===`linear`?Kr:oi).scaleTo(Ec(f,t?.duration,t?.ease,()=>n(!0)),e)}):!1}async function C(e,t){return f?new Promise(n=>{d?.interpolate(t?.interpolate===`linear`?Kr:oi).scaleBy(Ec(f,t?.duration,t?.ease,()=>n(!0)),e)}):!1}function w(e){d?.scaleExtent(e)}function T(e){d?.translateExtent(e)}function E(e){let t=!Go(e)||e<0?0:e;d?.clickDistance(t)}return{update:g,destroy:_,setViewport:y,setViewportConstrained:v,getViewport:x,scaleTo:S,scaleBy:C,setScaleExtent:w,setTranslateExtent:T,syncViewport:b,setClickDistance:E}}var Fc;(function(e){e.Line=`line`,e.Handle=`handle`})(Fc||={});function Ic({width:e,prevWidth:t,height:n,prevHeight:r,affectsX:i,affectsY:a}){let o=e-t,s=n-r,c=[o>0?1:o<0?-1:0,s>0?1:s<0?-1:0];return o&&i&&(c[0]*=-1),s&&a&&(c[1]*=-1),c}function Lc(e){return{isHorizontal:e.includes(`right`)||e.includes(`left`),isVertical:e.includes(`bottom`)||e.includes(`top`),affectsX:e.includes(`left`),affectsY:e.includes(`top`)}}function Rc(e,t){return Math.max(0,t-e)}function zc(e,t){return Math.max(0,e-t)}function Bc(e,t,n){return Math.max(0,t-e,e-n)}function Vc(e,t){return e?!t:t}function Hc(e,t,n,r,i,a,o,s){let{affectsX:c,affectsY:l}=t,{isHorizontal:u,isVertical:d}=t,f=u&&d,{xSnapped:p,ySnapped:m}=n,{minWidth:h,maxWidth:g,minHeight:_,maxHeight:v}=r,{x:y,y:b,width:x,height:S,aspectRatio:C}=e,w=Math.floor(u?p-e.pointerX:0),T=Math.floor(d?m-e.pointerY:0),E=x+(c?-w:w),D=S+(l?-T:T),O=-a[0]*x,k=-a[1]*S,A=Bc(E,h,g),j=Bc(D,_,v);if(o){let e=0,t=0;c&&w<0?e=Rc(y+w+O,o[0][0]):!c&&w>0&&(e=zc(y+E+O,o[1][0])),l&&T<0?t=Rc(b+T+k,o[0][1]):!l&&T>0&&(t=zc(b+D+k,o[1][1])),A=Math.max(A,e),j=Math.max(j,t)}if(s){let e=0,t=0;c&&w>0?e=zc(y+w,s[0][0]):!c&&w<0&&(e=Rc(y+E,s[1][0])),l&&T>0?t=zc(b+T,s[0][1]):!l&&T<0&&(t=Rc(b+D,s[1][1])),A=Math.max(A,e),j=Math.max(j,t)}if(i){if(u){let e=Bc(E/C,_,v)*C;if(A=Math.max(A,e),o){let e=0;e=!c&&!l||c&&!l&&f?zc(b+k+E/C,o[1][1])*C:Rc(b+k+(c?w:-w)/C,o[0][1])*C,A=Math.max(A,e)}if(s){let e=0;e=!c&&!l||c&&!l&&f?Rc(b+E/C,s[1][1])*C:zc(b+(c?w:-w)/C,s[0][1])*C,A=Math.max(A,e)}}if(d){let e=Bc(D*C,h,g)/C;if(j=Math.max(j,e),o){let e=0;e=!c&&!l||l&&!c&&f?zc(y+D*C+O,o[1][0])/C:Rc(y+(l?T:-T)*C+O,o[0][0])/C,j=Math.max(j,e)}if(s){let e=0;e=!c&&!l||l&&!c&&f?Rc(y+D*C,s[1][0])/C:zc(y+(l?T:-T)*C,s[0][0])/C,j=Math.max(j,e)}}}T+=T<0?j:-j,w+=w<0?A:-A,i&&(f?E>D*C?T=(Vc(c,l)?-w:w)/C:w=(Vc(c,l)?-T:T)*C:u?(T=w/C,l=c):(w=T*C,c=l));let M=c?y+w:y,N=l?b+T:b;return{width:x+(c?-w:w),height:S+(l?-T:T),x:a[0]*w*(c?-1:1)+M,y:a[1]*T*(l?-1:1)+N}}var Uc={width:0,height:0,x:0,y:0},Wc={...Uc,pointerX:0,pointerY:0,aspectRatio:1};function Gc(e,t,n){let r=t.position.x+e.position.x,i=t.position.y+e.position.y,a=e.measured.width??0,o=e.measured.height??0,s=n[0]*a,c=n[1]*o;return[[r-s,i-c],[r+a-s,i+o-c]]}function Kc({domNode:e,nodeId:t,getStoreItems:n,onChange:r,onEnd:i}){let a=On(e),o={controlDirection:Lc(`bottom-right`),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function s({controlPosition:e,boundaries:s,keepAspectRatio:c,resizeDirection:l,onResizeStart:u,onResize:d,onResizeEnd:f,shouldResize:p}){let m={...Uc},h={...Wc};o={boundaries:s,resizeDirection:l,keepAspectRatio:c,controlDirection:Lc(e)};let g,_=null,v=[],y,b,x,S=!1,C=Un().on(`start`,e=>{let{nodeLookup:r,transform:i,snapGrid:a,snapToGrid:o,nodeOrigin:s,paneDomNode:c}=n();if(g=r.get(t),!g)return;_=c?.getBoundingClientRect()??null;let{xSnapped:l,ySnapped:d}=cs(e.sourceEvent,{transform:i,snapGrid:a,snapToGrid:o,containerBounds:_});m={width:g.measured.width??0,height:g.measured.height??0,x:g.position.x??0,y:g.position.y??0},h={...m,pointerX:l,pointerY:d,aspectRatio:m.width/m.height},y=void 0,b=ts(g.extent)?g.extent:void 0,g.parentId&&(g.extent===`parent`||g.expandParent)&&(y=r.get(g.parentId)),y&&g.extent===`parent`&&(b=[[0,0],[y.measured.width,y.measured.height]]),v=[],x=void 0;for(let[e,n]of r)if(n.parentId===t&&(v.push({id:e,position:{...n.position},extent:n.extent}),n.extent===`parent`||n.expandParent)){let e=Gc(n,g,n.origin??s);x=x?[[Math.min(e[0][0],x[0][0]),Math.min(e[0][1],x[0][1])],[Math.max(e[1][0],x[1][0]),Math.max(e[1][1],x[1][1])]]:e}u?.(e,{...m})}).on(`drag`,e=>{let{transform:t,snapGrid:i,snapToGrid:a,nodeOrigin:s}=n(),c=cs(e.sourceEvent,{transform:t,snapGrid:i,snapToGrid:a,containerBounds:_}),l=[];if(!g)return;let{x:u,y:f,width:C,height:w}=m,T={},E=g.origin??s,{width:D,height:O,x:k,y:A}=Hc(h,o.controlDirection,c,o.boundaries,o.keepAspectRatio,E,b,x),j=D!==C,M=O!==w,N=k!==u&&j,P=A!==f&&M;if(!N&&!P&&!j&&!M)return;if((N||P||E[0]===1||E[1]===1)&&(T.x=N?k:m.x,T.y=P?A:m.y,m.x=T.x,m.y=T.y,v.length>0)){let e=k-u,t=A-f;for(let n of v)n.position={x:n.position.x-e+E[0]*(D-C),y:n.position.y-t+E[1]*(O-w)},l.push(n)}if((j||M)&&(T.width=j&&(!o.resizeDirection||o.resizeDirection===`horizontal`)?D:m.width,T.height=M&&(!o.resizeDirection||o.resizeDirection===`vertical`)?O:m.height,m.width=T.width,m.height=T.height),y&&g.expandParent){let e=E[0]*(T.width??0);T.x&&T.x{S&&=(f?.(e,{...m}),i?.({...m}),!1)});a.call(C)}function c(){a.on(`.drag`,null)}return{update:s,destroy:c}}var qc=t((e=>{var t=n();function r(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var i=typeof Object.is==`function`?Object.is:r,a=t.useState,o=t.useEffect,s=t.useLayoutEffect,c=t.useDebugValue;function l(e,t){var n=t(),r=a({inst:{value:n,getSnapshot:t}}),i=r[0].inst,l=r[1];return s(function(){i.value=n,i.getSnapshot=t,u(i)&&l({inst:i})},[e,n,t]),o(function(){return u(i)&&l({inst:i}),e(function(){u(i)&&l({inst:i})})},[e]),c(n),n}function u(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!i(e,n)}catch{return!0}}function d(e,t){return t()}var f=typeof window>`u`||window.document===void 0||window.document.createElement===void 0?d:l;e.useSyncExternalStore=t.useSyncExternalStore===void 0?f:t.useSyncExternalStore})),Jc=t(((e,t)=>{t.exports=qc()})),Yc=t((e=>{var t=n(),r=Jc();function i(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var a=typeof Object.is==`function`?Object.is:i,o=r.useSyncExternalStore,s=t.useRef,c=t.useEffect,l=t.useMemo,u=t.useDebugValue;e.useSyncExternalStoreWithSelector=function(e,t,n,r,i){var d=s(null);if(d.current===null){var f={hasValue:!1,value:null};d.current=f}else f=d.current;d=l(function(){function e(e){if(!o){if(o=!0,s=e,e=r(e),i!==void 0&&f.hasValue){var t=f.value;if(i(t,e))return c=t}return c=e}if(t=c,a(s,e))return t;var n=r(e);return i!==void 0&&i(t,n)?(s=e,t):(s=e,c=n)}var o=!1,s,c,l=n===void 0?null:n;return[function(){return e(t())},l===null?void 0:function(){return e(l())}]},[t,n,r,i]);var p=o(e,d[0],d[1]);return c(function(){f.hasValue=!0,f.value=p},[p]),u(p),p}})),Xc=e(t(((e,t)=>{t.exports=Yc()}))(),1),Zc=e=>{let t,n=new Set,r=(e,r)=>{let i=typeof e==`function`?e(t):e;if(!Object.is(i,t)){let e=t;t=r??(typeof i!=`object`||!i)?i:Object.assign({},t,i),n.forEach(n=>n(t,e))}},i=()=>t,a={setState:r,getState:i,getInitialState:()=>o,subscribe:e=>(n.add(e),()=>n.delete(e)),destroy:()=>{n.clear()}},o=t=e(r,i,a);return a},Qc=e=>e?Zc(e):Zc,{useDebugValue:$c}=Y.default,{useSyncExternalStoreWithSelector:el}=Xc.default,tl=e=>e;function nl(e,t=tl,n){let r=el(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return $c(r),r}var rl=(e,t)=>{let n=Qc(e),r=(e,r=t)=>nl(n,e,r);return Object.assign(r,n),r},il=(e,t)=>e?rl(e,t):rl;function al(e,t){if(Object.is(e,t))return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(let[n,r]of e)if(!Object.is(r,t.get(n)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}let n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let r of n)if(!Object.prototype.hasOwnProperty.call(t,r)||!Object.is(e[r],t[r]))return!1;return!0}var ol=(0,Y.createContext)(null),sl=ol.Provider,cl=oo.error001(`react`);function Q(e,t){let n=(0,Y.useContext)(ol);if(n===null)throw Error(cl);return nl(n,e,t)}function $(){let e=(0,Y.useContext)(ol);if(e===null)throw Error(cl);return(0,Y.useMemo)(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}var ll={display:`none`},ul={position:`absolute`,width:1,height:1,margin:-1,border:0,padding:0,overflow:`hidden`,clip:`rect(0px, 0px, 0px, 0px)`,clipPath:`inset(100%)`},dl=`react-flow__node-desc`,fl=`react-flow__edge-desc`,pl=`react-flow__aria-live`,ml=e=>e.ariaLiveMessage,hl=e=>e.ariaLabelConfig;function gl({rfId:e}){let t=Q(ml);return(0,J.jsx)(`div`,{id:`${pl}-${e}`,"aria-live":`assertive`,"aria-atomic":`true`,style:ul,children:t})}function _l({rfId:e,disableKeyboardA11y:t}){let n=Q(hl);return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{id:`${dl}-${e}`,style:ll,children:t?n[`node.a11yDescription.default`]:n[`node.a11yDescription.keyboardDisabled`]}),(0,J.jsx)(`div`,{id:`${fl}-${e}`,style:ll,children:n[`edge.a11yDescription.default`]}),!t&&(0,J.jsx)(gl,{rfId:e})]})}var vl=(0,Y.forwardRef)(({position:e=`top-left`,children:t,className:n,style:r,...i},a)=>{let o=`${e}`.split(`-`);return(0,J.jsx)(`div`,{className:Se([`react-flow__panel`,n,...o]),style:r,ref:a,...i,children:t})});vl.displayName=`Panel`;var yl=`https://reactflow.dev?utm_source=attribution`;function bl({proOptions:e,position:t=`bottom-right`}){return e?.hideAttribution?null:(0,J.jsx)(vl,{position:t,className:`react-flow__attribution`,"data-message":`Please only hide this attribution when you are subscribed to React Flow Pro: ${yl}`,children:(0,J.jsx)(`a`,{href:yl,target:`_blank`,rel:`noopener noreferrer`,"aria-label":`React Flow attribution`,children:`React Flow`})})}var xl=e=>{let t=[],n=[];for(let[,n]of e.nodeLookup)n.selected&&t.push(n.internals.userNode);for(let[,t]of e.edgeLookup)t.selected&&n.push(t);return{selectedNodes:t,selectedEdges:n}},Sl=e=>e.id;function Cl(e,t){return al(e.selectedNodes.map(Sl),t.selectedNodes.map(Sl))&&al(e.selectedEdges.map(Sl),t.selectedEdges.map(Sl))}function wl({onSelectionChange:e}){let t=$(),{selectedNodes:n,selectedEdges:r}=Q(xl,Cl);return(0,Y.useEffect)(()=>{let i={nodes:n,edges:r};e?.(i),t.getState().onSelectionChangeHandlers.forEach(e=>e(i))},[n,r,e]),null}var Tl=e=>!!e.onSelectionChangeHandlers;function El({onSelectionChange:e}){let t=Q(Tl);return e||t?(0,J.jsx)(wl,{onSelectionChange:e}):null}var Dl=[0,0],Ol={x:0,y:0,zoom:1},kl=[...`nodes.edges.defaultNodes.defaultEdges.onConnect.onConnectStart.onConnectEnd.onClickConnectStart.onClickConnectEnd.nodesDraggable.autoPanOnNodeFocus.nodesConnectable.nodesFocusable.edgesFocusable.edgesReconnectable.elevateNodesOnSelect.elevateEdgesOnSelect.minZoom.maxZoom.nodeExtent.onNodesChange.onEdgesChange.elementsSelectable.connectionMode.snapGrid.snapToGrid.translateExtent.connectOnClick.defaultEdgeOptions.fitView.fitViewOptions.onNodesDelete.onEdgesDelete.onDelete.onNodeDrag.onNodeDragStart.onNodeDragStop.onSelectionDrag.onSelectionDragStart.onSelectionDragStop.onMoveStart.onMove.onMoveEnd.noPanClassName.nodeOrigin.autoPanOnConnect.autoPanOnNodeDrag.onError.connectionRadius.isValidConnection.selectNodesOnDrag.nodeDragThreshold.connectionDragThreshold.onBeforeDelete.debug.autoPanSpeed.ariaLabelConfig.zIndexMode`.split(`.`),`rfId`],Al=e=>({setNodes:e.setNodes,setEdges:e.setEdges,setMinZoom:e.setMinZoom,setMaxZoom:e.setMaxZoom,setTranslateExtent:e.setTranslateExtent,setNodeExtent:e.setNodeExtent,reset:e.reset,setDefaultNodesAndEdges:e.setDefaultNodesAndEdges}),jl={translateExtent:so,nodeOrigin:Dl,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:`nopan`,rfId:`1`};function Ml(e){let{setNodes:t,setEdges:n,setMinZoom:r,setMaxZoom:i,setTranslateExtent:a,setNodeExtent:o,reset:s,setDefaultNodesAndEdges:c}=Q(Al,al),l=$();(0,Y.useEffect)(()=>(c(e.defaultNodes,e.defaultEdges),()=>{u.current=jl,s()}),[]);let u=(0,Y.useRef)(jl);return(0,Y.useEffect)(()=>{for(let s of kl){let c=e[s];c!==u.current[s]&&e[s]!==void 0&&(s===`nodes`?t(c):s===`edges`?n(c):s===`minZoom`?r(c):s===`maxZoom`?i(c):s===`translateExtent`?a(c):s===`nodeExtent`?o(c):s===`ariaLabelConfig`?l.setState({ariaLabelConfig:ss(c)}):s===`fitView`?l.setState({fitViewQueued:c}):s===`fitViewOptions`?l.setState({fitViewOptions:c}):l.setState({[s]:c}))}u.current=e},kl.map(t=>e[t])),null}function Nl(){return typeof window>`u`||!window.matchMedia?null:window.matchMedia(`(prefers-color-scheme: dark)`)}function Pl(e){let[t,n]=(0,Y.useState)(e===`system`?null:e);return(0,Y.useEffect)(()=>{if(e!==`system`){n(e);return}let t=Nl(),r=()=>n(t?.matches?`dark`:`light`);return r(),t?.addEventListener(`change`,r),()=>{t?.removeEventListener(`change`,r)}},[e]),t===null?Nl()?.matches?`dark`:`light`:t}var Fl=typeof document<`u`?document:null;function Il(e=null,t={target:Fl,actInsideInputWithModifier:!0}){let[n,r]=(0,Y.useState)(!1),i=(0,Y.useRef)(!1),a=(0,Y.useRef)(new Set([])),[o,s]=(0,Y.useMemo)(()=>{if(e!==null){let t=(Array.isArray(e)?e:[e]).filter(e=>typeof e==`string`).map(e=>e.replace(`+`,` +`).replace(` + +`,` ++`).split(` +`));return[t,t.reduce((e,t)=>e.concat(...t),[])]}return[[],[]]},[e]);return(0,Y.useEffect)(()=>{let n=t?.target??Fl,c=t?.actInsideInputWithModifier??!0;if(e!==null){let e=e=>{if(i.current=e.ctrlKey||e.metaKey||e.shiftKey||e.altKey,(!i.current||i.current&&!c)&&fs(e))return!1;let n=Rl(e.code,s);if(a.current.add(e[n]),Ll(o,a.current,!1)){let n=e.composedPath?.()?.[0]||e.target,a=n?.nodeName===`BUTTON`||n?.nodeName===`A`;t.preventDefault!==!1&&(i.current||!a)&&e.preventDefault(),r(!0)}},l=e=>{let t=Rl(e.code,s);Ll(o,a.current,!0)?(r(!1),a.current.clear()):a.current.delete(e[t]),e.key===`Meta`&&a.current.clear(),i.current=!1},u=()=>{a.current.clear(),r(!1)};return n?.addEventListener(`keydown`,e),n?.addEventListener(`keyup`,l),window.addEventListener(`blur`,u),window.addEventListener(`contextmenu`,u),()=>{n?.removeEventListener(`keydown`,e),n?.removeEventListener(`keyup`,l),window.removeEventListener(`blur`,u),window.removeEventListener(`contextmenu`,u)}}},[e,r]),n}function Ll(e,t,n){return e.filter(e=>n||e.length===t.size).some(e=>e.every(e=>t.has(e)))}function Rl(e,t){return t.includes(e)?`code`:`key`}var zl=()=>{let e=$();return(0,Y.useMemo)(()=>({zoomIn:async t=>{let{panZoom:n}=e.getState();return n?n.scaleBy(1.2,t):!1},zoomOut:async t=>{let{panZoom:n}=e.getState();return n?n.scaleBy(1/1.2,t):!1},zoomTo:async(t,n)=>{let{panZoom:r}=e.getState();return r?r.scaleTo(t,n):!1},getZoom:()=>e.getState().transform[2],setViewport:async(t,n)=>{let{transform:[r,i,a],panZoom:o}=e.getState();return o?(await o.setViewport({x:t.x??r,y:t.y??i,zoom:t.zoom??a},n),!0):!1},getViewport:()=>{let[t,n,r]=e.getState().transform;return{x:t,y:n,zoom:r}},setCenter:async(t,n,r)=>e.getState().setCenter(t,n,r),fitBounds:async(t,n)=>{let{width:r,height:i,minZoom:a,maxZoom:o,panZoom:s}=e.getState(),c=$o(t,r,i,a,o,n?.padding??.1);return s?(await s.setViewport(c,{duration:n?.duration,ease:n?.ease,interpolate:n?.interpolate}),!0):!1},screenToFlowPosition:(t,n={})=>{let{transform:r,snapGrid:i,snapToGrid:a,domNode:o}=e.getState();if(!o)return t;let{x:s,y:c}=o.getBoundingClientRect(),l={x:t.x-s,y:t.y-c},u=n.snapGrid??i;return Jo(l,r,n.snapToGrid??a,u)},flowToScreenPosition:t=>{let{transform:n,domNode:r}=e.getState();if(!r)return t;let{x:i,y:a}=r.getBoundingClientRect(),o=Yo(t,n);return{x:o.x+i,y:o.y+a}}}),[])};function Bl(e,t){let n=[],r=new Map,i=[];for(let t of e)if(t.type===`add`){i.push(t);continue}else if(t.type===`remove`||t.type===`replace`)r.set(t.id,[t]);else{let e=r.get(t.id);e?e.push(t):r.set(t.id,[t])}for(let e of t){let t=r.get(e.id);if(!t){n.push(e);continue}if(t[0].type===`remove`)continue;if(t[0].type===`replace`){n.push({...t[0].item});continue}let i={...e};for(let e of t)Vl(e,i);n.push(i)}return i.length&&i.forEach(e=>{e.index===void 0?n.push({...e.item}):n.splice(e.index,0,{...e.item})}),n}function Vl(e,t){switch(e.type){case`select`:t.selected=e.selected;break;case`position`:e.position!==void 0&&(t.position=e.position),e.dragging!==void 0&&(t.dragging=e.dragging);break;case`dimensions`:e.dimensions!==void 0&&(t.measured={...e.dimensions},e.setAttributes&&((e.setAttributes===!0||e.setAttributes===`width`)&&(t.width=e.dimensions.width),(e.setAttributes===!0||e.setAttributes===`height`)&&(t.height=e.dimensions.height))),typeof e.resizing==`boolean`&&(t.resizing=e.resizing)}}function Hl(e,t){return Bl(e,t)}function Ul(e,t){return Bl(e,t)}function Wl(e,t){return{id:e,type:`select`,selected:t}}function Gl(e,t=new Set,n=!1){let r=[];for(let[i,a]of e){let e=t.has(i);!(a.selected===void 0&&!e)&&a.selected!==e&&(n&&(a.selected=e),r.push(Wl(a.id,e)))}return r}function Kl({items:e=[],lookup:t}){let n=[],r=new Map(e.map(e=>[e.id,e]));for(let[r,i]of e.entries()){let e=t.get(i.id),a=e?.internals?.userNode??e;a!==void 0&&a!==i&&n.push({id:i.id,item:i,type:`replace`}),a===void 0&&n.push({item:i,type:`add`,index:r})}for(let[e]of t)r.get(e)===void 0&&n.push({id:e,type:`remove`});return n}function ql(e){return{id:e.id,type:`remove`}}var Jl=Ko(`React Flow`,`https://reactflow.dev/`);function Yl(e,t,n={}){return Ts(e,t,{...n,onError:n.onError??Jl})}var Xl=e=>bo(e),Zl=e=>yo(e);function Ql(e){return(0,Y.forwardRef)(e)}var $l=typeof window<`u`?Y.useLayoutEffect:Y.useEffect;function eu(e){let[t,n]=(0,Y.useState)(BigInt(0)),[r]=(0,Y.useState)(()=>tu(()=>n(e=>e+BigInt(1))));return $l(()=>{let t=r.get();t.length&&(e(t),r.reset())},[t]),r}function tu(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}var nu=(0,Y.createContext)(null);function ru({children:e}){let t=$(),n=eu((0,Y.useCallback)(e=>{let{nodes:n=[],setNodes:r,hasDefaultNodes:i,onNodesChange:a,nodeLookup:o,fitViewQueued:s,onNodesChangeMiddlewareMap:c}=t.getState(),l=n;for(let t of e)l=typeof t==`function`?t(l):t;let u=Kl({items:l,lookup:o});for(let e of c.values())u=e(u);i&&r(l),u.length>0?a?.(u):s&&window.requestAnimationFrame(()=>{let{fitViewQueued:e,nodes:n,setNodes:r}=t.getState();e&&r(n)})},[])),r=eu((0,Y.useCallback)(e=>{let{edges:n=[],setEdges:r,hasDefaultEdges:i,onEdgesChange:a,edgeLookup:o}=t.getState(),s=n;for(let t of e)s=typeof t==`function`?t(s):t;i?r(s):a&&a(Kl({items:s,lookup:o}))},[])),i=(0,Y.useMemo)(()=>({nodeQueue:n,edgeQueue:r}),[]);return(0,J.jsx)(nu.Provider,{value:i,children:e})}function iu(){let e=(0,Y.useContext)(nu);if(!e)throw Error(`useBatchContext must be used within a BatchProvider`);return e}var au=e=>!!e.panZoom;function ou(){let e=zl(),t=$(),n=iu(),r=Q(au),i=(0,Y.useMemo)(()=>{let e=e=>t.getState().nodeLookup.get(e),r=e=>{n.nodeQueue.push(e)},i=e=>{n.edgeQueue.push(e)},a=e=>{let{nodeLookup:n,nodeOrigin:r}=t.getState(),i=Xl(e)?e:n.get(e.id),a=i.parentId?is(i.position,i.measured,i.parentId,n,r):i.position;return zo({...i,position:a,width:i.measured?.width??i.width,height:i.measured?.height??i.height})},o=(e,t,n={replace:!1})=>{r(r=>r.map(r=>{if(r.id===e){let e=typeof t==`function`?t(r):t;return n.replace&&Xl(e)?e:{...r,...e}}return r}))},s=(e,t,n={replace:!1})=>{i(r=>r.map(r=>{if(r.id===e){let e=typeof t==`function`?t(r):t;return n.replace&&Zl(e)?e:{...r,...e}}return r}))};return{getNodes:()=>t.getState().nodes.map(e=>({...e})),getNode:t=>e(t)?.internals.userNode,getInternalNode:e,getEdges:()=>{let{edges:e=[]}=t.getState();return e.map(e=>({...e}))},getEdge:e=>t.getState().edgeLookup.get(e),setNodes:r,setEdges:i,addNodes:e=>{let t=Array.isArray(e)?e:[e];n.nodeQueue.push(e=>[...e,...t])},addEdges:e=>{let t=Array.isArray(e)?e:[e];n.edgeQueue.push(e=>[...e,...t])},toObject:()=>{let{nodes:e=[],edges:n=[],transform:r}=t.getState(),[i,a,o]=r;return{nodes:e.map(e=>({...e})),edges:n.map(e=>({...e})),viewport:{x:i,y:a,zoom:o}}},deleteElements:async({nodes:e=[],edges:n=[]})=>{let{nodes:r,edges:i,onNodesDelete:a,onEdgesDelete:o,triggerNodeChanges:s,triggerEdgeChanges:c,onDelete:l,onBeforeDelete:u}=t.getState(),{nodes:d,edges:f}=await Ao({nodesToRemove:e,edgesToRemove:n,nodes:r,edges:i,onBeforeDelete:u}),p=f.length>0,m=d.length>0;if(p){let e=f.map(ql);o?.(f),c(e)}if(m){let e=d.map(ql);a?.(d),s(e)}return(m||p)&&l?.({nodes:d,edges:f}),{deletedNodes:d,deletedEdges:f}},getIntersectingNodes:(e,n=!0,r)=>{let i=Wo(e),o=i?e:a(e),s=r!==void 0;return o?(r||t.getState().nodes).filter(r=>{let a=t.getState().nodeLookup.get(r.id);if(a&&!i&&(r.id===e.id||!a.internals.positionAbsolute))return!1;let c=zo(s?r:a),l=Uo(c,o);return n&&l>0||l>=c.width*c.height||l>=o.width*o.height}):[]},isNodeIntersecting:(e,t,n=!0)=>{let r=Wo(e)?e:a(e);if(!r)return!1;let i=Uo(r,t);return n&&i>0||i>=t.width*t.height||i>=r.width*r.height},updateNode:o,updateNodeData:(e,t,n={replace:!1})=>{o(e,e=>{let r=typeof t==`function`?t(e):t;return n.replace?{...e,data:r}:{...e,data:{...e.data,...r}}},n)},updateEdge:s,updateEdgeData:(e,t,n={replace:!1})=>{s(e,e=>{let r=typeof t==`function`?t(e):t;return n.replace?{...e,data:r}:{...e,data:{...e.data,...r}}},n)},getNodesBounds:e=>{let{nodeLookup:n,nodeOrigin:r}=t.getState();return Co(e,{nodeLookup:n,nodeOrigin:r})},getHandleConnections:({type:e,id:n,nodeId:r})=>Array.from(t.getState().connectionLookup.get(`${r}-${e}${n?`-${n}`:``}`)?.values()??[]),getNodeConnections:({type:e,handleId:n,nodeId:r})=>Array.from(t.getState().connectionLookup.get(`${r}${e?n?`-${e}-${n}`:`-${e}`:``}`)?.values()??[]),fitView:async e=>{let r=t.getState().fitViewResolver??os();return t.setState({fitViewQueued:!0,fitViewOptions:e,fitViewResolver:r}),n.nodeQueue.push(e=>[...e]),r.promise}}},[]);return(0,Y.useMemo)(()=>({...i,...e,viewportInitialized:r}),[r])}var su=e=>e.selected,cu=typeof window<`u`?window:void 0;function lu({deleteKeyCode:e,multiSelectionKeyCode:t}){let n=$(),{deleteElements:r}=ou(),i=Il(e,{actInsideInputWithModifier:!1}),a=Il(t,{target:cu});(0,Y.useEffect)(()=>{if(i){let{edges:e,nodes:t}=n.getState();r({nodes:t.filter(su),edges:e.filter(su)}),n.setState({nodesSelectionActive:!1})}},[i]),(0,Y.useEffect)(()=>{n.setState({multiSelectionActive:a})},[a])}function uu(e){let t=$();(0,Y.useEffect)(()=>{let n=()=>{if(!e.current||!(e.current.checkVisibility?.()??!0))return!1;let n=ls(e.current);(n.height===0||n.width===0)&&t.getState().onError?.(`004`,oo.error004()),t.setState({width:n.width||500,height:n.height||500})};if(e.current){n(),window.addEventListener(`resize`,n);let t=new ResizeObserver(()=>n());return t.observe(e.current),()=>{window.removeEventListener(`resize`,n),t&&e.current&&t.unobserve(e.current)}}},[])}var du={position:`absolute`,width:`100%`,height:`100%`,top:0,left:0},fu=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function pu({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:r=!1,panOnScrollSpeed:i=.5,panOnScrollMode:a=fo.Free,zoomOnDoubleClick:o=!0,panOnDrag:s=!0,defaultViewport:c,translateExtent:l,minZoom:u,maxZoom:d,zoomActivationKeyCode:f,preventScrolling:p=!0,children:m,noWheelClassName:h,noPanClassName:g,onViewportChange:_,isControlledViewport:v,paneClickDistance:y,selectionOnDrag:b}){let x=$(),S=(0,Y.useRef)(null),{userSelectionActive:C,lib:w,connectionInProgress:T}=Q(fu,al),E=Il(f),D=(0,Y.useRef)();uu(S);let O=(0,Y.useCallback)(e=>{_?.({x:e[0],y:e[1],zoom:e[2]}),v||x.setState({transform:e})},[_,v]);return(0,Y.useEffect)(()=>{if(S.current){D.current=Pc({domNode:S.current,minZoom:u,maxZoom:d,translateExtent:l,viewport:c,onDraggingChange:e=>x.setState(t=>t.paneDragging===e?t:{paneDragging:e}),onPanZoomStart:(e,t)=>{let{onViewportChangeStart:n,onMoveStart:r}=x.getState();r?.(e,t),n?.(t)},onPanZoom:(e,t)=>{let{onViewportChange:n,onMove:r}=x.getState();r?.(e,t),n?.(t)},onPanZoomEnd:(e,t)=>{let{onViewportChangeEnd:n,onMoveEnd:r}=x.getState();r?.(e,t),n?.(t)}});let{x:e,y:t,zoom:n}=D.current.getViewport();return x.setState({panZoom:D.current,transform:[e,t,n],domNode:S.current.closest(`.react-flow`)}),()=>{D.current?.destroy()}}},[]),(0,Y.useEffect)(()=>{D.current?.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:n,panOnScroll:r,panOnScrollSpeed:i,panOnScrollMode:a,zoomOnDoubleClick:o,panOnDrag:s,zoomActivationKeyPressed:E,preventScrolling:p,noPanClassName:g,userSelectionActive:C,noWheelClassName:h,lib:w,onTransformChange:O,connectionInProgress:T,selectionOnDrag:b,paneClickDistance:y})},[e,t,n,r,i,a,o,s,E,p,g,C,h,w,O,T,b,y]),(0,J.jsx)(`div`,{className:`react-flow__renderer`,ref:S,style:du,children:m})}var mu=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function hu(){let{userSelectionActive:e,userSelectionRect:t}=Q(mu,al);return e&&t?(0,J.jsx)(`div`,{className:`react-flow__selection react-flow__container`,style:{width:t.width,height:t.height,transform:`translate(${t.x}px, ${t.y}px)`}}):null}var gu=(e,t)=>n=>{n.target===t.current&&e?.(n)},_u=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,dragging:e.paneDragging,panBy:e.panBy,autoPanSpeed:e.autoPanSpeed});function vu({isSelecting:e,selectionKeyPressed:t,selectionMode:n=po.Full,panOnDrag:r,autoPanOnSelection:i,paneClickDistance:a,selectionOnDrag:o,onSelectionStart:s,onSelectionEnd:c,onPaneClick:l,onPaneContextMenu:u,onPaneScroll:d,onPaneMouseEnter:f,onPaneMouseMove:p,onPaneMouseLeave:m,children:h}){let g=(0,Y.useRef)(0),_=$(),{userSelectionActive:v,elementsSelectable:y,dragging:b,panBy:x,autoPanSpeed:S}=Q(_u,al),C=y&&(e||v),w=(0,Y.useRef)(null),T=(0,Y.useRef)(),E=(0,Y.useRef)(new Set),D=(0,Y.useRef)(new Set),O=(0,Y.useRef)(!1),k=(0,Y.useRef)(!1),A=(0,Y.useRef)({x:0,y:0}),j=(0,Y.useRef)(!1),M=e=>{if(k.current||O.current||_.getState().connection.inProgress){k.current=!1,O.current=!1;return}l?.(e),_.getState().resetSelectedElements(),_.setState({nodesSelectionActive:!1})},N=e=>{if(Array.isArray(r)&&r?.includes(2)){e.preventDefault();return}u?.(e)},P=d?e=>d(e):void 0,F=e=>{k.current&&=(e.stopPropagation(),!1)},I=n=>{let{domNode:r,transform:i}=_.getState();if(T.current=r?.getBoundingClientRect(),!T.current)return;let a=n.target===w.current;if(!a&&n.target.closest(`.nokey`)||!e||!(o&&a||t)||n.button!==0||!n.isPrimary)return;n.target?.setPointerCapture?.(n.pointerId),k.current=!1;let{x:s,y:c}=ms(n.nativeEvent,T.current),l=Jo({x:s,y:c},i);_.setState({userSelectionRect:{width:0,height:0,startX:l.x,startY:l.y,x:s,y:c}}),a||(n.stopPropagation(),n.preventDefault())};function L(e,t){let{userSelectionRect:r}=_.getState();if(!r)return;let{transform:i,nodeLookup:a,edgeLookup:o,connectionLookup:s,triggerNodeChanges:c,triggerEdgeChanges:l,defaultEdgeOptions:u}=_.getState(),d={x:r.startX,y:r.startY},{x:f,y:p}=Yo(d,i),m={startX:d.x,startY:d.y,x:ee.id)),D.current=new Set;let v=u?.selectable??!0;for(let e of E.current){let t=s.get(e);if(t)for(let{edgeId:e}of t.values()){let t=o.get(e);t&&(t.selectable??v)&&D.current.add(e)}}as(h,E.current)||c(Gl(a,E.current,!0)),as(g,D.current)||l(Gl(o,D.current)),_.setState({userSelectionRect:m,userSelectionActive:!0,nodesSelectionActive:!1})}function R(){if(!i||!T.current)return;let[e,t]=Fo(A.current,T.current,S);x({x:e,y:t}).then(e=>{if(!k.current||!e){g.current=requestAnimationFrame(R);return}let{x:t,y:n}=A.current;L(t,n),g.current=requestAnimationFrame(R)})}let z=()=>{cancelAnimationFrame(g.current),g.current=0,j.current=!1};(0,Y.useEffect)(()=>()=>z(),[]);let B=e=>{let{userSelectionRect:n,transform:r,resetSelectedElements:i}=_.getState();if(!T.current||!n)return;let{x:o,y:c}=ms(e.nativeEvent,T.current);A.current={x:o,y:c};let l=Yo({x:n.startX,y:n.startY},r);if(!k.current){let n=t?0:a;if(Math.hypot(o-l.x,c-l.y)<=n)return;i(),s?.(e)}k.current=!0,j.current||=(R(),!0),L(o,c)},V=e=>{if(!C){e.target===w.current&&_.getState().connection.inProgress&&(O.current=!0);return}e.button===0&&(e.target?.releasePointerCapture?.(e.pointerId),!v&&e.target===w.current&&_.getState().userSelectionRect&&M?.(e),_.setState({userSelectionActive:!1,userSelectionRect:null}),k.current&&(c?.(e),_.setState({nodesSelectionActive:E.current.size>0})),z())},ee=e=>{e.target?.releasePointerCapture?.(e.pointerId),z()},te=r===!0||Array.isArray(r)&&r.includes(0);return(0,J.jsxs)(`div`,{className:Se([`react-flow__pane`,{draggable:te,dragging:b,selection:e}]),onClick:C?void 0:gu(M,w),onContextMenu:gu(N,w),onWheel:gu(P,w),onPointerEnter:C?void 0:f,onPointerMove:C?B:p,onPointerUp:V,onPointerCancel:C?ee:void 0,onPointerDownCapture:C?I:void 0,onClickCapture:C?F:void 0,onPointerLeave:m,ref:w,style:du,children:[h,(0,J.jsx)(hu,{})]})}function yu({id:e,store:t,unselect:n=!1,nodeRef:r}){let{addSelectedNodes:i,unselectNodesAndEdges:a,multiSelectionActive:o,nodeLookup:s,onError:c}=t.getState(),l=s.get(e);if(!l){c?.(`012`,oo.error012(e));return}t.setState({nodesSelectionActive:!1}),l.selected?(n||l.selected&&o)&&(a({nodes:[l],edges:[]}),requestAnimationFrame(()=>r?.current?.blur())):i([e])}function bu({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:r,nodeId:i,isSelectable:a,nodeClickDistance:o}){let s=$(),[c,l]=(0,Y.useState)(!1),u=(0,Y.useRef)();return(0,Y.useEffect)(()=>{u.current=lc({getStoreItems:()=>s.getState(),onNodeMouseDown:t=>{yu({id:t,store:s,nodeRef:e})},onDragStart:()=>{l(!0)},onDragStop:()=>{l(!1)}})},[]),(0,Y.useEffect)(()=>{if(!(t||!e.current||!u.current))return u.current.update({noDragClassName:n,handleSelector:r,domNode:e.current,isSelectable:a,nodeId:i,nodeClickDistance:o}),()=>{u.current?.destroy()}},[n,r,t,a,e,i,o]),c}var xu=e=>t=>t.selected&&(t.draggable||e&&t.draggable===void 0);function Su(){let e=$();return(0,Y.useCallback)(t=>{let{nodeExtent:n,snapToGrid:r,snapGrid:i,nodesDraggable:a,onError:o,updateNodePositions:s,nodeLookup:c,nodeOrigin:l}=e.getState(),u=new Map,d=xu(a),f=r?i[0]:5,p=r?i[1]:5,m=t.direction.x*f*t.factor,h=t.direction.y*p*t.factor;for(let[,e]of c){if(!d(e))continue;let t={x:e.internals.positionAbsolute.x+m,y:e.internals.positionAbsolute.y+h};r&&(t=qo(t,i));let{position:a,positionAbsolute:s}=ko({nodeId:e.id,nextPosition:t,nodeLookup:c,nodeExtent:n,nodeOrigin:l,onError:o});e.position=a,e.internals.positionAbsolute=s,u.set(e.id,e)}s(u)},[])}var Cu=(0,Y.createContext)(null),wu=Cu.Provider;Cu.Consumer;var Tu=()=>(0,Y.useContext)(Cu),Eu=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),Du=(0,Y.createContext)(null);function Ou({children:e}){let t=Q(Eu,al);return(0,J.jsx)(Du.Provider,{value:t,children:e})}function ku(){let e=(0,Y.useContext)(Du);if(!e)throw Error(`useHandleConfig must be used within a HandleConfigProvider`);return e}var Au={connectingFrom:!1,connectingTo:!1,clickConnecting:!1,isPossibleEndHandle:!0,connectionInProcess:!1,clickConnectionInProcess:!1,valid:!1},ju=(e,t,n)=>r=>{let{connectionClickStartHandle:i,connectionMode:a,connection:o}=r,{fromHandle:s,toHandle:c,isValid:l}=o;if(!s&&!i)return Au;let u=c?.nodeId===e&&c?.id===t&&c?.type===n;return{connectingFrom:s?.nodeId===e&&s?.id===t&&s?.type===n,connectingTo:u,clickConnecting:i?.nodeId===e&&i?.id===t&&i?.type===n,isPossibleEndHandle:a===uo.Strict?s?.type!==n:e!==s?.nodeId||t!==s?.id,connectionInProcess:!!s,clickConnectionInProcess:!!i,valid:u&&l}};function Mu({type:e=`source`,position:t=Z.Top,isValidConnection:n,isConnectable:r=!0,isConnectableStart:i=!0,isConnectableEnd:a=!0,id:o,onConnect:s,children:c,className:l,onMouseDown:u,onTouchStart:d,...f},p){let m=o||null,h=e===`target`,g=$(),_=Tu(),{connectOnClick:v,noPanClassName:y,rfId:b}=ku(),{connectingFrom:x,connectingTo:S,clickConnecting:C,isPossibleEndHandle:w,connectionInProcess:T,clickConnectionInProcess:E,valid:D}=Q(ju(_,m,e),al);_||g.getState().onError?.(`010`,oo.error010());let O=e=>{let{defaultEdgeOptions:t,onConnect:n,hasDefaultEdges:r}=g.getState(),i={...t,...e};if(r){let{edges:e,setEdges:t,onError:n}=g.getState();t(Yl(i,e,{onError:n}))}n?.(i),s?.(i)},k=e=>{if(!_)return;let t=ps(e.nativeEvent);if(i&&(t&&e.button===0||!t)){let t=g.getState();yc.onPointerDown(e.nativeEvent,{handleDomNode:e.currentTarget,autoPanOnConnect:t.autoPanOnConnect,connectionMode:t.connectionMode,connectionRadius:t.connectionRadius,domNode:t.domNode,nodeLookup:t.nodeLookup,lib:t.lib,isTarget:h,handleId:m,nodeId:_,flowId:t.rfId,panBy:t.panBy,cancelConnection:t.cancelConnection,onConnectStart:t.onConnectStart,onConnectEnd:(...e)=>g.getState().onConnectEnd?.(...e),updateConnection:t.updateConnection,onConnect:O,isValidConnection:n||((...e)=>g.getState().isValidConnection?.(...e)??!0),getTransform:()=>g.getState().transform,getFromHandle:()=>g.getState().connection.fromHandle,autoPanSpeed:t.autoPanSpeed,dragThreshold:t.connectionDragThreshold})}t?u?.(e):d?.(e)};return(0,J.jsx)(`div`,{"data-handleid":m,"data-nodeid":_,"data-handlepos":t,"data-id":`${b}-${_}-${m}-${e}`,className:Se([`react-flow__handle`,`react-flow__handle-${t}`,`nodrag`,y,l,{source:!h,target:h,connectable:r,connectablestart:i,connectableend:a,clickconnecting:C,connectingfrom:x,connectingto:S,valid:D,connectionindicator:r&&(!T||w)&&(T||E?a:i)}]),onMouseDown:k,onTouchStart:k,onClick:v?t=>{let{onClickConnectStart:r,onClickConnectEnd:a,connectionClickStartHandle:o,connectionMode:s,isValidConnection:c,lib:l,rfId:u,nodeLookup:d,connection:f}=g.getState();if(!_||!o&&!i)return;if(!o){r?.(t.nativeEvent,{nodeId:_,handleId:m,handleType:e}),g.setState({connectionClickStartHandle:{nodeId:_,type:e,id:m}});return}let p=us(t.target),h=n||c,{connection:v,isValid:y}=yc.isValid(t.nativeEvent,{handle:{nodeId:_,id:m,type:e},connectionMode:s,fromNodeId:o.nodeId,fromHandleId:o.id||null,fromType:o.type,isValidConnection:h,flowId:u,doc:p,lib:l,nodeLookup:d});y&&v&&O(v);let b=structuredClone(f);delete b.inProgress,b.toPosition=b.toHandle?b.toHandle.position:null,a?.(t,b),g.setState({connectionClickStartHandle:null})}:void 0,ref:p,...f,children:c})}var Nu=(0,Y.memo)(Ql(Mu));function Pu({data:e,isConnectable:t,sourcePosition:n=Z.Bottom}){return(0,J.jsxs)(J.Fragment,{children:[e?.label,(0,J.jsx)(Nu,{type:`source`,position:n,isConnectable:t})]})}function Fu({data:e,isConnectable:t,targetPosition:n=Z.Top,sourcePosition:r=Z.Bottom}){return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Nu,{type:`target`,position:n,isConnectable:t}),e?.label,(0,J.jsx)(Nu,{type:`source`,position:r,isConnectable:t})]})}function Iu(){return null}function Lu({data:e,isConnectable:t,targetPosition:n=Z.Top}){return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Nu,{type:`target`,position:n,isConnectable:t}),e?.label]})}var Ru={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},zu={input:Pu,default:Fu,output:Lu,group:Iu};function Bu(e){return e.internals.handleBounds===void 0?{width:e.width??e.initialWidth??e.style?.width,height:e.height??e.initialHeight??e.style?.height}:{width:e.width??e.style?.width,height:e.height??e.style?.height}}var Vu=e=>{let{width:t,height:n,x:r,y:i}=wo(e.nodeLookup,{filter:e=>!!e.selected});return{width:Go(t)?t:null,height:Go(n)?n:null,userSelectionActive:e.userSelectionActive,transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]}) translate(${r}px,${i}px)`}};function Hu({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){let r=$(),{width:i,height:a,transformString:o,userSelectionActive:s}=Q(Vu,al),c=Su(),l=(0,Y.useRef)(null);(0,Y.useEffect)(()=>{n||l.current?.focus({preventScroll:!0})},[n]);let u=!s&&i!==null&&a!==null;if(bu({nodeRef:l,disabled:!u}),!u)return null;let d=e?t=>{e(t,r.getState().nodes.filter(e=>e.selected))}:void 0;return(0,J.jsx)(`div`,{className:Se([`react-flow__nodesselection`,`react-flow__container`,t]),style:{transform:o},children:(0,J.jsx)(`div`,{ref:l,className:`react-flow__nodesselection-rect`,onContextMenu:d,tabIndex:n?void 0:-1,onKeyDown:n?void 0:e=>{Object.prototype.hasOwnProperty.call(Ru,e.key)&&(e.preventDefault(),c({direction:Ru[e.key],factor:e.shiftKey?4:1}))},style:{width:i,height:a}})})}var Uu=typeof window<`u`?window:void 0,Wu=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function Gu({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:i,onPaneContextMenu:a,onPaneScroll:o,paneClickDistance:s,deleteKeyCode:c,selectionKeyCode:l,selectionOnDrag:u,selectionMode:d,onSelectionStart:f,onSelectionEnd:p,multiSelectionKeyCode:m,panActivationKeyCode:h,zoomActivationKeyCode:g,elementsSelectable:_,zoomOnScroll:v,zoomOnPinch:y,panOnScroll:b,panOnScrollSpeed:x,panOnScrollMode:S,zoomOnDoubleClick:C,panOnDrag:w,autoPanOnSelection:T,defaultViewport:E,translateExtent:D,minZoom:O,maxZoom:k,preventScrolling:A,onSelectionContextMenu:j,noWheelClassName:M,noPanClassName:N,disableKeyboardA11y:P,onViewportChange:F,isControlledViewport:I}){let{nodesSelectionActive:L,userSelectionActive:R}=Q(Wu,al),z=Il(l,{target:Uu}),B=Il(h,{target:Uu}),V=B||w,ee=B||b,te=u&&V!==!0,H=z||R||te;return lu({deleteKeyCode:c,multiSelectionKeyCode:m}),(0,J.jsx)(pu,{onPaneContextMenu:a,elementsSelectable:_,zoomOnScroll:v,zoomOnPinch:y,panOnScroll:ee,panOnScrollSpeed:x,panOnScrollMode:S,zoomOnDoubleClick:C,panOnDrag:!z&&V,defaultViewport:E,translateExtent:D,minZoom:O,maxZoom:k,zoomActivationKeyCode:g,preventScrolling:A,noWheelClassName:M,noPanClassName:N,onViewportChange:F,isControlledViewport:I,paneClickDistance:s,selectionOnDrag:te,children:(0,J.jsxs)(vu,{onSelectionStart:f,onSelectionEnd:p,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:i,onPaneContextMenu:a,onPaneScroll:o,panOnDrag:V,autoPanOnSelection:T,isSelecting:!!H,selectionMode:d,selectionKeyPressed:z,paneClickDistance:s,selectionOnDrag:te,children:[e,L&&(0,J.jsx)(Hu,{onSelectionContextMenu:j,noPanClassName:N,disableKeyboardA11y:P})]})})}Gu.displayName=`FlowRenderer`;var Ku=(0,Y.memo)(Gu),qu=e=>t=>e?To(t.nodeLookup,{x:0,y:0,width:t.width,height:t.height},t.transform,!0).map(e=>e.id):Array.from(t.nodeLookup.keys());function Ju(e){return Q((0,Y.useCallback)(qu(e),[e]),al)}var Yu=e=>e.updateNodeInternals;function Xu(){let e=Q(Yu),[t]=(0,Y.useState)(()=>typeof ResizeObserver>`u`?null:new ResizeObserver(t=>{let n=new Map;t.forEach(e=>{let t=e.target.getAttribute(`data-id`);n.set(t,{id:t,nodeElement:e.target,force:!0})}),e(n)}));return(0,Y.useEffect)(()=>()=>{t?.disconnect()},[t]),t}function Zu({node:e,nodeType:t,hasDimensions:n,resizeObserver:r}){let i=$(),a=(0,Y.useRef)(null),o=(0,Y.useRef)(null),s=(0,Y.useRef)(e.sourcePosition),c=(0,Y.useRef)(e.targetPosition),l=(0,Y.useRef)(t),u=n&&!!e.internals.handleBounds;return(0,Y.useEffect)(()=>{a.current&&!e.hidden&&(!u||o.current!==a.current)&&(o.current&&r?.unobserve(o.current),r?.observe(a.current),o.current=a.current)},[u,e.hidden]),(0,Y.useEffect)(()=>()=>{o.current&&=(r?.unobserve(o.current),null)},[]),(0,Y.useEffect)(()=>{if(a.current){let n=l.current!==t,r=s.current!==e.sourcePosition,o=c.current!==e.targetPosition;(n||r||o)&&(l.current=t,s.current=e.sourcePosition,c.current=e.targetPosition,i.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:a.current,force:!0}]])))}},[e.id,t,e.sourcePosition,e.targetPosition]),a}function Qu({id:e,onClick:t,onMouseEnter:n,onMouseMove:r,onMouseLeave:i,onContextMenu:a,onDoubleClick:o,nodesDraggable:s,elementsSelectable:c,nodesConnectable:l,nodesFocusable:u,resizeObserver:d,noDragClassName:f,noPanClassName:p,disableKeyboardA11y:m,rfId:h,nodeTypes:g,nodeClickDistance:_,onError:v}){let{node:y,internals:b,isParent:x}=Q(t=>{let n=t.nodeLookup.get(e),r=t.parentLookup.has(e);return{node:n,internals:n.internals,isParent:r}},al),S=y.type||`default`,C=g?.[S]||zu[S];C===void 0&&(v?.(`003`,oo.error003(S)),S=`default`,C=g?.default||zu.default);let w=!!(y.draggable||s&&y.draggable===void 0),T=!!(y.selectable||c&&y.selectable===void 0),E=!!(y.connectable||l&&y.connectable===void 0),D=!!(y.focusable||u&&y.focusable===void 0),O=$(),k=rs(y),A=Zu({node:y,nodeType:S,hasDimensions:k,resizeObserver:d}),j=bu({nodeRef:A,disabled:y.hidden||!w,noDragClassName:f,handleSelector:y.dragHandle,nodeId:e,isSelectable:T,nodeClickDistance:_}),M=Su();if(y.hidden)return null;let N=ns(y),P=Bu(y),F=T||w||t||n||r||i,I=n?e=>n(e,{...b.userNode}):void 0,L=r?e=>r(e,{...b.userNode}):void 0,R=i?e=>i(e,{...b.userNode}):void 0,z=a?e=>a(e,{...b.userNode}):void 0,B=o?e=>o(e,{...b.userNode}):void 0,V=n=>{let{selectNodesOnDrag:r,nodeDragThreshold:i}=O.getState();T&&(!r||!w||i>0)&&yu({id:e,store:O,nodeRef:A}),t&&t(n,{...b.userNode})},ee=t=>{if(!(fs(t.nativeEvent)||m)){if(co.includes(t.key)&&T){let n=t.key===`Escape`;yu({id:e,store:O,unselect:n,nodeRef:A})}else if(w&&y.selected&&Object.prototype.hasOwnProperty.call(Ru,t.key)){t.preventDefault();let{ariaLabelConfig:e}=O.getState();O.setState({ariaLiveMessage:e[`node.a11yDescription.ariaLiveMessage`]({direction:t.key.replace(`Arrow`,``).toLowerCase(),x:~~b.positionAbsolute.x,y:~~b.positionAbsolute.y})}),M({direction:Ru[t.key],factor:t.shiftKey?4:1})}}},te=()=>{if(m||!A.current?.matches(`:focus-visible`))return;let{transform:t,width:n,height:r,autoPanOnNodeFocus:i,setCenter:a}=O.getState();i&&(To(new Map([[e,y]]),{x:0,y:0,width:n,height:r},t,!0).length>0||a(y.position.x+N.width/2,y.position.y+N.height/2,{zoom:t[2]}))};return(0,J.jsx)(`div`,{className:Se([`react-flow__node`,`react-flow__node-${S}`,{[p]:w},y.className,{selected:y.selected,selectable:T,parent:x,draggable:w,dragging:j}]),ref:A,style:{zIndex:b.z,transform:`translate(${b.positionAbsolute.x}px,${b.positionAbsolute.y}px)`,pointerEvents:F?`all`:`none`,visibility:k?`visible`:`hidden`,...y.style,...P},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:I,onMouseMove:L,onMouseLeave:R,onContextMenu:z,onClick:V,onDoubleClick:B,onKeyDown:D?ee:void 0,tabIndex:D?0:void 0,onFocus:D?te:void 0,role:y.ariaRole??(D?`group`:void 0),"aria-roledescription":`node`,"aria-describedby":m?void 0:`${dl}-${h}`,"aria-label":y.ariaLabel,...y.domAttributes,children:(0,J.jsx)(wu,{value:e,children:(0,J.jsx)(C,{id:e,data:y.data,type:S,positionAbsoluteX:b.positionAbsolute.x,positionAbsoluteY:b.positionAbsolute.y,selected:y.selected??!1,selectable:T,draggable:w,deletable:y.deletable??!0,isConnectable:E,sourcePosition:y.sourcePosition,targetPosition:y.targetPosition,dragging:j,dragHandle:y.dragHandle,zIndex:b.z,parentId:y.parentId,...N})})})}var $u=(0,Y.memo)(Qu),ed=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function td(e){let{nodesDraggable:t,nodesConnectable:n,nodesFocusable:r,elementsSelectable:i,onError:a}=Q(ed,al),o=Ju(e.onlyRenderVisibleElements),s=Xu();return(0,J.jsx)(`div`,{className:`react-flow__nodes`,style:du,children:o.map(o=>(0,J.jsx)($u,{id:o,nodeTypes:e.nodeTypes,nodeExtent:e.nodeExtent,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,resizeObserver:s,nodesDraggable:t,nodesConnectable:n,nodesFocusable:r,elementsSelectable:i,nodeClickDistance:e.nodeClickDistance,onError:a},o))})}td.displayName=`NodeRenderer`;var nd=(0,Y.memo)(td);function rd(e){return Q((0,Y.useCallback)(t=>{if(!e)return t.edges.map(e=>e.id);let n=[];if(t.width&&t.height)for(let e of t.edges){let r=t.nodeLookup.get(e.source),i=t.nodeLookup.get(e.target);r&&i&&Ss({sourceNode:r,targetNode:i,width:t.width,height:t.height,transform:t.transform})&&n.push(e.id)}return n},[e]),al)}var id=({color:e=`none`,strokeWidth:t=1})=>{let n={strokeWidth:t,...e&&{stroke:e}};return(0,J.jsx)(`polyline`,{className:`arrow`,style:n,strokeLinecap:`round`,fill:`none`,strokeLinejoin:`round`,points:`-5,-4 0,0 -5,4`})},ad=({color:e=`none`,strokeWidth:t=1})=>{let n={strokeWidth:t,...e&&{stroke:e,fill:e}};return(0,J.jsx)(`polyline`,{className:`arrowclosed`,style:n,strokeLinecap:`round`,strokeLinejoin:`round`,points:`-5,-4 0,0 -5,4 -5,-4`})},od={[go.Arrow]:id,[go.ArrowClosed]:ad};function sd(e){let t=$();return(0,Y.useMemo)(()=>Object.prototype.hasOwnProperty.call(od,e)?od[e]:(t.getState().onError?.(`009`,oo.error009(e)),null),[e])}var cd=({id:e,type:t,color:n,width:r=12.5,height:i=12.5,markerUnits:a=`strokeWidth`,strokeWidth:o,orient:s=`auto-start-reverse`})=>{let c=sd(t);return c?(0,J.jsx)(`marker`,{className:`react-flow__arrowhead`,id:e,markerWidth:`${r}`,markerHeight:`${i}`,viewBox:`-10 -10 20 20`,markerUnits:a,orient:s,refX:`0`,refY:`0`,children:(0,J.jsx)(c,{color:n,strokeWidth:o})}):null},ld=({defaultColor:e,rfId:t})=>{let n=Q(e=>e.edges),r=Q(e=>e.defaultEdgeOptions),i=(0,Y.useMemo)(()=>zs(n,{id:t,defaultColor:e,defaultMarkerStart:r?.markerStart,defaultMarkerEnd:r?.markerEnd}),[n,r,t,e]);return i.length?(0,J.jsx)(`svg`,{className:`react-flow__marker`,"aria-hidden":`true`,children:(0,J.jsx)(`defs`,{children:i.map(e=>(0,J.jsx)(cd,{id:e.id,type:e.type,color:e.color,width:e.width,height:e.height,markerUnits:e.markerUnits,strokeWidth:e.strokeWidth,orient:e.orient},e.id))})}):null};ld.displayName=`MarkerDefinitions`;var ud=(0,Y.memo)(ld);function dd({x:e,y:t,label:n,labelStyle:r,labelShowBg:i=!0,labelBgStyle:a,labelBgPadding:o=[2,4],labelBgBorderRadius:s=2,children:c,className:l,...u}){let[d,f]=(0,Y.useState)({x:1,y:0,width:0,height:0}),p=Se([`react-flow__edge-textwrapper`,l]),m=(0,Y.useRef)(null);return(0,Y.useEffect)(()=>{if(m.current){let e=m.current.getBBox();f({x:e.x,y:e.y,width:e.width,height:e.height})}},[n]),n?(0,J.jsxs)(`g`,{transform:`translate(${e-d.width/2} ${t-d.height/2})`,className:p,visibility:d.width?`visible`:`hidden`,...u,children:[i&&(0,J.jsx)(`rect`,{width:d.width+2*o[0],x:-o[0],y:-o[1],height:d.height+2*o[1],className:`react-flow__edge-textbg`,style:a,rx:s,ry:s}),(0,J.jsx)(`text`,{className:`react-flow__edge-text`,y:d.height/2,dy:`0.3em`,ref:m,style:r,children:n}),c]}):null}dd.displayName=`EdgeText`;var fd=(0,Y.memo)(dd);function pd({path:e,labelX:t,labelY:n,label:r,labelStyle:i,labelShowBg:a,labelBgStyle:o,labelBgPadding:s,labelBgBorderRadius:c,interactionWidth:l=20,...u}){return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`path`,{...u,d:e,fill:`none`,className:Se([`react-flow__edge-path`,u.className])}),l?(0,J.jsx)(`path`,{d:e,fill:`none`,strokeOpacity:0,strokeWidth:l,className:`react-flow__edge-interaction`}):null,r&&Go(t)&&Go(n)?(0,J.jsx)(fd,{x:t,y:n,label:r,labelStyle:i,labelShowBg:a,labelBgStyle:o,labelBgPadding:s,labelBgBorderRadius:c}):null]})}function md({pos:e,x1:t,y1:n,x2:r,y2:i}){return e===Z.Left||e===Z.Right?[.5*(t+r),n]:[t,.5*(n+i)]}function hd({sourceX:e,sourceY:t,sourcePosition:n=Z.Bottom,targetX:r,targetY:i,targetPosition:a=Z.Top}){let[o,s]=md({pos:n,x1:e,y1:t,x2:r,y2:i}),[c,l]=md({pos:a,x1:r,y1:i,x2:e,y2:t}),[u,d,f,p]=gs({sourceX:e,sourceY:t,targetX:r,targetY:i,sourceControlX:o,sourceControlY:s,targetControlX:c,targetControlY:l});return[`M${e},${t} C${o},${s} ${c},${l} ${r},${i}`,u,d,f,p]}function gd(e){return(0,Y.memo)(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:a,sourcePosition:o,targetPosition:s,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:h,markerStart:g,interactionWidth:_})=>{let[v,y,b]=hd({sourceX:n,sourceY:r,sourcePosition:o,targetX:i,targetY:a,targetPosition:s}),x=e.isInternal?void 0:t;return(0,J.jsx)(pd,{id:x,path:v,labelX:y,labelY:b,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:h,markerStart:g,interactionWidth:_})})}var _d=gd({isInternal:!1}),vd=gd({isInternal:!0});_d.displayName=`SimpleBezierEdge`,vd.displayName=`SimpleBezierEdgeInternal`;function yd(e){return(0,Y.memo)(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:a,label:o,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,sourcePosition:p=Z.Bottom,targetPosition:m=Z.Top,markerEnd:h,markerStart:g,pathOptions:_,interactionWidth:v})=>{let[y,b,x]=Ms({sourceX:n,sourceY:r,sourcePosition:p,targetX:i,targetY:a,targetPosition:m,borderRadius:_?.borderRadius,offset:_?.offset,stepPosition:_?.stepPosition}),S=e.isInternal?void 0:t;return(0,J.jsx)(pd,{id:S,path:y,labelX:b,labelY:x,label:o,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,markerEnd:h,markerStart:g,interactionWidth:v})})}var bd=yd({isInternal:!1}),xd=yd({isInternal:!0});bd.displayName=`SmoothStepEdge`,xd.displayName=`SmoothStepEdgeInternal`;function Sd(e){return(0,Y.memo)(({id:t,...n})=>{let r=e.isInternal?void 0:t;return(0,J.jsx)(bd,{...n,id:r,pathOptions:(0,Y.useMemo)(()=>({borderRadius:0,offset:n.pathOptions?.offset}),[n.pathOptions?.offset])})})}var Cd=Sd({isInternal:!1}),wd=Sd({isInternal:!0});Cd.displayName=`StepEdge`,wd.displayName=`StepEdgeInternal`;function Td(e){return(0,Y.memo)(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:a,label:o,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,markerEnd:p,markerStart:m,interactionWidth:h})=>{let[g,_,v]=Es({sourceX:n,sourceY:r,targetX:i,targetY:a}),y=e.isInternal?void 0:t;return(0,J.jsx)(pd,{id:y,path:g,labelX:_,labelY:v,label:o,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,markerEnd:p,markerStart:m,interactionWidth:h})})}var Ed=Td({isInternal:!1}),Dd=Td({isInternal:!0});Ed.displayName=`StraightEdge`,Dd.displayName=`StraightEdgeInternal`;function Od(e){return(0,Y.memo)(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:a,sourcePosition:o=Z.Bottom,targetPosition:s=Z.Top,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:h,markerStart:g,pathOptions:_,interactionWidth:v})=>{let[y,b,x]=ys({sourceX:n,sourceY:r,sourcePosition:o,targetX:i,targetY:a,targetPosition:s,curvature:_?.curvature}),S=e.isInternal?void 0:t;return(0,J.jsx)(pd,{id:S,path:y,labelX:b,labelY:x,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:h,markerStart:g,interactionWidth:v})})}var kd=Od({isInternal:!1}),Ad=Od({isInternal:!0});kd.displayName=`BezierEdge`,Ad.displayName=`BezierEdgeInternal`;var jd={default:Ad,straight:Dd,step:wd,smoothstep:xd,simplebezier:vd},Md={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null,zIndex:void 0},Nd=(e,t,n)=>n===Z.Left?e-t:n===Z.Right?e+t:e,Pd=(e,t,n)=>n===Z.Top?e-t:n===Z.Bottom?e+t:e,Fd=`react-flow__edgeupdater`;function Id({position:e,centerX:t,centerY:n,radius:r=10,onMouseDown:i,onMouseEnter:a,onMouseOut:o,type:s}){return(0,J.jsx)(`circle`,{onMouseDown:i,onMouseEnter:a,onMouseOut:o,className:Se([Fd,`${Fd}-${s}`]),cx:Nd(t,r,e),cy:Pd(n,r,e),r,stroke:`transparent`,fill:`transparent`})}function Ld({isReconnectable:e,reconnectRadius:t,edge:n,sourceX:r,sourceY:i,targetX:a,targetY:o,sourcePosition:s,targetPosition:c,onReconnect:l,onReconnectStart:u,onReconnectEnd:d,setReconnecting:f,setUpdateHover:p}){let m=$(),h=(e,t)=>{if(e.button!==0)return;let{autoPanOnConnect:r,domNode:i,connectionMode:a,connectionRadius:o,lib:s,onConnectStart:c,cancelConnection:p,nodeLookup:h,rfId:g,panBy:_,updateConnection:v}=m.getState(),y=t.type===`target`;yc.onPointerDown(e.nativeEvent,{autoPanOnConnect:r,connectionMode:a,connectionRadius:o,domNode:i,handleId:t.id,nodeId:t.nodeId,nodeLookup:h,isTarget:y,edgeUpdaterType:t.type,lib:s,flowId:g,cancelConnection:p,panBy:_,isValidConnection:(...e)=>m.getState().isValidConnection?.(...e)??!0,onConnect:e=>l?.(n,e),onConnectStart:(r,i)=>{f(!0),u?.(e,n,t.type),c?.(r,i)},onConnectEnd:(...e)=>m.getState().onConnectEnd?.(...e),onReconnectEnd:(e,r)=>{f(!1),d?.(e,n,t.type,r)},updateConnection:v,getTransform:()=>m.getState().transform,getFromHandle:()=>m.getState().connection.fromHandle,dragThreshold:m.getState().connectionDragThreshold,handleDomNode:e.currentTarget})},g=e=>h(e,{nodeId:n.target,id:n.targetHandle??null,type:`target`}),_=e=>h(e,{nodeId:n.source,id:n.sourceHandle??null,type:`source`}),v=()=>p(!0),y=()=>p(!1);return(0,J.jsxs)(J.Fragment,{children:[(e===!0||e===`source`)&&(0,J.jsx)(Id,{position:s,centerX:r,centerY:i,radius:t,onMouseDown:g,onMouseEnter:v,onMouseOut:y,type:`source`}),(e===!0||e===`target`)&&(0,J.jsx)(Id,{position:c,centerX:a,centerY:o,radius:t,onMouseDown:_,onMouseEnter:v,onMouseOut:y,type:`target`})]})}function Rd({id:e,edgesFocusable:t,edgesReconnectable:n,elementsSelectable:r,onClick:i,onDoubleClick:a,onContextMenu:o,onMouseEnter:s,onMouseMove:c,onMouseLeave:l,reconnectRadius:u,onReconnect:d,onReconnectStart:f,onReconnectEnd:p,rfId:m,edgeTypes:h,noPanClassName:g,onError:_,disableKeyboardA11y:v}){let y=Q(t=>t.edgeLookup.get(e)),b=Q(e=>e.defaultEdgeOptions);y=b?{...b,...y}:y;let x=y.type||`default`,S=h?.[x]||jd[x];S===void 0&&(_?.(`011`,oo.error011(x)),x=`default`,S=h?.default||jd.default);let C=!!(y.focusable||t&&y.focusable===void 0),w=d!==void 0&&(y.reconnectable||n&&y.reconnectable===void 0),T=!!(y.selectable||r&&y.selectable===void 0),E=(0,Y.useRef)(null),[D,O]=(0,Y.useState)(!1),[k,A]=(0,Y.useState)(!1),j=$(),{zIndex:M=y.zIndex,sourceX:N,sourceY:P,targetX:F,targetY:I,sourcePosition:L,targetPosition:R}=Q((0,Y.useCallback)(t=>{let n=t.nodeLookup.get(y.source),r=t.nodeLookup.get(y.target);if(!n||!r)return Md;let i=Ps({id:e,sourceNode:n,targetNode:r,sourceHandle:y.sourceHandle||null,targetHandle:y.targetHandle||null,connectionMode:t.connectionMode,onError:_}),a=xs({selected:y.selected,zIndex:y.zIndex,sourceNode:n,targetNode:r,elevateOnSelect:t.elevateEdgesOnSelect,zIndexMode:t.zIndexMode});return{...i||Md,zIndex:a}},[y.source,y.target,y.sourceHandle,y.targetHandle,y.selected,y.zIndex]),al),z=(0,Y.useMemo)(()=>y.markerStart?`url('#${Rs(y.markerStart,m)}')`:void 0,[y.markerStart,m]),B=(0,Y.useMemo)(()=>y.markerEnd?`url('#${Rs(y.markerEnd,m)}')`:void 0,[y.markerEnd,m]);if(y.hidden||N===null||P===null||F===null||I===null)return null;let V=t=>{let{addSelectedEdges:n,unselectNodesAndEdges:r,multiSelectionActive:a}=j.getState();T&&(j.setState({nodesSelectionActive:!1}),y.selected&&a?(r({nodes:[],edges:[y]}),E.current?.blur()):n([e])),i&&i(t,y)},ee=a?e=>{a(e,{...y})}:void 0,te=o?e=>{o(e,{...y})}:void 0,H=s?e=>{s(e,{...y})}:void 0,U=c?e=>{c(e,{...y})}:void 0,W=l?e=>{l(e,{...y})}:void 0;return(0,J.jsx)(`svg`,{style:{zIndex:M},children:(0,J.jsxs)(`g`,{className:Se([`react-flow__edge`,`react-flow__edge-${x}`,y.className,g,{selected:y.selected,animated:y.animated,inactive:!T&&!i,updating:D,selectable:T}]),onClick:V,onDoubleClick:ee,onContextMenu:te,onMouseEnter:H,onMouseMove:U,onMouseLeave:W,onKeyDown:C?t=>{if(!v&&co.includes(t.key)&&T){let{unselectNodesAndEdges:n,addSelectedEdges:r}=j.getState();t.key===`Escape`?(E.current?.blur(),n({edges:[y]})):r([e])}}:void 0,tabIndex:C?0:void 0,role:y.ariaRole??(C?`group`:`img`),"aria-roledescription":`edge`,"data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":y.ariaLabel===null?void 0:y.ariaLabel||`Edge from ${y.source} to ${y.target}`,"aria-describedby":C?`${fl}-${m}`:void 0,ref:E,...y.domAttributes,children:[!k&&(0,J.jsx)(S,{id:e,source:y.source,target:y.target,type:y.type,selected:y.selected,animated:y.animated,selectable:T,deletable:y.deletable??!0,label:y.label,labelStyle:y.labelStyle,labelShowBg:y.labelShowBg,labelBgStyle:y.labelBgStyle,labelBgPadding:y.labelBgPadding,labelBgBorderRadius:y.labelBgBorderRadius,sourceX:N,sourceY:P,targetX:F,targetY:I,sourcePosition:L,targetPosition:R,data:y.data,style:y.style,sourceHandleId:y.sourceHandle,targetHandleId:y.targetHandle,markerStart:z,markerEnd:B,pathOptions:`pathOptions`in y?y.pathOptions:void 0,interactionWidth:y.interactionWidth}),w&&(0,J.jsx)(Ld,{edge:y,isReconnectable:w,reconnectRadius:u,onReconnect:d,onReconnectStart:f,onReconnectEnd:p,sourceX:N,sourceY:P,targetX:F,targetY:I,sourcePosition:L,targetPosition:R,setUpdateHover:O,setReconnecting:A})]})})}var zd=(0,Y.memo)(Rd),Bd=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function Vd({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:n,edgeTypes:r,noPanClassName:i,onReconnect:a,onEdgeContextMenu:o,onEdgeMouseEnter:s,onEdgeMouseMove:c,onEdgeMouseLeave:l,onEdgeClick:u,reconnectRadius:d,onEdgeDoubleClick:f,onReconnectStart:p,onReconnectEnd:m,disableKeyboardA11y:h}){let{edgesFocusable:g,edgesReconnectable:_,elementsSelectable:v,onError:y}=Q(Bd,al),b=rd(t);return(0,J.jsxs)(`div`,{className:`react-flow__edges`,children:[(0,J.jsx)(ud,{defaultColor:e,rfId:n}),b.map(e=>(0,J.jsx)(zd,{id:e,edgesFocusable:g,edgesReconnectable:_,elementsSelectable:v,noPanClassName:i,onReconnect:a,onContextMenu:o,onMouseEnter:s,onMouseMove:c,onMouseLeave:l,onClick:u,reconnectRadius:d,onDoubleClick:f,onReconnectStart:p,onReconnectEnd:m,rfId:n,onError:y,edgeTypes:r,disableKeyboardA11y:h},e))]})}Vd.displayName=`EdgeRenderer`;var Hd=(0,Y.memo)(Vd),Ud=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function Wd({children:e}){let t=Q(Ud);return(0,J.jsx)(`div`,{className:`react-flow__viewport xyflow__viewport react-flow__container`,style:{transform:t},children:e})}function Gd(e){let t=ou(),n=(0,Y.useRef)(!1);(0,Y.useEffect)(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}var Kd=e=>e.panZoom?.syncViewport;function qd(e){let t=Q(Kd),n=$();return(0,Y.useEffect)(()=>{e&&(t?.(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function Jd(e){return e.connection.inProgress?{...e.connection,to:Jo(e.connection.to,e.transform)}:{...e.connection}}function Yd(e){return e?t=>e(Jd(t)):Jd}function Xd(e){return Q(Yd(e),al)}var Zd=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function Qd({containerStyle:e,style:t,type:n,component:r}){let{nodesConnectable:i,width:a,height:o,isValid:s,inProgress:c}=Q(Zd,al);return a&&i&&c?(0,J.jsx)(`svg`,{style:e,width:a,height:o,className:`react-flow__connectionline react-flow__container`,children:(0,J.jsx)(`g`,{className:Se([`react-flow__connection`,vo(s)]),children:(0,J.jsx)($d,{style:t,type:n,CustomComponent:r,isValid:s})})}):null}var $d=({style:e,type:t=ho.Bezier,CustomComponent:n,isValid:r})=>{let{inProgress:i,from:a,fromNode:o,fromHandle:s,fromPosition:c,to:l,toNode:u,toHandle:d,toPosition:f,pointer:p}=Xd();if(!i)return;if(n)return(0,J.jsx)(n,{connectionLineType:t,connectionLineStyle:e,fromNode:o,fromHandle:s,fromX:a.x,fromY:a.y,toX:l.x,toY:l.y,fromPosition:c,toPosition:f,connectionStatus:vo(r),toNode:u,toHandle:d,pointer:p});let m=``,h={sourceX:a.x,sourceY:a.y,sourcePosition:c,targetX:l.x,targetY:l.y,targetPosition:f};switch(t){case ho.Bezier:[m]=ys(h);break;case ho.SimpleBezier:[m]=hd(h);break;case ho.Step:[m]=Ms({...h,borderRadius:0});break;case ho.SmoothStep:[m]=Ms(h);break;default:[m]=Es(h)}return(0,J.jsx)(`path`,{d:m,fill:`none`,className:`react-flow__connection-path`,style:e})};$d.displayName=`ConnectionLine`;var ef={};function tf(e=ef){(0,Y.useRef)(e),$(),(0,Y.useEffect)(()=>{},[e])}function nf(){$(),(0,Y.useRef)(!1),(0,Y.useEffect)(()=>{},[])}function rf({nodeTypes:e,edgeTypes:t,onInit:n,onNodeClick:r,onEdgeClick:i,onNodeDoubleClick:a,onEdgeDoubleClick:o,onNodeMouseEnter:s,onNodeMouseMove:c,onNodeMouseLeave:l,onNodeContextMenu:u,onSelectionContextMenu:d,onSelectionStart:f,onSelectionEnd:p,connectionLineType:m,connectionLineStyle:h,connectionLineComponent:g,connectionLineContainerStyle:_,selectionKeyCode:v,selectionOnDrag:y,selectionMode:b,multiSelectionKeyCode:x,panActivationKeyCode:S,zoomActivationKeyCode:C,deleteKeyCode:w,onlyRenderVisibleElements:T,elementsSelectable:E,defaultViewport:D,translateExtent:O,minZoom:k,maxZoom:A,preventScrolling:j,defaultMarkerColor:M,zoomOnScroll:N,zoomOnPinch:P,panOnScroll:F,panOnScrollSpeed:I,panOnScrollMode:L,zoomOnDoubleClick:R,panOnDrag:z,autoPanOnSelection:B,onPaneClick:V,onPaneMouseEnter:ee,onPaneMouseMove:te,onPaneMouseLeave:H,onPaneScroll:U,onPaneContextMenu:W,paneClickDistance:G,nodeClickDistance:K,onEdgeContextMenu:ne,onEdgeMouseEnter:re,onEdgeMouseMove:ie,onEdgeMouseLeave:ae,reconnectRadius:oe,onReconnect:se,onReconnectStart:ce,onReconnectEnd:le,noDragClassName:q,noWheelClassName:ue,noPanClassName:de,disableKeyboardA11y:fe,nodeExtent:Y,rfId:pe,viewport:me,onViewportChange:X}){return tf(e),tf(t),nf(),Gd(n),qd(me),(0,J.jsx)(Ku,{onPaneClick:V,onPaneMouseEnter:ee,onPaneMouseMove:te,onPaneMouseLeave:H,onPaneContextMenu:W,onPaneScroll:U,paneClickDistance:G,deleteKeyCode:w,selectionKeyCode:v,selectionOnDrag:y,selectionMode:b,onSelectionStart:f,onSelectionEnd:p,multiSelectionKeyCode:x,panActivationKeyCode:S,zoomActivationKeyCode:C,elementsSelectable:E,zoomOnScroll:N,zoomOnPinch:P,zoomOnDoubleClick:R,panOnScroll:F,panOnScrollSpeed:I,panOnScrollMode:L,panOnDrag:z,autoPanOnSelection:B,defaultViewport:D,translateExtent:O,minZoom:k,maxZoom:A,onSelectionContextMenu:d,preventScrolling:j,noDragClassName:q,noWheelClassName:ue,noPanClassName:de,disableKeyboardA11y:fe,onViewportChange:X,isControlledViewport:!!me,children:(0,J.jsxs)(Wd,{children:[(0,J.jsx)(Hd,{edgeTypes:t,onEdgeClick:i,onEdgeDoubleClick:o,onReconnect:se,onReconnectStart:ce,onReconnectEnd:le,onlyRenderVisibleElements:T,onEdgeContextMenu:ne,onEdgeMouseEnter:re,onEdgeMouseMove:ie,onEdgeMouseLeave:ae,reconnectRadius:oe,defaultMarkerColor:M,noPanClassName:de,disableKeyboardA11y:fe,rfId:pe}),(0,J.jsx)(Qd,{style:h,type:m,component:g,containerStyle:_}),(0,J.jsx)(`div`,{className:`react-flow__edgelabel-renderer`}),(0,J.jsx)(nd,{nodeTypes:e,onNodeClick:r,onNodeDoubleClick:a,onNodeMouseEnter:s,onNodeMouseMove:c,onNodeMouseLeave:l,onNodeContextMenu:u,nodeClickDistance:K,onlyRenderVisibleElements:T,noPanClassName:de,noDragClassName:q,disableKeyboardA11y:fe,nodeExtent:Y,rfId:pe}),(0,J.jsx)(`div`,{className:`react-flow__viewport-portal`})]})})}rf.displayName=`GraphView`;var af=(0,Y.memo)(rf),of=Ko(`React Flow`,`https://reactflow.dev/`),sf=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:i,height:a,fitView:o,fitViewOptions:s,minZoom:c=.5,maxZoom:l=2,nodeOrigin:u,nodeExtent:d,zIndexMode:f=`basic`}={})=>{let p=new Map,m=new Map,h=new Map,g=new Map,_=r??t??[],v=n??e??[],y=u??[0,0],b=d??so;rc(h,g,_);let{nodesInitialized:x}=Js(v,p,m,{nodeOrigin:y,nodeExtent:b,zIndexMode:f}),S=[0,0,1];if(o&&i&&a){let{x:e,y:t,zoom:n}=$o(wo(p,{filter:e=>!!((e.width||e.initialWidth)&&(e.height||e.initialHeight))}),i,a,c,l,s?.padding??.1);S=[e,t,n]}return{rfId:`1`,width:i??0,height:a??0,transform:S,nodes:v,nodesInitialized:x,nodeLookup:p,parentLookup:m,edges:_,edgeLookup:g,connectionLookup:h,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:n!==void 0,hasDefaultEdges:r!==void 0,panZoom:null,minZoom:c,maxZoom:l,translateExtent:so,nodeExtent:b,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:uo.Strict,domNode:null,paneDragging:!1,noPanClassName:`nopan`,nodeOrigin:y,nodeDragThreshold:1,connectionDragThreshold:1,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesReconnectable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,elevateEdgesOnSelect:!0,selectNodesOnDrag:!0,multiSelectionActive:!1,fitViewQueued:o??!1,fitViewOptions:s,fitViewResolver:null,connection:{...mo},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:``,autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:of,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:`react`,debug:!1,ariaLabelConfig:lo,zIndexMode:f,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},cf=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:i,height:a,fitView:o,fitViewOptions:s,minZoom:c,maxZoom:l,nodeOrigin:u,nodeExtent:d,zIndexMode:f})=>il((p,m)=>{async function h(){let{nodeLookup:e,panZoom:t,fitViewOptions:n,fitViewResolver:r,width:i,height:a,minZoom:o,maxZoom:s}=m();t&&(await Oo({nodes:e,width:i,height:a,panZoom:t,minZoom:o,maxZoom:s},n),r?.resolve(!0),p({fitViewResolver:null}))}return{...sf({nodes:e,edges:t,width:i,height:a,fitView:o,fitViewOptions:s,minZoom:c,maxZoom:l,nodeOrigin:u,nodeExtent:d,defaultNodes:n,defaultEdges:r,zIndexMode:f}),setNodes:e=>{let{nodeLookup:t,parentLookup:n,nodeOrigin:r,elevateNodesOnSelect:i,fitViewQueued:a,zIndexMode:o,nodesSelectionActive:s}=m(),{nodesInitialized:c,hasSelectedNodes:l}=Js(e,t,n,{nodeOrigin:r,nodeExtent:d,elevateNodesOnSelect:i,checkEquality:!0,zIndexMode:o}),u=s&&l;a&&c?(h(),p({nodes:e,nodesInitialized:c,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:u})):p({nodes:e,nodesInitialized:c,nodesSelectionActive:u})},setEdges:e=>{let{connectionLookup:t,edgeLookup:n}=m();rc(t,n,e),p({edges:e})},setDefaultNodesAndEdges:(e,t)=>{if(e){let{setNodes:t}=m();t(e),p({hasDefaultNodes:!0})}if(t){let{setEdges:e}=m();e(t),p({hasDefaultEdges:!0})}},updateNodeInternals:e=>{let{triggerNodeChanges:t,nodeLookup:n,parentLookup:r,domNode:i,nodeOrigin:a,nodeExtent:o,debug:s,fitViewQueued:c,zIndexMode:l}=m(),{changes:u,updatedInternals:d}=ec(e,n,r,i,a,o,l);d&&(Gs(n,r,{nodeOrigin:a,nodeExtent:o,zIndexMode:l}),c?(h(),p({fitViewQueued:!1,fitViewOptions:void 0})):p({}),u?.length>0&&(s&&console.log(`React Flow: trigger node changes`,u),t?.(u)))},updateNodePositions:(e,t=!1)=>{let n=[],r=[],{nodeLookup:i,triggerNodeChanges:a,connection:o,updateConnection:s,onNodesChangeMiddlewareMap:c}=m();for(let[a,c]of e){let e=i.get(a),l=!!(e?.expandParent&&e?.parentId&&c?.position),u={id:a,type:`position`,position:l?{x:Math.max(0,c.position.x),y:Math.max(0,c.position.y)}:c.position,dragging:t};if(e&&o.inProgress&&o.fromNode.id===e.id){let t=Is(e,o.fromHandle,Z.Left,!0);s({...o,from:t})}l&&e.parentId&&n.push({id:a,parentId:e.parentId,rect:{...c.internals.positionAbsolute,width:c.measured.width??0,height:c.measured.height??0}}),r.push(u)}if(n.length>0){let{parentLookup:e,nodeOrigin:t}=m(),a=$s(n,i,e,t);r.push(...a)}for(let e of c.values())r=e(r);a(r)},triggerNodeChanges:e=>{let{onNodesChange:t,setNodes:n,nodes:r,hasDefaultNodes:i,debug:a}=m();e?.length&&(i&&n(Hl(e,r)),a&&console.log(`React Flow: trigger node changes`,e),t?.(e))},triggerEdgeChanges:e=>{let{onEdgesChange:t,setEdges:n,edges:r,hasDefaultEdges:i,debug:a}=m();e?.length&&(i&&n(Ul(e,r)),a&&console.log(`React Flow: trigger edge changes`,e),t?.(e))},addSelectedNodes:e=>{let{multiSelectionActive:t,edgeLookup:n,nodeLookup:r,triggerNodeChanges:i,triggerEdgeChanges:a}=m();if(t){i(e.map(e=>Wl(e,!0)));return}i(Gl(r,new Set([...e]),!0)),a(Gl(n))},addSelectedEdges:e=>{let{multiSelectionActive:t,edgeLookup:n,nodeLookup:r,triggerNodeChanges:i,triggerEdgeChanges:a}=m();if(t){a(e.map(e=>Wl(e,!0)));return}a(Gl(n,new Set([...e]))),i(Gl(r,new Set,!0))},unselectNodesAndEdges:({nodes:e,edges:t}={})=>{let{edges:n,nodes:r,nodeLookup:i,triggerNodeChanges:a,triggerEdgeChanges:o}=m(),s=e||r,c=t||n,l=[];for(let e of s){if(!e.selected)continue;let t=i.get(e.id);t&&(t.selected=!1),l.push(Wl(e.id,!1))}let u=[];for(let e of c)e.selected&&u.push(Wl(e.id,!1));a(l),o(u)},setMinZoom:e=>{let{panZoom:t,maxZoom:n}=m();t?.setScaleExtent([e,n]),p({minZoom:e})},setMaxZoom:e=>{let{panZoom:t,minZoom:n}=m();t?.setScaleExtent([n,e]),p({maxZoom:e})},setTranslateExtent:e=>{m().panZoom?.setTranslateExtent(e),p({translateExtent:e})},resetSelectedElements:()=>{let{edges:e,nodes:t,triggerNodeChanges:n,triggerEdgeChanges:r,elementsSelectable:i}=m();if(!i)return;let a=t.reduce((e,t)=>t.selected?[...e,Wl(t.id,!1)]:e,[]),o=e.reduce((e,t)=>t.selected?[...e,Wl(t.id,!1)]:e,[]);n(a),r(o)},setNodeExtent:e=>{let{nodes:t,nodeLookup:n,parentLookup:r,nodeOrigin:i,elevateNodesOnSelect:a,nodeExtent:o,zIndexMode:s}=m();(e[0][0]!==o[0][0]||e[0][1]!==o[0][1]||e[1][0]!==o[1][0]||e[1][1]!==o[1][1])&&(Js(t,n,r,{nodeOrigin:i,nodeExtent:e,elevateNodesOnSelect:a,checkEquality:!1,zIndexMode:s}),p({nodeExtent:e}))},panBy:e=>{let{transform:t,width:n,height:r,panZoom:i,translateExtent:a}=m();return tc({delta:e,panZoom:i,transform:t,translateExtent:a,width:n,height:r})},setCenter:async(e,t,n)=>{let{width:r,height:i,maxZoom:a,panZoom:o}=m();if(!o)return!1;let s=n?.zoom===void 0?a:n.zoom;return await o.setViewport({x:r/2-e*s,y:i/2-t*s,zoom:s},{duration:n?.duration,ease:n?.ease,interpolate:n?.interpolate}),!0},cancelConnection:()=>{p({connection:{...mo}})},updateConnection:e=>{p({connection:e})},reset:()=>p({...sf()})}},Object.is);function lf({initialNodes:e,initialEdges:t,defaultNodes:n,defaultEdges:r,initialWidth:i,initialHeight:a,initialMinZoom:o,initialMaxZoom:s,initialFitViewOptions:c,fitView:l,nodeOrigin:u,nodeExtent:d,zIndexMode:f,children:p}){let[m]=(0,Y.useState)(()=>cf({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:i,height:a,fitView:l,minZoom:o,maxZoom:s,fitViewOptions:c,nodeOrigin:u,nodeExtent:d,zIndexMode:f}));return(0,J.jsx)(sl,{value:m,children:(0,J.jsx)(ru,{children:(0,J.jsx)(Ou,{children:p})})})}function uf({children:e,nodes:t,edges:n,defaultNodes:r,defaultEdges:i,width:a,height:o,fitView:s,fitViewOptions:c,minZoom:l,maxZoom:u,nodeOrigin:d,nodeExtent:f,zIndexMode:p}){return(0,Y.useContext)(ol)?(0,J.jsx)(J.Fragment,{children:e}):(0,J.jsx)(lf,{initialNodes:t,initialEdges:n,defaultNodes:r,defaultEdges:i,initialWidth:a,initialHeight:o,fitView:s,initialFitViewOptions:c,initialMinZoom:l,initialMaxZoom:u,nodeOrigin:d,nodeExtent:f,zIndexMode:p,children:e})}var df={width:`100%`,height:`100%`,overflow:`hidden`,position:`relative`,zIndex:0};function ff({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,className:i,nodeTypes:a,edgeTypes:o,onNodeClick:s,onEdgeClick:c,onInit:l,onMove:u,onMoveStart:d,onMoveEnd:f,onConnect:p,onConnectStart:m,onConnectEnd:h,onClickConnectStart:g,onClickConnectEnd:_,onNodeMouseEnter:v,onNodeMouseMove:y,onNodeMouseLeave:b,onNodeContextMenu:x,onNodeDoubleClick:S,onNodeDragStart:C,onNodeDrag:w,onNodeDragStop:T,onNodesDelete:E,onEdgesDelete:D,onDelete:O,onSelectionChange:k,onSelectionDragStart:A,onSelectionDrag:j,onSelectionDragStop:M,onSelectionContextMenu:N,onSelectionStart:P,onSelectionEnd:F,onBeforeDelete:I,connectionMode:L,connectionLineType:R=ho.Bezier,connectionLineStyle:z,connectionLineComponent:B,connectionLineContainerStyle:V,deleteKeyCode:ee=`Backspace`,selectionKeyCode:te=`Shift`,selectionOnDrag:H=!1,selectionMode:U=po.Full,panActivationKeyCode:W=`Space`,multiSelectionKeyCode:G=es()?`Meta`:`Control`,zoomActivationKeyCode:K=es()?`Meta`:`Control`,snapToGrid:ne,snapGrid:re,onlyRenderVisibleElements:ie=!1,selectNodesOnDrag:ae,nodesDraggable:oe,autoPanOnNodeFocus:se,nodesConnectable:ce,nodesFocusable:le,nodeOrigin:q=Dl,edgesFocusable:ue,edgesReconnectable:de,elementsSelectable:fe=!0,defaultViewport:pe=Ol,minZoom:me=.5,maxZoom:X=2,translateExtent:he=so,preventScrolling:ge=!0,nodeExtent:_e,defaultMarkerColor:ve=`#b1b1b7`,zoomOnScroll:ye=!0,zoomOnPinch:be=!0,panOnScroll:xe=!1,panOnScrollSpeed:Ce=.5,panOnScrollMode:we=fo.Free,zoomOnDoubleClick:Te=!0,panOnDrag:Ee=!0,onPaneClick:De,onPaneMouseEnter:Oe,onPaneMouseMove:ke,onPaneMouseLeave:Ae,onPaneScroll:je,onPaneContextMenu:Me,paneClickDistance:Ne=1,nodeClickDistance:Pe=0,children:Fe,onReconnect:Ie,onReconnectStart:Le,onReconnectEnd:Re,onEdgeContextMenu:ze,onEdgeDoubleClick:Be,onEdgeMouseEnter:Ve,onEdgeMouseMove:He,onEdgeMouseLeave:Ue,reconnectRadius:We=10,onNodesChange:Ge,onEdgesChange:Ke,noDragClassName:qe=`nodrag`,noWheelClassName:Je=`nowheel`,noPanClassName:Ye=`nopan`,fitView:Xe,fitViewOptions:Ze,connectOnClick:Qe,attributionPosition:$e,proOptions:et,defaultEdgeOptions:tt,elevateNodesOnSelect:nt=!0,elevateEdgesOnSelect:rt=!1,disableKeyboardA11y:it=!1,autoPanOnConnect:at,autoPanOnNodeDrag:ot,autoPanOnSelection:st=!0,autoPanSpeed:ct,connectionRadius:lt,isValidConnection:ut,onError:dt,style:ft,id:pt,nodeDragThreshold:mt,connectionDragThreshold:ht,viewport:gt,onViewportChange:_t,width:vt,height:yt,colorMode:bt=`light`,debug:xt,onScroll:St,ariaLabelConfig:Ct,zIndexMode:wt=`basic`,...Tt},Et){let Dt=pt||`1`,Ot=Pl(bt),kt=(0,Y.useCallback)(e=>{e.currentTarget.scrollTo({top:0,left:0,behavior:`instant`}),St?.(e)},[St]);return(0,J.jsx)(`div`,{"data-testid":`rf__wrapper`,...Tt,onScroll:kt,style:{...ft,...df},ref:Et,className:Se([`react-flow`,i,Ot]),id:pt,role:`application`,children:(0,J.jsxs)(uf,{nodes:e,edges:t,width:vt,height:yt,fitView:Xe,fitViewOptions:Ze,minZoom:me,maxZoom:X,nodeOrigin:q,nodeExtent:_e,zIndexMode:wt,children:[(0,J.jsx)(Ml,{nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:p,onConnectStart:m,onConnectEnd:h,onClickConnectStart:g,onClickConnectEnd:_,nodesDraggable:oe,autoPanOnNodeFocus:se,nodesConnectable:ce,nodesFocusable:le,edgesFocusable:ue,edgesReconnectable:de,elementsSelectable:fe,elevateNodesOnSelect:nt,elevateEdgesOnSelect:rt,minZoom:me,maxZoom:X,nodeExtent:_e,onNodesChange:Ge,onEdgesChange:Ke,snapToGrid:ne,snapGrid:re,connectionMode:L,translateExtent:he,connectOnClick:Qe,defaultEdgeOptions:tt,fitView:Xe,fitViewOptions:Ze,onNodesDelete:E,onEdgesDelete:D,onDelete:O,onNodeDragStart:C,onNodeDrag:w,onNodeDragStop:T,onSelectionDrag:j,onSelectionDragStart:A,onSelectionDragStop:M,onMove:u,onMoveStart:d,onMoveEnd:f,noPanClassName:Ye,nodeOrigin:q,rfId:Dt,autoPanOnConnect:at,autoPanOnNodeDrag:ot,autoPanSpeed:ct,onError:dt,connectionRadius:lt,isValidConnection:ut,selectNodesOnDrag:ae,nodeDragThreshold:mt,connectionDragThreshold:ht,onBeforeDelete:I,debug:xt,ariaLabelConfig:Ct,zIndexMode:wt}),(0,J.jsx)(af,{onInit:l,onNodeClick:s,onEdgeClick:c,onNodeMouseEnter:v,onNodeMouseMove:y,onNodeMouseLeave:b,onNodeContextMenu:x,onNodeDoubleClick:S,nodeTypes:a,edgeTypes:o,connectionLineType:R,connectionLineStyle:z,connectionLineComponent:B,connectionLineContainerStyle:V,selectionKeyCode:te,selectionOnDrag:H,selectionMode:U,deleteKeyCode:ee,multiSelectionKeyCode:G,panActivationKeyCode:W,zoomActivationKeyCode:K,onlyRenderVisibleElements:ie,defaultViewport:pe,translateExtent:he,minZoom:me,maxZoom:X,preventScrolling:ge,zoomOnScroll:ye,zoomOnPinch:be,zoomOnDoubleClick:Te,panOnScroll:xe,panOnScrollSpeed:Ce,panOnScrollMode:we,panOnDrag:Ee,autoPanOnSelection:st,onPaneClick:De,onPaneMouseEnter:Oe,onPaneMouseMove:ke,onPaneMouseLeave:Ae,onPaneScroll:je,onPaneContextMenu:Me,paneClickDistance:Ne,nodeClickDistance:Pe,onSelectionContextMenu:N,onSelectionStart:P,onSelectionEnd:F,onReconnect:Ie,onReconnectStart:Le,onReconnectEnd:Re,onEdgeContextMenu:ze,onEdgeDoubleClick:Be,onEdgeMouseEnter:Ve,onEdgeMouseMove:He,onEdgeMouseLeave:Ue,reconnectRadius:We,defaultMarkerColor:ve,noDragClassName:qe,noWheelClassName:Je,noPanClassName:Ye,rfId:Dt,disableKeyboardA11y:it,nodeExtent:_e,viewport:gt,onViewportChange:_t}),(0,J.jsx)(El,{onSelectionChange:k}),Fe,(0,J.jsx)(bl,{proOptions:et,position:$e}),(0,J.jsx)(_l,{rfId:Dt,disableKeyboardA11y:it})]})})}var pf=Ql(ff),mf=e=>e.domNode?.querySelector(`.react-flow__edgelabel-renderer`);function hf({children:e}){let t=Q(mf);return t?(0,pe.createPortal)(e,t):null}function gf(e){let[t,n]=(0,Y.useState)(e);return[t,n,(0,Y.useCallback)(e=>n(t=>Hl(e,t)),[])]}var _f=e=>t=>{if(!e.includeHiddenNodes)return t.nodesInitialized;if(t.nodeLookup.size===0)return!1;for(let[,{internals:e}]of t.nodeLookup)if(e.handleBounds===void 0||!rs(e.userNode))return!1;return!0};function vf(e={includeHiddenNodes:!1}){return Q(_f(e))}oo.error014();function yf({dimensions:e,lineWidth:t,variant:n,className:r}){return(0,J.jsx)(`path`,{strokeWidth:t,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:Se([`react-flow__background-pattern`,n,r])})}function bf({radius:e,className:t}){return(0,J.jsx)(`circle`,{cx:e,cy:e,r:e,className:Se([`react-flow__background-pattern`,`dots`,t])})}var xf;(function(e){e.Lines=`lines`,e.Dots=`dots`,e.Cross=`cross`})(xf||={});var Sf={[xf.Dots]:1,[xf.Lines]:1,[xf.Cross]:6},Cf=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function wf({id:e,variant:t=xf.Dots,gap:n=20,size:r,lineWidth:i=1,offset:a=0,color:o,bgColor:s,style:c,className:l,patternClassName:u}){let d=(0,Y.useRef)(null),{transform:f,patternId:p}=Q(Cf,al),m=r||Sf[t],h=t===xf.Dots,g=t===xf.Cross,_=Array.isArray(n)?n:[n,n],v=[_[0]*f[2]||1,_[1]*f[2]||1],y=m*f[2],b=Array.isArray(a)?a:[a,a],x=g?[y,y]:v,S=[b[0]*f[2]||1+x[0]/2,b[1]*f[2]||1+x[1]/2],C=`${p}${e||``}`;return(0,J.jsxs)(`svg`,{className:Se([`react-flow__background`,l]),style:{...c,...du,"--xy-background-color-props":s,"--xy-background-pattern-color-props":o},ref:d,"data-testid":`rf__background`,children:[(0,J.jsx)(`pattern`,{id:C,x:f[0]%v[0],y:f[1]%v[1],width:v[0],height:v[1],patternUnits:`userSpaceOnUse`,patternTransform:`translate(-${S[0]},-${S[1]})`,children:h?(0,J.jsx)(bf,{radius:y/2,className:u}):(0,J.jsx)(yf,{dimensions:x,lineWidth:i,variant:t,className:u})}),(0,J.jsx)(`rect`,{x:`0`,y:`0`,width:`100%`,height:`100%`,fill:`url(#${C})`})]})}wf.displayName=`Background`;var Tf=(0,Y.memo)(wf);function Ef(){return(0,J.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 32 32`,children:(0,J.jsx)(`path`,{d:`M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z`})})}function Df(){return(0,J.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 32 5`,children:(0,J.jsx)(`path`,{d:`M0 0h32v4.2H0z`})})}function Of(){return(0,J.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 32 30`,children:(0,J.jsx)(`path`,{d:`M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z`})})}function kf(){return(0,J.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 25 32`,children:(0,J.jsx)(`path`,{d:`M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z`})})}function Af(){return(0,J.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 25 32`,children:(0,J.jsx)(`path`,{d:`M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z`})})}function jf({children:e,className:t,...n}){return(0,J.jsx)(`button`,{type:`button`,className:Se([`react-flow__controls-button`,t]),...n,children:e})}var Mf=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function Nf({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:r=!0,fitViewOptions:i,onZoomIn:a,onZoomOut:o,onFitView:s,onInteractiveChange:c,className:l,children:u,position:d=`bottom-left`,orientation:f=`vertical`,"aria-label":p}){let m=$(),{isInteractive:h,minZoomReached:g,maxZoomReached:_,ariaLabelConfig:v}=Q(Mf,al),{zoomIn:y,zoomOut:b,fitView:x}=ou();return(0,J.jsxs)(vl,{className:Se([`react-flow__controls`,f===`horizontal`?`horizontal`:`vertical`,l]),position:d,style:e,"data-testid":`rf__controls`,"aria-label":p??v[`controls.ariaLabel`],children:[t&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(jf,{onClick:()=>{y(),a?.()},className:`react-flow__controls-zoomin`,title:v[`controls.zoomIn.ariaLabel`],"aria-label":v[`controls.zoomIn.ariaLabel`],disabled:_,children:(0,J.jsx)(Ef,{})}),(0,J.jsx)(jf,{onClick:()=>{b(),o?.()},className:`react-flow__controls-zoomout`,title:v[`controls.zoomOut.ariaLabel`],"aria-label":v[`controls.zoomOut.ariaLabel`],disabled:g,children:(0,J.jsx)(Df,{})})]}),n&&(0,J.jsx)(jf,{className:`react-flow__controls-fitview`,onClick:()=>{x(i),s?.()},title:v[`controls.fitView.ariaLabel`],"aria-label":v[`controls.fitView.ariaLabel`],children:(0,J.jsx)(Of,{})}),r&&(0,J.jsx)(jf,{className:`react-flow__controls-interactive`,onClick:()=>{m.setState({nodesDraggable:!h,nodesConnectable:!h,elementsSelectable:!h}),c?.(!h)},title:v[`controls.interactive.ariaLabel`],"aria-label":v[`controls.interactive.ariaLabel`],children:h?(0,J.jsx)(Af,{}):(0,J.jsx)(kf,{})}),u]})}Nf.displayName=`Controls`;var Pf=(0,Y.memo)(Nf);function Ff({id:e,x:t,y:n,width:r,height:i,style:a,color:o,strokeColor:s,strokeWidth:c,className:l,borderRadius:u,shapeRendering:d,selected:f,onClick:p}){let{background:m,backgroundColor:h}=a||{},g=o||m||h;return(0,J.jsx)(`rect`,{className:Se([`react-flow__minimap-node`,{selected:f},l]),x:t,y:n,rx:u,ry:u,width:r,height:i,style:{fill:g,stroke:s,strokeWidth:c},shapeRendering:d,onClick:p?t=>p(t,e):void 0})}var If=(0,Y.memo)(Ff),Lf=e=>e.nodes.map(e=>e.id),Rf=e=>e instanceof Function?e:()=>e;function zf({nodeStrokeColor:e,nodeColor:t,nodeClassName:n=``,nodeBorderRadius:r=5,nodeStrokeWidth:i,nodeComponent:a=If,onClick:o}){let s=Q(Lf,al),c=Rf(t),l=Rf(e),u=Rf(n),d=typeof window>`u`||window.chrome?`crispEdges`:`geometricPrecision`;return(0,J.jsx)(J.Fragment,{children:s.map(e=>(0,J.jsx)(Vf,{id:e,nodeColorFunc:c,nodeStrokeColorFunc:l,nodeClassNameFunc:u,nodeBorderRadius:r,nodeStrokeWidth:i,NodeComponent:a,onClick:o,shapeRendering:d},e))})}function Bf({id:e,nodeColorFunc:t,nodeStrokeColorFunc:n,nodeClassNameFunc:r,nodeBorderRadius:i,nodeStrokeWidth:a,shapeRendering:o,NodeComponent:s,onClick:c}){let{node:l,x:u,y:d,width:f,height:p}=Q(t=>{let n=t.nodeLookup.get(e);if(!n)return{node:void 0,x:0,y:0,width:0,height:0};let r=n.internals.userNode,{x:i,y:a}=n.internals.positionAbsolute,{width:o,height:s}=ns(r);return{node:r,x:i,y:a,width:o,height:s}},al);return!l||l.hidden||!rs(l)?null:(0,J.jsx)(s,{x:u,y:d,width:f,height:p,style:l.style,selected:!!l.selected,className:r(l),color:t(l),borderRadius:i,strokeColor:n(l),strokeWidth:a,shapeRendering:o,onClick:c,id:l.id})}var Vf=(0,Y.memo)(Bf),Hf=(0,Y.memo)(zf),Uf=200,Wf=150,Gf=e=>!e.hidden,Kf=e=>{let t={x:-e.transform[0]/e.transform[2],y:-e.transform[1]/e.transform[2],width:e.width/e.transform[2],height:e.height/e.transform[2]};return{viewBB:t,boundingRect:e.nodeLookup.size>0?Vo(wo(e.nodeLookup,{filter:Gf}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},qf=`react-flow__minimap-desc`;function Jf({style:e,className:t,nodeStrokeColor:n,nodeColor:r,nodeClassName:i=``,nodeBorderRadius:a=5,nodeStrokeWidth:o,nodeComponent:s,bgColor:c,maskColor:l,maskStrokeColor:u,maskStrokeWidth:d,position:f=`bottom-right`,onClick:p,onNodeClick:m,pannable:h=!1,zoomable:g=!1,ariaLabel:_,inversePan:v,zoomStep:y=1,offsetScale:b=5}){let x=$(),S=(0,Y.useRef)(null),{boundingRect:C,viewBB:w,rfId:T,panZoom:E,translateExtent:D,flowWidth:O,flowHeight:k,ariaLabelConfig:A}=Q(Kf,al),j=e?.width??Uf,M=e?.height??Wf,N=C.width/j,P=C.height/M,F=Math.max(N,P),I=F*j,L=F*M,R=b*F,z=C.x-(I-C.width)/2-R,B=C.y-(L-C.height)/2-R,V=I+R*2,ee=L+R*2,te=`${qf}-${T}`,H=(0,Y.useRef)(0),U=(0,Y.useRef)();H.current=F,(0,Y.useEffect)(()=>{if(S.current&&E)return U.current=bc({domNode:S.current,panZoom:E,getTransform:()=>x.getState().transform,getViewScale:()=>H.current}),()=>{U.current?.destroy()}},[E]),(0,Y.useEffect)(()=>{U.current?.update({translateExtent:D,width:O,height:k,inversePan:v,pannable:h,zoomStep:y,zoomable:g})},[h,g,v,y,D,O,k]);let W=p?e=>{let[t,n]=U.current?.pointer(e)||[0,0];p(e,{x:t,y:n})}:void 0,G=m?(0,Y.useCallback)((e,t)=>{let n=x.getState().nodeLookup.get(t).internals.userNode;m(e,n)},[]):void 0,K=_??A[`minimap.ariaLabel`];return(0,J.jsx)(vl,{position:f,style:{...e,"--xy-minimap-background-color-props":typeof c==`string`?c:void 0,"--xy-minimap-mask-background-color-props":typeof l==`string`?l:void 0,"--xy-minimap-mask-stroke-color-props":typeof u==`string`?u:void 0,"--xy-minimap-mask-stroke-width-props":typeof d==`number`?d*F:void 0,"--xy-minimap-node-background-color-props":typeof r==`string`?r:void 0,"--xy-minimap-node-stroke-color-props":typeof n==`string`?n:void 0,"--xy-minimap-node-stroke-width-props":typeof o==`number`?o:void 0},className:Se([`react-flow__minimap`,t]),"data-testid":`rf__minimap`,children:(0,J.jsxs)(`svg`,{width:j,height:M,viewBox:`${z} ${B} ${V} ${ee}`,className:`react-flow__minimap-svg`,role:`img`,"aria-labelledby":te,ref:S,onClick:W,children:[K&&(0,J.jsx)(`title`,{id:te,children:K}),(0,J.jsx)(Hf,{onClick:G,nodeColor:r,nodeStrokeColor:n,nodeBorderRadius:a,nodeClassName:i,nodeStrokeWidth:o,nodeComponent:s}),(0,J.jsx)(`path`,{className:`react-flow__minimap-mask`,d:`M${z-R},${B-R}h${V+R*2}v${ee+R*2}h${-V-R*2}z + M${w.x},${w.y}h${w.width}v${w.height}h${-w.width}z`,fillRule:`evenodd`,pointerEvents:`none`})]})})}Jf.displayName=`MiniMap`;var Yf=(0,Y.memo)(Jf),Xf=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,Zf={[Fc.Line]:`right`,[Fc.Handle]:`bottom-right`};function Qf({nodeId:e,position:t,variant:n=Fc.Handle,className:r,style:i=void 0,children:a,color:o,minWidth:s=10,minHeight:c=10,maxWidth:l=Number.MAX_VALUE,maxHeight:u=Number.MAX_VALUE,keepAspectRatio:d=!1,resizeDirection:f,autoScale:p=!0,shouldResize:m,onResizeStart:h,onResize:g,onResizeEnd:_}){let v=Tu(),y=typeof e==`string`?e:v,b=$(),x=(0,Y.useRef)(null),S=n===Fc.Handle,C=Q((0,Y.useCallback)(Xf(S&&p),[S,p]),al),w=(0,Y.useRef)(null),T=t??Zf[n];(0,Y.useEffect)(()=>{if(!(!x.current||!y))return w.current||=Kc({domNode:x.current,nodeId:y,getStoreItems:()=>{let{nodeLookup:e,transform:t,snapGrid:n,snapToGrid:r,nodeOrigin:i,domNode:a}=b.getState();return{nodeLookup:e,transform:t,snapGrid:n,snapToGrid:r,nodeOrigin:i,paneDomNode:a}},onChange:(e,t)=>{let{triggerNodeChanges:n,nodeLookup:r,parentLookup:i,nodeOrigin:a}=b.getState(),o=[],s={x:e.x,y:e.y},c=r.get(y);if(c&&c.expandParent&&c.parentId){let t=c.origin??a,n=e.width??c.measured.width??0,l=e.height??c.measured.height??0,u=$s([{id:c.id,parentId:c.parentId,rect:{width:n,height:l,...is({x:e.x??c.position.x,y:e.y??c.position.y},{width:n,height:l},c.parentId,r,t)}}],r,i,a);o.push(...u),s.x=e.x?Math.max(t[0]*n,e.x):void 0,s.y=e.y?Math.max(t[1]*l,e.y):void 0}if(s.x!==void 0&&s.y!==void 0){let e={id:y,type:`position`,position:{...s}};o.push(e)}if(e.width!==void 0&&e.height!==void 0){let t={id:y,type:`dimensions`,resizing:!0,setAttributes:f?f===`horizontal`?`width`:`height`:!0,dimensions:{width:e.width,height:e.height}};o.push(t)}for(let e of t){let t={...e,type:`position`};o.push(t)}n(o)},onEnd:({width:e,height:t})=>{let n={id:y,type:`dimensions`,resizing:!1,dimensions:{width:e,height:t}};b.getState().triggerNodeChanges([n])}}),w.current.update({controlPosition:T,boundaries:{minWidth:s,minHeight:c,maxWidth:l,maxHeight:u},keepAspectRatio:d,resizeDirection:f,onResizeStart:h,onResize:g,onResizeEnd:_,shouldResize:m}),()=>{w.current?.destroy()}},[T,s,c,l,u,d,h,g,_,m]);let E=T.split(`-`);return(0,J.jsx)(`div`,{className:Se([`react-flow__resize-control`,`nodrag`,...E,n,r]),ref:x,style:{...i,scale:C,...o&&{[S?`backgroundColor`:`borderColor`]:o}},children:a})}(0,Y.memo)(Qf);var $f=new Set([`running`,`in_progress`,`claimed`]);function ep(e){return e.pending_question?`question`:$f.has(e.status)?`running`:e.status.startsWith(`paused`)||e.status===`blocked`?`paused`:[`done`,`failed`,`aborted`,`skipped`,`superseded`,`pending`,`missing`].includes(e.status)?e.status:`unknown`}function tp(e){let t=new Set,n=[],r=new Map([...e.keys()].map(e=>[e,[]]));for(let[t,n]of e)for(let e of n)r.get(e).push(t);for(let r of e.keys()){let i=[[r,!1]];for(;i.length;){let[r,a]=i.pop();if(a)n.push(r);else if(!t.has(r)){t.add(r),i.push([r,!0]);for(let n of e.get(r))t.has(n)||i.push([n,!1])}}}let i=new Map;for(let e of n.reverse()){if(i.has(e))continue;let t=i.size,n=[e];for(;n.length;){let e=n.pop();if(!i.has(e)){i.set(e,t);for(let t of r.get(e))n.push(t)}}}return i}function np(e){let t=new Map(e.map(e=>[e.id,e])),n=[...t.values()].sort((e,t)=>(e.ts??0)-(t.ts??0)||e.id.localeCompare(t.id)),r=[],i=new Set;for(let e of n)for(let n of new Set(e.deps??[]))t.has(n)||i.add(n),r.push({id:JSON.stringify([`dep`,n,e.id]),source:n,target:e.id,kind:`dependency`,missing:!t.has(n)});let a=[...[...i].map(e=>({id:e,title:`未包含的依赖`,objective:`该引用不在当前数据范围内。`,status:`missing`,deps:[],role:`system`})),...n],o=new Map(a.map(e=>[e.id,0])),s=new Map(a.map(e=>[e.id,[]]));r.forEach(e=>{o.set(e.target,(o.get(e.target)??0)+1),s.get(e.source)?.push(e.target)});let c=a.filter(e=>o.get(e.id)===0).map(e=>e.id),l=0;for(let e=0;et.id!==e.id&&t.plan_id===e.superseded_by_plan_id);t.length&&r.push({id:JSON.stringify([`replacement`,e.id,e.superseded_by_plan_id]),source:e.id,target:t[0].id,kind:`replacement`,target_plan_id:e.superseded_by_plan_id,target_count:t.length})}if(u){let e=tp(s);r.filter(t=>t.kind===`dependency`&&e.get(t.source)===e.get(t.target)).forEach(e=>{e.cycle=!0})}return{tasks:a,links:r,missing:i.size,cyclic:u}}function rp(e,t){let n=e.team_task_id?.match(/route-(\d+)/)?.[1],r=e.team_role===`idea-route`?t?`研究路线`:`Research route`:e.team_role===`idea-review`?t?`独立复核`:`Independent review`:e.team_role===`idea-selector`?t?`方案选择`:`Idea selection`:``;return r?`${r}${n?` ${n}`:``}`:e.title||(t?`并行子任务`:`Parallel task`)}function ip(e){let t=String(e||``).split(/\r?\n/).map(e=>e.replace(/^\s*(?:RESULT|SUMMARY|NEXT_ACTION)\s*=\s*/i,``).trim()).filter(e=>e&&!/^(?:Decision\s*:|(?:MILESTONE_STATUS|NEXT_OWNER|OPERATOR_QUESTION|OPERATOR_OPTIONS)\s*=)/i.test(e)).join(` `);return t.length>160?`${t.slice(0,159)}…`:t}function ap(e){let t=new Map;for(let n of e){if(n.type!==`idea.portfolio.formed`)continue;let e=Number(n.width);if(!Number.isInteger(e)||e<=0)continue;let r=t.get(n.item_id);(!r||n.ts>=r.ts)&&t.set(n.item_id,{ts:n.ts,width:e})}return new Map([...t].map(([e,t])=>[e,t.width]))}function op(e,t,n){let r=new Map;for(let e of t){if(e.type!==`team.task`||!e.item_id)continue;let t=r.get(e.item_id)??new Map;t.set(e.id,e),r.set(e.item_id,t)}if(!r.size)return e;let i=new Set(e.tasks.map(e=>e.id)),a=[],o=[];for(let t of e.tasks){if(t.branch)continue;let e=[...r.get(t.id)?.values()??[]].filter(e=>!i.has(e.id)).sort((e,t)=>e.ts-t.ts||e.id.localeCompare(t.id));if(!e.length)continue;let s=e.slice(0,16),c=new Set(s.map(e=>e.id));for(let e of s)i.add(e.id),a.push({id:e.id,title:rp(e,n),objective:ip(e.text),excerpt:ip(e.text),status:e.status||`unknown`,deps:[],pending_question:e.pending_question,role:`team`,team_role:e.team_role,ts:e.ts,branch:!0,parent_id:t.id});let l=new Set(s.flatMap(e=>(e.deps??[]).filter(t=>c.has(t)&&t!==e.id)));for(let e of s){let n=[...new Set(e.deps??[])].filter(t=>c.has(t)&&t!==e.id);if(n.length)for(let t of n)o.push({id:JSON.stringify([`fanout`,t,e.id]),source:t,target:e.id,kind:`fanout`});else o.push({id:JSON.stringify([`fanout`,t.id,e.id]),source:t.id,target:e.id,kind:`fanout`});l.has(e.id)||o.push({id:JSON.stringify([`fanin`,e.id,t.id]),source:e.id,target:t.id,kind:`fanin`})}let u=e.length-s.length,d=`team-overflow:${t.id}`;u>0&&!i.has(d)&&(i.add(d),a.push({id:d,title:n?`还有 ${u} 条`:`+${u} more`,objective:n?`更多并行子任务收录在所属任务卡片中。`:`The remaining parallel subtasks live inside the owning card.`,status:`recorded`,deps:[],role:`team`,ts:e[16]?.ts,branch:!0,parent_id:t.id,overflow_count:u}),o.push({id:JSON.stringify([`fanout`,t.id,d]),source:t.id,target:d,kind:`fanout`},{id:JSON.stringify([`fanin`,d,t.id]),source:d,target:t.id,kind:`fanin`}))}return a.length?{...e,tasks:[...e.tasks,...a],links:[...e.links,...o]}:e}function sp(e,t,n){let r=e.links.map(e=>{let r=t.find(t=>t.source===e.source&&t.target===e.target);return r&&e.kind===`dependency`?{...e,label:r.label,evidence:`${n?`执行依赖`:`Execution dependency`} · ${r.evidence}`}:e}),i=new Map(e.tasks.map(e=>[e.id,e.id])),a=e=>{let t=i.get(e);return t===e?e:a(t)},o=(e,t)=>{i.set(a(e),a(t))};for(let e of r.filter(e=>e.kind===`dependency`))o(e.source,e.target);for(let n of t)!i.has(n.source)||!i.has(n.target)||e.tasks.findIndex(e=>e.id===n.source)>=e.tasks.findIndex(e=>e.id===n.target)||a(n.source)===a(n.target)||(r.push({...n,kind:`semantic`,id:`semantic:${n.source}:${n.target}`}),o(n.source,n.target));for(let t=1;tcp+Math.min(500,Math.max(0,e-8)*60);function dp(e,t,n,r,i,a,o){let s=new Map(n.map(e=>[e,t[e].y+i[e].height/2]));for(let c=0;c<6;c++)for(let l of c%2?[...e].reverse():e){let e=new Set(l),c=[],u=[],d=0;l.forEach((f,p)=>{let m=s.get(f)*.8,h=.8;for(let o of a[r.get(f)]){let r=n[o.index];e.has(r)||(m+=(t[r].y+i[r].height/2)*o.weight,h+=o.weight)}c.push(d);let g=m/h-i[f].height/2-d;for(u.push({start:p,end:p,sum:g*h,weight:h});u.length>1;){let e=u[u.length-2],t=u[u.length-1];if(e.sum/e.weight<=t.sum/t.weight)break;e.end=t.end,e.sum+=t.sum,e.weight+=t.weight,u.pop()}d+=i[f].height+(p+1[e,t])),a=t.filter(e=>e.kind!==`replacement`&&e.source!==e.target).map(e=>({source:i.get(e.source),target:i.get(e.target),weight:e.kind===`dependency`||e.kind===`continuation`?1:.4})),o=e.map(()=>[]),s=e.map(()=>[]),c=e.map(()=>[]);for(let e of a)o[e.source].push(e.target),s[e.target].push(e.source),c[e.source].push({index:e.target,weight:e.weight}),c[e.target].push({index:e.source,weight:e.weight});let l=e.reduce((e,t)=>e+n[t].width*n[t].height,0),u=Math.sqrt(l/e.length),d=e.reduce((e,t)=>e+n[t].height,0)/e.length,f=Math.ceil(Math.sqrt(e.length)*1.8),p=e.map(()=>[]);for(let e of a)p[Math.max(e.source,e.target)].push(e);let m=e.map((t,n)=>{let r=0;return Array.from({length:Math.min(f,e.length-n)+1},(e,t)=>{if(t)for(let e of p[n+t-1])Math.min(e.source,e.target)1||s[e.target].length>1)&&(r+=e.weight*.9),r+=Math.max(0,Math.abs(e.target-e.source)-1)*e.weight);return r})}),h={},g=1/0,_=new Set;for(let t=1;t<=f;t++){let o=t*d+(t-1)*lp,f=Array(e.length+1).fill(1/0),p=Array(e.length+1).fill(0);f[0]=0;for(let r=1;r<=e.length;r++){let i=0;for(let a=r-1;a>=Math.max(0,r-t);a--){i+=n[e[a]].height+(a===r-1?0:lp);let t=m[a][r-a];a>0&&s[a].some(e=>s[a-1].includes(e))&&(t+=.7);let c=f[a]+.2+(i/o-1)**2+t;c0;t=p[t])v.unshift(e.slice(p[t],t));let y=JSON.stringify(v);if(_.has(y))continue;_.add(y);let b=v.map(e=>Math.max(...e.map(e=>n[e].width))),x=v.map(e=>e.reduce((e,t)=>e+n[t].height,0)+(e.length-1)*lp),S=b.reduce((e,t)=>e+t,0)+(v.length-1)*r,C=Math.max(...x),w={},T=0;v.forEach((e,t)=>{let i=(C-x[t])/2;for(let r of e)w[r]={x:T+(b[t]-n[r].width)/2,y:i},i+=n[r].height+lp;T+=b[t]+r}),dp(v,w,e,i,n,c,()=>lp);let E=Math.min(...e.map(e=>w[e].y));for(let t of e)w[t].y-=E;C=Math.max(...e.map(e=>w[e].y+n[e].height));let D=a.reduce((t,r)=>{let i=w[e[r.source]],a=w[e[r.target]];return t+Math.hypot(a.x+n[e[r.target]].width/2-i.x-n[e[r.source]].width/2,a.y+n[e[r.target]].height/2-i.y-n[e[r.source]].height/2)*r.weight},0)/Math.max(1,a.length)/u,O=2*Math.log(S/C/2.1)**2+.08*S*C/l+.14*D+.08*f[e.length]/v.length;O[e,t])),a=e=>e.source!==e.target&&i.has(e.source)&&i.has(e.target),o=new Set,s=new Map;for(let e of t)!a(e)||e.kind!==`fanout`&&e.kind!==`fanin`||(e.kind===`fanout`?o.add(e.target):o.add(e.source),(s.get(e.source)??s.set(e.source,new Set).get(e.source)).add(e.target),(s.get(e.target)??s.set(e.target,new Set).get(e.target)).add(e.source));let c=e.map(()=>[]),l=t.filter(e=>e.kind!==`replacement`&&a(e)).map(e=>({source:i.get(e.source),target:i.get(e.target),weight:e.kind===`dependency`||e.kind===`continuation`?1:e.kind===`fanout`||e.kind===`fanin`?.8:.4}));for(let e of l)c[e.source].push({index:e.target,weight:e.weight}),c[e.target].push({index:e.source,weight:e.weight});let u=e.map(()=>[]);for(let e of t){if(!pp.has(e.kind)||!a(e))continue;let t=i.get(e.source),n=i.get(e.target);td[e]))+1:f+1;d.push(e),f=Math.max(f,e)}let p=[];e.forEach((e,t)=>{(p[d[t]]??=[]).push(e)});let m=p.filter(e=>e?.length),h=(e,t)=>o.has(e)&&o.has(t)?lp/2:lp,g=e=>e.reduce((t,r,i)=>t+n[r].height+(i?h(e[i-1],r):0),0),_=e.reduce((e,t)=>e+n[t].width*n[t].height,0),v=Math.sqrt(_/e.length),y=e.filter(e=>!o.has(e)),b=(y.length?y:e).reduce((e,t)=>e+n[t].height,0)/Math.max(1,y.length||e.length),x=Math.ceil(Math.sqrt(e.length)*1.8),S={},C=1/0,w=new Set;for(let t=1;t<=x;t++){let a=t*b+(t-1)*lp,u=[];for(let e of m){let t=[],n=()=>{if(!t.length)return;let e=o.has(t[0]);if(e)u.push({nodes:t,isBranch:e});else{let n=[];for(let r of t)n.length&&g([...n,r])>a&&(u.push({nodes:n,isBranch:e}),n=[]),n.push(r);n.length&&u.push({nodes:n,isBranch:e})}t=[]};for(let r of e)t.length&&o.has(t[0])!==o.has(r)&&n(),t.push(r);n()}let d=[],f=[];for(let e of u){let t=d.at(-1),n=t&&e.nodes.some(e=>t.some(t=>s.get(e)?.has(t)));!t||n||f.at(-1)!==e.isBranch||g([...t,...e.nodes])>a?(d.push([...e.nodes]),f.push(e.isBranch)):t.push(...e.nodes)}let p=JSON.stringify(d);if(w.has(p))continue;w.add(p);let y=d.map(e=>Math.max(...e.map(e=>n[e].width))),x=d.map(g),T=y.reduce((e,t)=>e+t,0)+(d.length-1)*r,E=Math.max(...x),D={},O=0;d.forEach((e,t)=>{let i=(E-x[t])/2;e.forEach((r,a)=>{D[r]={x:O+(y[t]-n[r].width)/2,y:i},i+=n[r].height+(a+1D[e].y));for(let t of e)D[t].y-=k;E=Math.max(...e.map(e=>D[e].y+n[e].height));let A=l.reduce((t,r)=>{let i=D[e[r.source]],a=D[e[r.target]];return t+Math.hypot(a.x+n[e[r.target]].width/2-i.x-n[e[r.source]].width/2,a.y+n[e[r.target]].height/2-i.y-n[e[r.source]].height/2)*r.weight},0)/Math.max(1,l.length)/v,j=2*Math.log(T/E/2.1)**2+.08*T*E/_+.14*A;j=e.length*.3?mp(e,t,n):fp(e,t,n)}function gp(e){let t=new Map,n=new Map,r=new Map;return e.map(e=>{let i=`${e.source}\u0000${e.target}`,a=(t.get(e.source)??0)+(n.get(e.target)??0)-(r.get(i)??0);return t.set(e.source,(t.get(e.source)??0)+1),n.set(e.target,(n.get(e.target)??0)+1),r.set(i,(r.get(i)??0)+1),a})}function _p(e,t){if(e.x===t.x&&e.y===t.y)return{sourceHandle:`right`,targetHandle:`bottom`};let n=t.x+t.width/2-e.x-e.width/2,r=t.y+t.height/2-e.y-e.height/2,i=r>0?t.y-e.y-e.height:e.y-t.y-t.height,a=n>0?t.x-e.x-e.width:e.x-t.x-t.width;return i>=0&&a<0?r>=0?{sourceHandle:`bottom`,targetHandle:`top`}:{sourceHandle:`top`,targetHandle:`bottom`}:n>=0?{sourceHandle:`right`,targetHandle:`left`}:{sourceHandle:`left`,targetHandle:`right`}}var vp={width:1440,height:1080},yp=[`plan`,`execution`,`review`,`revision`,`result`];function bp(e,t){let n=e.team_task_id?.match(/route-(\d+)/)?.[1],r=e.team_role===`idea-route`?t?`研究路线`:`Research route`:e.team_role===`idea-review`?t?`独立复核`:`Independent review`:e.team_role===`idea-selector`?t?`方案选择`:`Idea selection`:``;return r?`${r}${n?` ${n}`:``}`:e.title||(t?`并行子任务`:`Parallel task`)}function xp(e,t,n){return e.pending_question?t?`需要答复,展开查看具体问题`:`Needs your input; open to read the question`:e.status===`failed`?t?`本次执行失败,展开查看原因`:`This attempt failed; open to read the reason`:e.status===`blocked`?t?`执行受阻,展开查看原因`:`Work is blocked; open to read the reason`:e.status===`done`?e.team_role===`idea-review`?t?`独立复核已完成,展开查看记录`:`Independent review completed; open to read the record`:t?`子任务执行已完成,展开查看记录`:`Subtask execution completed; open to read the record`:e.status===`pending`?n?t?`等待前置子任务完成后开始`:`Waiting for prerequisite subtasks to finish`:t?`等待分配 Agent 执行`:`Waiting for an agent to start`:$f.has(e.status||``)?e.team_role===`idea-route`?t?`正在开展来源研究,整理候选方案`:`Researching sources and developing a candidate idea`:e.team_role===`idea-review`?t?`正在独立核对依据、创新性和风险`:`Independently checking evidence, novelty and risks`:e.team_role===`idea-selector`?t?`正在对比研究路线及复核意见`:`Comparing research routes and independent reviews`:t?`Agent 正在执行此子任务`:`An agent is working on this subtask`:t?`展开查看子任务执行记录`:`Open to read the subtask record`}var Sp=e=>e?`暂无详细记录`:`No details available yet.`,Cp=[{match:/provider[\s-]?turn/i,bare:/^One Engineer call used its whole per-call provider-turn allowance/,zh:`继续换了个新会话接着做,之前的进展都在`,en:`Continued in a fresh session; earlier progress is kept`},{match:/budget (limit|cap|exhausted)|blocking budget|预算上限/i,bare:/^Paused because this project reached its budget limit/,zh:`花费到了预算上限,先暂停;提高预算后可以继续`,en:`Paused at the budget limit; work resumes once the budget is raised`},{match:/quarantin/i,bare:/^The task signature is quarantined out of planner rotation/,zh:`这个方向连续失败,先搁置,不再自动重试`,en:`This direction kept failing and is set aside; it will not retry on its own`},{match:/backend[\s\S]{0,24}?(fail|unavailable|paused)|backend_failure|provider cooldown|configured model is unavailable/i,bare:/^(?:backend failure; retrying in a fresh|The backend has failed the same way \d+ times in a row)/,zh:`模型服务暂时不稳定,稍后会自动重试`,en:`The model service was briefly unavailable; it retries after a short wait`}];function wp(e,t){let n=String(e||``).trim(),r=n.search(/Runner receipt:/i),i=r>=0?n.slice(r).trim():``,a=i?Cp.find(e=>e.match.test(n)):Cp.find(e=>e.bare?.test(n));return a?{summary:t?a.zh:a.en,receipt:i||n}:{summary:``,receipt:i}}function Tp(e,t=140){let n=e.replace(/\s+/g,` `).trim();if(!n)return``;let r=n.match(/^.*?[。!?!?.](?=\s|$)/),i=(r?r[0]:n).trim();return i.length>t?`${i.slice(0,t-1).trimEnd()}…`:i}function Ep(e){let t=e.replace(/\s+/g,` `).trim().split(/[。!?;;::,,\n]|\.(?=\s|$)|[!?](?=\s|$)/)[0]?.trim();return t&&t.length>=6&&t.length<=40?t:``}function Dp(e){return String(e||``).split(/\r?\n/).filter(e=>!/^(?:Decision\s*:|(?:MILESTONE_STATUS|NEXT_OWNER|OPERATOR_QUESTION|OPERATOR_OPTIONS)\s*=)/i.test(e.trim())).map(e=>e.replace(/^\s*(?:RESULT|SUMMARY)\s*=\s*/i,``).replace(/^\s*NEXT_ACTION\s*=\s*/i,``)).join(` +`).trim()}function Op(e,t,n){let r=[{id:`${e.id}:brief`,kind:`plan`,title:n?`任务目标`:`Task brief`,detail:e.objective||e.title,status:`recorded`,source:`task`,eventIds:[]}],i=new Set,a=0,o=t.filter(t=>t.item_id===e.id).sort((e,t)=>e.ts-t.ts||(e.type===`team.task`&&t.type===`team.task`?(e.team_task_id||e.id).localeCompare(t.team_task_id||t.id):0)),s=new Map(o.filter(e=>e.type===`team.task`).map(e=>[e.id,e]));for(let e of o){if(i.has(e.id))continue;if(i.add(e.id),e.type===`team.task`){let t=[...new Set(e.deps||[])],i=t.map(e=>s.has(e)?bp(s.get(e),n):n?`其他记录中的子任务`:`Task outside this view`),a=Dp(e.text);r.push({id:e.id,kind:e.team_role===`idea-review`||e.role===`reviewer`?`review`:e.team_role===`idea-selector`?`plan`:`execution`,title:bp(e,n),summary:xp(e,n,t.some(e=>s.has(e)&&s.get(e).status!==`done`)),detail:[a,e.reason&&!a.includes(e.reason)?e.reason:``,e.pending_question?`${n?`需要答复`:`Needs input`}: ${e.pending_question}`:``,i.length?`${n?`依赖`:`Depends on`}: ${i.join(` · `)}`:``].filter(Boolean).join(` + +`),status:e.pending_question?`question`:e.status||`unknown`,ts:e.ts,source:`team`,eventIds:[e.id],teamId:e.team_id,teamTaskId:e.team_task_id,teamRole:e.team_role,deps:t,updatedAt:e.updated_ts,revision:e.revision});continue}e.type===`life.mission.started`&&a++;let t=e.type.includes(`review`)||e.type===`life.phase.started`&&e.role===`reviewer`?`review`:e.type===`life.planner.task_added`?`plan`:e.type===`life.mission.completed`||e.type===`life.mission.failed`?`result`:e.type===`round.start`||e.type===`round.main.completed`||e.type===`life.mission.started`||e.type===`life.phase.started`?`execution`:null;if(!t)continue;let o=e.round_index,c=e.type.endsWith(`.completed`)||e.type.endsWith(`.failed`),l=t===`review`&&e.review_skipped===!0,u=(l?`skipped`:e.status)||(e.success===!1||e.type.endsWith(`.failed`)?`failed`:e.success===!0?`done`:c?`recorded`:`started`),d=wp(e.text||``,n),f=String(e.text||``),p=d.receipt?f.lastIndexOf(d.receipt):-1,m=Dp(p>=0?f.slice(0,p):f),h=u===`done`?n?`审查通过`:`Review passed`:u===`continue`?n?`审查:继续推进`:`Review: keep going`:[`blocked`,`replan`,`replan_requested`].includes(u)?n?`审查:需要调整`:`Review: needs a change`:u===`failed`?n?`审查未通过`:`Review failed`:``,g=t===`execution`?Ep(m):``,_=l?n?`审查未执行`:`Review not performed`:t===`review`?c?h||(n?`审查意见`:`Review outcome`):n?`开始审查`:`Review started`:t===`result`?n?`执行结果`:`Execution result`:t===`plan`?n?`任务进入计划`:`Added to plan`:g||(e.type===`life.mission.started`?n?`开始执行`:`Execution started`:e.type===`round.main.completed`?n?`本轮执行记录`:`Round execution`:n?`执行尝试`:`Execution attempt`);r.push({id:e.id,kind:t,title:_,summary:d.summary||Tp(m)||void 0,detail:[m||d.summary||Sp(n),l&&e.next_action?`${n?`下一步`:`Next action`}: ${e.next_action}`:``,d.receipt?`${n?`——运行记录:`:`— runner receipt: `}${d.receipt.replace(/^Runner receipt:\s*/i,``)}`:``].filter(Boolean).join(` + +`),status:u,ts:e.ts,round:o,episode:a,source:e.association===`single_active_window`?`interval`:`event`,eventIds:[e.id]}),!l&&e.next_action&&[`continue`,`blocked`,`replan`,`replan_requested`].includes(e.status||``)&&r.push({id:`${e.id}:next`,kind:`revision`,title:n?`建议的修订`:`Requested revision`,detail:e.next_action,status:`requested`,ts:e.ts,round:o,episode:a,source:e.association===`single_active_window`?`interval`:`event`,eventIds:[e.id]})}!r.some(e=>e.kind===`execution`)&&$f.has(e.status)&&r.push({id:`${e.id}:active`,kind:`execution`,title:n?`执行进展`:`Execution progress`,detail:e.summary||``,status:e.status,source:`task`,eventIds:[]}),!r.some(e=>e.kind===`result`)&&[`done`,`failed`,`aborted`,`skipped`,`superseded`].includes(e.status)&&r.push({id:`${e.id}:outcome`,kind:`result`,title:n?`任务状态记录`:`Recorded task outcome`,detail:e.summary||``,status:e.status,source:`task`,eventIds:[]});let c=[],l=new Map;for(let e of r){let t=e.round!=null&&[`execution`,`review`].includes(e.kind),n=`${e.episode}:${e.round}:${e.kind}`,r=t?l.get(n):void 0;if(r)r.title=e.title,r.summary=e.summary??r.summary,r.detail=e.detail,r.status=e.status,r.eventIds.push(...e.eventIds),e.source===`interval`&&(r.source=`interval`);else{let r={...e,eventIds:[...e.eventIds]};c.push(r),t&&l.set(n,r)}}return c}function kp(e,t,n,r=Op(e,t,n),i=0){let a=1,o=1/0;for(let e=1;e<=Math.min(3,r.length);e++){let t=Math.ceil(r.length/e),n=Math.max(640,t*232+(t-1)*108+96),i=408+(e-1)*236,s=Math.abs(Math.log(n/i/1.6))+.6*(t*e-r.length)/(t*e);s{let o=t*a,s=Math.min(o+a,r.length),c=u+t*340;return r.slice(o,s).forEach((e,t)=>{d[e.id]={x:c,y:180+t*236}}),{id:`steps:${i+o}`,title:n?`环节 ${i+o+1}–${i+s}`:`Steps ${i+o+1}–${i+s}`,x:c,y:142}});return{steps:r,links:jp(r,n),columns:f,positions:d,width:c,height:l}}function Ap(e){let t=Math.max(600/e.height,Math.min(1e3/e.height,vp.width/e.width));return{width:e.width*t,height:e.height*t,scale:t}}function jp(e,t){let n=e.filter(e=>e.source===`team`);if(n.length){let r=e.filter(e=>e.source!==`team`),i=new Map(n.map(e=>[e.id,e])),a=r.find(e=>e.source===`task`&&e.kind===`plan`),o=[];for(let e of n){for(let n of e.deps||[]){let r=i.get(n);!r||r.id===e.id||r.teamId!==e.teamId||o.push({id:`link:${r.id}:${e.id}`,source:r.id,target:e.id,relation:`dependency`,label:t?`前置任务`:`Depends on`,explanation:t?`${e.title} 的任务记录明确依赖 ${r.title}。`:`${e.title} explicitly depends on ${r.title} in its taskboard.`,contextual:!1})}a&&!e.deps?.length&&o.push({id:`link:${a.id}:${e.id}`,source:a.id,target:e.id,relation:`assignment`,label:t?`任务分支`:`Branch`,explanation:t?`该子任务属于当前主任务;此线不表示等待主任务完成。`:`This worker belongs to the current mission; the link does not require the parent to finish first.`,contextual:!0})}return[...jp(r,t),...o]}return e.slice(1).map((n,r)=>{let i=e[r],a=i.episode===n.episode,o=a&&i.round!=null&&i.round===n.round,s=`record_order`,c=t?`后续记录`:`Later record`,l=t?`同一任务的相邻观察,未确认直接因果或执行依赖。`:`Adjacent observations of the same task; no causal dependency is asserted.`;i.kind===`plan`&&[`plan`,`execution`].includes(n.kind)?(s=`assignment`,c=t?n.kind===`plan`?`纳入计划`:`执行此任务`:`Execute`,l=t?`同一任务的目标/计划与其执行记录关联。`:`The task brief or plan is linked to execution of that same task.`):i.kind===`execution`&&n.kind===`review`&&o?(s=`review`,c=t?`提交审查`:`Review`,l=t?`同一个任务、同一执行段、同一轮次的执行与审查记录。`:`Execution and review belong to the same task, episode and numbered round.`):i.kind===`review`&&n.kind===`revision`&&n.eventIds.some(e=>i.eventIds.includes(e))?(s=`revision`,c=t?`提出修订`:`Revise`,l=t?`这条修订建议来自对应的审查记录。`:`This revision was requested in the corresponding review.`):i.kind===`revision`&&n.kind===`execution`&&a&&i.round!=null&&n.round!=null&&n.round>i.round?(s=`next_attempt`,c=t?`进入下轮`:`Next round`,l=t?`修订建议之后出现了同一任务的下一轮执行;不表示建议的全部内容已被采纳。`:`A later round follows the revision request; this does not certify every requested change was applied.`):n.kind===`result`&&n.source===`task`?(s=`snapshot`,c=t?`状态记录`:`Recorded status`,l=t?`任务状态记录;部分执行过程可能缺失。`:`Links to the captured state of this task; intermediate records may be missing.`):n.kind===`result`&&[`review`,`execution`,`revision`].includes(i.kind)&&(s=`outcome`,c=t?`形成结果`:`Outcome`,l=t?`同一任务的后续完成/失败事件,不等同于成功认证。`:`A completion or failure event of this task, not a certification of success.`);let u=[`record_order`,`snapshot`].includes(s)||i.source===`interval`||n.source===`interval`;return(i.source===`interval`||n.source===`interval`)&&(l+=t?` 部分旧记录按唯一活动任务区间归属,因此使用虚线。`:` Some legacy observations are associated by the sole active mission window, so this link is dashed.`),{id:`link:${i.id}:${n.id}`,source:i.id,target:n.id,relation:s,label:c,explanation:l,contextual:u}})}function Mp(e){let t=[],n=[];for(let r=0;r12&&(t.push(n),n=[]),n.push(...i)}return n.length&&t.push(n),t}function Np(e,t,n,r){for(let i of[n,r]){let n={x:(i.x-t.x)/t.zoom,y:(i.y-t.y)/t.zoom},r=e.find(e=>!e.hidden&&n.x>=e.position.x&&n.x<=e.position.x+(e.width??1152)&&n.y>=e.position.y&&n.y<=e.position.y+(e.height??824));if(r)return r.id}return null}function Pp(e,t,n,r,i=sp(e,[],n)){let a=[],o={},s=[],c=new Map;for(let[r,i]of e.tasks.entries()){let e=Op(i,t,n),l=Mp(e),u=l.length,d=e=>e===1?i.id:JSON.stringify([`part`,i.id,e]),f=0;for(let c=1;c<=u;c++){let p=l[c-1],m=d(c);if(a.push({id:m,task:i,ordinal:r+1,part:c,partCount:u,start:f+1,end:f+p.length,totalSteps:e.length,previousId:c>1?d(c-1):void 0,nextId:c1){let t=jp([e[f-1],p[0]],n)[0];s.push({id:JSON.stringify([`continuation`,i.id,c]),source:d(c-1),target:m,kind:`continuation`,label:t?n?`继续`:`Continued`:n?`更多分支`:`More branches`,evidence:t?`${i.title} · ${t.label} · ${e[f-1].title} → ${p[0].title}`:`${i.title} · ${n?`同一任务的其他分支,不表示串行依赖。`:`Other branches of the same mission, without a serial dependency.`}`})}f+=p.length}c.set(i.id,d(u))}let l=Object.fromEntries(Object.entries(o).map(([e,t])=>[e,Ap(t)])),u=[...i.map(e=>({...e,source:c.get(e.source),target:e.target})),...s],d=a.map(e=>e.id),f=JSON.stringify([d.map(e=>[e,l[e].width,l[e].height]),u.map(e=>[e.source,e.target,e.kind])]);return{cards:a,links:u,layouts:o,positions:r?.structure===f?r.positions:hp(d,u,l),frames:l,structure:f}}var Fp=({children:e})=>(0,J.jsxs)(`span`,{children:[e,` `]}),Ip=(0,Y.memo)(function({children:e}){return(0,J.jsx)(s,{remarkPlugins:[c],components:{p:Fp,h1:Fp,h2:Fp,h3:Fp,h4:Fp,h5:Fp,h6:Fp,ul:Fp,ol:Fp,blockquote:Fp,pre:Fp,li:({children:e})=>(0,J.jsxs)(`span`,{className:`markdown-excerpt-item`,children:[e,` `]}),table:Fp,thead:Fp,tbody:Fp,tr:Fp,th:({children:e})=>(0,J.jsxs)(`strong`,{children:[e,` · `]}),td:Fp,a:({children:e})=>(0,J.jsx)(`span`,{className:`markdown-excerpt-link`,children:e}),img:({alt:e})=>(0,J.jsx)(`span`,{children:e}),input:({checked:e})=>(0,J.jsx)(`span`,{children:e?`✓ `:`○ `}),hr:()=>(0,J.jsx)(`span`,{children:` · `}),code:({children:e})=>(0,J.jsx)(`code`,{children:e})},children:C(e)})});function Lp({path:e,delay:t,padding:n=24,children:r}){let i=`map-growth-${(0,Y.useId)().replace(/:/g,``)}`;if(t==null)return(0,J.jsx)(J.Fragment,{children:r});let a=(e.match(/-?\d+(?:\.\d+)?(?:e[+-]?\d+)?/gi)??[]).map(Number),o=a.filter((e,t)=>t%2==0),s=a.filter((e,t)=>t%2==1);if(!o.length||!s.length)return(0,J.jsx)(J.Fragment,{children:r});let c=Math.min(...o)-n,l=Math.min(...s)-n;return(0,J.jsxs)(`g`,{"data-map-growing-edge":`true`,children:[(0,J.jsx)(`defs`,{children:(0,J.jsx)(`mask`,{id:i,maskUnits:`userSpaceOnUse`,x:c,y:l,width:Math.max(...o)-c+n,height:Math.max(...s)-l+n,children:(0,J.jsx)(`path`,{className:`map-growth-mask`,d:e,pathLength:1,fill:`none`,stroke:`white`,strokeWidth:n*2,strokeLinecap:`round`,style:{animationDelay:`${t}ms`}})})}),(0,J.jsx)(`g`,{mask:`url(#${i})`,children:r})]})}function Rp({layout:e,growing:t={},activeStep:n,activeTeamSteps:r=[]}){let i=`submap-arrow-${(0,Y.useId)().replace(/:/g,``)}`;return(0,J.jsxs)(`svg`,{className:`submap-relations`,width:e.width,height:e.height,"aria-label":`Task process relationships`,children:[(0,J.jsx)(`defs`,{children:(0,J.jsx)(`marker`,{id:i,viewBox:`0 0 10 10`,refX:`9`,refY:`5`,markerWidth:`8`,markerHeight:`8`,orient:`auto`,children:(0,J.jsx)(`path`,{d:`M 0 0 L 10 5 L 0 10 z`,fill:`#91a8bc`})})}),e.links.map(a=>{let o=e.positions[a.source],s=e.positions[a.target],c=o.x===s.x&&s.y>o.y,l=o.x+(c?116:232),u=o.y+(c?180:90),d=s.x+(c?116:0),f=s.y+(c?0:90),p=(l+d)/2,m=(u+f)/2,h=c?`M ${l} ${u} L ${d} ${f}`:`M ${l} ${u} C ${p} ${u}, ${p} ${f}, ${d} ${f}`;return(0,J.jsxs)(`g`,{"data-testid":`submap-relation`,"data-relation":a.relation,"data-source":a.source,"data-target":a.target,"aria-label":`${a.label}: ${a.explanation}`,children:[(0,J.jsx)(`title`,{children:a.explanation}),(0,J.jsx)(Lp,{path:h,delay:t[a.id],children:(0,J.jsx)(`path`,{className:`submap-relation-path`,d:h,fill:`none`,stroke:`#91a8bc`,strokeWidth:`2`,strokeDasharray:a.contextual?`5 6`:void 0,markerEnd:`url(#${i})`})}),(n===a.target||r.includes(a.target))&&(0,J.jsx)(`path`,{className:`submap-flow`,d:h,pathLength:1,fill:`none`,stroke:`#4b9cae`,strokeWidth:`3`,strokeDasharray:`.09 .91`,strokeLinecap:`round`,"aria-hidden":`true`}),(0,J.jsxs)(`g`,{className:`submap-relation-label`,transform:`translate(${p}, ${m})`,children:[(0,J.jsx)(`rect`,{x:`-38`,y:`-11`,width:`76`,height:`22`,rx:`6`}),(0,J.jsx)(`text`,{textAnchor:`middle`,dominantBaseline:`central`,children:a.label})]})]},a.id)})]})}var zp=(0,Y.createContext)({notes:{}}),Bp=(0,Y.createContext)({}),Vp={plan:[`Planner`,`Planner`],execution:[`Engineer`,`Engineer`],review:[`Reviewer`,`Reviewer`],revision:[`修订`,`Revise`],result:[`结果`,`Result`]},Hp={plan:l,execution:d,review:I,revision:le,result:O},Up={done:[`已完成`,`Completed`],running:[`进行中`,`In progress`],pending:[`待开始`,`Planned`],failed:[`未通过`,`Failed`],aborted:[`已取消`,`Cancelled`],skipped:[`已跳过`,`Skipped`],superseded:[`已替代`,`Superseded`],question:[`待答复`,`Needs input`],paused:[`已暂停`,`Paused`],paused_external_work:[`等待后台任务`,`Waiting on background work`],missing:[`引用缺失`,`Missing`],unknown:[`状态未知`,`Unknown`],continue:[`需修订`,`Revise`],blocked:[`受阻`,`Blocked`],started:[`开始记录`,`Started`],recorded:[`已记录`,`Recorded`],requested:[`修订建议`,`Suggested`],replan:[`调整计划`,`Revise plan`],replan_requested:[`调整计划`,`Revise plan`]},Wp=(e,t)=>e.source===`team`?t?`子任务工作记录`:`Subtask work record`:e.source===`task`?t?`任务记录`:`Task record`:e.source===`interval`?t?`根据同期记录关联`:`By execution window`:t?`来自任务记录`:`Linked event`,Gp=(0,Y.memo)(function({id:e,data:t}){let{task:n,ordinal:r,zh:i,layout:a,focused:o,detailed:s}=t,{artifacts:c,onOpenArtifact:l}=(0,Y.useContext)(Bp),d=(0,Y.useContext)(zp).notes[n.id]??[],f=Q(e=>{let n=e.transform[2]*t.frame.width;return n<140?`micro`:n<230?`compact`:`full`}),[p]=(0,Y.useState)(()=>!t.restoring&&!t.seenCards?.has(e));(0,Y.useEffect)(()=>{t.seenCards?.add(e)},[t.seenCards,e]);let[m,h]=(0,Y.useState)(null),g=m||a,v=e=>e.source===`team`&&a.steps.find(t=>t.id===e.id)||e,y=t.canvasSize?.width||window.innerWidth,b=t.canvasSize?.height||window.innerHeight;(0,Y.useEffect)(()=>{s||(S(null),h(null))},[s]);let[x,S]=(0,Y.useState)(null),E=(0,Y.useRef)(n.status),[D,O]=(0,Y.useState)(!1);(0,Y.useEffect)(()=>{let e=E.current!==n.status;if(E.current=n.status,!e||n.status!==`done`)return;O(!0);let t=setTimeout(()=>O(!1),1500);return()=>clearTimeout(t)},[n.status]);let k=g.steps.find(e=>e.id===x),A=k?v(k):void 0,N=A?.updatedAt??A?.ts,P=t.part===t.partCount,F=P?n.status===`missing`?`missing`:t.paused&&$f.has(n.status)?`paused`:ep(n):`recorded`,I=F===`paused`&&n.status===`paused_external_work`?n.status:F,L=Math.min(t.frame.width/288,t.frame.height/218),R=t.copy?.cards||{},z=!!R[n.id]?.summary&&R[n.id]?.task_status!==n.status&&($f.has(n.status)||n.status===`pending`),B=e=>{let t=R[e.id];if(e.source!==`team`)return t;let n=t?.event_ids?.indexOf(e.id)??-1;return v(e).revision&&n>=0&&t?.event_revisions?.[n]===v(e).revision?t:void 0},V=(R[n.id]?.title||n.title)+(t.part>1?i?` · 续篇 ${t.part-1}`:` · Continued ${t.part-1}`:``),ee=i?`环节 ${t.start}–${t.end} / ${t.totalSteps}`:`Steps ${t.start}–${t.end} / ${t.totalSteps}`,te=t.partCount>1?g.steps.map(e=>B(e)?.summary||v(e).summary||v(e).detail).filter(e=>e&&![Sp(!0),Sp(!1)].includes(e)).at(-1):void 0,H=Math.min(t.frame.width/g.width,t.frame.height/g.height),U=P&&t.live&&$f.has(n.status)?[...g.steps].reverse().find(e=>e.source!==`team`&&![`plan`,`result`].includes(e.kind))?.id:null,W=t.paused?null:U,G=a.steps.filter(e=>e.source===`team`),K=t.live?G.filter(e=>$f.has(e.status)).map(e=>e.id):[],re=G.filter(e=>e.status===`done`).length,ie=G.filter(e=>$f.has(e.status)).length,ae=e=>e.source===`team`?K.includes(e.id):W===e.id,oe=e=>e.source===`team`?v(e).status:U===e.id?t.paused?`paused`:`running`:e.status,se=e=>({source:t.source,task_id:n.id,task_title:V,lang:i?`zh`:`en`,part:t.partCount>1?t.part:void 0,step_id:e?.id,step_title:e?.title,team_id:e?.teamId,team_task_id:e?.teamTaskId,event_ids:e?e.eventIds:t.partCount>1?[...new Set(g.steps.flatMap(e=>e.eventIds))]:R[n.id]?.event_ids||[]}),ce=Math.min(640,g.width-48,Math.max(260,(y-50)/1.05)),le=Math.min(600,g.height-48,Math.max(300,(b-(y<640?180:160))/1.05)),q=e=>({x:Math.max(24,Math.min(g.positions[e.id].x-16,g.width-ce-24)),y:Math.max(24,Math.min(g.positions[e.id].y-16,g.height-le-24)),width:ce,height:le,scale:H}),ue=A?q(A):null,de=n=>{h(g),S(n.id),t.readStep(e,q(n))};(0,Y.useEffect)(()=>{A&&t.readStep(e,q(A))},[y,b]);let fe=e=>(Up[e===`paused_external_work`?e:e.startsWith(`paused_`)?`paused`:$f.has(e)?`running`:e]??Up.unknown)[+!i];return(0,J.jsxs)(`article`,{className:`map-macro map-state-${F}`,"data-testid":`map-macro`,"data-task-id":n.id,"data-card-id":e,"data-part":t.part,"data-arrive":p,"data-growing":t.growthDelay!=null,"data-dispatch":t.dispatchState,style:{animationDelay:`${t.growthDelay??0}ms`},"data-focused":o,"data-detailed":s,"aria-label":V,"data-overview-density":f,"data-completed-now":D,"data-active":K.length>0||P&&t.live&&!t.paused&&$f.has(n.status),onContextMenu:e=>{e.preventDefault(),e.stopPropagation(),t.menu(se(),{x:e.clientX,y:e.clientY})},children:[[`source`,`target`].flatMap(e=>[Z.Left,Z.Right,Z.Top,Z.Bottom].map(t=>(0,J.jsx)(Nu,{id:t,type:e,position:t,isConnectable:!1},`${e}-${t}`))),(0,J.jsx)(`div`,{className:`macro-summary`,"aria-hidden":s,style:{"--summary-scale":L,"--summary-height":`${t.frame.height/L-20}px`,width:t.frame.width/L-20,transform:`translate(-50%, -50%) scale(${L})`},children:(0,J.jsxs)(`button`,{className:`map-card map-state-${F} nodrag nopan`,"data-testid":`map-card`,"data-task-id":n.id,"data-card-id":e,"data-part":t.part,tabIndex:s?-1:0,onClick:()=>t.open(e),"aria-label":`${V} · ${i?`放大任务`:`Explore task`}`,children:[(0,J.jsxs)(`div`,{className:`map-card-top`,children:[(0,J.jsxs)(`span`,{className:`map-card-number`,children:[String(r).padStart(2,`0`),t.partCount>1&&` · ${t.part}/${t.partCount}`]}),(0,J.jsxs)(`span`,{className:`map-status`,children:[F===`done`?(0,J.jsx)(T,{size:11}):F===`failed`?(0,J.jsx)(j,{size:11}):F===`question`?(0,J.jsx)(w,{size:11}):F===`paused`?(0,J.jsx)(M,{size:11}):(0,J.jsx)(`span`,{className:`map-state-dot`}),fe(I)]})]}),(0,J.jsxs)(`h3`,{children:[(0,J.jsx)(Ip,{children:V}),d.length>0&&(0,J.jsx)(`span`,{className:`macro-note-badge`,title:i?`操作员批注`:`Operator notes`,children:d.length})]}),(0,J.jsx)(`div`,{className:`map-card-copy`,children:(0,J.jsx)(Ip,{children:te||R[n.id]?.summary||n.pending_question||n.summary||n.objective||(i?`放大查看任务内部`:`Zoom to explore`)})}),(0,J.jsx)(`div`,{className:`map-card-stages`,"aria-label":i?`任务阶段`:`Task stages`,children:[`plan`,`execution`,`review`,`result`].map(e=>{let t=Hp[e],n=g.steps.some(t=>t.kind===e),r=g.steps.some(t=>t.kind===e&&ae(t));return(0,J.jsxs)(`span`,{className:`submap-kind-${e}`,"data-present":n,"data-active":r,title:Vp[e][+!i],children:[(0,J.jsx)(t,{size:12}),(0,J.jsx)(`span`,{children:i?{plan:`规划`,execution:`执行`,review:`审查`,result:`交付`}[e]:Vp[e][1]})]},e)})}),G.length>0&&(0,J.jsx)(`span`,{className:`map-card-teambar`,"aria-hidden":!0,children:(0,J.jsx)(`i`,{style:{width:`${Math.round(re/G.length*100)}%`}})}),(0,J.jsxs)(`div`,{className:`map-card-bottom`,children:[(0,J.jsx)(`span`,{className:G.length?`map-card-team-summary`:void 0,title:ee,children:G.length?(i?`子任务 ${re}/${G.length} 完成 · ${ie} 进行中`:`Subtasks ${re}/${G.length} done · ${ie} running`)+((t.plannedWidth??0)>G.length?i?` · 计划并行 ×${t.plannedWidth}`:` · planned ×${t.plannedWidth}`:``):t.plannedWidth&&$f.has(n.status)?i?`并行编队 ×${t.plannedWidth} 展开中`:`Fanning out ×${t.plannedWidth}`:t.partCount>1?ee:`${g.steps.length} ${i?`个环节`:`steps`}`}),(0,J.jsxs)(`span`,{className:`map-card-submap-hint`,children:[z?i?`描述更新中`:`Summary updating`:i?`查看进展`:`View progress`,(0,J.jsx)(u,{size:12})]})]})]})}),(0,J.jsxs)(`div`,{className:`macro-detail ${A?`is-reading`:``}`,"aria-hidden":!s,style:{width:g.width,height:g.height,transform:`scale(${H})`,transformOrigin:`top left`},children:[(0,J.jsxs)(`header`,{className:`macro-heading`,children:[(0,J.jsx)(`span`,{className:`macro-index`,children:String(r).padStart(2,`0`)}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`small`,{children:t.partCount>1?i?`第 ${t.part} / ${t.partCount} 部分`:`Part ${t.part} / ${t.partCount}`:i?`任务内部`:`INSIDE THIS TASK`}),(0,J.jsx)(`h2`,{children:(0,J.jsx)(Ip,{children:V})})]}),(0,J.jsx)(`span`,{className:`macro-state`,children:fe(I)})]}),(0,J.jsx)(`div`,{className:`macro-stage-key`,children:yp.map(e=>(0,J.jsx)(`span`,{className:`submap-kind-${e} ${g.steps.some(t=>t.kind===e)?``:`is-unrecorded`}`,children:Vp[e][+!i]},e))}),d.length>0&&(0,J.jsxs)(`aside`,{className:`macro-notes`,"aria-label":i?`操作员批注`:`Operator notes`,children:[(0,J.jsx)(`small`,{children:i?`批注`:`Notes`}),d.map(e=>(0,J.jsx)(`p`,{children:e.text},e.id))]}),(0,J.jsx)(Rp,{layout:g,growing:t.growingLinks,activeStep:W,activeTeamSteps:K}),g.columns.map(e=>(0,J.jsx)(`div`,{className:`macro-column-label`,style:{left:e.x,top:e.y},children:e.title},e.id)),g.steps.map(e=>{let n=v(e),r=Hp[n.kind];return(0,J.jsxs)(`button`,{className:`submap-step submap-kind-${n.kind} nodrag nopan ${x===n.id?`is-selected`:``}`,"data-testid":`submap-step`,"data-step-id":n.id,"data-source":n.source,"data-team-id":n.teamId,"data-team-task-id":n.teamTaskId,"data-status":oe(n),"data-active":ae(n),"data-growing":t.growingSteps?.[n.id]!=null,onContextMenu:e=>{e.preventDefault(),e.stopPropagation(),t.menu(se(n),{x:e.clientX,y:e.clientY})},style:{animationDelay:`${t.growingSteps?.[n.id]??0}ms`,left:g.positions[n.id].x,top:g.positions[n.id].y},tabIndex:s?0:-1,onClick:()=>de(n),"aria-expanded":x===n.id,children:[(0,J.jsxs)(`div`,{className:`submap-step-meta`,children:[(0,J.jsxs)(`span`,{children:[(0,J.jsx)(r,{size:16}),n.source===`team`?i?`子任务 · `:`Subtask · `:``,Vp[n.kind][+!i],n.round!=null&&(0,J.jsx)(`em`,{className:`submap-round`,children:i?`第 ${n.round} 轮`:`R${n.round}`})]}),(0,J.jsx)(`small`,{children:n.source===`team`&&oe(n)===`failed`?i?`失败`:`Failed`:fe(oe(n))})]}),(0,J.jsx)(`h4`,{children:(0,J.jsx)(Ip,{children:n.title})}),(0,J.jsx)(`div`,{className:`submap-step-copy`,children:(0,J.jsx)(Ip,{children:B(n)?.summary||v(n).summary||n.detail||Sp(i)})}),(0,J.jsxs)(`div`,{className:`submap-step-foot`,children:[(0,J.jsx)(`span`,{title:Wp(n,i),children:i?`查看详情`:`Read more`}),(0,J.jsx)(u,{size:14})]})]},n.id)}),t.partCount>1&&!A&&(0,J.jsxs)(`nav`,{className:`macro-part-nav nodrag nopan`,"aria-label":i?`任务各部分`:`Task parts`,children:[(0,J.jsx)(`span`,{children:ee}),(0,J.jsxs)(`div`,{children:[(0,J.jsxs)(`button`,{disabled:!t.previousId,onClick:()=>t.previousId&&t.open(t.previousId),children:[(0,J.jsx)(ne,{size:14}),i?`上一部分`:`Previous part`]}),(0,J.jsxs)(`button`,{disabled:!t.nextId,onClick:()=>t.nextId&&t.open(t.nextId),children:[i?`下一部分`:`Next part`,(0,J.jsx)(u,{size:14})]})]})]}),A&&ue&&(0,J.jsxs)(`section`,{className:`macro-reader nodrag nopan nowheel`,"data-testid":`map-reader`,"data-kind":A.kind,role:`region`,"aria-label":i?`卡片详情`:`Card details`,style:{left:ue.x,top:ue.y,width:ue.width,height:ue.height},onContextMenu:e=>{e.preventDefault(),e.stopPropagation(),t.menu(se(A),{x:e.clientX,y:e.clientY})},children:[(0,J.jsxs)(`header`,{children:[(0,J.jsx)(`span`,{children:Vp[A.kind][+!i]}),(0,J.jsx)(`button`,{"aria-label":`Close step details`,onClick:()=>{S(null),h(null),t.open(e)},children:(0,J.jsx)(j,{size:20})})]}),(0,J.jsx)(`h3`,{children:(0,J.jsx)(Ip,{children:A.title})}),(0,J.jsx)(`div`,{className:`macro-reader-body`,children:(0,J.jsx)(_,{artifacts:c,onOpenArtifact:l,children:C(B(A)?.detail||A.detail||Sp(i))})}),(0,J.jsxs)(`footer`,{children:[(0,J.jsx)(`span`,{title:Wp(A,i),children:N?new Date(N*1e3).toLocaleString(i?`zh-CN`:`en-US`):``}),!t.readOnly&&(0,J.jsx)(`button`,{onClick:()=>t.quote(se(A)),children:i?`引用此项`:`Reference`})]})]})]})]})});function Kp(e){let t={};for(let n of e)(t[n.node_id]??=[]).push(n);for(let e of Object.values(t))e.sort((e,t)=>e.ts-t.ts||e.id.localeCompare(t.id));return t}var qp={width:640,height:190},Jp={"idea-route":q,"idea-review":I,"idea-selector":oe},Yp={done:`✓`,failed:`✕`,question:`?`,paused:`‖`,running:`▶`,superseded:`↪`},Xp={done:[`已完成`,`Completed`],running:[`进行中`,`In progress`],pending:[`待开始`,`Planned`],failed:[`未通过`,`Failed`],question:[`待答复`,`Needs input`],paused:[`已暂停`,`Paused`],aborted:[`已取消`,`Cancelled`],skipped:[`已跳过`,`Skipped`],superseded:[`已替代`,`Superseded`],unknown:[`已记录`,`Recorded`]},Zp=(0,Y.memo)(function({data:e}){let{task:t,zh:n,fanIndex:r,fanCount:i}=e,a=ep(t),o=t.overflow_count?ae:Jp[t.team_role??``]??l,s=(Xp[a]??Xp.unknown)[+!n],c=Yp[a],u=typeof r==`number`&&typeof i==`number`;return(0,J.jsxs)(`button`,{type:`button`,className:`map-branch map-state-${a} nodrag nopan`,"data-testid":`map-branch`,"data-branch-id":t.id,"data-status":a,"data-overflow":!!t.overflow_count,title:t.excerpt||t.objective||t.title,"aria-label":`${t.title} · ${s} · ${n?`打开所属任务`:`Open the owning task`}`,onClick:()=>e.open(e.parentCardId),children:[[`source`,`target`].flatMap(e=>[Z.Left,Z.Right,Z.Top,Z.Bottom].map(t=>(0,J.jsx)(Nu,{id:t,type:e,position:t,isConnectable:!1},`${e}-${t}`))),(0,J.jsx)(`span`,{className:`map-branch-glyph`,"aria-hidden":`true`,children:(0,J.jsx)(o,{})}),c&&(0,J.jsx)(`span`,{className:`map-branch-state`,"aria-hidden":`true`,children:c}),(0,J.jsx)(`span`,{className:`map-branch-title`,children:t.title}),u&&(0,J.jsx)(`span`,{className:`map-branch-fan`,"data-testid":`map-branch-fan`,title:n?`并行分支 ${r} / ${i}`:`Parallel branch ${r} of ${i}`,children:`${r}/${i}`}),(0,J.jsx)(`span`,{className:`map-branch-dot`,"aria-hidden":`true`})]})}),Qp={x:52,y:125,zoom:.24},$p=.035,em=3.5,tm=(e,t,n)=>Math.max(t,Math.min(n,e));function nm(e){let t=e.getBoundingClientRect(),n=e.querySelector(`.map-canvas-toolbar`)?.getBoundingClientRect(),r=e.querySelector(`.map-composer-dock`)?.getBoundingClientRect(),i=e.querySelector(`.react-flow__minimap`)?.getBoundingClientRect(),a=e.querySelector(`.map-legend`)?.getBoundingClientRect(),o=e.querySelector(`.react-flow__controls`)?.getBoundingClientRect(),s=e.dataset.reading===`true`,c=e.clientWidth<640?20:50,l=Math.max(n?n.bottom-t.top+20:85,!s&&e.clientWidth<640&&a?a.bottom-t.top+16:0,!s&&e.clientWidth<640&&o?o.bottom-t.top+16:0),u=Math.max(r?t.bottom-r.top+24:100,!s&&i?t.bottom-i.top+20:0);return{x:c,y:l,width:Math.max(180,e.clientWidth-c*2),height:Math.max(100,e.clientHeight-l-u)}}var rm=.72,im=.85,am=(e,t)=>e?0:t;function om(e,t,n){let r=Math.min(t.width/n.width,t.height/n.height),i=Math.min(e.width,e.height)/Math.min(n.width,n.height);return Math.min(Math.max(r,rm*i),im*i)}function sm(e,t,n){let r=tm(Math.min(t.width/(n.width+160),t.height/(n.height+160)),$p,.27),i=(e,t,n,r)=>r>t?(n-r)/2:tm((n-r)/2,e,e+t-r);return{x:i(t.x,t.width,e.width,n.width*r)-n.x*r,y:i(t.y,t.height,e.height,n.height*r)-n.y*r,zoom:r}}function cm(e,t,n){let r=Math.min(48,e.height*.35),i=e.height-r,a=Math.min(em,Math.min(1.05,e.width/n.width,i/n.height)/n.scale);return{x:e.x+e.width/2-(t.x+(n.x+n.width/2)*n.scale)*a,y:e.y+r+i/2-(t.y+(n.y+n.height/2)*n.scale)*a,zoom:a}}function lm(e,t=!0){let n=ou(),[r,i]=(0,Y.useState)(null),[a,o]=(0,Y.useState)(!1),[s,c]=(0,Y.useState)({width:0,height:0}),l=(0,Y.useRef)(null),u=(0,Y.useRef)(!1),d=(0,Y.useRef)(!1),f=(0,Y.useRef)(!1),p=(0,Y.useRef)(()=>{}),m=(0,Y.useRef)(null),h=(0,Y.useRef)(null),g=(0,Y.useRef)(()=>{}),_=(0,Y.useRef)(()=>{}),[v,y]=(0,Y.useState)(()=>window.matchMedia(`(prefers-reduced-motion: reduce)`).matches),b=(0,Y.useRef)(Qp),x=(0,Y.useRef)(null),S=(0,Y.useRef)(null),C=(0,Y.useRef)(null),w=(0,Y.useRef)(0),T=(0,Y.useRef)(null),E=(0,Y.useCallback)(()=>{cancelAnimationFrame(w.current),w.current=0,T.current=null},[]),D=(0,Y.useCallback)((t,r)=>{t&&(f.current=!1,d.current=!1);let a=e.current;if(!a)return;let s={x:a.clientWidth/2,y:a.clientHeight/2},c=x.current&&x.current.until>performance.now()?x.current:s,p=S.current??(u.current?m.current:null)??Np(n.getNodes().filter(e=>e.data.frame),r,c,s),h=p&&(n.getNode(p)?.data)?.frame?.scale||1,g=tm((r.zoom-.3)/.14,0,1)*tm((r.zoom*h-.28)/.3,0,1),_=C.current,v=u.current?1:_?.id===p?tm((r.zoom-_.zoom*.65)/(_.zoom*.35),0,1):g;l.current=v>0?p:null,a.style.setProperty(`--detail-alpha`,String(v)),a.style.setProperty(`--summary-alpha`,String(1-v)),a.style.setProperty(`--context-alpha`,String(p?1-v*.72:1)),a.dataset.zoom=r.zoom.toFixed(2),a.style.setProperty(`--map-zoom`,String(r.zoom)),i(v>0&&p?p:null),o(v>=.55),r.zoom<=.32&&!S.current&&!T.current&&!C.current&&(b.current=r)},[n,e]),O=(0,Y.useCallback)(t=>{f.current=!1,E();let r=n.getNode(t),i=e.current;if(!r||!i)return;n.getZoom()<=.32&&!C.current&&(b.current=n.getViewport()),S.current=t,u.current=!1,delete i.dataset.reading,d.current=!0;let a=nm(i),o=r.width||1440,s=r.height||1080,c=tm(Math.max(om({width:i.clientWidth,height:i.clientHeight},a,{width:o,height:s}),i.clientWidth<640||(r.data.layout?.steps.length??0)>20?.6/(r.data.frame?.scale||1):0),$p,em);C.current={id:t,zoom:c};let l=a.x+Math.max(0,(a.width-o*c)/2)-r.position.x*c,p=a.y+Math.max(0,(a.height-s*c)/2)-r.position.y*c;n.setViewport({x:l,y:p,zoom:c},{duration:am(v,380)}).then(()=>{S.current=null})},[E,n,v,e]);_.current=O;let k=(0,Y.useCallback)(()=>{f.current=!1,E(),S.current=null,u.current=!1,e.current&&delete e.current.dataset.reading,d.current=!1,C.current=null,x.current=null;let t=e.current?.querySelector(`.map-macro[data-focused="true"]`)?.dataset.cardId;n.setViewport(b.current,{duration:am(v,320)}).then(()=>{t&&e.current?.querySelector(`[data-testid="map-card"][data-card-id="${CSS.escape(t)}"]`)?.focus({preventScroll:!0})})},[E,n,v,e]),A=(0,Y.useCallback)((t,r)=>{f.current=!1,E(),S.current=t;let i=n.getNode(t),a=e.current;!i||!a||(u.current=!0,a.dataset.reading=`true`,d.current=!0,m.current=t,h.current={id:t,rect:r},n.setViewport(cm(nm(a),i.position,r),{duration:am(v,340)}).then(()=>{S.current=null}))},[E,n,v,e]);g.current=A;let j=(0,Y.useCallback)(e=>{f.current=!1,E(),u.current=!1,d.current=!1,S.current=null,x.current=null,n.setCenter(e.x,e.y,{zoom:n.getZoom(),duration:am(v,180)})},[E,n,v]),M=(0,Y.useCallback)(()=>{f.current=!0,E(),S.current=null,u.current=!1,d.current=!1,C.current=null,x.current=null;let t=e.current,r=n.getNodes().filter(e=>!e.hidden);!t||!r.length||n.setViewport(sm({width:t.clientWidth,height:t.clientHeight},nm(t),n.getNodesBounds(r)),{duration:am(v,320)})},[E,n,v,e]);p.current=M;let N=(0,Y.useCallback)(()=>{f.current?p.current():d.current&&u.current&&h.current?g.current(h.current.id,h.current.rect):d.current&&l.current&&_.current(l.current)},[]);return(0,Y.useEffect)(()=>{let t=e.current;if(!t)return;let n,r=t.querySelector(`.map-composer-dock`),i=-1,a=-1,o=-1,s=new ResizeObserver(()=>{let e=r?.getBoundingClientRect().height||0;(i!==t.clientWidth||a!==t.clientHeight||o!==e)&&(i=t.clientWidth,a=t.clientHeight,o=e,t.style.setProperty(`--map-composer-height`,`${o}px`),c(e=>e.width===i&&e.height===a?e:{width:i,height:a}),clearTimeout(n),n=setTimeout(()=>{d.current&&u.current&&h.current?g.current(h.current.id,h.current.rect):d.current&&l.current&&!u.current?_.current(l.current):f.current&&p.current()},100))});return s.observe(t),r&&s.observe(r),()=>{s.disconnect(),clearTimeout(n)}},[e,t]),(0,Y.useEffect)(()=>{let e=window.matchMedia(`(prefers-reduced-motion: reduce)`),t=()=>y(e.matches);return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]),(0,Y.useEffect)(()=>{let t=e.current;if(!t)return;let r=e=>{if(e.target.closest(`.nowheel, .map-canvas-toolbar, .map-legend, .react-flow__minimap, .react-flow__controls`))return;e.preventDefault(),e.stopPropagation(),f.current=!1,u.current=!1,d.current=!0,S.current=null;let r=t.getBoundingClientRect(),i=e.clientX-r.left,a=e.clientY-r.top;x.current={x:i,y:a,until:performance.now()+1e3};let o=T.current??n.getViewport();!T.current&&o.zoom<=.32&&!C.current&&(b.current=o);let s=e.deltaY*(e.deltaMode===1?16:e.deltaMode===2?t.clientHeight:1),c=tm(o.zoom*Math.exp(-tm(s,-400,400)*.002),$p,em);if(T.current={x:i-(i-o.x)*c/o.zoom,y:a-(a-o.y)*c/o.zoom,zoom:c},v){n.setViewport(T.current),T.current=null;return}if(w.current)return;let l=performance.now(),p=e=>{if(!T.current)return;let t=1-Math.exp(-Math.min(e-l,64)/55);l=e;let r=n.getViewport(),i=T.current,a=Math.abs(i.zoom-r.zoom)<15e-5&&Math.abs(i.x-r.x)+Math.abs(i.y-r.y)<.15;n.setViewport(a?i:{x:r.x+(i.x-r.x)*t,y:r.y+(i.y-r.y)*t,zoom:r.zoom+(i.zoom-r.zoom)*t}),a?(w.current=0,T.current=null):w.current=requestAnimationFrame(p)};w.current=requestAnimationFrame(p)},i=()=>{E(),S.current=null,x.current=null},a=e=>{e.defaultPrevented||document.querySelector(`[role="dialog"][aria-modal="true"]`)||e.key===`Escape`&&![`INPUT`,`TEXTAREA`,`SELECT`].includes(e.target.tagName)&&k()};return t.addEventListener(`wheel`,r,{passive:!1,capture:!0}),t.addEventListener(`pointerdown`,i,!0),window.addEventListener(`keydown`,a),()=>{E(),t.removeEventListener(`wheel`,r,!0),t.removeEventListener(`pointerdown`,i,!0),window.removeEventListener(`keydown`,a)}},[k,E,n,v,e]),{capture:(0,Y.useCallback)(()=>({viewport:n.getViewport(),overview:b.current,focusId:l.current,detailed:!!l.current&&(u.current||!!C.current||n.getZoom()>=.44)}),[n]),restore:(0,Y.useCallback)(e=>{E(),b.current=e.overview;let t=e.focusId&&n.getNode(e.focusId)?e.focusId:null;S.current=e.detailed?t:null,C.current=e.detailed&&t?{id:t,zoom:e.viewport.zoom}:null,d.current=!1,f.current=!1,n.setViewport(e.viewport,{duration:0}),D(null,e.viewport)},[E,n,D]),focusId:r,canvasSize:s,detailed:a,enter:O,back:k,fit:M,fitUpdatedScene:N,navigate:j,readStep:A,onMove:D,reducedMotion:v}}function um(e,t,n,r=!0,i,s,c=!1){let l=n?`zh-CN`:`en-US`,u=e.kind===`live`?`project`:`dataset`,d=e.id.replace(/^live:/,``),f=[`map-copy`,u,d,l,s],m=JSON.stringify(f),h=(0,Y.useRef)(m);h.current=m;let g=a(),_=o({queryKey:f,queryFn:async({signal:e})=>{let t=await p.mapCopy(u,d,l,e,s),n=g.getQueryData(f);return V(n,t,n?.model_revision)},staleTime:1/0,gcTime:72e5,refetchOnWindowFocus:!1}),v=e.tasks.find(e=>e.id===t),y=(0,Y.useMemo)(()=>i??(v?Op(v,e.events,n):[]),[v,e.events,n,i]),[b,x]=(0,Y.useState)(0),[S,C]=(0,Y.useState)(!1),w=(0,Y.useRef)(!0),T=(0,Y.useRef)(null),E=(0,Y.useRef)(c);E.current=c;let D=(0,Y.useRef)(0),O=te(e,y,t).filter(t=>k(t,e,_.data)).slice(0,8),A=JSON.stringify([m,O,O.map(t=>e.tasks.find(e=>e.id===t.task_id)?.revision),_.data?.model_revision]);return(0,Y.useEffect)(()=>(w.current=!0,()=>{w.current=!1}),[]),(0,Y.useEffect)(()=>{D.current=0},[m,c]),(0,Y.useEffect)(()=>{if(!r||!_.data?.available||!O.length||!Number.isFinite(D.current)||T.current)return;let e=_.data?.model_revision,t=setTimeout(()=>{let t=g.fetchQuery({queryKey:[`map-copy-generation`,...f],queryFn:()=>p.generateMapCopy(u,d,{cards:O,locale:l},void 0,s),staleTime:0,gcTime:0,retry:!1});T.current=t,C(!0),t.then(t=>{g.setQueryData(f,n=>V(n,t,e)),h.current===m&&(D.current=t.retry_after?Date.now()+t.retry_after*1e3:0)}).catch(()=>{h.current===m&&(D.current=E.current?1/0:Date.now()+6e4)}).finally(()=>{T.current===t&&(T.current=null),w.current&&h.current===m&&(C(!1),x(e=>e+1))})},Math.max(700,D.current-Date.now()));return()=>clearTimeout(t)},[A,b,_.data?.available,r,c]),{copy:_.data,generating:S,ready:_.isFetched}}function dm({value:e,onChange:t,onSend:n,attachments:r,onAttachmentsChange:i,pending:a,pendingLabel:o,dispatchStatus:s,onCancel:c,focusSignal:l,sessionName:u,historical:d,zh:p,routeOverride:g=`auto`,onRouteOverrideChange:_}){let{t:x}=G(),S=(0,Y.useId)(),C=(0,Y.useRef)(null),w=(0,Y.useRef)(null),E=(0,Y.useRef)(null),D=(0,Y.useRef)(!1),O=(0,Y.useRef)(!0),k=(0,Y.useRef)(),[M,I]=(0,Y.useState)(``),[L,R]=(0,Y.useState)(!1),[B,V]=(0,Y.useState)(()=>!!(e.trim()||r.length)),[ee,te]=(0,Y.useState)(44),H=(0,Y.useRef)(e);H.current=e;let W=!B,{refs:K,text:ne}=A(e),re=!!(e.trim()||r.length),ae=(0,Y.useRef)(re);ae.current=re,(0,Y.useEffect)(()=>{O.current=!0;let e=e=>{let t=e.type===`focusout`?e.relatedTarget:e.target;t?.closest?.(`.map-island-launch, .map-island-stop, .map-composer-brand`)||(w.current?.contains(t)?V(!0):ae.current||V(!1))},t=e=>{let t=e.target;w.current?.contains(t)||t?.closest?.(`.map-context-menu`)||ae.current||(V(!1),w.current?.contains(document.activeElement)&&document.activeElement?.blur())},n=e=>{if(e.key!==`c`||e.metaKey||e.ctrlKey||e.altKey||e.defaultPrevented||e.isComposing)return;let t=e.target;t&&(t.tagName===`INPUT`||t.tagName===`TEXTAREA`||t.tagName===`SELECT`||t.isContentEditable)||t?.closest?.(`[role="dialog"], [role="menu"]`)||(e.preventDefault(),V(!0),C.current?.focus())};return document.addEventListener(`focusin`,e),document.addEventListener(`focusout`,e),document.addEventListener(`pointerdown`,t),document.addEventListener(`keydown`,n),()=>{O.current=!1,clearTimeout(k.current),document.removeEventListener(`focusin`,e),document.removeEventListener(`focusout`,e),document.removeEventListener(`pointerdown`,t),document.removeEventListener(`keydown`,n)}},[]);let oe=(0,Y.useRef)(l);(0,Y.useEffect)(()=>{l!==oe.current&&(oe.current=l,V(!0),C.current?.focus())},[l]);let se=(0,Y.useRef)(K.length);(0,Y.useEffect)(()=>{K.length>se.current&&(V(!0),C.current?.focus()),se.current=K.length},[K.length]);let ce=()=>{if(!C.current)return;C.current.style.height=`0px`;let e=Math.min(156,Math.max(44,C.current.scrollHeight));C.current.style.height=`${e}px`,te(e)};(0,Y.useEffect)(ce,[ne]),(0,Y.useEffect)(()=>(window.addEventListener(`resize`,ce),()=>window.removeEventListener(`resize`,ce)),[]);let le=()=>{V(!0),C.current?.focus()},q=()=>{V(!1),w.current?.contains(document.activeElement)&&document.activeElement?.blur()},ue=(0,Y.useRef)(),de=(0,Y.useRef)(typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(`(hover: hover) and (pointer: fine)`).matches);(0,Y.useEffect)(()=>()=>clearTimeout(ue.current),[]);let fe=()=>{de.current&&(clearTimeout(ue.current),V(!0))},pe=()=>{de.current&&(clearTimeout(ue.current),ue.current=setTimeout(()=>{ae.current||w.current?.contains(document.activeElement)||V(!1)},320))},me=async()=>{if(!(!ne.trim()||a||D.current)){D.current=!0;try{await n(e,r)&&O.current&&(I(``),R(!0),(!H.current.trim()||H.current===e)&&q(),clearTimeout(k.current),k.current=setTimeout(()=>R(!1),1800))}finally{D.current=!1}}},X=e=>{if(a||D.current||!e.length)return;let{accepted:t,issues:n}=N(r,e);i([...r,...t]),I(n.map(e=>e.code===`unsupported`?x(`chat.attachUnsupported`,{name:e.fileName}):e.code===`too-large`?x(`chat.attachTooLarge`,{name:e.fileName,size:v(e.limitBytes)}):e.code===`too-many`?x(`chat.attachTooMany`,{count:e.limitCount}):x(`chat.attachTotalTooLarge`,{size:v(e.limitBytes)})).join(` `))},he=s?{launching:[p?`任务已接收`:`Task accepted`,p?`正在放入地图…`:`Adding it to your map…`],task:[p?`任务已进入地图`:`Your task is on the map`,p?`跟随地图,查看执行进展`:`Follow its progress on the map`],message:[p?`Argus 已回复`:`Argus replied`,p?`在对话中查看回复`:`Open the conversation to read it`],error:[p?`发送没有成功`:`Message could not be sent`,p?`草稿已保留,可以重试`:`Your draft is ready to retry`],cancelled:[p?`已停止等待`:`Waiting stopped`,p?`随时继续对话`:`Continue whenever you are ready`]}[s]:void 0,ge=he?.[0]||(a?p?`Argus 正在处理`:`Argus is working`:L?p?`已发送给 Argus`:`Sent to Argus`:p?`交给 Argus`:`Ask Argus`),_e=he?.[1]||(a?o||(p?`正在处理你的消息…`:`Processing your message…`):L?p?`点此继续对话`:`Tap to keep the conversation going`:re?p?`草稿已保留,点此继续`:`Draft saved — tap to continue`:p?`描述目标,看它变成成果`:`Turn your next idea into a result`),ve=s||(a?`working`:L?`sent`:`idle`);return(0,J.jsxs)(`div`,{ref:w,className:`map-composer-dock map-island-dock`,"data-compact":W,"data-state":ve,"data-pending":a,style:{"--map-editor-height":`${ee}px`},onPointerEnter:fe,onPointerLeave:pe,onTransitionEnd:e=>{e.target===w.current&&e.propertyName===`width`&&ce()},children:[!W&&K.length>0&&(0,J.jsx)(`div`,{className:`map-reference-chips`,children:K.map((e,n)=>(0,J.jsxs)(`span`,{title:`${e.source} · ${e.task_id} ${e.step_id||``}`,children:[(0,J.jsxs)(`span`,{children:[p?`引用`:`Reference`,` · `,e.step_title||e.task_title]}),(0,J.jsx)(`button`,{"aria-label":p?`移除引用`:`Remove reference`,onClick:()=>t(K.filter((e,t)=>n!==t).map(F).join(``)+ne),children:(0,J.jsx)(j,{size:12})})]},`${e.task_id}:${e.step_id}:${n}`))}),!W&&!!r.length&&(0,J.jsx)(`div`,{className:`map-attachment-tray nowheel`,role:`group`,"aria-label":p?`待发送附件`:`Selected attachments`,children:r.map((e,t)=>(0,J.jsx)(P,{file:e,disabled:a,removeLabel:x(`chat.attachRemove`,{name:e.name}),onRemove:()=>{i(r.filter(t=>t!==e)),I(``)}},`${e.name}:${e.lastModified}:${t}`))}),!W&&M&&(0,J.jsx)(`div`,{className:`map-attachment-notice nowheel`,role:`alert`,children:M}),(0,J.jsxs)(`div`,{className:`map-composer map-island-surface`,children:[(0,J.jsx)(`button`,{type:`button`,className:`map-composer-brand map-attach`,"aria-label":x(`chat.attach`),title:x(`chat.attach`),"aria-hidden":W,tabIndex:W?-1:0,disabled:a&&!W,onClick:()=>E.current?.click(),children:(0,J.jsx)(h,{size:25})}),(0,J.jsxs)(`button`,{type:`button`,className:`map-island-launch`,"aria-label":p?`打开消息输入`:`Open message composer`,"aria-expanded":!W,"aria-controls":S,"aria-hidden":!W,tabIndex:W?0:-1,onClick:le,children:[(0,J.jsxs)(`span`,{className:`map-island-copy`,children:[(0,J.jsx)(`strong`,{children:ge}),(0,J.jsx)(`small`,{title:_e,children:_e})]}),(0,J.jsx)(`span`,{className:`map-island-indicator`,"aria-hidden":`true`,children:ve===`working`||ve===`launching`?(0,J.jsxs)(`span`,{className:`map-island-wave`,children:[(0,J.jsx)(`i`,{}),(0,J.jsx)(`i`,{}),(0,J.jsx)(`i`,{})]}):ve===`sent`||ve===`task`||ve===`message`?(0,J.jsx)(T,{size:16}):(0,J.jsx)(ie,{size:15})})]}),W&&a&&(0,J.jsx)(`button`,{type:`button`,className:`map-island-stop`,onClick:c,"aria-label":p?`停止等待`:`Stop waiting`,children:(0,J.jsx)(z,{size:13})}),(0,J.jsxs)(`form`,{id:S,className:`map-composer-editor`,"aria-hidden":W,onSubmit:e=>{e.preventDefault(),me()},children:[(0,J.jsx)(`input`,{ref:E,type:`file`,multiple:!0,accept:f,hidden:!0,disabled:a,onChange:e=>{X(Array.from(e.target.files||[])),e.target.value=``}}),(0,J.jsx)(`textarea`,{ref:C,rows:1,tabIndex:W?-1:0,value:ne,"aria-label":p?`给 Argus 发送消息`:`Message Argus`,placeholder:p?`告诉 Argus,你想完成什么…`:`What would you like Argus to do?`,onFocus:()=>V(!0),onChange:e=>{R(!1),t(K.map(F).join(``)+e.target.value)},onPaste:e=>{let t=y(e.clipboardData);t.length&&(e.preventDefault(),X(t))},onKeyDown:e=>{e.key===`Escape`&&!b(e)&&!ne.trim()&&!r.length&&(e.preventDefault(),e.stopPropagation(),q()),e.key===`Enter`&&!e.shiftKey&&!b(e)&&(e.preventDefault(),me())}}),(0,J.jsxs)(`div`,{className:`map-island-toolbar`,children:[(0,J.jsx)(`button`,{type:`button`,className:`map-island-collapse`,tabIndex:W?-1:0,onClick:q,"aria-label":p?`收起消息输入`:`Collapse message composer`,title:p?`收起(草稿会保留)`:`Collapse (draft is kept)`,children:(0,J.jsx)(U,{size:15})}),(0,J.jsx)(`span`,{className:`map-island-key-hint`,"aria-hidden":`true`,children:p?`Enter 发送`:`Enter to send`}),_&&(0,J.jsxs)(`select`,{className:`map-route-select`,tabIndex:W?-1:0,"aria-label":x(`chat.routeLabel`),title:x(`chat.routeHint`),value:g,disabled:a,onChange:e=>_(e.target.value),children:[(0,J.jsx)(`option`,{value:`auto`,children:x(`chat.routeAuto`)}),(0,J.jsx)(`option`,{value:`task`,children:x(`chat.routeTask`)}),(0,J.jsx)(`option`,{value:`chat`,children:x(`chat.routeChat`)})]}),a?(0,J.jsx)(`button`,{type:`button`,onClick:e=>{e.preventDefault(),c()},tabIndex:W?-1:0,"aria-label":p?`停止等待`:`Stop waiting`,className:`map-send is-pending`,children:(0,J.jsx)(z,{size:15})}):(0,J.jsx)(`button`,{type:`submit`,tabIndex:W?-1:0,disabled:!ne.trim(),"aria-label":p?`发送消息`:`Send message`,className:`map-send`,children:(0,J.jsx)(m,{size:20})})]})]})]}),(0,J.jsx)(`span`,{className:`map-composer-caption`,role:`status`,children:he?`${he[0]} · ${he[1]}`:a?o||(p?`Argus 正在处理…`:`Argus is responding…`):L?p?`已发送`:`Sent`:d?`${p?`发送至`:`Send to`} ${u}`:``})]})}function fm(e,t){let n=1-t;return{x:n**3*e[0].x+3*n**2*t*e[1].x+3*n*t**2*e[2].x+t**3*e[3].x,y:n**3*e[0].y+3*n**2*t*e[1].y+3*n*t**2*e[2].y+t**3*e[3].y}}function pm(e,t,n=!1){if(!e.length)return null;let r=n?[...e].reverse():e,i=0;for(let e=1;e0&&i+n>=t){let a=(t-i)/n;return{x:r[e-1].x+(r[e].x-r[e-1].x)*a,y:r[e-1].y+(r[e].y-r[e-1].y)*a}}i+=n}return r[r.length-1]}function mm(e,t,n=0){return e.x>t.x-n&&e.xt.y-n&&e.y({x:n===`left`?-e.x:e.x,y:n===`up`?-e.y:e.y}),s=o(e),c=o(t);i=i.map(e=>({...e,x:n===`left`?-e.x-e.width:e.x,y:n===`up`?-e.y-e.height:e.y}));let l=Math.max(80,n===`loop`?Math.max(Math.abs(c.x-s.x),Math.abs(c.y-s.y))*2.8:0,Math.abs(a?c.y-s.y:c.x-s.x)*(.4+r*.06)),u=[s,a?{x:s.x+0,y:s.y+l}:{x:s.x+l,y:s.y},n===`loop`?{x:c.x,y:c.y+l}:a?{x:c.x-0,y:c.y-l}:{x:c.x-l,y:c.y},c],d=e=>e.flatMap(e=>Array.from({length:31},(t,n)=>fm(e,n/30))),f=e=>d(e).reduce((e,t)=>e+i.filter(e=>mm(t,e,22)).length,0),p=[u],m=f(p)*1e5;if(m){let e={x:(s.x+c.x)/2,y:(s.y+c.y)/2},t=a?e.x:e.y,n=[...new Set(i.flatMap(e=>a?[e.x-110-r*30,e.x+e.width+110+r*30]:[e.y-110-r*30,e.y+e.height+110+r*30]))].sort((e,n)=>Math.abs(e-t)-Math.abs(n-t)).slice(0,12);for(let e of n){let n=(e-t)*4/3;for(let r of[.25,.4,.55]){let i=Math.max(60,Math.abs(a?c.y-s.y:c.x-s.x)*r),o=[a?[s,{x:s.x+n,y:s.y+i},{x:c.x+n,y:c.y-i},c]:[s,{x:s.x+i,y:s.y+n},{x:c.x-i,y:c.y+n},c]],l=f(o)*1e5+Math.abs(e-t)+Math.abs(r-.4)*100;le.map(o)),{path:`M ${e.x} ${e.y}`+p.map(e=>` C ${e[1].x} ${e[1].y}, ${e[2].x} ${e[2].y}, ${e[3].x} ${e[3].y}`).join(``),points:d(p),labels:[.5,.4,.6,.3,.7,.2,.8,.35,.45,.55,.65,.25,.75,.15,.85].map(e=>{let t=Math.min(p.length-1,Math.floor(e*p.length));return fm(p[t],e*p.length-t)})}}var gm=new WeakMap,_m=.5;function vm(e){return e<_m?0:Math.max(_m,Math.floor(e*8)/8)}function ym(e){return e==null?``:String(e).replace(/\s+/g,` `).trim()}function bm(e){let t=[...ym(e)].reduce((e,t)=>e+(/[^\x00-\x7F]/.test(t)?10.5:6),20);return{width:Math.min(t,166),height:26}}function xm(e,t){let n=e.getState(),r=[...n.nodeLookup.values()].filter(e=>!e.hidden).map(e=>({id:e.id,...e.internals.positionAbsolute,width:e.width||e.measured.width||0,height:e.height||e.measured.height||0}));function i(e,t){let r=n.nodeLookup.get(e);if(!r)return null;let{x:i,y:a}=r.internals.positionAbsolute,o=r.width||r.measured.width||0,s=r.height||r.measured.height||0;return{x:i+(t===`left`?0:t===`right`?o:o/2),y:a+(t===`top`?0:t===`bottom`?s:s/2)}}let a=n.edges.filter(e=>!e.hidden).map(e=>({...e,s:i(e.source,e.sourceHandle),t:i(e.target,e.targetHandle)})),o=JSON.stringify([r,a.map(e=>[e.id,e.s,e.t,e.label,e.data?.lane,e.sourceHandle,e.targetHandle,e.className])]),s=gm.get(e);if(!s||s.key!==o){let t=new Map,n=new Map;for(let e of a)n.set(e.id,/(?:^|\s)map-edge-(\w+)/.exec(e.className??``)?.[1]),e.s&&e.t&&t.set(e.id,hm(e.s,e.t,e.source===e.target?`loop`:e.sourceHandle===`left`?`left`:e.sourceHandle===`top`?`up`:e.sourceHandle===`bottom`,Number(e.data?.lane||0),r.filter(t=>t.id!==e.source&&t.id!==e.target)));s={key:o,routes:t,kinds:n,zoom:-1,labels:new Map},gm.set(e,s)}let c=vm(t);return s.zoom!==c&&(s.zoom=c,s.labels=new Map,c&&Sm(s,a,r,c)),s}function Sm(e,t,n,r){let i=[...n];for(let n of t){let t=e.routes.get(n.id);if(!t||!n.label)continue;let a=bm(n.label),o=a.width/r,s=a.height/r,c=[0,3,4,5,6][Number(n.data?.lane||0)%5],l=[t.labels[c],...t.labels.filter((e,t)=>t!==c)].filter(e=>i.every(t=>e.x+o/2<=t.x||e.x-o/2>=t.x+t.width||e.y+s/2<=t.y||e.y-s/2>=t.y+t.height)),u,d=1/0;for(let t of l){let r={x:t.x-o/2,y:t.y-s/2,width:o,height:s},i=0;for(let[t,a]of e.routes)t!==n.id&&a.points.some(e=>mm(e,r))&&i++;if(iMath.round(e.transform[2]*24)/24||e.transform[2]),a=`relation-arrow-${(0,Y.useId)().replace(/:/g,``)}`,o=xm($(),i),s=o.routes.get(e),c=o.labels.get(e);if(!s)return null;let l=o.kinds.get(e),u=l===`fanout`||l===`fanin`,d=!l||n?.stroke===Cm?n?.stroke||`#7594ad`:`var(--map-edge-${l}, ${n?.stroke||`#7594ad`})`,f=(Number(n?.strokeWidth||2)+(u?.4:0))/i,p=u?pm(s.points,(l===`fanout`?2:15)/i,l===`fanin`):null,m=typeof t==`string`?ym(t):void 0;return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`defs`,{children:(0,J.jsx)(`marker`,{id:a,viewBox:`0 0 10 10`,refX:`9`,refY:`5`,markerWidth:10.5/i,markerHeight:10.5/i,markerUnits:`userSpaceOnUse`,orient:`auto`,children:(0,J.jsx)(`path`,{d:`M 0 0 L 10 5 L 0 10 z`,style:{fill:d}})})}),(0,J.jsxs)(Lp,{path:s.path,delay:r?.growthDelay,padding:24/i,children:[(0,J.jsx)(pd,{id:e,path:s.path,markerEnd:`url(#${a})`,style:{...n,stroke:d,vectorEffect:`none`,strokeWidth:f,strokeDasharray:n?.strokeDasharray?String(n.strokeDasharray).split(/[\s,]+/).map(e=>Number(e)/i).join(` `):void 0}}),p&&(0,J.jsx)(`circle`,{className:`map-edge-joint`,cx:p.x,cy:p.y,r:3.2/i,style:{fill:d},"aria-hidden":`true`})]}),r?.active&&(0,J.jsx)(hf,{children:(0,J.jsx)(`div`,{className:`map-edge-spark`,"aria-hidden":`true`,style:{offsetPath:`path("${s.path}")`,width:8/i,height:8/i,margin:`${-4/i}px 0 0 ${-4/i}px`,animationDelay:`${-((e.charCodeAt(0)*131+e.length*47)%2800)}ms`}})}),t&&m!==``&&c&&(0,J.jsx)(hf,{children:(0,J.jsx)(`div`,{className:`map-relation-label nodrag nopan`,"data-kind":l,title:m,style:{transform:`translate(-50%, -50%) translate(${c.x}px, ${c.y}px) scale(${1/i})`},children:m??t})})]})}function Tm({open:e,info:t,zh:n,onChoose:r,readOnly:i=!1}){return(0,J.jsx)(R,{open:e,onClose:()=>r({mode:`off`}),label:n?`选择地图加载范围`:`Choose map history`,width:`max-w-lg`,children:(0,J.jsxs)(`div`,{className:`map-history-choice`,children:[(0,J.jsx)(`h2`,{children:n?`选择地图加载范围`:`Choose map history`}),(0,J.jsx)(`p`,{children:n?`本会话有 ${t.task_count} 个任务,历史记录约 ${(t.event_bytes/1024/1024).toFixed(1)} MB。`:`This session has ${t.task_count} tasks and about ${(t.event_bytes/1024/1024).toFixed(1)} MB of history.`}),(0,J.jsx)(`p`,{children:i?n?`只读模式只加载历史记录,不调用模型。较长历史需要一些加载时间。`:`Read-only mode loads records without model calls. Long histories take time to load.`:n?`加载较长历史需要一些时间。生成卡片摘要与关系说明会调用已配置的模型,并消耗额外 Token。已有摘要会优先复用。`:`Loading a long history takes time. Card summaries and relationship descriptions use your configured model and consume additional tokens. Existing summaries are reused.`}),(0,J.jsxs)(`div`,{className:`map-history-options`,children:[(0,J.jsxs)(`button`,{type:`button`,onClick:()=>r({mode:`current`,since:t.current_task_ts,eventSince:t.current_event_ts,taskId:t.current_task_id||void 0}),children:[(0,J.jsx)(`strong`,{children:n?`从当前进度加载`:`Start at current progress`}),(0,J.jsx)(`span`,{children:n?`推荐 · 加载当前任务及后续进度,保留相关连接`:`Recommended · Load current and future work with its connections`})]}),(0,J.jsxs)(`button`,{type:`button`,onClick:()=>r({mode:`full`}),children:[(0,J.jsx)(`strong`,{children:n?`从头加载`:`Load from the beginning`}),(0,J.jsx)(`span`,{children:n?`分批加载完整历史,再补齐需要的摘要`:`Load the complete history in pages, then prepare missing summaries`})]}),(0,J.jsxs)(`button`,{type:`button`,onClick:()=>r({mode:`off`}),children:[(0,J.jsx)(`strong`,{children:n?`不开启地图模式`:`Keep map mode off`}),(0,J.jsx)(`span`,{children:n?`不加载地图,也不生成摘要`:`Do not load the map or generate summaries`})]})]}),(0,J.jsx)(`small`,{children:n?`选择仅用于本会话,可随时更改加载范围。`:`This choice applies to this session and can be changed later.`})]})})}function Em(e){try{let t=JSON.parse(e||`null`);return!t||![`full`,`current`,`off`].includes(t.mode)||t.mode===`current`&&![t.since,t.eventSince].every(e=>typeof e==`number`&&Number.isFinite(e)&&e>=0)?null:t}catch{return null}}function Dm(e,t){if(!e||e.id!==t.id||t.reset_history)return t;let n=new Map((!t.incremental||t.tasks_complete?[]:e.tasks).map(e=>[e.id,e]));for(let e of t.tasks)n.set(e.id,e);for(let e of t.removed_task_ids||[])n.delete(e);let r=new Map(e.events.filter(e=>t.incremental&&!t.team_events_complete||e.type!==`team.task`).map(e=>[e.id,e]));for(let e of t.events)r.set(e.id,e);for(let e of t.removed_event_ids||[])r.delete(e);return i(e,{...e,...t,tasks:[...n.values()].sort((e,t)=>(e.ts||0)-(t.ts||0)||e.id.localeCompare(t.id)),events:[...r.values()].filter(e=>n.has(e.item_id))})}function Om(e,t,n){return e?t?.history_loading?400:!km(n)||t?.events.some(e=>e.type===`team.task`&&$f.has(e.status||``))?15e3:!1:!1}function km(e){return!e.daemon.alive||e.continuous?.enabled===!1&&/pause|stop/i.test(e.continuous.done_reason||``)?!0:e.daemon.health?.state===`stopped`}var Am=new Map;function jm(e){let t=Am.get(e);if(t)return t;try{let t=JSON.parse(ee(`argus.map.camera.v1:`+e)||`null`);if(t&&[t.viewport,t.overview].every(e=>e&&[e.x,e.y,e.zoom].every(Number.isFinite)&&e.zoom>=.035&&e.zoom<=3.5)&&(t.focusId===null||typeof t.focusId==`string`)&&typeof t.detailed==`boolean`)return{camera:t}}catch{}return{}}function Mm(e,t){for(Am.delete(e),Am.set(e,t);Am.size>8;)Am.delete(Am.keys().next().value);t.camera&&L(`argus.map.camera.v1:`+e,JSON.stringify(t.camera))}var Nm={task:Gp,branch:Zp},Pm={relation:wm},Fm={done:`#a8cfbb`,running:`#8fb6e4`,question:`#e2c78e`,failed:`#dfab97`,paused:`#d6c6a0`,superseded:`#c8bdd5`,aborted:`#c3c5cb`,skipped:`#c3c5cb`,missing:`#c3c5cb`};function Im({events:e,zh:t}){let n=[...new Map(e.filter(e=>e.type===`team.task`).map(e=>[e.id,e])).values()];if(!n.length)return null;let r=n.filter(e=>e.status===`done`).length,i=n.filter(e=>$f.has(e.status||``)).length,a=n.filter(e=>e.status===`failed`).length;return(0,J.jsxs)(`div`,{className:`map-team-progress`,role:`status`,"aria-label":t?`子任务进度`:`Subtask progress`,children:[(0,J.jsx)(`strong`,{children:t?`子任务`:`Subtasks`}),(0,J.jsxs)(`span`,{children:[(0,J.jsx)(T,{size:12}),(0,J.jsxs)(`b`,{children:[r,`/`,n.length]}),` `,t?`已完成`:`completed`]}),(0,J.jsxs)(`span`,{children:[(0,J.jsx)(`b`,{children:i}),` `,t?`进行中`:`running`]}),(0,J.jsxs)(`span`,{children:[(0,J.jsx)(`b`,{children:a}),` `,t?`失败`:`failed`]})]})}function Lm({data:e,zh:t,composer:n,activePhase:r,snapshot:s,events:c,pendingLabel:f,readOnly:m,sessionId:h,viewKey:g,paused:_,actions:v}){let[y,b]=(0,Y.useState)(!1),[x,S]=(0,Y.useState)(!1),[C,w]=(0,Y.useState)(null),O=(0,Y.useRef)(0),k=(0,Y.useRef)(!0);(0,Y.useEffect)(()=>(k.current=!0,()=>{k.current=!1}),[]);let j=(0,Y.useMemo)(()=>np(e.tasks),[e.tasks]),[N,P,I]=gf([]),L=(0,Y.useRef)(null),R=lm(L,!m),z=vf(),V=(0,Y.useRef)(!1),[ee,te]=(0,Y.useState)(!1),U=(0,Y.useRef)(null);U.current||=jm(g);let[W]=(0,Y.useState)(()=>new Set(U.current?.scene?.cards.map(e=>e.id))),G=N.find(e=>e.id===R.focusId),{copy:re,ready:ie}=um(e,G?.data.task.id||null,t,!m&&!e.history_loading,G?.data.layout.steps,h,_),ae=(0,Y.useMemo)(()=>sp(j,re?.relations||[],t),[j,re?.relations,t]),oe=(0,Y.useRef)(U.current.scene),q=(0,Y.useMemo)(()=>{let n=Pp(j,e.events,t,oe.current,ae);return oe.current=i(oe.current,n),oe.current},[j,e.events,t,ae]),de=(0,Y.useRef)(null),pe=(0,Y.useMemo)(()=>(de.current=i(de.current,op(j,e.events,t)),de.current),[j,e.events,t]),me=(0,Y.useRef)(null),X=(0,Y.useMemo)(()=>{let e=pe.tasks.filter(e=>e.branch);if(!e.length)return{links:q.links,positions:q.positions,frames:q.frames,structure:q.structure,branches:e,branchAnchor:new Map};let t=new Map;for(let e of q.cards)t.set(e.task.id,e.id);let n=new Map(e.map(e=>[e.id,t.get(e.parent_id)??e.parent_id])),r={...q.frames};for(let t of e)r[t.id]={...qp,scale:1};let i=[...q.links,...pe.links.filter(e=>e.kind===`fanout`||e.kind===`fanin`).map(e=>({...e,source:t.get(e.source)??e.source,target:t.get(e.target)??e.target}))],a=new Map;for(let t of e){let e=n.get(t.id);a.set(e,[...a.get(e)??[],t.id])}let o=q.cards.flatMap(e=>[e.id,...a.get(e.id)??[]]),s=JSON.stringify([o.map(e=>[e,r[e].width,r[e].height]),i.map(e=>[e.source,e.target,e.kind])]),c=me.current?.structure===s?me.current.positions:hp(o,i,r);return me.current={structure:s,positions:c},{links:i,positions:c,frames:r,structure:s,branches:e,branchAnchor:n}},[q,pe]),he=xe(q,!!e.history_loading),ge=(0,Y.useMemo)(()=>ap(e.events),[e.events]),ve=async(e,t=[])=>{let r=++O.current,i=L.current?.querySelector(`.map-composer`)?.getBoundingClientRect();w({id:r,text:A(e).text.replace(/\s+/g,` `).slice(0,180),origin:{x:i?.left??20,y:i?.top??innerHeight-100,width:i?.width??260,height:i?.height??56}});let a=!1,o=e=>{e.type===`task`&&(a=!0),k.current&&e.type===`settled`&&e.outcome===`message`&&!a&&(S(!0),b(!1)),k.current&&w(t=>t?.id===r?{...t,result:e}:t)};try{let r=await n.onSend(e,t,o);return r&&k.current&&A(e).refs.length>0&&(S(!0),b(!1)),r||o({type:`settled`,outcome:`error`}),r}catch(e){throw o({type:`settled`,outcome:`error`}),e}},be=()=>{w(e=>e?{...e,result:{type:`settled`,outcome:`cancelled`}}:null),n.onCancel()};(0,Y.useEffect)(()=>{if(!z||V.current||!ie||U.current?.camera&&e.history_loading)return;let t=requestAnimationFrame(()=>{V.current=!0,U.current?.camera?R.restore(U.current.camera):R.fit(),te(!0)});return()=>cancelAnimationFrame(t)},[z,R.fit,R.restore,e.history_loading,ie]),(0,Y.useEffect)(()=>{let e=()=>{V.current&&Mm(g,{scene:oe.current,camera:R.capture()})};return window.addEventListener(`pagehide`,e),()=>{e(),window.removeEventListener(`pagehide`,e)}},[g,R.capture]),(0,Y.useEffect)(()=>{if(!z)return;let e=requestAnimationFrame(R.fitUpdatedScene);return()=>cancelAnimationFrame(e)},[X.structure,z,R.fitUpdatedScene]);let Se=(0,Y.useRef)(n);Se.current=n;let Ce=(0,Y.useCallback)(e=>{if(m)return;let t=Se.current;t.onChange(F(e)+t.value),window.setTimeout(()=>document.querySelector(`.map-composer textarea`)?.focus(),0)},[m]),[we,Te]=(0,Y.useState)(null),Ee=a(),De=o({queryKey:[`map-notes`,h],queryFn:({signal:e})=>p.mapNotes(h,e),enabled:e.kind===`live`&&!m,staleTime:6e4}),Oe=(0,Y.useMemo)(()=>({notes:Kp(De.data?.notes??[])}),[De.data]),[ke,Ae]=(0,Y.useState)(null),[je,Me]=(0,Y.useState)(``),[Ne,Pe]=(0,Y.useState)(!1);(0,Y.useEffect)(()=>{if(!ke)return;let e=e=>{e.target.closest(`.map-note-editor`)||Ae(null)},t=e=>{e.key===`Escape`&&(e.stopPropagation(),Ae(null))};return window.addEventListener(`pointerdown`,e),document.addEventListener(`keydown`,t,!0),()=>{window.removeEventListener(`pointerdown`,e),document.removeEventListener(`keydown`,t,!0)}},[ke]);let Fe=async()=>{let e=ke,t=je.trim();if(!(!e||!t)){Pe(!1);try{await p.addMapNote(h,{node_id:e.ref.task_id,text:t}),await Ee.invalidateQueries({queryKey:[`map-notes`,h]}),Ae(null),Me(``)}catch{Pe(!0)}}},Ie=(0,Y.useCallback)((e,t)=>{m||Te({ref:e,x:Math.min(window.innerWidth-180,t.x),y:Math.min(window.innerHeight-140,t.y)})},[m]);(0,Y.useEffect)(()=>{if(!we)return;let e=e=>{e.target.closest(`.map-context-menu`)||Te(null)},t=e=>{e.key===`Escape`&&(e.stopPropagation(),Te(null))};return window.addEventListener(`pointerdown`,e),document.addEventListener(`keydown`,t,!0),()=>{window.removeEventListener(`pointerdown`,e),document.removeEventListener(`keydown`,t,!0)}},[we]);let[Le,Re]=(0,Y.useState)(``),ze=(0,Y.useCallback)(e=>`${e.task.title} ${e.task.objective??``} ${re?.cards[e.task.id]?.title||``} ${re?.cards[e.task.id]?.summary||``} ${e.part>1?t?`续篇 ${e.part-1}`:`Continued ${e.part-1}`:``}`.toLowerCase(),[re,t]),Be=(0,Y.useMemo)(()=>Le?q.cards.filter(e=>ze(e).includes(Le.toLowerCase())):[],[Le,q.cards,ze]),[Ve,He]=(0,Y.useState)(0);(0,Y.useEffect)(()=>He(0),[Le]);let[Ue,We]=(0,Y.useState)(j.tasks.length),[Ge,Ke]=(0,Y.useState)(!1),[qe,Je]=(0,Y.useState)(!1),[Ye,Xe]=(0,Y.useState)(``);(0,Y.useEffect)(()=>{P(n=>i(n,q.cards.map(n=>({id:n.id,type:`task`,position:X.positions[n.id]??q.positions[n.id],width:q.frames[n.id].width,height:q.frames[n.id].height,style:{width:q.frames[n.id].width,height:q.frames[n.id].height},data:{...n,zh:t,open:R.enter,readStep:R.readStep,menu:Ie,quote:Ce,source:e.id,readOnly:m,live:e.kind===`live`,paused:_,seenCards:W,restoring:!!U.current?.camera&&!V.current,layout:q.layouts[n.id],frame:q.frames[n.id],plannedWidth:ge.get(n.task.id),focused:!1,detailed:!1}}))))},[j,q,X,t,P,R.enter,R.readStep,Ie,Ce,e.id,e.kind,m,_,W,ge]),(0,Y.useEffect)(()=>{We(e=>Math.min(Math.max(e,1),j.tasks.length))},[j.tasks.length]),(0,Y.useEffect)(()=>{if(!Ge||R.detailed)return;let e=window.setInterval(()=>We(e=>e>=j.tasks.length?(Ke(!1),e):e+1),900);return()=>window.clearInterval(e)},[Ge,j.tasks.length,R.detailed]);let Ze=(0,Y.useMemo)(()=>{let t=new Set(q.cards.filter(t=>e.kind===`live`||t.ordinal<=Ue).map(e=>e.id));for(let[e,n]of X.branchAnchor)t.has(n)&&t.add(e);return t},[q.cards,Ue,e.kind,X.branchAnchor]),Qe=(0,Y.useRef)([]),$e=(0,Y.useMemo)(()=>{let e=N.map(e=>({...e,hidden:!Ze.has(e.id),data:{...e.data,copy:re?{cards:Object.fromEntries([e.data.task.id,...e.data.layout.steps.map(e=>e.id)].filter(e=>re.cards[e]).map(e=>[e,re.cards[e]]))}:void 0,focused:e.id===R.focusId,detailed:R.detailed&&e.id===R.focusId,canvasSize:R.canvasSize,growthDelay:he.cards[e.id],dispatchState:C?.result?.type===`task`&&C.result.taskId===e.data.task.id&&!n.historical?C.landed?`landed`:`receiving`:void 0,growingSteps:Object.fromEntries(e.data.layout.steps.flatMap(t=>{let n=he.steps[ye(e.id,t.id)];return n==null?[]:[[t.id,n]]})),growingLinks:Object.fromEntries(e.data.layout.links.flatMap(t=>{let n=he.links[ye(e.id,t.id)];return n==null?[]:[[t.id,n]]}))},style:{...e.style,opacity:Le&&!ze(e.data).includes(Le.toLowerCase())?.22:1}}));return Qe.current=i(Qe.current,e),Qe.current},[N,Ze,R.focusId,R.detailed,R.canvasSize,Le,ze,re,t,he,C,n.historical]),et=(0,Y.useRef)([]),tt=(0,Y.useMemo)(()=>{let e=new Map;for(let t of X.branches){let n=t.parent_id??``;e.set(n,(e.get(n)??0)+1)}let n=new Map,r=X.branches.map(r=>{let i=r.parent_id??``,a=(n.get(i)??0)+1;return n.set(i,a),{id:r.id,type:`branch`,position:X.positions[r.id]??{x:0,y:0},width:qp.width,height:qp.height,style:{width:qp.width,height:qp.height},hidden:!Ze.has(r.id),draggable:!1,selectable:!1,focusable:!1,data:{task:r,zh:t,parentCardId:X.branchAnchor.get(r.id),open:R.enter,fanIndex:a,fanCount:e.get(i)}}});return et.current=i(et.current,r),et.current},[X,Ze,t,R.enter]),nt=(0,Y.useMemo)(()=>tt.length?[...$e,...tt]:$e,[$e,tt]),rt=(0,Y.useMemo)(()=>{let n=X.links.filter(e=>Ze.has(e.source)&&Ze.has(e.target)&&(e.kind!==`replacement`||qe)),r=gp(n),i=new Map(q.cards.map(e=>[e.id,e.task])),a=new Set;if(e.kind===`live`&&!_){for(let e of q.cards)$f.has(e.task.status)&&a.add(e.id);for(let e of X.branches)$f.has(e.status)&&a.add(e.id)}return n.map((e,n)=>{let o=e.kind===`fanout`||e.kind===`fanin`;return{id:e.id,source:e.source,target:e.target,..._p({...X.positions[e.source],...X.frames[e.source]},{...X.positions[e.target],...X.frames[e.target]}),type:`relation`,data:{growthDelay:he.links[e.id],active:a.has(e.target),lane:r[n]},className:`map-edge-${e.kind}`,label:o?void 0:e.label||(e.kind===`replacement`?(i.get(e.source)?.superseded_reason||``).replace(/\s+/g,` `).slice(0,60)||(t?`转入新计划`:`New plan`):e.kind===`dependency`?t?`依赖`:`Dependency`:t?`同一研究`:`Related work`),labelStyle:{fontSize:30,fill:e.kind===`replacement`?`#95809f`:`#6685a4`},labelBgPadding:[12,6],labelBgBorderRadius:12,labelBgStyle:{fill:`var(--map-paper)`,fillOpacity:.96},style:{stroke:e.cycle?`#dc6648`:e.kind===`replacement`?`#a48caf`:e.kind===`dependency`?`#527fa7`:`#7594ad`,strokeWidth:e.kind===`dependency`?1.55:o?.95:1.3,vectorEffect:`non-scaling-stroke`,strokeDasharray:e.kind===`dependency`||o?void 0:e.kind===`context`?`3 10`:`4 5`},markerEnd:{type:go.ArrowClosed,color:e.kind===`replacement`?`#a48caf`:`#8aa5b8`,width:32,height:32},ariaLabel:e.evidence||(o?`Team branch: ${e.source} → ${e.target}`:e.kind===`dependency`?`Dependency: ${e.source} → ${e.target}`:`Plan replacement: ${e.source} → ${e.target_plan_id} (${e.target_count} tasks, representative ${e.target})`)}})},[X,Ze,qe,t,he,e.kind,_,q.cards]),it=j.links.filter(e=>e.kind===`replacement`).length,at=(0,Y.useMemo)(()=>{let t={done:0,running:0,question:0,failed:0,other:0};for(let n of e.tasks)n.status===`done`?t.done++:$f.has(n.status)?t.running++:n.pending_question?t.question++:n.status===`failed`?t.failed++:t.other++;return t},[e.tasks]),ot=at.done,st=at.question+at.failed,ct=e=>{We(t=>Math.max(t,q.cards.find(t=>t.id===e)?.ordinal||1)),R.enter(e)},lt=()=>{let n=e.tasks.find(e=>$f.has(e.status))??e.tasks.find(e=>e.pending_question)??e.tasks.find(e=>e.status===`pending`)??e.tasks.at(-1);n?(ct(q.cards.filter(e=>e.task.id===n.id).at(-1).id),Xe(``)):Xe(t?`发送一个目标,地图就会开始生长`:`Send a goal to start your map`)},ut=()=>{let t=e.tasks.find(e=>e.pending_question)??e.tasks.find(e=>e.status===`failed`);t&&ct(q.cards.filter(e=>e.task.id===t.id).at(-1).id)};(0,Y.useEffect)(()=>{let e=e=>{if(!(e.defaultPrevented||e.metaKey||e.ctrlKey||e.altKey||e.isComposing)&&!e.target?.closest(`input, textarea, select, [contenteditable]`)){if(e.key===`/`)e.preventDefault(),L.current?.querySelector(`.map-search input`)?.focus();else if(e.key===`f`||e.key===`F`)R.fit();else if((e.key===`ArrowRight`||e.key===`ArrowLeft`)&&R.detailed&&R.focusId){let t=q.cards.filter(e=>Ze.has(e.id)),n=t.findIndex(e=>e.id===R.focusId);if(n<0)return;let r=t[n+(e.key===`ArrowRight`?1:-1)];r&&(e.preventDefault(),R.enter(r.id))}}};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[R.fit,R.enter,R.detailed,R.focusId,q.cards,Ze]);let dt=(0,Y.useMemo)(()=>({artifacts:v.artifacts,onOpenArtifact:v.onOpenArtifact}),[v.artifacts,v.onOpenArtifact]);return(0,J.jsx)(zp.Provider,{value:Oe,children:(0,J.jsxs)(Bp.Provider,{value:dt,children:[(0,J.jsx)(`div`,{className:`map-progress-line`,role:`progressbar`,"aria-label":t?`已完成任务`:`Completed tasks`,"aria-valuemin":0,"aria-valuemax":e.tasks.length||1,"aria-valuenow":ot,children:(0,J.jsx)(`span`,{style:{width:`${e.tasks.length?ot/e.tasks.length*100:0}%`}})}),(0,J.jsxs)(`div`,{className:`map-summary`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`span`,{className:`map-summary-value`,title:q.cards.length>j.tasks.length?`${q.cards.length} ${t?`张卡片`:`cards`}`:void 0,children:e.tasks.length}),(0,J.jsx)(`span`,{children:t?`个任务`:`tasks`}),e.tasks.length>0&&(0,J.jsx)(`span`,{className:`map-progress-strip`,role:`img`,"aria-label":t?`已完成 ${at.done},进行中 ${at.running},值得关注 ${st}`:`${at.done} completed, ${at.running} running, ${st} need attention`,children:[`done`,`running`,`question`,`failed`,`other`].map(e=>at[e]>0&&(0,J.jsx)(`i`,{className:`seg-${e}`,style:{flexGrow:at[e]}},e))}),(0,J.jsxs)(`span`,{className:`map-count-chip is-done`,children:[(0,J.jsx)(T,{size:13}),(0,J.jsx)(`strong`,{children:ot}),(0,J.jsx)(`span`,{children:t?`已完成`:`completed`})]}),at.running>0&&(0,J.jsxs)(`span`,{className:`map-count-chip is-running`,children:[(0,J.jsx)(`strong`,{children:at.running}),(0,J.jsx)(`span`,{children:t?`进行中`:`running`})]}),st>0&&(0,J.jsxs)(`button`,{type:`button`,className:`map-count-chip map-attention-jump`,onClick:ut,title:t?`跳到需要你处理的任务`:`Jump to the task waiting on you`,children:[(0,J.jsx)(`span`,{className:`map-attention-dot`}),(0,J.jsx)(`strong`,{children:st}),(0,J.jsx)(`span`,{children:t?`值得关注`:`need attention`})]})]}),n.pending?(0,J.jsxs)(`span`,{className:`map-live-phase`,children:[(0,J.jsx)(`i`,{}),t?`正在处理消息`:`Processing your message`]}):_?(0,J.jsx)(`span`,{className:`map-paused-label`,children:e.tasks.length>0&&ot===e.tasks.length?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(T,{size:13}),t?`已完成`:`Completed`]}):e.tasks.some(e=>$f.has(e.status)||e.status===`pending`)?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(M,{size:13}),t?`已暂停`:`Paused`]}):t?`就绪`:`Ready`}):r&&(0,J.jsxs)(`span`,{className:`map-live-phase`,children:[(0,J.jsx)(`i`,{}),{planner:`Planner`,manager:`Manager`,engineer:`Engineer`,reviewer:`Reviewer`}[r]||r]}),(0,J.jsx)(`span`,{className:`map-summary-note`,children:t?`滚轮缩放 · 点击任务深入 · / 搜索 · F 全览`:`Scroll to zoom · click a task to explore · / search · F fit`})]}),(0,J.jsx)(Im,{events:e.events,zh:t}),e.kind===`live`&&(0,J.jsxs)(`div`,{className:`map-workspace-actions`,children:[(0,J.jsxs)(`button`,{type:`button`,"aria-expanded":x,onClick:()=>{S(e=>!e),b(!1)},children:[(0,J.jsx)(ce,{size:15}),t?`对话`:`Conversation`]}),(0,J.jsxs)(`button`,{type:`button`,"aria-expanded":y,onClick:()=>{b(e=>!e),S(!1)},children:[(0,J.jsx)(`i`,{"data-active":!!r||n.pending}),t?`Agent 动态`:`Agent activity`]}),(0,J.jsxs)(`button`,{type:`button`,className:`map-delivery-toggle`,disabled:!v.deliveryCount,onClick:v.onOpenDelivery,children:[(0,J.jsx)(E,{size:15}),t?`交付成果`:`Deliveries`,v.deliveryCount>0&&(0,J.jsx)(`span`,{children:v.deliveryCount})]})]}),e.kind===`live`&&!m&&(0,J.jsx)(D,{questions:s.pending_questions??[],backlog:s.backlog,onAnswer:v.onAnswer,onLocate:ut}),(0,J.jsx)(`div`,{className:`map-workspace`,children:(0,J.jsxs)(`div`,{ref:L,className:`map-canvas-wrap`,"data-focused":!!R.focusId,"data-detailed":R.detailed,"data-fitted":ee,children:[x&&(0,J.jsx)(fe,{events:v.conversationEvents,connected:v.connected,pending:n.pending,artifacts:v.artifacts,zh:t,onClose:()=>S(!1),onOpenArtifact:v.onOpenArtifact,onOpenDelivery:v.onOpenReceipt}),y&&e.kind===`live`&&(0,J.jsx)(`aside`,{className:`map-agent-drawer nowheel nodrag nopan`,children:(0,J.jsx)(B,{view:s.mission_view,roles:s.roles,events:c,taskId:G?.data.task.id||s.mission_view?.mission.id||void 0,paused:_&&!n.pending,onClose:()=>b(!1)})}),C&&!m&&(0,J.jsx)(_e,{flight:C,canvas:L,zh:t,historical:n.historical,onReveal:t=>{e.tasks.some(e=>e.id===t)&&R.fit()},onLand:e=>w(t=>t?.id===e?{...t,landed:!0}:t),onFinish:e=>w(t=>t?.id===e?null:t)}),(0,J.jsxs)(`div`,{className:`map-canvas-toolbar nowheel`,children:[(0,J.jsxs)(`label`,{className:`map-search`,children:[(0,J.jsx)(ue,{size:14}),(0,J.jsx)(`input`,{"aria-label":t?`搜索地图任务`:`Search map tasks`,placeholder:t?`搜索任务…`:`Find a task…`,title:t?`Enter 逐个跳转匹配`:`Enter jumps through matches`,value:Le,onChange:e=>Re(e.target.value),onKeyDown:e=>{e.key===`Enter`&&Be.length?(ct(Be[Ve%Be.length].id),He(e=>e+1)):e.key===`Escape`&&Le&&(e.stopPropagation(),Re(``))}}),Le&&(0,J.jsx)(`span`,{className:`map-search-count`,"aria-live":`polite`,children:Be.length?`${Ve%Be.length+1}/${Be.length}`:t?`无匹配`:`0 found`})]}),(0,J.jsxs)(`button`,{onClick:lt,title:t?`定位当前或最近任务`:`Locate current or latest task`,children:[(0,J.jsx)(se,{size:15}),(0,J.jsx)(`span`,{children:t?`定位当前`:`Locate current`})]}),(0,J.jsx)(`button`,{onClick:R.fit,title:t?`适配全图`:`Fit map`,"aria-label":`Fit map`,children:(0,J.jsx)(H,{size:15})}),R.detailed&&(0,J.jsxs)(`button`,{onClick:R.back,className:`map-back-button`,"aria-label":`Return to map`,children:[(0,J.jsx)(K,{size:14}),(0,J.jsx)(`span`,{children:t?`返回全图`:`Overview`})]})]}),Ye&&(0,J.jsx)(`div`,{className:`map-feedback`,role:`status`,children:Ye}),R.detailed&&G&&G.data.partCount>1&&(0,J.jsxs)(`nav`,{className:`map-part-switcher nowheel`,"aria-label":t?`切换任务部分`:`Switch task part`,children:[(0,J.jsx)(`button`,{"aria-label":t?`上一部分`:`Previous part`,disabled:!G.data.previousId,onClick:()=>G.data.previousId&&R.enter(G.data.previousId),children:(0,J.jsx)(ne,{size:15})}),(0,J.jsxs)(`span`,{children:[G.data.part,` / `,G.data.partCount]}),(0,J.jsx)(`button`,{"aria-label":t?`下一部分`:`Next part`,disabled:!G.data.nextId,onClick:()=>G.data.nextId&&R.enter(G.data.nextId),children:(0,J.jsx)(u,{size:15})})]}),j.tasks.length===0?(0,J.jsxs)(`div`,{className:`map-empty`,children:[(0,J.jsx)(l,{size:36}),(0,J.jsx)(`h3`,{children:t?`把一个目标,变成可见的成果`:`Turn a goal into a visible result`}),(0,J.jsx)(`p`,{children:m?t?`尚无任务记录。`:`No task records are available.`:t?`描述你想完成的事情,看 Argus 规划、执行、审查,最后在这里交付。`:`Describe your goal. Watch Argus plan, build, review, and deliver here.`}),!m&&(0,J.jsx)(`div`,{className:`map-starters`,children:(t?[[`交互实验`,`做一个交互式实验室,用动画展示 Dijkstra 和 A* 怎样寻找最短路径。让我能画障碍、单步播放、比较探索范围,并验证两个算法的结果一致。`],[`数据洞察`,`用一组可复现的模拟数据,做一个辛普森悖论交互演示。让我能切换整体和分组视角,看结论怎样反转,附上验证过程。`],[`产品原型`,`做一个精致的个人旅行规划网页。我能调整预算和出行天数,比较三种行程方案,并将选中的方案导出。让手机上也方便操作。`]]:[[`Interactive lab`,`Build an interactive Dijkstra vs A* pathfinding lab with editable obstacles, step-by-step animation, and correctness checks.`],[`Data insights`,`Create an interactive Simpson’s paradox demo using reproducible synthetic data, with aggregate and grouped views and validation.`],[`Product prototype`,`Build a polished travel planner. Let me adjust budget and duration, compare three itineraries, and export my choice. Make it easy to use on a phone.`]]).map(([e,t])=>(0,J.jsxs)(`button`,{type:`button`,onClick:()=>{n.onChange(t),requestAnimationFrame(()=>L.current?.querySelector(`textarea`)?.focus())},children:[e,` ↗`]},e))})]}):(0,J.jsxs)(pf,{nodes:nt,edges:rt,nodeTypes:Nm,edgeTypes:Pm,onNodesChange:I,onMove:R.onMove,defaultViewport:Qp,minZoom:.035,maxZoom:3.5,nodesDraggable:!1,nodesFocusable:!1,nodesConnectable:!1,edgesReconnectable:!1,zoomOnScroll:!1,zoomOnPinch:!0,zoomOnDoubleClick:!1,deleteKeyCode:null,selectionKeyCode:null,onlyRenderVisibleElements:!0,proOptions:{hideAttribution:!0},children:[(0,J.jsx)(Tf,{variant:xf.Dots,gap:88,size:3,color:`var(--map-dot)`}),(0,J.jsx)(Pf,{orientation:`horizontal`,showInteractive:!1,onFitView:R.fit,fitViewOptions:{padding:.16,maxZoom:.27,minZoom:.035,duration:R.reducedMotion?0:320}}),(0,J.jsx)(Yf,{nodeColor:e=>e.type===`branch`?`#c5d4e2`:Fm[ep(e.data.task)]??`#a7bfd9`,maskColor:`var(--map-minimap-mask)`,maskStrokeColor:`#85aacf`,maskStrokeWidth:2,onClick:(e,t)=>R.navigate(t),pannable:!0,zoomable:!0,ariaLabel:t?`地图导航预览`:`Map navigation preview`})]}),(0,J.jsxs)(`div`,{className:`map-legend nowheel`,children:[(0,J.jsxs)(`span`,{title:t?`同一会话中的时间归属,不是执行依赖`:`Chronological context, not execution dependencies`,children:[(0,J.jsx)(`b`,{className:`dashed`}),t?`内容关联`:`Related work`]}),(0,J.jsxs)(`span`,{children:[(0,J.jsx)(`b`,{}),t?`任务依赖`:`Dependency`]}),(0,J.jsxs)(`button`,{className:qe?``:`is-muted`,onClick:()=>Je(e=>!e),"aria-pressed":qe,disabled:it===0,"aria-label":`Toggle plan replacements`,children:[(0,J.jsx)(`b`,{className:`replacement`}),t?`计划替代`:`Plan changes`,it?` · ${it}`:``]})]}),!m&&(0,J.jsx)(dm,{...n,pendingLabel:f,dispatchStatus:C?.result?.type===`task`?C.landed||n.historical?`task`:`launching`:C?.result?.outcome,onSend:ve,onCancel:be,overview:!R.detailed}),we&&!m&&(0,J.jsxs)(`div`,{className:`map-context-menu`,role:`menu`,style:{left:we.x,top:we.y},children:[(0,J.jsx)(`button`,{role:`menuitem`,onClick:()=>{Ce(we.ref),Te(null)},children:t?`引用`:`Reference`}),e.kind===`live`&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`button`,{role:`menuitem`,onClick:()=>{Me(``),Ae({ref:we.ref,x:we.x,y:we.y}),Te(null)},children:t?`添加批注`:`Add a note`}),(0,J.jsx)(`button`,{role:`menuitem`,onClick:()=>{n.onRouteOverrideChange?.(`task`),Ce(we.ref),Te(null)},children:t?`从这里展开`:`Branch from here`})]})]}),ke&&!m&&(0,J.jsxs)(`div`,{className:`map-note-editor nodrag nopan`,style:{left:Math.min(window.innerWidth-320,ke.x),top:Math.min(window.innerHeight-240,ke.y)},children:[(0,J.jsx)(`small`,{children:t?`批注《${ke.ref.task_title}》`:`Note on “${ke.ref.task_title}”`}),(0,J.jsx)(`textarea`,{autoFocus:!0,maxLength:2e3,value:je,onChange:e=>Me(e.target.value),placeholder:t?`写下你的观察,Argus 在下个规划周期会读到`:`Your observation; Argus reads it next planning cycle`}),Ne&&(0,J.jsx)(`small`,{className:`map-note-error`,children:t?`没有保存上,稍后再试;草稿还在`:`Not saved; try again — the draft is kept`}),(0,J.jsxs)(`div`,{className:`map-note-actions`,children:[(0,J.jsx)(`button`,{onClick:()=>Ae(null),children:t?`取消`:`Cancel`}),(0,J.jsx)(`button`,{className:`is-primary`,disabled:!je.trim(),onClick:()=>void Fe(),children:t?`保存`:`Save`})]})]}),(j.cyclic||j.missing>0)&&(0,J.jsx)(`div`,{className:`map-graph-warning`,children:j.cyclic?t?`检测到循环引用,保留原始连线。`:`Cyclic references retained.`:`${j.missing} ${t?`个依赖不在当前记录范围内`:`dependencies outside the available history`}`})]})}),e.kind!==`live`&&(0,J.jsxs)(`div`,{className:`map-playback`,children:[(0,J.jsx)(`button`,{"aria-label":Ge?`Pause reveal`:`Play reveal`,onClick:()=>{Ue>=j.tasks.length&&We(1),Ke(e=>!e)},children:Ge?(0,J.jsx)(M,{size:14}):(0,J.jsx)(d,{size:14})}),(0,J.jsx)(`button`,{"aria-label":`Restart reveal`,onClick:()=>{Ke(!1),We(1),R.back()},children:(0,J.jsx)(le,{size:13})}),(0,J.jsx)(`span`,{children:t?`逐卡展开`:`Reveal cards`}),(0,J.jsx)(`input`,{"aria-label":`Visible task count`,type:`range`,min:Math.min(1,j.tasks.length),max:j.tasks.length,value:Ue,onChange:e=>{Ke(!1),We(Number(e.target.value))}}),(0,J.jsxs)(`span`,{className:`map-count`,children:[Ue,` / `,j.tasks.length]}),(0,J.jsx)(`button`,{"aria-label":`Reveal next card`,disabled:Ue>=j.tasks.length,onClick:()=>We(e=>Math.min(j.tasks.length,e+1)),children:(0,J.jsx)(u,{size:14})}),(0,J.jsx)(`small`,{children:t?`时间顺序`:`Chronological order`})]})]})})}var Rm=(0,Y.memo)(function({snapshot:e,events:t,managerSteps:n=[],draft:r,onDraftChange:i,onSend:s,pending:c,onCancel:u,focusSignal:d,readOnly:f=!1,onOpenSettings:m,routeOverride:h,onRouteOverrideChange:g,conversationEvents:_,connected:v,artifacts:y,deliveryCount:b,onOpenDelivery:x,onOpenReceipt:S,onOpenArtifact:C,onAnswer:w}){let{locale:T}=G(),E=T===`zh-CN`,[D,O]=(0,Y.useState)([]),k=(0,Y.useRef)(r);k.current=r;let A=(0,Y.useRef)(!0);(0,Y.useEffect)(()=>(A.current=!0,()=>{A.current=!1}),[]);let j=(0,Y.useCallback)(async(e,t=[],n)=>{let r=await s(e,t,r=>{A.current&&(r.type===`settled`&&r.outcome===`error`&&!k.current.trim()&&(i(e),O(e=>e.length?e:t)),n?.(r))});return r&&A.current&&(k.current===e&&i(``),O(e=>e.filter(e=>!t.includes(e)))),r},[s,i]),[M,N]=(0,Y.useState)(()=>new URLSearchParams(window.location.search).get(`dataset`)||ee(`argus.map.source.v1`)||`live`),P=o({queryKey:[`map-datasets`],queryFn:({signal:e})=>p.mapDatasets(e),staleTime:1/0}),F=o({queryKey:[`map-dataset`,M],queryFn:({signal:e})=>p.mapDataset(M,e),enabled:M!==`live`,staleTime:1/0,retry:!1}),I=a(),R=`argus.map.history.v1:`+e.session.id,[z,B]=(0,Y.useState)(()=>Em(ee(R))),[V,te]=(0,Y.useState)(!1),H=o({queryKey:[`map-info`,e.session.id],queryFn:({signal:t})=>p.mapInfo(e.session.id,t),enabled:M===`live`,staleTime:6e4}),U=z??(H.data&&!H.data.requires_choice?{mode:`full`}:null);(0,Y.useEffect)(()=>{if(!z&&H.data&&!H.data.requires_choice){let e={mode:`full`};B(e),L(R,JSON.stringify(e))}},[H.data,z,R]);let K=M!==`live`||!!U&&U.mode!==`off`&&!V,ne=[`map-live`,e.session.id,U?.mode,U?.since,U?.eventSince,U?.taskId],ie=JSON.stringify([M,e.session.id,T,U]),ae=e=>{B(e),L(R,JSON.stringify(e)),te(!1)},oe=o({queryKey:ne,queryFn:async({signal:t})=>{let n=I.getQueryData(ne),r=U?.mode===`full`?await p.mapHistory(e.session.id,t,n?.history_cursor,n?.cursor):await p.liveMap(e.session.id,t,n?.cursor,U||void 0);return Dm(I.getQueryData(ne),r)},enabled:M===`live`&&K,staleTime:1/0,gcTime:72e5,refetchOnMount:`always`,refetchInterval:t=>Om(K,t.state.data,e)}),se=M===`live`&&km(e),ce=t.filter(e=>e.run_label!==`map-summary`&&/^(life\.(mission\.|phase\.|planner\.task_added)|round\.|agent\.message|team\.|idea\.portfolio\.)/.test(String(e.type))).at(-1),le=JSON.stringify([ce?.ts,ce?.event_id||ce?.id,ce?.revision,ce?.updated_ts,ce?.status,e.backlog,se]),q=(0,Y.useRef)(null),ue=(0,Y.useRef)(0),fe=(0,Y.useRef)(null);(0,Y.useEffect)(()=>{let e=fe.current;if(!e)return;let t=()=>{ue.current=Date.now()+900},n=e=>{e.buttons&&t()};return e.addEventListener(`wheel`,t,{passive:!0}),e.addEventListener(`pointerdown`,t),e.addEventListener(`pointermove`,n),()=>{e.removeEventListener(`wheel`,t),e.removeEventListener(`pointerdown`,t),e.removeEventListener(`pointermove`,n)}},[]),(0,Y.useEffect)(()=>{if(M!==`live`||!K||q.current)return;let t=()=>{let n=ue.current-Date.now();if(n>0){q.current=setTimeout(t,n+120);return}q.current=null,I.invalidateQueries({queryKey:[`map-live`,e.session.id]})};q.current=setTimeout(t,650)},[le,M,e.session.id,I,K]),(0,Y.useEffect)(()=>()=>{q.current&&clearTimeout(q.current),q.current=null},[M,e.session.id,K]);let pe=M===`live`?oe.data:F.data,me=(0,Y.useMemo)(()=>({conversationEvents:_,connected:v,artifacts:y,deliveryCount:b,onOpenDelivery:x,onOpenReceipt:S,onOpenArtifact:C,onAnswer:w}),[_,v,y,b,x,S,C,w]),X=(0,Y.useMemo)(()=>({routeOverride:h,onRouteOverrideChange:g,value:r,onChange:i,onSend:j,attachments:D,onAttachmentsChange:O,pending:c,onCancel:u,focusSignal:d,sessionName:e.session.display_name||e.session.id,historical:M!==`live`,zh:E}),[h,g,r,i,j,D,c,u,d,e.session.display_name,e.session.id,M,E]),he=e=>{N(e),L(`argus.map.source.v1`,e);let t=new URL(window.location.href);t.searchParams.set(`dataset`,e),window.history.replaceState(null,``,t)};return(0,J.jsxs)(`section`,{ref:fe,className:`argus-map`,"aria-label":E?`研究进度地图`:`Research progress map`,children:[(0,J.jsxs)(`header`,{className:`map-header`,children:[(0,J.jsx)(`div`,{className:`map-heading-icon`,children:(0,J.jsx)(l,{size:20})}),(0,J.jsxs)(`div`,{className:`map-heading`,children:[(0,J.jsx)(`div`,{className:`map-eyebrow`,children:`ARGUS / RESEARCH MAP`}),(0,J.jsx)(`h1`,{children:E?`研究地图`:`Research map`})]}),(0,J.jsxs)(`div`,{className:`map-header-actions`,children:[!f&&m&&(0,J.jsx)(`button`,{type:`button`,onClick:m,className:`map-settings`,"aria-label":E?`地图模型设置`:`Map model settings`,title:E?`地图模型设置`:`Map model settings`,children:(0,J.jsx)(de,{size:16})}),M===`live`&&H.data&&(0,J.jsx)(`button`,{type:`button`,className:`map-scope-button`,onClick:()=>te(!0),children:E?`加载范围`:`History range`}),(0,J.jsxs)(`span`,{className:`map-source-badge`,children:[(0,J.jsx)(`span`,{}),M===`live`?E?`当前会话`:`Current session`:pe?.kind===`synthetic`?E?`人工示例`:`Synthetic example`:pe?.kind===`demo`?E?`历史演示`:`Recorded demo`:E?`历史记录`:`Historical records`]})]})]}),(0,J.jsxs)(`div`,{className:`map-dataset-bar`,children:[(0,J.jsx)(re,{size:15}),(0,J.jsxs)(`select`,{"aria-label":E?`地图数据来源`:`Map data source`,value:M,onChange:e=>he(e.target.value),children:[(0,J.jsxs)(`option`,{value:`live`,children:[E?`当前会话`:`Current session`,` ·`,` `,e.session.display_name]}),!P.data?.datasets.some(e=>e.id===M)&&M!==`live`&&(0,J.jsx)(`option`,{value:M,children:M}),P.data?.datasets.map(e=>(0,J.jsxs)(`option`,{value:e.id,children:[e.title,` · `,e.task_count]},e.id))]}),pe?.captured_at&&(0,J.jsxs)(`span`,{className:`map-capture`,children:[(0,J.jsx)(W,{size:12}),new Date(pe.captured_at).toLocaleDateString()]})]}),M===`live`&&H.data&&(0,J.jsx)(Tm,{open:V||!U&&H.data.requires_choice,info:H.data,zh:E,readOnly:f,onChoose:ae}),M===`live`&&H.isError&&(0,J.jsxs)(`div`,{className:`map-data-error`,children:[E?`暂时无法检查历史记录。`:`Could not check session history.`,(0,J.jsx)(`button`,{onClick:()=>void H.refetch(),children:E?`重试`:`Retry`})]}),K&&pe?.history_loading&&(0,J.jsxs)(`div`,{className:`map-history-progress`,role:`status`,children:[E?`正在分批加载历史记录`:`Loading history in pages`,pe.history_progress&&` · ${(pe.history_progress.loaded_bytes/1024/1024).toFixed(1)} / ${(pe.history_progress.total_bytes/1024/1024).toFixed(1)} MB`,(0,J.jsx)(`button`,{onClick:()=>te(!0),children:E?`更改范围`:`Change range`})]}),K&&pe&&(M===`live`?oe.isError:F.isError)&&(0,J.jsxs)(`div`,{className:`map-data-error`,role:`status`,children:[E?`暂时无法更新,已保留加载的地图。`:`Updates are unavailable. Your loaded map is preserved.`,(0,J.jsx)(`button`,{onClick:()=>void(M===`live`?oe.refetch():F.refetch()),children:E?`重试`:`Retry`})]}),P.isError&&(0,J.jsxs)(`div`,{className:`map-data-error`,children:[E?`历史记录列表暂时无法读取,可切换当前会话或重试。`:`Historical maps are unavailable. Open the current session or retry.`,(0,J.jsx)(`button`,{onClick:()=>void P.refetch(),children:E?`重试`:`Retry`})]}),K?(M===`live`?oe.isError:F.isError)&&!pe?(0,J.jsxs)(`div`,{className:`map-empty`,children:[(0,J.jsx)(`h3`,{children:E?`地图暂时无法读取`:`Map unavailable`}),(0,J.jsx)(`p`,{children:String(M===`live`?oe.error:F.error)}),(0,J.jsx)(`button`,{onClick:()=>void(M===`live`?oe.refetch():F.refetch()),children:E?`重试`:`Retry`})]}):pe?(0,J.jsx)(lf,{children:(0,J.jsx)(Lm,{data:pe,actions:me,snapshot:e,events:t,pendingLabel:n.at(-1)?.detail||n.at(-1)?.label,viewKey:ie,paused:se,sessionId:e.session.id,zh:E,readOnly:f,activePhase:M===`live`&&!se?e.roles.find(e=>e.active)?.role:void 0,composer:X})},ie):(0,J.jsxs)(`div`,{className:`map-empty is-loading`,"aria-busy":`true`,children:[(0,J.jsxs)(`div`,{className:`map-ghosts`,"aria-hidden":!0,children:[(0,J.jsx)(`i`,{}),(0,J.jsx)(`i`,{}),(0,J.jsx)(`i`,{})]}),E?`正在载入地图…`:`Loading map…`]}):(0,J.jsxs)(`div`,{className:`map-empty`,children:[(0,J.jsx)(`h3`,{children:E?`地图尚未开启`:`Map is not enabled`}),(0,J.jsx)(`p`,{children:H.isPending?E?`正在检查历史记录规模…`:`Checking history size…`:E?`选择加载范围后查看研究进度。`:`Choose a history range to view research progress.`}),H.data&&(0,J.jsx)(`button`,{onClick:()=>te(!0),children:E?`选择加载范围`:`Choose history range`})]})]})});export{Rm as MapPanel,Im as MapTeamProgress}; \ No newline at end of file diff --git a/frontend/web/dist/assets/ResearchWorkbenchPanel-B7craOIV.js b/frontend/web/dist/assets/ResearchWorkbenchPanel-B7craOIV.js new file mode 100644 index 000000000..6188e03ac --- /dev/null +++ b/frontend/web/dist/assets/ResearchWorkbenchPanel-B7craOIV.js @@ -0,0 +1,10 @@ +import{r as e}from"./rolldown-runtime-hePW80VL.js";import{A as t,k as n}from"./icons-2gFhc0pq.js";import{i as r,n as i,t as a}from"./query-CGMsBv4s.js";import{n as o,r as s,t as c}from"./play-4uDgOsGD.js";import{C as l,D as u,H as d,O as f,T as p,U as m,V as h,W as g,f as _,g as v,h as y,i as b,m as x,n as S,p as C,t as w,w as T,x as E,y as D,z as O}from"./index-CpMiioIG.js";var k=f(`ArrowRight`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`m12 5 7 7-7 7`,key:`xquz4c`}]]),A=f(`Circle`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),j=f(`CodeXml`,[[`path`,{d:`m18 16 4-4-4-4`,key:`1inbqp`}],[`path`,{d:`m6 8-4 4 4 4`,key:`15zrgr`}],[`path`,{d:`m14.5 4-5 16`,key:`e7oirm`}]]),M=f(`FileCode2`,[[`path`,{d:`M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4`,key:`1pf5j1`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`path`,{d:`m5 12-3 3 3 3`,key:`oke12k`}],[`path`,{d:`m9 18 3-3-3-3`,key:`112psh`}]]),N=f(`File`,[[`path`,{d:`M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z`,key:`1rqfz7`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}]]),ee=f(`Files`,[[`path`,{d:`M20 7h-3a2 2 0 0 1-2-2V2`,key:`x099mo`}],[`path`,{d:`M9 18a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h7l4 4v10a2 2 0 0 1-2 2Z`,key:`18t6ie`}],[`path`,{d:`M3 7.6v12.8A1.6 1.6 0 0 0 4.6 22h9.8`,key:`1nja0z`}]]),te=f(`FlaskConical`,[[`path`,{d:`M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2`,key:`18mbvz`}],[`path`,{d:`M6.453 15h11.094`,key:`3shlmq`}],[`path`,{d:`M8.5 2h7`,key:`csnxdl`}]]),P=f(`FolderKanban`,[[`path`,{d:`M4 20h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.93a2 2 0 0 1-1.66-.9l-.82-1.2A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13c0 1.1.9 2 2 2Z`,key:`1fr9dc`}],[`path`,{d:`M8 10v4`,key:`tgpxqk`}],[`path`,{d:`M12 10v2`,key:`hh53o1`}],[`path`,{d:`M16 10v6`,key:`1d6xys`}]]),ne=f(`Folder`,[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]),re=f(`Gauge`,[[`path`,{d:`m12 14 4-4`,key:`9kzdfg`}],[`path`,{d:`M3.34 19a10 10 0 1 1 17.32 0`,key:`19p75a`}]]),F=f(`Github`,[[`path`,{d:`M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4`,key:`tonef`}],[`path`,{d:`M9 18c-4.51 2-5-2-7-2`,key:`9comsn`}]]),ie=f(`LockKeyhole`,[[`circle`,{cx:`12`,cy:`16`,r:`1`,key:`1au0dj`}],[`rect`,{x:`3`,y:`10`,width:`18`,height:`12`,rx:`2`,key:`6s8ecr`}],[`path`,{d:`M7 10V7a5 5 0 0 1 10 0v3`,key:`1pqi11`}]]),ae=f(`Radio`,[[`path`,{d:`M4.9 19.1C1 15.2 1 8.8 4.9 4.9`,key:`1vaf9d`}],[`path`,{d:`M7.8 16.2c-2.3-2.3-2.3-6.1 0-8.5`,key:`u1ii0m`}],[`circle`,{cx:`12`,cy:`12`,r:`2`,key:`1c9p78`}],[`path`,{d:`M16.2 7.8c2.3 2.3 2.3 6.1 0 8.5`,key:`1j5fej`}],[`path`,{d:`M19.1 4.9C23 8.8 23 15.1 19.1 19`,key:`10b0cb`}]]),I=f(`Server`,[[`rect`,{width:`20`,height:`8`,x:`2`,y:`2`,rx:`2`,ry:`2`,key:`ngkwjq`}],[`rect`,{width:`20`,height:`8`,x:`2`,y:`14`,rx:`2`,ry:`2`,key:`iecqi9`}],[`line`,{x1:`6`,x2:`6.01`,y1:`6`,y2:`6`,key:`16zg32`}],[`line`,{x1:`6`,x2:`6.01`,y1:`18`,y2:`18`,key:`nzw8ys`}]]),oe=f(`SquareTerminal`,[[`path`,{d:`m7 11 2-2-2-2`,key:`1lz0vl`}],[`path`,{d:`M11 13h4`,key:`1p7l4v`}],[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}]]),se=f(`TimerReset`,[[`path`,{d:`M10 2h4`,key:`n1abiw`}],[`path`,{d:`M12 14v-4`,key:`1evpnu`}],[`path`,{d:`M4 13a8 8 0 0 1 8-7 8 8 0 1 1-5.3 14L4 17.6`,key:`1ts96g`}],[`path`,{d:`M9 17H4v5`,key:`8t5av`}]]),ce=f(`TriangleAlert`,[[`path`,{d:`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`,key:`wmoenq`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),le=f(`UserRound`,[[`circle`,{cx:`12`,cy:`8`,r:`5`,key:`1hypcn`}],[`path`,{d:`M20 21a8 8 0 0 0-16 0`,key:`rfgkzh`}]]),ue=f(`Workflow`,[[`rect`,{width:`8`,height:`8`,x:`3`,y:`3`,rx:`2`,key:`by2w9f`}],[`path`,{d:`M7 11v4a2 2 0 0 0 2 2h4`,key:`xkn7yn`}],[`rect`,{width:`8`,height:`8`,x:`13`,y:`13`,rx:`2`,key:`1cgmvn`}]]),L=e(t(),1),de=12e3;function R(e=!1){let t={...h()};return e&&(t[`Content-Type`]=`application/json`),t}async function z(e,t={}){await m();let n={...t,headers:{...R(!!t.body),...t.headers??{}},cache:`no-store`},r=String(t.method??`GET`).toUpperCase(),i=async n=>{if(!n.ok){let r=await n.text().catch(()=>``),i=r;try{i=JSON.parse(r).detail??r}catch{}throw Error(i||`${t.method??`GET`} ${e} failed (${n.status})`)}return await n.json()};return r===`GET`?g(e,n,de,i):i(await fetch(e,n))}var B=(e,t=``)=>`/api/projects/${encodeURIComponent(e)}${t}`,fe=()=>globalThis.crypto?.randomUUID?.()??`${Date.now()}-${Math.random()}`;function pe(e){let t=e.replaceAll(`\r +`,` +`).split(` + +`),n=t.pop()??``,r=[];return t.forEach(e=>{e.split(` +`).forEach(e=>{if(e.startsWith(`data:`))try{let t=JSON.parse(e.slice(5).trim());r.push(t)}catch{}})}),{frames:r,rest:n}}function me(e,t){let n=String(e.type??``);if(n===`phase`)t.onPhase?.(String(e.label??``),String(e.role??`manager`),String(e.detail??``),e.heartbeat===!0);else if(n===`delta`)t.onDelta?.(String(e.text??``),String(e.fragment_mode??`auto`));else if(n===`done`){let n=e.result??{};return t.onDone?.(n),n}else if(n===`error`)throw Error(String(e.error??`Manager stream failed`));return null}var V={projects:e=>z(`/api/projects`,{signal:e}),snapshot:(e,t)=>z(B(e,`/snapshot?events_limit=40&compact=false`),{signal:t}),status:(e,t)=>z(B(e,`/status`),{signal:t}),events:(e,t=180,n)=>z(B(e,`/events?limit=${t}&view=ui`),{signal:n}).then(e=>e.events),transcript:(e,t=100,n)=>z(B(e,`/transcript?n=${t}`),{signal:n}).then(e=>e.turns),journal:(e,t=80,n)=>z(B(e,`/journal?n=${t}`),{signal:n}).then(e=>e.journal),artifacts:(e,t)=>z(B(e,`/artifacts`),{signal:t}).then(e=>e.artifacts),counterexamples:(e,t)=>z(B(e,`/counterexamples`),{signal:t}),artifact:(e,t,n)=>z(B(e,`/artifact?${new URLSearchParams({path:t})}`),{signal:n}),artifactBlob:async(e,t,n=!1,r)=>{await m();let i=new URLSearchParams({path:t});n&&i.set(`download`,`true`);let a=B(e,`/artifact/raw?${i}`);return g(a,{headers:R(),signal:r,cache:`no-store`},de,async e=>{if(!e.ok)throw Error(`Artifact unavailable (${e.status})`);return e.blob()})},gitDiff:(e,t)=>z(B(e,`/git-diff`),{signal:t}),rewritePrompt:(e,t,n)=>z(B(e,`/prompt/rewrite`),{method:`POST`,body:JSON.stringify({text:t}),signal:n}),note:(e,t)=>z(B(e,`/note`),{method:`POST`,body:JSON.stringify({text:t})}),uploadAttachments:async(e,t,n)=>{await m();let r=new FormData;t.forEach(e=>r.append(`files`,e,e.name));let i=await fetch(B(e,`/attachments`),{method:`POST`,headers:R(),body:r,signal:n});if(!i.ok)throw Error(await i.text()||`attachment upload failed (${i.status})`);return await i.json()},createDaemon:(e,t=``,n=``)=>z(`/api/daemons`,{method:`POST`,body:JSON.stringify({objective:e,name:t,workdir:n,command_id:fe()})}),createFinalReview:(e,t)=>z(B(e,`/reviews/final`),{method:`POST`,body:JSON.stringify(t)}),startDaemon:(e,t)=>z(B(e,`/daemon/start`),{method:`POST`,body:JSON.stringify({command_id:fe(),expected_revision:t})}),stopDaemon:(e,t,n)=>z(B(e,`/daemon/stop`),{method:`POST`,body:JSON.stringify({drain:t,command_id:fe(),expected_revision:n})}),async messageStream(e,t,n={},r,i=[]){await m();let a=B(e,`/message/stream`),o=await fetch(a,{method:`POST`,headers:R(!0),body:JSON.stringify(i.length?{text:t,attachments:i}:{text:t}),signal:r});if(!o.ok){let e=await o.text().catch(()=>``);throw Error(e||`Manager request failed (${o.status})`)}if(!o.body)throw Error(`Manager returned an empty stream`);let s=o.body.getReader(),c=new TextDecoder,l=``,u={};for(;;){let e=await s.read();if(e.done)break;l+=c.decode(e.value,{stream:!0});let t=pe(l);l=t.rest,t.frames.forEach(e=>{let t=me(e,n);t&&(u=t)})}return pe(`${l}\n\n`).frames.forEach(e=>{let t=me(e,n);t&&(u=t)}),u}};function he(e,t,n){let r=!1,i=null,a,o=800,s=()=>{if(r)return;let c=window.location.protocol===`https:`?`wss:`:`ws:`,l=new URLSearchParams({replay:`40`,view:`ui`}),u=d();u&&l.set(`token`,u),i=new WebSocket(`${c}//${window.location.host}${B(e,`/stream`)}?${l}`),i.onopen=()=>{o=800,n(!0)},i.onmessage=e=>{try{t(JSON.parse(String(e.data)))}catch{}},i.onerror=()=>i?.close(),i.onclose=e=>{n(!1),!(r||e.code===4401||e.code===4404)&&(a=window.setTimeout(s,o),o=Math.min(o*1.7,8e3))}};return s(),{close:()=>{r=!0,a&&window.clearTimeout(a),i?.close()}}}var ge={active:[`进行中`,`In progress`],claimed:[`进行中`,`In progress`],in_progress:[`进行中`,`In progress`],running:[`进行中`,`In progress`],working:[`进行中`,`In progress`],pending:[`等待中`,`Waiting`],queued:[`等待中`,`Waiting`],waiting:[`等待中`,`Waiting`],idle:[`等待中`,`Waiting`],accepted:[`已完成`,`Completed`],complete:[`已完成`,`Completed`],completed:[`已完成`,`Completed`],done:[`已完成`,`Completed`],success:[`已完成`,`Completed`],blocked:[`已阻塞`,`Blocked`],failed:[`失败`,`Failed`],error:[`失败`,`Failed`],rejected:[`需要修改`,`Needs changes`],continue:[`需要修改`,`Needs changes`],replan:[`需要重新规划`,`Needs replanning`],skipped:[`已跳过`,`Skipped`],paused:[`已暂停`,`Paused`],stopped:[`已暂停`,`Paused`],cancelled:[`已暂停`,`Paused`],aborted:[`已暂停`,`Paused`],not_started:[`等待中`,`Waiting`],healthy:[`状态正常`,`Healthy`],degraded:[`部分受限`,`Limited`]},_e={manager:[`Manager`,`Manager`],planner:[`Planner`,`Planner`],engineer:[`Engineer`,`Engineer`],reviewer:[`Reviewer`,`Reviewer`],system:[`Argus`,`Argus`],operator:[`你`,`You`],stopped:[`已暂停`,`Paused`],idle:[`等待中`,`Waiting`]},ve={scope:[`研究定义`,`Scope`],research:[`文献与假设`,`Literature and hypotheses`],implementation:[`方法实现`,`Implementation`],experiment:[`实验验证`,`Experiments`],analysis:[`结果分析`,`Analysis`],writing:[`论文写作`,`Writing`],review:[`最终审核`,`Final review`],delivery:[`成果交付`,`Delivery`]},ye={certified:[`阶段已通过`,`Stage approved`],not_certified:[`阶段未通过`,`Stage not approved`],revoked:[`阶段批准已撤回`,`Stage approval revoked`],intentionally_skipped:[`无需阶段审核`,`Stage review not needed`],deferred:[`阶段审核待定`,`Stage review pending`],not_assessed:[`尚未审核阶段`,`Stage not reviewed`]};function be(e,t,n,r){let i=t[String(e??``).toLowerCase()]??n;return r(i[0],i[1])}function H(e,t){return be(e,ge,[`状态已更新`,`Status updated`],t)}function U(e,t){return be(e,_e,[`Argus`,`Argus`],t)}function xe(e,t){return be(e,ve,[`未分阶段`,`Unstaged`],t)}function Se(e,t){return be(e,ye,[`阶段状态已更新`,`Stage status updated`],t)}function W(){let{locale:e}=O();return{locale:e,text:(0,L.useCallback)((t,n)=>e===`zh-CN`?t:n,[e])}}function G(...e){return e.filter(Boolean).join(` `)}function K(e){let t=Math.max(0,Math.floor(Number(e??0)));if(t<60)return`${t}s`;let n=Math.floor(t/86400),r=Math.floor(t%86400/3600),i=Math.floor(t%3600/60);return n?`${n}d ${r}h`:r?`${r}h ${i}m`:`${i}m`}function Ce(e,t){return e?new Date(e*1e3).toLocaleTimeString(t,{hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hour12:!1}):`—`}function we(e){let t=String(e??``).toLowerCase();return/failed|error|blocked|rejected|stalled|dead|abort/.test(t)?`danger`:/warn|waiting|paused|hold|queued|pending|continue/.test(t)?`warn`:/done|complete|completed|accepted|healthy|success|passed/.test(t)?`success`:/run|active|work|claimed|progress|live/.test(t)?`live`:/research|plan|info|ready/.test(t)?`info`:`neutral`}function Te(e){let t=String(e.agent_layer??e.actor??``).toLowerCase();if(t===`main`||t.startsWith(`engineer`))return`engineer`;if(t.startsWith(`review`))return`reviewer`;if(t.startsWith(`plan`))return`planner`;if(t.startsWith(`manager`))return`manager`;let n=String(e.type??``);return/review/.test(n)?`reviewer`:/planner/.test(n)?`planner`:/manager/.test(n)?`manager`:/engineer|round/.test(n)?`engineer`:`system`}function q(e){let t=String(e.action_summary??``).trim();if(t)return t;let n=String(e.title??``).trim();if(n)return n;let r=String(e.kind??``).trim();return r?r.replaceAll(`_`,` `):String(e.type??`event`).split(`.`).slice(-2).join(` · `).replaceAll(`_`,` `)}function Ee(e,t=400){let n=String(e.text??e.reason??e.summary??e.detail??``).trim();return n?n.length>t?`${n.slice(0,t)}…`:n:``}var J=n();function Y({children:e,tone:t=`neutral`,dot:n=!1,className:r}){return(0,J.jsxs)(`span`,{className:G(`badge`,`badge--${t}`,r),children:[n?(0,J.jsx)(`span`,{className:G(`badge__dot`,t===`live`&&`is-pulsing`)}):null,e]})}function De({title:e,eyebrow:t,action:n,children:r,className:i,bodyClassName:a}){return(0,J.jsxs)(`section`,{className:G(`panel`,i),children:[e||t||n?(0,J.jsxs)(`header`,{className:`panel__header`,children:[(0,J.jsxs)(`div`,{className:`panel__heading`,children:[t?(0,J.jsx)(`div`,{className:`eyebrow`,children:t}):null,e?(0,J.jsx)(`div`,{className:`panel__title`,children:e}):null]}),n?(0,J.jsx)(`div`,{className:`panel__action`,children:n}):null]}):null,(0,J.jsx)(`div`,{className:G(`panel__body`,a),children:r})]})}function X({icon:e=N,title:t,description:n,action:r}){return(0,J.jsxs)(`div`,{className:`empty-state`,children:[(0,J.jsx)(`span`,{className:`empty-state__icon`,children:(0,J.jsx)(e,{size:19})}),(0,J.jsx)(`div`,{className:`empty-state__title`,children:t}),n?(0,J.jsx)(`p`,{children:n}):null,r?(0,J.jsx)(`div`,{className:`empty-state__action`,children:r}):null]})}function Oe({label:e}){let{text:t}=W();return(0,J.jsxs)(`span`,{className:`spinner`,role:`status`,children:[(0,J.jsx)(D,{size:15,className:`spin`}),` `,e||t(`加载中`,`Loading`)]})}function ke({events:e,limit:t=24,empty:n,dense:r=!1}){let{locale:i,text:a}=W(),o=e.slice(-t).reverse();return o.length?(0,J.jsx)(`div`,{className:G(`event-list`,r&&`event-list--dense`),children:o.map((e,t)=>{let n=Te(e),o=q(e),s=Ee(e,r?180:480),c=we(String(e.status??e.kind??e.type??``));return(0,J.jsxs)(`article`,{className:`event-row`,children:[(0,J.jsx)(`div`,{className:G(`event-row__marker`,`event-row__marker--${c}`)}),(0,J.jsxs)(`div`,{className:`event-row__content`,children:[(0,J.jsxs)(`div`,{className:`event-row__meta`,children:[(0,J.jsx)(`span`,{className:G(`role-label`,`role-label--${n}`),children:U(n,a)}),(0,J.jsx)(`time`,{children:Ce(e.ts,i)})]}),(0,J.jsx)(`div`,{className:`event-row__title`,children:o}),s?(0,J.jsx)(`div`,{className:`event-row__detail`,children:s}):null]})]},`${e.type}-${e.ts}-${e.message_id??t}`)})}):(0,J.jsx)(X,{icon:ae,title:n||a(`还没有可展示的实时动态`,`No activity to show yet`)})}var Ae=new Set([`done`,`completed`,`accepted`,`success`]),je=new Set([`running`,`in_progress`,`claimed`,`active`,`working`]);function Me(e){if(!e.length)return null;let t=[...e].sort((e,t)=>e-t),n=Math.floor(t.length/2);return t.length%2?t[n]:(t[n-1]+t[n])/2}function Ne(e){return[...e].reverse().find(e=>{let t=String(e.kind??``),n=String(e.type??``);return t!==`reasoning`&&!n.startsWith(`provider.`)&&![`ui.operator`,`ui.argus`].includes(n)})??null}function Pe(e){return e.backlog.find(e=>je.has(e.status))??e.backlog.find(e=>e.status===`pending`)??e.backlog.at(-1)??null}function Fe(e,t,n=Date.now()/1e3,r=`zh-CN`){let i=(e,t)=>r===`zh-CN`?e:t,a=e.mission_view,o=a?.dag?.length?a.dag:e.backlog,s=o.length,c=o.filter(e=>Ae.has(e.status)).length,l=o.filter(e=>/pending|queued|waiting/.test(e.status)).length,u=Pe(e),d=a?.active_role||e.roles.find(e=>e.active)?.role||``,f=u?.started_ts||a?.mission.started_at||e.daemon.uptime_seconds&&n-e.daemon.uptime_seconds||n,p=t.filter(e=>Number(e.ts??0)>=Number(f||0)),m=Ne(p),h=String(a?.mission.status??``).toLowerCase(),g=[`complete`,`completed`,`done`].includes(h),_=[`incomplete`,`failed`,`blocked`,`aborted`,`stopped`,`cancelled`].includes(h),v=g||!_&&!!(s&&c===s),y=!e.daemon.alive,b=u?.finished_ts||a?.mission.completed_at||(y?Number(m?.ts??f):null),x=Math.max(0,Number(b??n)-Number(f||n)),S=!!(u&&je.has(u.status)&&e.daemon.alive),C=p.filter(e=>String(e.kind??``)===`command_execution`).length,w=p.filter(e=>/^(read|write|edit):/i.test(Ee(e,80))||String(e.kind??``)===`file_change`).length,T=!!a?.role_work?.some(e=>e.role===`engineer`&&/handoff|main completed/i.test(`${e.kind} ${e.title}`)&&e.ts>=Number(f||0)),E=p.some(e=>/review.*started/i.test(String(e.type??``))),D=p.some(e=>/review.*completed/i.test(String(e.type??``))),O=!!(u&&/failed|blocked|error/.test(u.status)),k=!!(a?.review?.status&&/replan|blocked|rejected|continue/.test(a.review.status)),A=0;u&&Ae.has(u.status)?A=1:u&&je.has(u.status)&&e.daemon.alive&&(A=.14,(C||w)&&(A=Math.min(.58,.27+Math.log2(1+C+w)*.055)),T&&(A=.7),(E||d===`reviewer`)&&(A=.8),D&&(A=.93));let j=v?1:_&&s&&c===s?.95:s?c/s:0,M=u&&o.some(e=>e.id===u.id)&&S&&!k,N=v?1:k?j:s?Math.min(1,(c+(M?A:0))/s):null,ee=s?Math.max(.05,Math.min(.18,.45/s)):0,te=v?[1,1]:k?[j,j]:N==null?null:[Math.max(j,N-ee*.45),Math.min(.99,Math.max(N,N+ee))],P=e.backlog.map(e=>e.started_ts&&e.finished_ts?e.finished_ts-e.started_ts:0).filter(e=>e>=5&&e<=604800),ne=Me(P),re=null,F=``;if(v)F=i(`项目已完成,无需预计完成时间`,`Project complete; no finish-time estimate is needed`);else if(y)F=i(`Argus 已停止,预计完成时间暂停更新`,`Argus stopped; the expected finish time is paused`);else if(!S)F=i(`当前没有执行中的任务,暂时无法预计完成时间`,`No active task; the expected finish time is unavailable`);else if(k)F=i(`Reviewer 正在改变任务范围,暂时无法预计完成时间`,`The Reviewer is changing scope, so the expected finish time is unavailable`);else if(!ne)F=i(`同类已完成任务不足,正在建立时间基线`,`Not enough completed tasks to establish a time baseline`);else if(!s||N==null)F=i(`任务路线尚未稳定,暂不预计完成时间`,`The task route is not stable enough to estimate a finish time`);else{let e=Math.max(0,s-c-(M?A:0))*ne;re={minSeconds:Math.max(60,e*.68),maxSeconds:Math.max(180,e*(P.length>=3?1.45:1.75)),basis:i(`${P.length} 个已完成任务的中位耗时`,`Median duration of ${P.length} completed tasks`)}}let ie=s>=4&&P.length>=3?`high`:s>=2&&P.length>=1?`medium`:`low`,ae=e.roles.find(e=>e.role===`planner`)?.status===`done`||!!u,I=[{id:`plan`,label:i(`规划任务`,`Plan task`),detail:ae?i(`Planner 已形成当前任务`,`Planner created the current task`):i(`等待 Planner`,`Waiting for Planner`),status:ae?`done`:d===`planner`?`active`:`pending`},{id:`start`,label:i(`启动执行`,`Start execution`),detail:u?.started_ts?i(`任务已领取并启动`,`Task claimed and started`):i(`等待执行`,`Waiting to execute`),status:u?.started_ts?`done`:u?.status===`pending`?`pending`:O?`blocked`:`active`},{id:`work`,label:i(`运行与产出`,`Execution and outputs`),detail:i(`${C} 条命令 · ${w} 次文件动作`,`${C} commands · ${w} file actions`),status:T?`done`:C||w?`active`:O?`blocked`:`pending`},{id:`handoff`,label:i(`提交 Reviewer`,`Ready for review`),detail:T?i(`已提交 Reviewer`,`Submitted to Reviewer`):i(`等待可审读的结果`,`Waiting for results the Reviewer can read`),status:T||d===`reviewer`?`done`:`pending`},{id:`review`,label:i(`Reviewer 认证`,`Reviewer certification`),detail:D?i(`本轮审查已完成`,`Round review complete`):E||d===`reviewer`?i(`Reviewer 正在检查`,`Reviewer is checking`):i(`等待审查`,`Waiting for review`),status:D?`done`:E||d===`reviewer`?`active`:O?`blocked`:`pending`}];return v?I=I.map(e=>({...e,status:`done`,detail:e.status===`done`?e.detail:i(`项目已完成`,`Project complete`)})):k?I=I.map(e=>e.status===`done`?e:{...e,status:`blocked`,detail:i(`等待 Reviewer 重新规划任务范围`,`Waiting for Reviewer to replan scope`)}):y&&(I=I.map(e=>e.status===`active`?{...e,status:`blocked`,detail:i(`Argus 已停止`,`Argus stopped`)}:e)),{confirmed:j,estimate:N,range:te,confidence:ie,basis:k?i(`Reviewer 正在重新规划,仅显示确定完成部分`,`Reviewer is replanning; only confirmed completion is shown`):s?i(`根据任务状态和事件里程碑估算`,`Estimated from task status and event milestones`):i(`任务路线尚未建立`,`Task route not established`),currentTask:u?.title||a?.mission.title||i(`等待新任务`,`Waiting for a new task`),currentRole:y?`stopped`:d||Te(m??{})||`idle`,currentStep:v?i(`项目已完成`,`Project complete`):k?i(`Reviewer 要求重新规划 · ${H(a?.review?.status||`replan`,i)}`,`Reviewer requested replanning · ${H(a?.review?.status||`replan`,i)}`):y?i(`已停止 · 最后执行到 ${m?q(m):H(u?.status,i)}`,`Stopped · last step: ${m?q(m):H(u?.status,i)}`):m?q(m):u?.status?H(u.status,i):i(`等待动态`,`Waiting for activity`),currentDetail:m?Ee(m,700):u?.objective||``,elapsedSeconds:x,eta:re,etaUnavailableReason:F,checkpoints:I,completedTasks:c,totalTasks:s,pendingTasks:l,currentFraction:k?0:A}}var Ie=new Set([`done`,`completed`,`accepted`,`success`]),Le=new Set([`running`,`in_progress`,`claimed`,`active`,`working`]),Re=[`manager`,`planner`,`engineer`,`reviewer`],ze=[`scope`,`research`,`implementation`,`experiment`,`analysis`,`writing`,`review`];function Be(e){let t=e.toLowerCase();return/review|delivery/.test(t)?6:/writ|draft|paper/.test(t)?5:/analy|select/.test(t)?4:/experiment|pilot|run|eval/.test(t)?3:/implement|build|engineer/.test(t)?2:+!!/research|literature|idea/.test(t)}function Ve(e){return e==null?`—`:`${Math.round(e*100)}%`}function He(e,t,n,r){let i=t=>new Date((e+t)*1e3).toLocaleTimeString(r,{hour:`2-digit`,minute:`2-digit`,hour12:!1});return`${i(t)}–${i(n)}`}function Ue(e){let{locale:t,text:n}=W(),[r,i]=(0,L.useState)(()=>Date.now()/1e3),[a,o]=(0,L.useState)(``);(0,L.useEffect)(()=>{if(!e.active||!e.snapshot.daemon.alive)return;i(Date.now()/1e3);let t=window.setInterval(()=>i(Date.now()/1e3),1e3);return()=>clearInterval(t)},[e.active,e.snapshot.daemon.alive]);let l=(0,L.useMemo)(()=>Fe(e.snapshot,e.events,r,t),[t,r,e.events,e.snapshot]),d=e.snapshot.mission_view,f=d?.dag?.length?d.dag:e.snapshot.backlog.map(e=>({id:e.id,title:e.title,objective:e.objective,status:e.status,deps:e.deps??[],branch_id:e.id,parent_branch_id:``})),m=f.find(e=>Le.has(e.status))??f.find(e=>/pending|queued/.test(e.status))??f.at(-1),h=f.find(e=>e.id===a)??m,g=Be(d?.stage.id||d?.stage.label||`scope`),_=Math.round(l.confirmed*100),b=Math.round((l.range?.[0]??l.confirmed)*100),S=Math.round((l.range?.[1]??l.confirmed)*100),w=Math.round((l.estimate??l.confirmed)*100),T=e.snapshot.daemon.health?.state||(e.snapshot.daemon.alive?`active`:`stopped`),D=d?.review?.status&&!Ie.has(d.review.status)?d.review:null,O=e.events.filter(e=>String(e.kind??``)!==`reasoning`&&!String(e.type??``).startsWith(`provider.`)),k=async t=>{let r=t?n(`确认完成当前步骤后停止 Argus?`,`Stop Argus after the current step finishes?`):n(`确认立即停止 Argus?当前步骤可能被中断。`,`Stop Argus now? The current step may be interrupted.`);confirm(r)&&await e.controls.stop(t)};return(0,J.jsxs)(`div`,{className:`ros-page experiment-v3`,children:[(0,J.jsxs)(`header`,{className:`ros-page-header`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`div`,{className:`eyebrow`,children:`EXPERIMENT PROGRESS`}),(0,J.jsx)(`h1`,{children:n(`实验进程`,`Experiment progress`)}),(0,J.jsx)(`p`,{children:n(`查看当前步骤、预计进度范围、预计完成时间,以及估算的可信程度。`,`See the current step, estimated progress range, expected finish time, and how confident Argus is in the estimate.`)})]}),(0,J.jsxs)(`div`,{className:`experiment-header-actions`,children:[(0,J.jsxs)(`button`,{className:`button button--secondary`,type:`button`,onClick:()=>void e.refresh(),children:[(0,J.jsx)(y,{size:14}),n(`刷新`,`Refresh`)]}),e.snapshot.daemon.control_available===!1?null:e.snapshot.daemon.alive?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`button`,{className:`button button--secondary`,type:`button`,disabled:e.controls.busy,onClick:()=>void k(!0),children:[(0,J.jsx)(v,{size:14}),n(`当前步后停止`,`Stop after step`)]}),(0,J.jsxs)(`button`,{className:`button button--danger`,type:`button`,disabled:e.controls.busy,onClick:()=>void k(!1),children:[(0,J.jsx)(C,{size:13}),n(`立即停止`,`Stop now`)]})]}):(0,J.jsxs)(`button`,{className:`button button--primary`,type:`button`,disabled:e.controls.busy,onClick:()=>void e.controls.start(),children:[(0,J.jsx)(c,{size:14}),n(`继续运行`,`Resume`)]})]})]}),(0,J.jsxs)(`section`,{className:`experiment-progress-hero`,children:[(0,J.jsxs)(`div`,{className:`progress-hero-main`,children:[(0,J.jsxs)(`div`,{className:`progress-live-line`,children:[(0,J.jsx)(Y,{tone:e.snapshot.daemon.alive?`live`:`neutral`,dot:!0,children:e.snapshot.daemon.alive?n(`ARGUS 运行中`,`ARGUS RUNNING`):n(`ARGUS 已停止`,`ARGUS STOPPED`)}),(0,J.jsx)(`span`,{children:d?.stage.label||xe(d?.stage.id,n)}),(0,J.jsx)(`span`,{children:U(l.currentRole,n)})]}),(0,J.jsx)(`h2`,{children:l.currentTask}),(0,J.jsxs)(`div`,{className:`current-step-callout`,children:[(0,J.jsx)(`span`,{children:(0,J.jsx)(u,{size:17})}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`small`,{children:e.snapshot.daemon.alive?n(`当前正在进行`,`In progress`):n(`最后执行位置`,`Last execution point`)}),(0,J.jsx)(`strong`,{children:l.currentStep}),l.currentDetail?(0,J.jsx)(`code`,{children:l.currentDetail}):null]})]})]}),(0,J.jsxs)(`div`,{className:`progress-number`,children:[(0,J.jsx)(`span`,{children:n(`预计进度`,`Estimated progress`)}),(0,J.jsx)(`strong`,{children:Ve(l.estimate)}),(0,J.jsxs)(`small`,{children:[n(`预计范围`,`Likely range`),` `,b,`–`,S,`%`]})]}),(0,J.jsxs)(`div`,{className:`truthful-progress`,"aria-label":n(`预计完成 ${w}%`,`Estimated completion ${w}%`),children:[(0,J.jsxs)(`div`,{className:`truthful-progress__track`,children:[(0,J.jsx)(`span`,{className:`confirmed`,style:{width:`${_}%`}}),(0,J.jsx)(`span`,{className:`estimated-range`,style:{left:`${b}%`,width:`${Math.max(1,S-b)}%`}}),(0,J.jsx)(`i`,{style:{left:`${w}%`}})]}),(0,J.jsxs)(`div`,{className:`truthful-progress__legend`,children:[(0,J.jsxs)(`span`,{children:[(0,J.jsx)(`b`,{className:`confirmed-dot`}),n(`确定完成`,`Confirmed`),` `,_,`%`]}),(0,J.jsxs)(`span`,{children:[(0,J.jsx)(`b`,{className:`range-dot`}),n(`估计范围`,`Estimated range`),` `,b,`–`,S,`%`]}),(0,J.jsx)(`span`,{children:l.basis})]})]}),(0,J.jsxs)(`div`,{className:`progress-metrics`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsxs)(`span`,{children:[(0,J.jsx)(E,{size:15}),n(`当前任务已运行`,`Current task elapsed`)]}),(0,J.jsx)(`strong`,{children:K(l.elapsedSeconds)}),(0,J.jsx)(`small`,{children:n(`从任务领取开始`,`Since task claim`)})]}),(0,J.jsxs)(`div`,{children:[(0,J.jsxs)(`span`,{children:[(0,J.jsx)(se,{size:15}),n(`预计完成时间`,`Expected finish time`)]}),(0,J.jsx)(`strong`,{children:l.eta?`${K(l.eta.minSeconds)}–${K(l.eta.maxSeconds)}`:n(`暂不可用`,`Unavailable`)}),(0,J.jsx)(`small`,{children:l.eta?He(r,l.eta.minSeconds,l.eta.maxSeconds,t):l.etaUnavailableReason})]}),(0,J.jsxs)(`div`,{children:[(0,J.jsxs)(`span`,{children:[(0,J.jsx)(re,{size:15}),n(`估算置信度`,`Estimate confidence`)]}),(0,J.jsx)(`strong`,{className:`confidence-${l.confidence}`,children:l.confidence===`high`?n(`高`,`High`):l.confidence===`medium`?n(`中`,`Medium`):n(`低`,`Low`)}),(0,J.jsx)(`small`,{children:l.eta?.basis||n(`需要更多历史任务`,`More task history is needed`)})]}),(0,J.jsxs)(`div`,{children:[(0,J.jsxs)(`span`,{children:[(0,J.jsx)(ue,{size:15}),n(`任务路线`,`Task route`)]}),(0,J.jsxs)(`strong`,{children:[l.completedTasks,` / `,l.totalTasks||`—`]}),(0,J.jsxs)(`small`,{children:[n(`${l.pendingTasks} 项等待中`,`${l.pendingTasks} waiting`),` · `,n(`当前步骤`,`current step`),` `,Math.round(l.currentFraction*100),`%`]})]})]})]}),(0,J.jsx)(`section`,{className:`research-stage-rail`,children:ze.map((e,t)=>(0,J.jsxs)(`div`,{className:t(0,J.jsxs)(`button`,{type:`button`,className:h?.id===e.id?`is-active`:``,onClick:()=>o(e.id),children:[(0,J.jsx)(`span`,{className:`task-state task-state--${we(e.status)}`,children:Ie.has(e.status)?(0,J.jsx)(p,{size:12}):Le.has(e.status)?(0,J.jsx)(u,{size:12}):(0,J.jsx)(A,{size:9})}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`strong`,{children:e.title||e.objective||n(`未命名任务`,`Untitled task`)}),(0,J.jsxs)(`small`,{children:[H(e.status,n),e.deps.length?n(` · 需等待前置任务 ${e.deps.length} 项`,` · Starts after ${e.deps.length} earlier tasks`):``]})]})]},e.id)):(0,J.jsx)(X,{icon:ue,title:n(`尚无任务路线`,`No task route yet`)})})]}),(0,J.jsxs)(`main`,{className:`experiment-v3-center`,children:[(0,J.jsxs)(`section`,{className:`ros-card checkpoint-card`,children:[(0,J.jsxs)(`header`,{children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`span`,{children:`CURRENT CHECKPOINTS`}),(0,J.jsx)(`h2`,{children:n(`当前任务走到哪一步`,`Current task checkpoints`)})]}),(0,J.jsxs)(Y,{tone:`info`,children:[Math.round(l.currentFraction*100),`%`]})]}),(0,J.jsx)(`div`,{className:`checkpoint-list`,children:l.checkpoints.map((e,t)=>(0,J.jsxs)(`div`,{className:`checkpoint checkpoint--${e.status}`,children:[(0,J.jsx)(`span`,{children:e.status===`done`?(0,J.jsx)(p,{size:13}):e.status===`active`?(0,J.jsx)(u,{size:13}):e.status===`blocked`?(0,J.jsx)(ce,{size:13}):t+1}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`strong`,{children:e.label}),(0,J.jsx)(`p`,{children:e.detail})]}),t{let r=e.snapshot.roles.find(e=>e.role===t);return(0,J.jsxs)(`article`,{className:r?.active?`is-active`:``,children:[(0,J.jsx)(`span`,{"data-role-dot":t,className:`role-dot role-dot--${t}`,"aria-hidden":`true`}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`strong`,{children:U(t,n)}),(0,J.jsx)(`p`,{children:r?.label||H(`waiting`,n)}),(0,J.jsx)(`small`,{children:H(r?.status||`idle`,n)})]}),r?.active?(0,J.jsx)(Y,{tone:`live`,dot:!0,children:H(`active`,n)}):(0,J.jsx)(Y,{tone:we(r?.status),children:H(r?.status||`idle`,n)})]},t)})})]}),(0,J.jsxs)(`section`,{className:`ros-card estimate-note`,children:[(0,J.jsx)(`header`,{children:(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`span`,{children:`ESTIMATE HEALTH`}),(0,J.jsx)(`h2`,{children:n(`估算与风险`,`Estimate and risk`)})]})}),(0,J.jsxs)(`div`,{children:[(0,J.jsxs)(`p`,{children:[(0,J.jsx)(`strong`,{children:n(`估算说明`,`Estimate note`)}),n(`当前百分比根据任务状态和事件里程碑估算,可能随新进展调整。`,`The percentage is estimated from task state and event milestones and may change as work progresses.`)]}),D?(0,J.jsxs)(`div`,{className:`estimate-risk`,children:[(0,J.jsx)(ce,{size:15}),(0,J.jsxs)(`span`,{children:[(0,J.jsxs)(`strong`,{children:[U(`reviewer`,n),` · `,H(D.status,n)]}),D.reason||n(`任务范围可能变化,预计完成时间已暂停更新。`,`Scope may change, so the expected finish time is paused.`)]})]}):(0,J.jsxs)(`div`,{className:`estimate-ok`,children:[(0,J.jsx)(x,{size:15}),(0,J.jsxs)(`span`,{children:[(0,J.jsx)(`strong`,{children:n(`当前估算可用`,`Estimate available`)}),H(T,n),` · `,n(`最近进度`,`last progress`),` `,K(e.snapshot.daemon.health?.seconds_since_progress)]})]}),e.controls.error?(0,J.jsx)(`div`,{className:`inline-error`,children:e.controls.error}):null]})]})]})]})]})}async function Z(e,t,n){let r=new URLSearchParams(t),i=await fetch(`${e}?${r}`,{headers:R(),signal:n,cache:`no-store`});if(!i.ok){let t=await i.json().catch(()=>({}));throw Error(t.detail||t.error||`${e} failed (${i.status})`)}return i.json()}var Q=(e,t)=>({sid:e,workspace_id:t}),$={profiles:(e,t)=>Z(`/api/v2/workspaces`,{sid:e},t),tree:(e,t,n)=>Z(`/api/v2/workspace/tree`,Q(e,t),n),file:(e,t,n,r)=>Z(`/api/v2/workspace/file`,{...Q(e,t),path:n},r),git:(e,t,n)=>Z(`/api/v2/workspace/git`,Q(e,t),n),literature:(e,t,n)=>Z(`/api/v2/workspace/literature`,Q(e,t),n),rawUrl:(e,t,n)=>`/api/v2/workspace/raw?${new URLSearchParams({...Q(e,t),path:n})}`,rawBlob:async(e,t,n,r)=>{let i=await fetch(`/api/v2/workspace/raw?${new URLSearchParams({...Q(e,t),path:n})}`,{headers:R(),signal:r,cache:`no-store`});if(!i.ok){let e=await i.json().catch(()=>({}));throw Error(e.detail||`raw preview failed (${i.status})`)}return i.blob()}};function We(e){let t=new Map;e.forEach(e=>t.set(e.path,{...e,children:[]}));let n=[];t.forEach(e=>{let r=e.path.lastIndexOf(`/`),i=r>=0?e.path.slice(0,r):``,a=i?t.get(i):null;a?a.children.push(e):n.push(e)});let r=e=>{e.sort((e,t)=>e.type===t.type?e.name.localeCompare(t.name):e.type===`directory`?-1:1),e.forEach(e=>r(e.children))};return r(n),n}function Ge(e,t,n){let[r,i]=(0,L.useState)(``),[a,o]=(0,L.useState)(``);return(0,L.useEffect)(()=>{if(i(``),o(``),!e||!t||!n)return;let r=new AbortController,a=``;return $.rawBlob(e,t,n,r.signal).then(e=>{a=URL.createObjectURL(e),i(a)},e=>{r.signal.aborted||o(e.message)}),()=>{r.abort(),a&&URL.revokeObjectURL(a)}},[n,e,t]),{url:r,error:a}}function Ke(e,t,n=!0){let r=i({queryKey:[`workspace-profiles`,e],queryFn:({signal:t})=>$.profiles(e,t),staleTime:1e4,enabled:!!e&&n}),a=`argus-v2-workspace-profile:${t}:${e}`,[o,s]=(0,L.useState)(()=>w(a)||``),c=(0,L.useMemo)(()=>{let e=r.data?.profiles??[];return e.find(e=>e.id===o)??e.find(e=>e.id===r.data?.default_id)??e.find(e=>e.canonical)??e[0]??null},[r.data,o]);return(0,L.useEffect)(()=>{c&&c.id!==o&&s(c.id)},[c,o]),{profiles:r,active:c,workspaceId:c?.id??``,setWorkspaceId:e=>{s(e),S(a,e)}}}function qe({node:e,depth:t,selected:n,expanded:r,onToggle:i,onSelect:a}){let o=e.type===`directory`,c=r.has(e.path);return(0,J.jsxs)(`div`,{className:`workspace-node`,children:[(0,J.jsxs)(`button`,{type:`button`,className:n===e.path?`is-selected`:``,style:{paddingLeft:7+t*13},onClick:()=>o?i(e.path):a(e.path),children:[o?c?(0,J.jsx)(T,{size:13}):(0,J.jsx)(s,{size:13}):(0,J.jsx)(`span`,{className:`node-spacer`}),o?(0,J.jsx)(ne,{size:14}):(0,J.jsx)(M,{size:14}),(0,J.jsx)(`span`,{children:e.name}),e.skipped?(0,J.jsx)(`small`,{children:`restricted`}):null]}),o&&c?e.children.map(e=>(0,J.jsx)(qe,{node:e,depth:t+1,selected:n,expanded:r,onToggle:i,onSelect:a},e.path)):null]})}function Je({sid:e,workspaceId:t,path:n,active:r}){let{text:a}=W(),o=n.toLowerCase().slice(n.lastIndexOf(`.`)),s=[`.pdf`,`.png`,`.jpg`,`.jpeg`,`.webp`,`.svg`].includes(o),c=i({queryKey:[`workspace-file`,e,t,n],queryFn:({signal:r})=>$.file(e,t,n,r),enabled:!!(r&&n&&t&&!s),refetchInterval:5e3}),l=Ge(s?e:``,s?t:``,s?n:``);if(!n)return(0,J.jsx)(X,{icon:N,title:a(`打开一个文件开始阅读`,`Open a file to start reading`),description:a(`左侧文件树直接映射已批准的服务器工作区。`,`The file tree maps the approved server workspace.`)});if(s)return l.error?(0,J.jsx)(X,{icon:ie,title:`Preview unavailable`,description:l.error}):l.url?o===`.pdf`?(0,J.jsx)(b,{src:l.url,name:n.split(`/`).at(-1)||n,className:`workspace-pdf`}):(0,J.jsx)(`img`,{className:`workspace-image`,src:l.url,alt:n}):(0,J.jsx)(`div`,{className:`editor-loading`,children:`Loading preview…`});if(c.isLoading)return(0,J.jsxs)(`div`,{className:`editor-loading`,children:[`Opening `,n,`…`]});if(c.isError)return(0,J.jsx)(X,{icon:ie,title:`Preview unavailable`,description:c.error.message});let u=(c.data?.content??``).split(` +`);return(0,J.jsxs)(`div`,{className:`vscode-code`,tabIndex:0,"aria-label":a(`文件内容`,`File contents`),children:[(0,J.jsx)(`div`,{className:`vscode-line-numbers`,children:u.map((e,t)=>(0,J.jsx)(`span`,{children:t+1},t))}),(0,J.jsx)(`pre`,{children:(0,J.jsx)(`code`,{children:c.data?.content})})]})}function Ye(e){let{locale:t,text:n}=W(),r=Ke(e.sid,`ide`,e.active),a=r.workspaceId,c=r.active?.path||``,[u,d]=(0,L.useState)(``),[f,m]=(0,L.useState)(new Set),h=(0,L.useRef)(``),g=(0,L.useRef)(null),v=e=>{d(e);let t=g.current,n=t?.closest(`.vscode-shell`),r=t?.closest(`.ros-content`);t&&n&&r&&getComputedStyle(n).display===`flex`&&r.scrollTo({top:r.scrollTop+t.getBoundingClientRect().top-r.getBoundingClientRect().top-12,behavior:window.matchMedia(`(prefers-reduced-motion: reduce)`).matches?`auto`:`smooth`})},[b,x]=(0,L.useState)(`files`),[S,C]=(0,L.useState)(`repository`),w=i({queryKey:[`workspace-tree`,e.sid,a],queryFn:({signal:t})=>$.tree(e.sid,a,t),enabled:!!(e.active&&a),refetchInterval:8e3}),E=i({queryKey:[`workspace-git`,e.sid,a],queryFn:({signal:t})=>$.git(e.sid,a,t),enabled:!!(e.active&&a),refetchInterval:8e3}),D=(0,L.useMemo)(()=>We(w.data?.entries??[]),[w.data?.entries]);(0,L.useEffect)(()=>{d(``),m(new Set),h.current=``},[a]),(0,L.useEffect)(()=>{!a||!D.length||h.current===a||(h.current=a,m(new Set(D.filter(e=>e.type===`directory`).slice(0,5).map(e=>e.path))))},[D,a]);let O=e.events.filter(e=>[`command_execution`,`tool_use`,`tool_result`,`file_change`].includes(String(e.kind??``))).slice(-100),k=(E.data?.status??``).split(` +`).filter(Boolean),A=(E.data?.log??``).split(` +`).filter(Boolean).map(e=>{let[t,n,r,...i]=e.split(` `);return{hash:t,date:n,author:r,subject:i.join(` `)}}),M=E.data;return(0,J.jsxs)(`div`,{className:`ros-page ide-v3`,children:[(0,J.jsxs)(`header`,{className:`ros-page-header`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`div`,{className:`eyebrow`,children:`AI IDE`}),(0,J.jsx)(`h1`,{children:n(`服务器代码工作区`,`Server code workspace`)}),(0,J.jsx)(`p`,{children:n(`接近 VS Code 的只读工作台:文件浏览、源码阅读、Git/GitHub 就绪状态和 Argus 终端轨迹。`,`A read-only VS Code-style workspace for files, source, Git/GitHub readiness, and Argus terminal activity.`)})]}),(0,J.jsxs)(Y,{tone:`info`,children:[(0,J.jsx)(ie,{size:12}),n(`只读安全模式`,`Read-only safe mode`)]})]}),(0,J.jsxs)(`div`,{className:`ide-context-strip`,children:[(0,J.jsx)(I,{size:15}),(0,J.jsx)(`select`,{"aria-label":n(`选择已批准工作区`,`Select approved workspace`),value:a,onChange:e=>r.setWorkspaceId(e.target.value),children:r.profiles.data?.profiles.map(e=>(0,J.jsx)(`option`,{value:e.id,children:e.label},e.id))}),(0,J.jsx)(`code`,{children:c}),w.isError?(0,J.jsx)(Y,{tone:`danger`,children:n(`连接失败`,`Connection failed`)}):w.isFetching?(0,J.jsx)(Y,{tone:`live`,dot:!0,children:n(`同步中`,`Syncing`)}):(0,J.jsxs)(Y,{tone:`success`,children:[(0,J.jsx)(l,{size:11}),`Synced`]}),(0,J.jsxs)(`small`,{children:[w.data?.entries.length??0,` entries`]}),(0,J.jsx)(`button`,{type:`button`,onClick:()=>{w.refetch(),E.refetch()},"aria-label":n(`刷新工作区`,`Refresh workspace`),children:(0,J.jsx)(y,{size:14})})]}),(0,J.jsxs)(`div`,{className:`vscode-shell`,children:[(0,J.jsxs)(`nav`,{className:`vscode-activitybar`,children:[(0,J.jsx)(`button`,{type:`button`,className:b===`files`?`is-active`:``,onClick:()=>x(`files`),title:`Explorer`,"aria-label":`Explorer`,children:(0,J.jsx)(ee,{size:21})}),(0,J.jsxs)(`button`,{type:`button`,className:b===`git`?`is-active`:``,onClick:()=>x(`git`),title:`Source Control`,"aria-label":`Source Control`,children:[(0,J.jsx)(o,{size:21}),k.length?(0,J.jsx)(`i`,{children:k.length}):null]})]}),(0,J.jsxs)(`aside`,{className:`vscode-sidebar`,children:[(0,J.jsxs)(`header`,{children:[(0,J.jsx)(`span`,{children:b===`git`?`SOURCE CONTROL`:`EXPLORER`}),(0,J.jsx)(`button`,{type:`button`,onClick:()=>void w.refetch(),"aria-label":n(`刷新文件树`,`Refresh file tree`),children:(0,J.jsx)(y,{size:14})})]}),b===`files`?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`vscode-root`,children:[(0,J.jsx)(T,{size:13}),(0,J.jsx)(`strong`,{children:c.split(`/`).at(-1)||c})]}),(0,J.jsx)(`div`,{className:`workspace-tree`,children:w.isError?(0,J.jsx)(X,{icon:I,title:n(`目录连接失败`,`Directory connection failed`),description:w.error.message}):D.map(e=>(0,J.jsx)(qe,{node:e,depth:0,selected:u,expanded:f,onToggle:e=>m(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),onSelect:v},e.path))})]}):(0,J.jsx)(`div`,{className:`vscode-changes`,children:k.length?k.map(e=>(0,J.jsxs)(`button`,{type:`button`,onClick:()=>{let t=e.slice(3).trim(),n=t.includes(` -> `)?t.split(` -> `).at(-1):t;n.endsWith(`/`)||v(n)},children:[(0,J.jsx)(`b`,{children:e.slice(0,2).trim()||`?`}),(0,J.jsx)(`span`,{children:e.slice(3)})]},e)):(0,J.jsx)(`p`,{children:`No changes`})})]}),(0,J.jsxs)(`main`,{className:`vscode-editor`,ref:g,children:[(0,J.jsx)(`div`,{className:`vscode-tabs`,children:(0,J.jsxs)(`button`,{type:`button`,className:`is-active`,children:[(0,J.jsx)(j,{size:13}),u||`Welcome`]})}),(0,J.jsx)(`div`,{className:`vscode-breadcrumbs`,children:u?u.split(`/`).map((e,t)=>(0,J.jsxs)(`span`,{children:[e,tC(`changes`),children:`Changes`}),(0,J.jsx)(`button`,{type:`button`,className:S===`timeline`?`is-active`:``,onClick:()=>C(`timeline`),children:`Timeline`}),(0,J.jsx)(`button`,{type:`button`,className:S===`repository`?`is-active`:``,onClick:()=>C(`repository`),children:`Repository`})]}),(0,J.jsx)(`div`,{className:`vscode-git-content`,children:M?.available?S===`changes`?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`pre`,{className:`vscode-status`,children:M.status||`Working tree clean`}),M.diff?(0,J.jsx)(`pre`,{className:`vscode-diff`,children:M.diff}):null]}):S===`timeline`?(0,J.jsx)(`div`,{className:`vscode-commits`,children:A.map(e=>(0,J.jsxs)(`article`,{children:[(0,J.jsx)(o,{size:13}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`strong`,{children:e.subject}),(0,J.jsxs)(`small`,{children:[e.author,` · `,e.date?.slice(0,10)]})]})]},e.hash))}):(0,J.jsxs)(`div`,{className:`repository-readiness`,children:[(0,J.jsx)(`h3`,{children:`Repository readiness`}),(0,J.jsxs)(`dl`,{children:[(0,J.jsxs)(`div`,{children:[(0,J.jsxs)(`dt`,{children:[(0,J.jsx)(o,{size:13}),`Remote`]}),(0,J.jsx)(`dd`,{children:M.remotes.length?M.remotes.map(e=>`${e.name}: ${e.fetch}`).join(` +`):`Not configured`}),(0,J.jsx)(`i`,{className:M.remotes.length?`ok`:`missing`,children:M.remotes.length?(0,J.jsx)(p,{size:12}):(0,J.jsx)(_,{size:12})})]}),(0,J.jsxs)(`div`,{children:[(0,J.jsxs)(`dt`,{children:[(0,J.jsx)(o,{size:13}),`Upstream`]}),(0,J.jsxs)(`dd`,{children:[M.upstream||`Not configured`,M.upstream?` · ahead ${M.ahead}, behind ${M.behind}`:``]}),(0,J.jsx)(`i`,{className:M.upstream?`ok`:`missing`,children:M.upstream?(0,J.jsx)(p,{size:12}):(0,J.jsx)(_,{size:12})})]}),(0,J.jsxs)(`div`,{children:[(0,J.jsxs)(`dt`,{children:[(0,J.jsx)(le,{size:13}),`Commit identity`]}),(0,J.jsx)(`dd`,{children:M.identity.name&&M.identity.email?`${M.identity.name} <${M.identity.email}>`:`Not configured`}),(0,J.jsx)(`i`,{className:M.identity.valid?`ok`:`missing`,children:M.identity.valid?(0,J.jsx)(p,{size:12}):(0,J.jsx)(_,{size:12})})]}),(0,J.jsxs)(`div`,{children:[(0,J.jsxs)(`dt`,{children:[(0,J.jsx)(F,{size:13}),`GitHub CLI`]}),(0,J.jsx)(`dd`,{children:M.github.authenticated?`${M.github.login} · ${M.github.protocol}`:`Not authenticated`}),(0,J.jsx)(`i`,{className:M.github.authenticated?`ok`:`missing`,children:M.github.authenticated?(0,J.jsx)(p,{size:12}):(0,J.jsx)(_,{size:12})})]})]}),(0,J.jsx)(`p`,{children:M.publish_ready?`Repository is ready for an explicitly approved push.`:`Configure the missing items before publishing. No credentials are shown in this UI.`})]}):(0,J.jsx)(X,{icon:o,title:`Not a Git repository`})})]}),(0,J.jsxs)(`section`,{className:`vscode-terminal`,children:[(0,J.jsxs)(`header`,{children:[(0,J.jsx)(`strong`,{children:`ARGUS ACTIVITY`}),(0,J.jsxs)(`span`,{children:[(0,J.jsx)(oe,{size:13}),`read-only`]})]}),(0,J.jsx)(`div`,{children:O.length?O.map((e,n)=>(0,J.jsxs)(`article`,{children:[(0,J.jsx)(`time`,{children:Ce(e.ts,t)}),(0,J.jsx)(`b`,{className:`terminal-role terminal-role--${Te(e)}`,children:Te(e)}),(0,J.jsx)(`span`,{children:`›`}),(0,J.jsx)(`code`,{children:Ee(e,800)||q(e)})]},`${e.ts}-${n}`)):(0,J.jsx)(`p`,{children:`$ waiting for Argus activity`})})]}),(0,J.jsxs)(`footer`,{className:`vscode-statusbar`,children:[(0,J.jsxs)(`span`,{children:[(0,J.jsx)(o,{size:12}),M?.branch||`no branch`]}),(0,J.jsx)(`span`,{children:w.isError?`Workspace error`:w.isFetching?`Workspace syncing`:w.data?.truncated?`Tree truncated`:`Workspace synced`}),(0,J.jsx)(`span`,{children:M?.github.authenticated?`GitHub: ${M.github.login}`:`GitHub: offline`}),(0,J.jsx)(`span`,{children:`UTF-8`}),(0,J.jsx)(`span`,{children:u.split(`.`).at(-1)?.toUpperCase()||`Plain Text`})]})]})]})}var Xe=[{id:`experiments`,zh:`运行进程`,en:`Execution`,zhDesc:`查看当前步骤、任务路线和角色交接。`,enDesc:`Follow the current step, task route, and role handoffs.`,icon:te,color:`blue`},{id:`ide`,zh:`AI IDE`,en:`AI IDE`,zhDesc:`阅读项目文件,查看 Git 状态与 Argus 活动。`,enDesc:`Read project files, Git state, and Argus activity.`,icon:j,color:`emerald`}],Ze=[{id:`overview`,zh:`项目概览`,en:`Project overview`,icon:P},...Xe];function Qe(e){let{text:t}=W(),n=e.snapshot.mission_view,r=n?.routing.vertical===`research`,i=n?.active_role||e.status?.active_role||`idle`,a=[H(n?.mission.status||`idle`,t),n?.outcome.stage_certification?Se(n.outcome.stage_certification,t):``].filter(Boolean).join(` · `);return(0,J.jsxs)(`div`,{className:`overview-page`,children:[(0,J.jsxs)(`section`,{className:`overview-hero`,children:[(0,J.jsxs)(`div`,{className:`overview-hero__copy`,children:[(0,J.jsxs)(`div`,{className:`overview-hero__badges`,children:[(0,J.jsx)(Y,{tone:e.snapshot.daemon.alive?`live`:`neutral`,dot:!0,children:e.snapshot.daemon.alive?t(`Argus 正在运行`,`Argus running`):t(`Argus 已停止`,`Argus stopped`)}),(0,J.jsx)(Y,{tone:we(n?.stage.id),children:n?.stage.label||xe(n?.stage.id,t)})]}),(0,J.jsx)(`h1`,{children:e.snapshot.session.display_name||e.project.label}),(0,J.jsx)(`p`,{children:n?.mission.objective||e.status?.continuous?.objective||e.project.objective||t(`尚未设置目标。`,`No objective has been set.`)})]}),(0,J.jsxs)(`div`,{className:`overview-hero__stats`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`span`,{children:t(`当前角色`,`Active role`)}),(0,J.jsx)(`strong`,{children:U(i,t)}),(0,J.jsx)(`small`,{children:e.snapshot.roles.find(e=>e.active)?.label||H(`waiting`,t)})]}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`span`,{children:r?t(`研究阶段`,`Research stage`):t(`工作流阶段`,`Workflow stage`)}),(0,J.jsx)(`strong`,{children:n?.stage.label||xe(n?.stage.id,t)}),(0,J.jsx)(`small`,{children:a})]}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`span`,{children:t(`累计运行`,`Elapsed`)}),(0,J.jsx)(`strong`,{children:K(n?.mission.campaign_elapsed_seconds||e.snapshot.daemon.uptime_seconds)}),(0,J.jsx)(`small`,{children:n?.round.current?t(`第 ${n.round.current}/${n.round.max||`—`} 轮`,`Round ${n.round.current}/${n.round.max||`—`}`):t(`暂无轮次`,`No round`)})]})]})]}),(0,J.jsx)(`div`,{className:`overview-section-heading`,children:(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`h2`,{children:t(`项目工作区`,`Project workspace`)}),(0,J.jsx)(`p`,{children:t(`所有模块共享同一个 Argus 项目、项目文件和实时动态。`,`All modules share the same Argus project, project files, and live activity.`)})]})}),(0,J.jsx)(`section`,{className:`module-grid`,children:Xe.map(n=>{let r=n.icon;return(0,J.jsxs)(`button`,{className:`module-card`,type:`button`,onClick:()=>e.navigate(n.id),children:[(0,J.jsx)(`span`,{className:`module-card__icon module-card__icon--${n.color}`,children:(0,J.jsx)(r,{size:20})}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`h3`,{children:t(n.zh,n.en)}),(0,J.jsx)(`p`,{children:t(n.zhDesc,n.enDesc)})]}),(0,J.jsx)(k,{size:16})]},n.id)})}),(0,J.jsxs)(`section`,{className:`overview-lower`,children:[(0,J.jsx)(De,{eyebrow:`CURRENT MISSION`,title:t(`当前任务`,`Current mission`),children:(0,J.jsxs)(`div`,{className:`overview-mission`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(se,{size:18}),(0,J.jsx)(`span`,{children:H(n?.mission.status||`idle`,t)})]}),(0,J.jsx)(`h3`,{children:n?.mission.title||e.project.current_task||t(`等待新任务`,`Waiting for a new task`)}),(0,J.jsx)(`p`,{children:n?.mission.summary||n?.frontier.summary||n?.review.reason||t(`Argus 的下一步和 Reviewer 边界会在这里同步。`,`Argus next steps and reviewer boundaries appear here.`)}),(0,J.jsxs)(`button`,{className:`button button--secondary`,type:`button`,onClick:()=>e.navigate(`experiments`),children:[t(`查看完整实验进程`,`View experiment progress`),` `,(0,J.jsx)(k,{size:14})]})]})}),(0,J.jsx)(De,{eyebrow:`RECENT ACTIVITY`,title:t(`最近活动`,`Recent activity`),bodyClassName:`panel__body--flush`,children:(0,J.jsx)(ke,{events:e.events,limit:7,dense:!0})})]})]})}function $e(e){let t=String(e.event_id??e.id??``);if(t)return t;let n=String(e.message_id??``);return n?`${e.type??``}:${n}:${e.kind??``}`:[e.type??``,e.ts??``,e.agent_layer??e.actor??``,e.kind??``,String(e.text??e.title??e.reason??``).slice(0,160)].join(`|`)}function et(e,t){let n=[...e],r=new Map(n.map((e,t)=>[$e(e),t]));return t.forEach(e=>{let t=$e(e),i=r.get(t);i==null?(r.set(t,n.length),n.push(e)):n[i]={...n[i],...e}}),n.sort((e,t)=>Number(e.ts??0)-Number(t.ts??0)).slice(-600)}function tt(e=!0){return i({queryKey:[`v2-projects`],queryFn:({signal:e})=>V.projects(e),enabled:e,refetchInterval:1e4})}function nt(e,t=!0){let n=r(),[o,s]=(0,L.useState)([]),[c,l]=(0,L.useState)(!1),u=(0,L.useRef)(null),d=!!e&&t,f=i({queryKey:[`v2-snapshot`,e],queryFn:({signal:t})=>V.snapshot(e,t),enabled:d,refetchInterval:5e3}),p=i({queryKey:[`v2-status`,e],queryFn:({signal:t})=>V.status(e,t),enabled:d,refetchInterval:6e3}),m=i({queryKey:[`v2-events`,e],queryFn:({signal:t})=>V.events(e,220,t),enabled:d,refetchInterval:15e3});(0,L.useEffect)(()=>{s([]),l(!1)},[e]),(0,L.useEffect)(()=>{!e||!m.data||s(e=>et(e,m.data))},[m.data,e]),(0,L.useEffect)(()=>{if(!e||!t){l(!1);return}let r=he(e,t=>{s(e=>et(e,[t])),u.current??=window.setTimeout(()=>{u.current=null,n.invalidateQueries({queryKey:[`v2-snapshot`,e]}),n.invalidateQueries({queryKey:[`v2-status`,e]})},900)},l);return()=>{r.close(),l(!1),u.current!=null&&(window.clearTimeout(u.current),u.current=null)}},[t,n,e]);let h=async()=>{e&&await Promise.all([n.invalidateQueries({queryKey:[`v2-snapshot`,e]}),n.invalidateQueries({queryKey:[`v2-status`,e]}),n.invalidateQueries({queryKey:[`v2-events`,e]})])},g=a({mutationFn:()=>V.startDaemon(e,f.data?.daemon_commands?.revision),onSuccess:h}),_=a({mutationFn:t=>V.stopDaemon(e,t,f.data?.daemon_commands?.revision),onSuccess:h}),v=(0,L.useMemo)(()=>{let e=[f,p,m].find(e=>e.error);return e?.error instanceof Error?e.error:null},[m,f,p]);return{snapshot:f,status:p,events:o,connected:c,refresh:h,controls:{start:g,stop:_},error:v}}function rt({sid:e,active:t}){let{locale:n}=O(),[r,i]=(0,L.useState)(()=>{let e=new URLSearchParams(window.location.search).get(`module`);return Ze.find(t=>t.id===e)?.id??`overview`}),[a,o]=(0,L.useState)(()=>new Set([r])),s=(0,L.useCallback)(e=>{i(e),o(t=>t.has(e)?t:new Set([...t,e]))},[]),c=tt(t),l=c.data?.projects??[],u=(0,L.useMemo)(()=>l.find(t=>t.id===e)??null,[l,e]),d=nt(e,t),f=r,p=d.controls.start.error||d.controls.stop.error,m=u&&d.snapshot.data?{sid:e,active:t,project:u,snapshot:d.snapshot.data,status:d.status.data,events:d.events,connected:d.connected,snapshotUpdatedAt:d.snapshot.dataUpdatedAt,refresh:d.refresh,controls:{start:async()=>{try{return await d.controls.start.mutateAsync()}catch{return null}},stop:async e=>{try{return await d.controls.stop.mutateAsync(e)}catch{return null}},busy:d.controls.start.isPending||d.controls.stop.isPending,error:p instanceof Error?p.message:``},navigate:s}:null;return(0,J.jsxs)(`section`,{className:`integrated-workbench flex min-h-0 flex-1 flex-col bg-transparent text-ink`,children:[(0,J.jsx)(`nav`,{className:`workbench-module-tabs shrink-0 border-b border-line/60 px-3 py-2`,"aria-label":n===`zh-CN`?`工作台模块`:`Workbench modules`,children:(0,J.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:Ze.map(({id:e,zh:t,en:r,icon:i})=>(0,J.jsxs)(`button`,{type:`button`,className:`workbench-module-tab`,"data-module":e,"data-selected":f===e,"aria-pressed":f===e,onClick:()=>s(e),children:[(0,J.jsx)(i,{size:14}),(0,J.jsx)(`span`,{children:n===`zh-CN`?t:r})]},e))})}),c.isError&&!u||d.snapshot.isError&&!d.snapshot.data?(0,J.jsx)(X,{title:n===`zh-CN`?`工作台读取失败`:`Workbench unavailable`,description:`Argus API did not return the selected project.`}):m?Ze.filter(({id:e})=>a.has(e)).map(({id:n})=>(0,J.jsx)(`div`,{className:`ros-content min-h-0 flex-1 overflow-x-hidden overflow-y-auto ${f===n?``:`hidden`}`,"aria-hidden":f!==n,children:n===`overview`?(0,J.jsx)(Qe,{...m,active:t&&f===n}):n===`experiments`?(0,J.jsx)(Ue,{...m,active:t&&f===n}):(0,J.jsx)(Ye,{...m,active:t&&f===n})},`${e}:${n}`)):(0,J.jsx)(`div`,{className:`boot-state`,children:(0,J.jsx)(Oe,{label:n===`zh-CN`?`正在载入工作台`:`Loading workbench`})})]})}export{rt as ResearchWorkbenchPanel}; \ No newline at end of file diff --git a/frontend/web/dist/assets/ResearchWorkbenchPanel-BXRghxPt.css b/frontend/web/dist/assets/ResearchWorkbenchPanel-BXRghxPt.css new file mode 100644 index 000000000..e41c5dee0 --- /dev/null +++ b/frontend/web/dist/assets/ResearchWorkbenchPanel-BXRghxPt.css @@ -0,0 +1 @@ +*,:before,:after,::backdrop{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:#3b82f680;--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }*,:before,:after{box-sizing:border-box;border:0 solid #e5e7eb}:before,:after{--tw-content:""}html,:host{-webkit-text-size-adjust:100%;tab-size:4;font-feature-settings:normal;font-variation-settings:normal;-webkit-tap-highlight-color:transparent;font-family:Geist Variable,PingFang SC,Microsoft YaHei,Noto Sans CJK SC,ui-sans-serif,system-ui,sans-serif;line-height:1.5}body{line-height:inherit;margin:0}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-feature-settings:normal;font-variation-settings:normal;font-family:Geist Mono Variable,SFMono-Regular,Menlo,ui-monospace,monospace;font-size:1em}small{font-size:80%}sub,sup{vertical-align:baseline;font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-feature-settings:inherit;font-variation-settings:inherit;font-family:inherit;font-size:100%;font-weight:inherit;line-height:inherit;letter-spacing:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:#0000;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button{height:auto}::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dl,dd,h1,h2,h3,h4,h5,h6,hr,figure,p,pre{margin:0}fieldset{margin:0;padding:0}legend{padding:0}ol,ul,menu{margin:0;padding:0;list-style:none}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder{opacity:1;color:#9ca3af}textarea::-moz-placeholder{opacity:1;color:#9ca3af}input::placeholder,textarea::placeholder{opacity:1;color:#9ca3af}button,[role=button]{cursor:pointer}:disabled{cursor:default}img,svg,video,canvas,audio,iframe,embed,object{vertical-align:middle;display:block}img,video{max-width:100%;height:auto}[hidden]:where(:not([hidden=until-found])){display:none}.integrated-workbench{--surface-2:var(--panel-raised);--surface-3:var(--panel);--overlay:var(--panel-raised);--border:var(--line);--border-strong:var(--glass-edge);--text:var(--ink);--muted:var(--ink-dim);--faint:var(--ink-faint);--accent:var(--blue-deep);--accent-fg:255 255 255;--blue-bg:var(--conversation-argus);--green:var(--blue);--green-bg:var(--conversation-argus);--amber:var(--ink-dim);--amber-bg:var(--conversation-user);--red:var(--err);--red-bg:var(--conversation-user);--violet:var(--ink-dim);--violet-bg:var(--conversation-argus);--rose:var(--ink-dim);--rose-bg:var(--conversation-user);--manager:var(--role-manager);--planner:var(--role-planner);--engineer:var(--role-engineer);--reviewer:var(--role-reviewer);--shadow-1:none;--shadow-2:none;--shadow-3:0 20px 60px -32px #00000047;--radius-sm:8px;--radius-md:12px;--radius-lg:16px;--font:"Geist Variable", "PingFang SC", "Microsoft YaHei", sans-serif;--mono:"SFMono-Regular", Consolas, "Liberation Mono", monospace;min-width:0;min-height:0;font-family:var(--font);-webkit-font-smoothing:antialiased;font-size:14px}.integrated-workbench ::selection{background:rgb(var(--blue) / .2)}.integrated-workbench :focus-visible{outline:2px solid rgb(var(--blue) / .62);outline-offset:2px}.integrated-workbench ::-webkit-scrollbar{width:7px;height:7px}.integrated-workbench ::-webkit-scrollbar-track{background:0 0}.integrated-workbench ::-webkit-scrollbar-thumb{background:rgb(var(--faint) / .55);background-clip:padding-box;border:2px solid #0000;border-radius:999px}.container{width:100%}@media (width>=640px){.container{max-width:640px}}@media (width>=768px){.container{max-width:768px}}@media (width>=1024px){.container{max-width:1024px}}@media (width>=1280px){.container{max-width:1280px}}@media (width>=1536px){.container{max-width:1536px}}.argus-wordmark{align-items:center;gap:10px;display:inline-flex}.argus-wordmark svg{flex:none}.argus-wordmark__copy{flex-direction:column;align-items:flex-start;line-height:1.05;display:flex}.argus-wordmark__copy strong{letter-spacing:-.025em;font-size:16px;font-weight:720}.argus-wordmark__copy small{color:rgb(var(--muted));margin-top:3px;font-size:9px;font-weight:530}.brand-button{background:0 0;align-items:center;padding:0;display:inline-flex}.button{background:rgb(var(--surface-2));min-height:36px;color:rgb(var(--text));box-shadow:none;border:1px solid #0000;border-radius:8px;justify-content:center;align-items:center;gap:7px;padding:7px 12px;font-size:12px;font-weight:590;transition:color .15s,background .15s;display:inline-flex}.button:hover:not(:disabled){background:rgb(var(--border))}.button--primary{border-color:rgb(var(--blue) / .34);background:rgb(var(--blue) / .08);color:rgb(var(--blue))}.button--primary:hover:not(:disabled){border-color:rgb(var(--blue-deep));background:rgb(var(--blue-deep));color:rgb(var(--accent-fg))}.button--secondary{background:rgb(var(--surface-2));box-shadow:none}.button--danger{border-color:rgb(var(--red) / .25);background:rgb(var(--red-bg));color:rgb(var(--red))}.button--large{border-radius:11px;min-height:42px;padding:9px 15px}.button--full{width:100%}.icon-button{width:34px;height:34px;color:rgb(var(--muted));background:0 0;border:0;border-radius:8px;flex:0 0 34px;place-items:center;transition:background .15s,color .15s;display:inline-grid}.icon-button:hover:not(:disabled){background:rgb(var(--surface-2));color:rgb(var(--text))}.badge{background:rgb(var(--surface-2));min-height:22px;color:rgb(var(--muted));white-space:nowrap;border:0;border-radius:6px;align-items:center;gap:5px;padding:3px 8px;font-size:10px;font-weight:610;line-height:1.2;display:inline-flex}.badge__dot,.status-dot{background:currentColor;border-radius:50%;width:6px;height:6px}.status-dot{color:rgb(var(--faint));background:rgb(var(--faint));display:inline-block}.status-dot.is-live{color:rgb(var(--green));background:rgb(var(--green));box-shadow:0 0 0 4px rgb(var(--green) / .11)}.is-pulsing{animation:2s infinite livePulse}.ros-card,.panel{border-radius:var(--radius-sm);background:rgb(var(--surface));min-width:0;min-height:0;box-shadow:none;border:0;overflow:hidden}.panel{flex-direction:column;display:flex}.panel__header,.ros-card>header{border-bottom:1px solid rgb(var(--border));justify-content:space-between;align-items:center;gap:12px;min-height:58px;padding:12px 16px;display:flex}.panel__heading,.ros-card>header>div{min-width:0}.panel__title,.ros-card>header h2{color:rgb(var(--text));margin:1px 0 0;font-size:13px;font-weight:650}.ros-card>header span,.panel__header .eyebrow{color:rgb(var(--faint));letter-spacing:.12em;font-size:9px;font-weight:690}.panel__body{min-width:0;min-height:0;padding:16px}.panel__body--flush{padding:0}.eyebrow{color:rgb(var(--faint));letter-spacing:.15em;margin-bottom:4px;font-size:9px;font-weight:700}.empty-state{text-align:center;flex-direction:column;justify-content:center;align-items:center;min-height:180px;padding:28px;display:flex}.empty-state__icon{border:1px solid rgb(var(--border));background:rgb(var(--surface-2));width:44px;height:44px;color:rgb(var(--faint));border-radius:12px;place-items:center;margin-bottom:12px;display:grid}.empty-state__title{font-size:13px;font-weight:640}.empty-state p{max-width:360px;color:rgb(var(--muted));margin:6px 0 0;font-size:11px;line-height:1.55}.empty-state__action{margin-top:14px}.spinner{color:rgb(var(--muted));align-items:center;gap:7px;font-size:12px;display:inline-flex}.spin{animation:.85s linear infinite spin}.inline-error{border:1px solid rgb(var(--red) / .22);background:rgb(var(--red-bg));color:rgb(var(--red));border-radius:10px;padding:10px 12px;font-size:11px;line-height:1.5}.\!notice{border:1px solid rgb(var(--border))!important;background:rgb(var(--surface))!important;color:rgb(var(--muted))!important;border-radius:11px!important;gap:8px!important;padding:11px 13px!important;font-size:11px!important;display:flex!important}.notice{border:1px solid rgb(var(--border));background:rgb(var(--surface));color:rgb(var(--muted));border-radius:11px;gap:8px;padding:11px 13px;font-size:11px;display:flex}.markdown{min-width:0;font-size:inherit;overflow-wrap:anywhere;line-height:1.68}.markdown>:first-child{margin-top:0}.markdown>:last-child{margin-bottom:0}.markdown p{margin:.55em 0}.markdown h1,.markdown h2,.markdown h3{margin:1.2em 0 .45em;line-height:1.3}.markdown h1{font-size:1.4em}.markdown h2{font-size:1.22em}.markdown h3{font-size:1.08em}.markdown ul,.markdown ol{padding-left:1.55em}.markdown blockquote{border-left:3px solid rgb(var(--blue) / .45);background:rgb(var(--blue-bg));color:rgb(var(--muted));border-radius:0 8px 8px 0;margin:.8em 0;padding:7px 12px}.markdown code{background:rgb(var(--surface-2));font-family:var(--mono);border-radius:5px;padding:.12em .34em;font-size:.88em}.markdown pre{border:1px solid rgb(var(--border));background:rgb(var(--surface-2));border-radius:10px;padding:12px;overflow:auto}.markdown pre code{background:0 0;padding:0}.markdown a{color:rgb(var(--blue));align-items:center;gap:3px;text-decoration:none;display:inline-flex}.markdown a:hover{text-decoration:underline}.markdown table{border-collapse:collapse;width:100%}.markdown th,.markdown td{border:1px solid rgb(var(--border));text-align:left;padding:6px 8px}.search-field{border:1px solid rgb(var(--border-strong));background:rgb(var(--surface));min-width:250px;color:rgb(var(--faint));border-radius:10px;align-items:center;gap:7px;padding:0 10px;display:flex}.search-field input{background:0 0;border:0;outline:0;width:100%;height:36px;font-size:12px}.search-field--block{margin:12px}.field{flex-direction:column;gap:6px;display:flex}.field>span,.form-grid label>span{color:rgb(var(--muted));font-size:11px;font-weight:580}.field input,.field textarea,.field select,.form-grid input,.new-project-fields input{border:1px solid rgb(var(--border-strong));background:rgb(var(--surface));border-radius:10px;outline:none;width:100%;padding:9px 10px;font-size:12px}.field input:focus,.field textarea:focus,.field select:focus,.form-grid input:focus,.new-project-fields input:focus{border-color:rgb(var(--blue) / .55);box-shadow:0 0 0 3px rgb(var(--blue) / .09)}.field textarea{resize:vertical;line-height:1.55}.field--grow{flex:1;min-height:0}.field--grow textarea{resize:none;flex:1;min-height:220px}.form-grid{grid-template-columns:1fr 1fr;gap:12px;display:grid}.form-grid label{flex-direction:column;gap:6px;display:flex}.file-button{position:relative;overflow:hidden}.file-button input{opacity:0;cursor:pointer;position:absolute;inset:0}.header-badges{flex-wrap:wrap;justify-content:flex-end;gap:7px;display:flex}.manager-mini-result{border-top:1px solid rgb(var(--border));max-height:260px;margin-top:10px;padding-top:10px;overflow:auto}.manager-mini-result .markdown{font-size:11px}.event-list{padding:5px}.event-row{border-radius:8px;grid-template-columns:22px minmax(0,1fr);gap:7px;padding:9px;display:grid;position:relative}.event-row:hover{background:rgb(var(--surface-2))}.event-row__marker{border:2px solid rgb(var(--surface));background:rgb(var(--faint));width:8px;height:8px;box-shadow:0 0 0 1px rgb(var(--border-strong));border-radius:50%;margin:6px auto 0}.event-row__content{min-width:0}.event-row__meta{gap:7px;display:flex}.event-row__meta time{color:rgb(var(--faint));font-family:var(--mono);margin-left:auto;font-size:9px}.role-label{text-transform:uppercase;font-size:9px;font-weight:700}.event-row__title{text-overflow:ellipsis;white-space:nowrap;margin-top:2px;font-size:11px;font-weight:620;overflow:hidden}.event-row__detail{color:rgb(var(--muted));font-family:var(--mono);-webkit-line-clamp:2;overflow-wrap:anywhere;-webkit-box-orient:vertical;margin-top:2px;font-size:9px;line-height:1.45;display:-webkit-box;overflow:hidden}.event-list--dense .event-row{padding-block:7px}.sr-only{clip:rect(0, 0, 0, 0);white-space:nowrap;border-width:0;width:1px;height:1px;margin:-1px;padding:0;position:absolute;overflow:hidden}.pointer-events-none{pointer-events:none}.\!visible{visibility:visible!important}.visible{visibility:visible}.invisible{visibility:hidden}.collapse{visibility:collapse}.static{position:static}.fixed{position:fixed}.absolute{position:absolute}.relative{position:relative}.inset-0{inset:0}.inset-x-0{left:0;right:0}.inset-y-0{top:0;bottom:0}.inset-y-1{top:.25rem;bottom:.25rem}.inset-y-2{top:.5rem;bottom:.5rem}.-bottom-2\.5{bottom:-.625rem}.-left-0\.5{left:-.125rem}.-top-2\.5{top:-.625rem}.bottom-0{bottom:0}.bottom-4{bottom:1rem}.left-0{left:0}.left-1\/2{left:50%}.left-4{left:1rem}.left-\[0\.6875rem\]{left:.6875rem}.left-\[10\%\]{left:10%}.left-\[5px\]{left:5px}.right-0\.5{right:.125rem}.right-1{right:.25rem}.right-2{right:.5rem}.right-4{right:1rem}.right-9{right:2.25rem}.right-\[10\%\]{right:10%}.top-0\.5{top:.125rem}.top-2{top:.5rem}.top-3{top:.75rem}.top-4{top:1rem}.top-6{top:1.5rem}.z-10{z-index:10}.z-30{z-index:30}.z-40{z-index:40}.z-50{z-index:50}.z-\[100\]{z-index:100}.z-\[70\]{z-index:70}.z-\[90\]{z-index:90}.order-2{order:2}.order-3{order:3}.m-auto{margin:auto}.mx-2{margin-left:.5rem;margin-right:.5rem}.mx-3{margin-left:.75rem;margin-right:.75rem}.mx-auto{margin-left:auto;margin-right:auto}.my-1{margin-top:.25rem;margin-bottom:.25rem}.my-1\.5{margin-top:.375rem;margin-bottom:.375rem}.my-2{margin-top:.5rem;margin-bottom:.5rem}.my-3{margin-top:.75rem;margin-bottom:.75rem}.mb-0\.5{margin-bottom:.125rem}.mb-1{margin-bottom:.25rem}.mb-1\.5{margin-bottom:.375rem}.mb-2{margin-bottom:.5rem}.mb-3{margin-bottom:.75rem}.mb-4{margin-bottom:1rem}.mb-6{margin-bottom:1.5rem}.ml-1{margin-left:.25rem}.ml-1\.5{margin-left:.375rem}.ml-2{margin-left:.5rem}.ml-3{margin-left:.75rem}.ml-auto{margin-left:auto}.mr-1{margin-right:.25rem}.mr-1\.5{margin-right:.375rem}.mr-auto{margin-right:auto}.mt-0\.5{margin-top:.125rem}.mt-1{margin-top:.25rem}.mt-1\.5{margin-top:.375rem}.mt-2{margin-top:.5rem}.mt-3{margin-top:.75rem}.mt-4{margin-top:1rem}.mt-5{margin-top:1.25rem}.mt-6{margin-top:1.5rem}.mt-8{margin-top:2rem}.mt-9{margin-top:2.25rem}.mt-\[7px\]{margin-top:7px}.mt-auto{margin-top:auto}.mt-px{margin-top:1px}.line-clamp-2{-webkit-line-clamp:2;-webkit-box-orient:vertical;display:-webkit-box;overflow:hidden}.line-clamp-3{-webkit-line-clamp:3;-webkit-box-orient:vertical;display:-webkit-box;overflow:hidden}.line-clamp-4{-webkit-line-clamp:4;-webkit-box-orient:vertical;display:-webkit-box;overflow:hidden}.block{display:block}.inline-block{display:inline-block}.inline{display:inline}.flex{display:flex}.inline-flex{display:inline-flex}.table{display:table}.grid{display:grid}.contents{display:contents}.hidden{display:none}.h-1{height:.25rem}.h-1\.5{height:.375rem}.h-10{height:2.5rem}.h-11{height:2.75rem}.h-12{height:3rem}.h-14{height:3.5rem}.h-16{height:4rem}.h-2{height:.5rem}.h-2\.5{height:.625rem}.h-3{height:.75rem}.h-3\.5{height:.875rem}.h-4{height:1rem}.h-5{height:1.25rem}.h-6{height:1.5rem}.h-7{height:1.75rem}.h-8{height:2rem}.h-9{height:2.25rem}.h-\[1\.4rem\]{height:1.4rem}.h-\[100dvh\]{height:100dvh}.h-\[68vh\]{height:68vh}.h-\[calc\(100\%-1rem\)\]{height:calc(100% - 1rem)}.h-auto{height:auto}.h-full{height:100%}.h-px{height:1px}.max-h-48{max-height:12rem}.max-h-64{max-height:16rem}.max-h-72{max-height:18rem}.max-h-\[100dvh\]{max-height:100dvh}.max-h-\[34rem\]{max-height:34rem}.max-h-\[52vh\]{max-height:52vh}.max-h-\[62vh\]{max-height:62vh}.max-h-\[64vh\]{max-height:64vh}.max-h-\[70dvh\]{max-height:70dvh}.max-h-\[70vh\]{max-height:70vh}.max-h-\[72vh\]{max-height:72vh}.max-h-\[76vh\]{max-height:76vh}.max-h-\[85vh\]{max-height:85vh}.max-h-\[calc\(100dvh-1\.5rem\)\]{max-height:calc(100dvh - 1.5rem)}.max-h-full{max-height:100%}.min-h-0{min-height:0}.min-h-10{min-height:2.5rem}.min-h-11{min-height:2.75rem}.min-h-14{min-height:3.5rem}.min-h-52{min-height:13rem}.min-h-64{min-height:16rem}.min-h-72{min-height:18rem}.min-h-\[3\.25rem\]{min-height:3.25rem}.min-h-\[320px\]{min-height:320px}.min-h-\[34rem\]{min-height:34rem}.min-h-\[60vh\]{min-height:60vh}.min-h-dvh{min-height:100dvh}.min-h-full{min-height:100%}.w-0\.5{width:.125rem}.w-1\.5{width:.375rem}.w-1\/2{width:50%}.w-10{width:2.5rem}.w-11{width:2.75rem}.w-12{width:3rem}.w-14{width:3.5rem}.w-16{width:4rem}.w-2{width:.5rem}.w-2\.5{width:.625rem}.w-20{width:5rem}.w-3{width:.75rem}.w-3\.5{width:.875rem}.w-4{width:1rem}.w-6{width:1.5rem}.w-64{width:16rem}.w-7{width:1.75rem}.w-8{width:2rem}.w-9{width:2.25rem}.w-\[1\.4rem\]{width:1.4rem}.w-\[min\(30rem\,calc\(100vw-2rem\)\)\]{width:min(30rem,100vw - 2rem)}.w-\[min\(92vw\,42rem\)\]{width:min(92vw,42rem)}.w-full{width:100%}.w-max{width:max-content}.w-px{width:1px}.w-screen{width:100vw}.min-w-0{min-width:0}.min-w-28{min-width:7rem}.min-w-3\.5{min-width:.875rem}.min-w-32{min-width:8rem}.min-w-44{min-width:11rem}.min-w-52{min-width:13rem}.min-w-full{min-width:100%}.min-w-max{min-width:max-content}.max-w-24{max-width:6rem}.max-w-28{max-width:7rem}.max-w-2xl{max-width:42rem}.max-w-3xl{max-width:48rem}.max-w-48{max-width:12rem}.max-w-4xl{max-width:56rem}.max-w-5xl{max-width:64rem}.max-w-64{max-width:16rem}.max-w-6xl{max-width:72rem}.max-w-72{max-width:18rem}.max-w-\[calc\(100\%_-_3rem\)\]{max-width:calc(100% - 3rem)}.max-w-full{max-width:100%}.max-w-lg{max-width:32rem}.max-w-md{max-width:28rem}.max-w-none{max-width:none}.max-w-sm{max-width:24rem}.max-w-xl{max-width:36rem}.flex-1{flex:1}.shrink{flex-shrink:1}.shrink-0{flex-shrink:0}.grow{flex-grow:1}.basis-full{flex-basis:100%}.table-fixed{table-layout:fixed}.border-collapse{border-collapse:collapse}.-translate-x-1\/2{--tw-translate-x:-50%;transform:translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.-translate-x-full{--tw-translate-x:-100%;transform:translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.translate-x-0{--tw-translate-x:0px;transform:translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.-rotate-90{--tw-rotate:-90deg;transform:translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.rotate-180{--tw-rotate:180deg;transform:translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.rotate-90{--tw-rotate:90deg;transform:translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.transform{transform:translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}@keyframes appear{0%{opacity:0;transform:translateY(4px)}to{opacity:1;transform:translateY(0)}}.animate-appear{animation:.2s cubic-bezier(.4,0,.2,1) appear}@keyframes pulse{50%{opacity:.5}}.animate-pulse{animation:2s cubic-bezier(.4,0,.6,1) infinite pulse}@keyframes spin{to{transform:rotate(360deg)}}.animate-spin{animation:1s linear infinite spin}.cursor-col-resize{cursor:col-resize}.cursor-default{cursor:default}.cursor-not-allowed{cursor:not-allowed}.cursor-pointer{cursor:pointer}.select-none{-webkit-user-select:none;user-select:none}.resize-y{resize:vertical}.resize{resize:both}.list-decimal{list-style-type:decimal}.list-disc{list-style-type:disc}.grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.grid-cols-\[16px_minmax\(0\,1fr\)\]{grid-template-columns:16px minmax(0,1fr)}.grid-cols-\[72px_minmax\(0\,1fr\)\]{grid-template-columns:72px minmax(0,1fr)}.grid-cols-\[84px_minmax\(0\,1fr\)_auto\]{grid-template-columns:84px minmax(0,1fr) auto}.grid-rows-\[1fr\]{grid-template-rows:1fr}.flex-col{flex-direction:column}.flex-wrap{flex-wrap:wrap}.place-items-center{place-items:center}.items-start{align-items:flex-start}.items-end{align-items:flex-end}.items-center{align-items:center}.items-baseline{align-items:baseline}.items-stretch{align-items:stretch}.justify-end{justify-content:flex-end}.justify-center{justify-content:center}.justify-between{justify-content:space-between}.gap-0\.5{gap:.125rem}.gap-1{gap:.25rem}.gap-1\.5{gap:.375rem}.gap-2{gap:.5rem}.gap-2\.5{gap:.625rem}.gap-3{gap:.75rem}.gap-4{gap:1rem}.gap-x-2{-moz-column-gap:.5rem;column-gap:.5rem}.gap-x-4{-moz-column-gap:1rem;column-gap:1rem}.gap-x-5{-moz-column-gap:1.25rem;column-gap:1.25rem}.gap-y-1{row-gap:.25rem}.space-y-0>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(0px * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(0px * var(--tw-space-y-reverse))}.space-y-0\.5>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(.125rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.125rem * var(--tw-space-y-reverse))}.space-y-1>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(.25rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.25rem * var(--tw-space-y-reverse))}.space-y-1\.5>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(.375rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.375rem * var(--tw-space-y-reverse))}.space-y-2>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(.5rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.5rem * var(--tw-space-y-reverse))}.space-y-3>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(.75rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.75rem * var(--tw-space-y-reverse))}.space-y-4>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(1rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1rem * var(--tw-space-y-reverse))}.overflow-auto{overflow:auto}.overflow-hidden{overflow:hidden}.overflow-x-auto{overflow-x:auto}.overflow-y-auto{overflow-y:auto}.overflow-x-hidden{overflow-x:hidden}.overscroll-contain{overscroll-behavior:contain}.truncate{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.whitespace-pre-wrap{white-space:pre-wrap}.break-words{overflow-wrap:break-word}.break-all{word-break:break-all}.rounded{border-radius:.25rem}.rounded-2xl{border-radius:1rem}.rounded-3xl{border-radius:1.5rem}.rounded-\[18px\]{border-radius:18px}.rounded-full{border-radius:9999px}.rounded-lg{border-radius:.5rem}.rounded-md{border-radius:.375rem}.rounded-none{border-radius:0}.rounded-xl{border-radius:.75rem}.rounded-r-md{border-top-right-radius:.375rem;border-bottom-right-radius:.375rem}.border{border-width:1px}.border-0{border-width:0}.border-2{border-width:2px}.border-b{border-bottom-width:1px}.border-l{border-left-width:1px}.border-l-2{border-left-width:2px}.border-r{border-right-width:1px}.border-t{border-top-width:1px}.border-blue{--tw-border-opacity:1;border-color:rgb(var(--blue) / var(--tw-border-opacity,1))}.border-blue-deep{--tw-border-opacity:1;border-color:rgb(var(--blue-deep) / var(--tw-border-opacity,1))}.border-blue-deep\/30{border-color:rgb(var(--blue-deep) / .3)}.border-blue-deep\/50{border-color:rgb(var(--blue-deep) / .5)}.border-blue-deep\/60{border-color:rgb(var(--blue-deep) / .6)}.border-blue\/25{border-color:rgb(var(--blue) / .25)}.border-blue\/30{border-color:rgb(var(--blue) / .3)}.border-blue\/35{border-color:rgb(var(--blue) / .35)}.border-blue\/45{border-color:rgb(var(--blue) / .45)}.border-blue\/50{border-color:rgb(var(--blue) / .5)}.border-err{--tw-border-opacity:1;border-color:rgb(var(--err) / var(--tw-border-opacity,1))}.border-err\/30{border-color:rgb(var(--err) / .3)}.border-err\/35{border-color:rgb(var(--err) / .35)}.border-err\/40{border-color:rgb(var(--err) / .4)}.border-err\/50{border-color:rgb(var(--err) / .5)}.border-err\/60{border-color:rgb(var(--err) / .6)}.border-gold\/25{border-color:rgb(var(--gold) / .25)}.border-gold\/30{border-color:rgb(var(--gold) / .3)}.border-gold\/40{border-color:rgb(var(--gold) / .4)}.border-line{--tw-border-opacity:1;border-color:rgb(var(--line) / var(--tw-border-opacity,1))}.border-line\/40{border-color:rgb(var(--line) / .4)}.border-line\/50{border-color:rgb(var(--line) / .5)}.border-line\/60{border-color:rgb(var(--line) / .6)}.border-line\/70{border-color:rgb(var(--line) / .7)}.border-line\/80{border-color:rgb(var(--line) / .8)}.border-ok{--tw-border-opacity:1;border-color:rgb(var(--ok) / var(--tw-border-opacity,1))}.border-ok\/20{border-color:rgb(var(--ok) / .2)}.border-ok\/25{border-color:rgb(var(--ok) / .25)}.border-ok\/30{border-color:rgb(var(--ok) / .3)}.border-ok\/35{border-color:rgb(var(--ok) / .35)}.border-ok\/40{border-color:rgb(var(--ok) / .4)}.border-ok\/45{border-color:rgb(var(--ok) / .45)}.border-ok\/60{border-color:rgb(var(--ok) / .6)}.border-panel{--tw-border-opacity:1;border-color:rgb(var(--panel) / var(--tw-border-opacity,1))}.border-transparent{border-color:#0000}.border-warn\/35{border-color:rgb(var(--warn) / .35)}.border-warn\/40{border-color:rgb(var(--warn) / .4)}.border-warn\/50{border-color:rgb(var(--warn) / .5)}.border-t-blue{--tw-border-opacity:1;border-top-color:rgb(var(--blue) / var(--tw-border-opacity,1))}.bg-bg{--tw-bg-opacity:1;background-color:rgb(var(--bg) / var(--tw-bg-opacity,1))}.bg-bg\/25{background-color:rgb(var(--bg) / .25)}.bg-bg\/30{background-color:rgb(var(--bg) / .3)}.bg-bg\/35{background-color:rgb(var(--bg) / .35)}.bg-bg\/40{background-color:rgb(var(--bg) / .4)}.bg-bg\/50{background-color:rgb(var(--bg) / .5)}.bg-bg\/60{background-color:rgb(var(--bg) / .6)}.bg-bg\/70{background-color:rgb(var(--bg) / .7)}.bg-black{--tw-bg-opacity:1;background-color:rgb(0 0 0/var(--tw-bg-opacity,1))}.bg-black\/20{background-color:#0003}.bg-black\/40{background-color:#0006}.bg-blue{--tw-bg-opacity:1;background-color:rgb(var(--blue) / var(--tw-bg-opacity,1))}.bg-blue-deep{--tw-bg-opacity:1;background-color:rgb(var(--blue-deep) / var(--tw-bg-opacity,1))}.bg-blue-deep\/10{background-color:rgb(var(--blue-deep) / .1)}.bg-blue-deep\/20{background-color:rgb(var(--blue-deep) / .2)}.bg-blue-deep\/5{background-color:rgb(var(--blue-deep) / .05)}.bg-blue-sky{--tw-bg-opacity:1;background-color:rgb(var(--blue-sky) / var(--tw-bg-opacity,1))}.bg-blue\/10{background-color:rgb(var(--blue) / .1)}.bg-blue\/5{background-color:rgb(var(--blue) / .05)}.bg-conversation-user{--tw-bg-opacity:1;background-color:rgb(var(--conversation-user) / var(--tw-bg-opacity,1))}.bg-engineer{--tw-bg-opacity:1;background-color:rgb(var(--role-engineer) / var(--tw-bg-opacity,1))}.bg-err{--tw-bg-opacity:1;background-color:rgb(var(--err) / var(--tw-bg-opacity,1))}.bg-err\/10{background-color:rgb(var(--err) / .1)}.bg-err\/5{background-color:rgb(var(--err) / .05)}.bg-gold{--tw-bg-opacity:1;background-color:rgb(var(--gold) / var(--tw-bg-opacity,1))}.bg-gold\/5{background-color:rgb(var(--gold) / .05)}.bg-gold\/80{background-color:rgb(var(--gold) / .8)}.bg-ink-faint{--tw-bg-opacity:1;background-color:rgb(var(--ink-faint) / var(--tw-bg-opacity,1))}.bg-ink-faint\/40{background-color:rgb(var(--ink-faint) / .4)}.bg-ink-faint\/45{background-color:rgb(var(--ink-faint) / .45)}.bg-ink-faint\/50{background-color:rgb(var(--ink-faint) / .5)}.bg-line{--tw-bg-opacity:1;background-color:rgb(var(--line) / var(--tw-bg-opacity,1))}.bg-line\/30{background-color:rgb(var(--line) / .3)}.bg-line\/40{background-color:rgb(var(--line) / .4)}.bg-line\/55{background-color:rgb(var(--line) / .55)}.bg-line\/60{background-color:rgb(var(--line) / .6)}.bg-line\/70{background-color:rgb(var(--line) / .7)}.bg-line\/80{background-color:rgb(var(--line) / .8)}.bg-ok{--tw-bg-opacity:1;background-color:rgb(var(--ok) / var(--tw-bg-opacity,1))}.bg-ok\/10{background-color:rgb(var(--ok) / .1)}.bg-ok\/15{background-color:rgb(var(--ok) / .15)}.bg-ok\/5{background-color:rgb(var(--ok) / .05)}.bg-panel{--tw-bg-opacity:1;background-color:rgb(var(--panel) / var(--tw-bg-opacity,1))}.bg-panel-raised{--tw-bg-opacity:1;background-color:rgb(var(--panel-raised) / var(--tw-bg-opacity,1))}.bg-panel\/80{background-color:rgb(var(--panel) / .8)}.bg-panel\/85{background-color:rgb(var(--panel) / .85)}.bg-panel\/95{background-color:rgb(var(--panel) / .95)}.bg-surface{--tw-bg-opacity:1;background-color:rgb(var(--surface) / var(--tw-bg-opacity,1))}.bg-surface\/50{background-color:rgb(var(--surface) / .5)}.bg-surface\/60{background-color:rgb(var(--surface) / .6)}.bg-transparent{background-color:#0000}.bg-warn\/10{background-color:rgb(var(--warn) / .1)}.bg-warn\/5{background-color:rgb(var(--warn) / .05)}.bg-white{--tw-bg-opacity:1;background-color:rgb(255 255 255/var(--tw-bg-opacity,1))}.bg-white\/\[0\.03\]{background-color:#ffffff08}.object-contain{-o-object-fit:contain;object-fit:contain}.object-cover{-o-object-fit:cover;object-fit:cover}.p-0{padding:0}.p-1\.5{padding:.375rem}.p-2{padding:.5rem}.p-2\.5{padding:.625rem}.p-3{padding:.75rem}.p-4{padding:1rem}.p-5{padding:1.25rem}.p-6{padding:1.5rem}.p-8{padding:2rem}.px-1{padding-left:.25rem;padding-right:.25rem}.px-1\.5{padding-left:.375rem;padding-right:.375rem}.px-2{padding-left:.5rem;padding-right:.5rem}.px-2\.5{padding-left:.625rem;padding-right:.625rem}.px-3{padding-left:.75rem;padding-right:.75rem}.px-3\.5{padding-left:.875rem;padding-right:.875rem}.px-4{padding-left:1rem;padding-right:1rem}.px-5{padding-left:1.25rem;padding-right:1.25rem}.px-6{padding-left:1.5rem;padding-right:1.5rem}.px-8{padding-left:2rem;padding-right:2rem}.py-0\.5{padding-top:.125rem;padding-bottom:.125rem}.py-1{padding-top:.25rem;padding-bottom:.25rem}.py-1\.5{padding-top:.375rem;padding-bottom:.375rem}.py-10{padding-top:2.5rem;padding-bottom:2.5rem}.py-12{padding-top:3rem;padding-bottom:3rem}.py-16{padding-top:4rem;padding-bottom:4rem}.py-2{padding-top:.5rem;padding-bottom:.5rem}.py-2\.5{padding-top:.625rem;padding-bottom:.625rem}.py-3{padding-top:.75rem;padding-bottom:.75rem}.py-4{padding-top:1rem;padding-bottom:1rem}.py-5{padding-top:1.25rem;padding-bottom:1.25rem}.py-6{padding-top:1.5rem;padding-bottom:1.5rem}.py-8{padding-top:2rem;padding-bottom:2rem}.pb-1{padding-bottom:.25rem}.pb-3{padding-bottom:.75rem}.pb-4{padding-bottom:1rem}.pb-5{padding-bottom:1.25rem}.pb-6{padding-bottom:1.5rem}.pl-0\.5{padding-left:.125rem}.pl-2{padding-left:.5rem}.pl-3{padding-left:.75rem}.pl-3\.5{padding-left:.875rem}.pl-4{padding-left:1rem}.pl-5{padding-left:1.25rem}.pl-7{padding-left:1.75rem}.pr-10{padding-right:2.5rem}.pr-14{padding-right:3.5rem}.pr-\[4\.75rem\]{padding-right:4.75rem}.pt-0\.5{padding-top:.125rem}.pt-1\.5{padding-top:.375rem}.pt-10{padding-top:2.5rem}.pt-2{padding-top:.5rem}.pt-3{padding-top:.75rem}.pt-4{padding-top:1rem}.pt-5{padding-top:1.25rem}.text-left{text-align:left}.text-center{text-align:center}.text-right{text-align:right}.align-top{vertical-align:top}.font-mono{font-family:Geist Mono Variable,SFMono-Regular,Menlo,ui-monospace,monospace}.font-sans{font-family:Geist Variable,PingFang SC,Microsoft YaHei,Noto Sans CJK SC,ui-sans-serif,system-ui,sans-serif}.text-3xl{font-size:1.875rem;line-height:2.25rem}.text-\[10px\]{font-size:10px}.text-\[11px\]{font-size:11px}.text-\[13px\]{font-size:13px}.text-\[15px\]{font-size:15px}.text-\[8px\]{font-size:8px}.text-\[9px\]{font-size:9px}.text-base{font-size:1rem;line-height:1.5rem}.text-lg{font-size:1.125rem;line-height:1.75rem}.text-sm{font-size:.875rem;line-height:1.25rem}.text-xl{font-size:1.25rem;line-height:1.75rem}.text-xs{font-size:.75rem;line-height:1rem}.font-bold{font-weight:700}.font-medium{font-weight:500}.font-normal{font-weight:400}.font-semibold{font-weight:600}.uppercase{text-transform:uppercase}.capitalize{text-transform:capitalize}.normal-case{text-transform:none}.italic{font-style:italic}.ordinal{--tw-ordinal:ordinal;font-variant-numeric:var(--tw-ordinal) var(--tw-slashed-zero) var(--tw-numeric-figure) var(--tw-numeric-spacing) var(--tw-numeric-fraction)}.tabular-nums{--tw-numeric-spacing:tabular-nums;font-variant-numeric:var(--tw-ordinal) var(--tw-slashed-zero) var(--tw-numeric-figure) var(--tw-numeric-spacing) var(--tw-numeric-fraction)}.leading-4{line-height:1rem}.leading-5{line-height:1.25rem}.leading-6{line-height:1.5rem}.leading-\[1\.625\]{line-height:1.625}.leading-none{line-height:1}.leading-relaxed{line-height:1.625}.leading-snug{line-height:1.375}.leading-tight{line-height:1.25}.tracking-\[-0\.01em\]{letter-spacing:-.01em}.tracking-\[0\.06em\]{letter-spacing:.06em}.tracking-\[0\.08em\]{letter-spacing:.08em}.tracking-\[0\.12em\]{letter-spacing:.12em}.tracking-\[0\.14em\]{letter-spacing:.14em}.tracking-\[0\.15em\]{letter-spacing:.15em}.tracking-\[0\.16em\]{letter-spacing:.16em}.tracking-\[0\.18em\]{letter-spacing:.18em}.tracking-normal{letter-spacing:0}.tracking-tight{letter-spacing:-.025em}.tracking-wide{letter-spacing:.025em}.tracking-wider{letter-spacing:.05em}.tracking-widest{letter-spacing:.1em}.text-bg{--tw-text-opacity:1;color:rgb(var(--bg) / var(--tw-text-opacity,1))}.text-blue{--tw-text-opacity:1;color:rgb(var(--blue) / var(--tw-text-opacity,1))}.text-blue-sky{--tw-text-opacity:1;color:rgb(var(--blue-sky) / var(--tw-text-opacity,1))}.text-blue\/75{color:rgb(var(--blue) / .75)}.text-err{--tw-text-opacity:1;color:rgb(var(--err) / var(--tw-text-opacity,1))}.text-gold{--tw-text-opacity:1;color:rgb(var(--gold) / var(--tw-text-opacity,1))}.text-ink{--tw-text-opacity:1;color:rgb(var(--ink) / var(--tw-text-opacity,1))}.text-ink-dim{--tw-text-opacity:1;color:rgb(var(--ink-dim) / var(--tw-text-opacity,1))}.text-ink-faint{--tw-text-opacity:1;color:rgb(var(--ink-faint) / var(--tw-text-opacity,1))}.text-manager{--tw-text-opacity:1;color:rgb(var(--role-manager) / var(--tw-text-opacity,1))}.text-ok{--tw-text-opacity:1;color:rgb(var(--ok) / var(--tw-text-opacity,1))}.text-warn{--tw-text-opacity:1;color:rgb(var(--warn) / var(--tw-text-opacity,1))}.text-white{--tw-text-opacity:1;color:rgb(255 255 255/var(--tw-text-opacity,1))}.underline{text-decoration-line:underline}.line-through{text-decoration-line:line-through}.decoration-blue\/35{-webkit-text-decoration-color:rgb(var(--blue) / .35);text-decoration-color:rgb(var(--blue) / .35)}.decoration-line{-webkit-text-decoration-color:rgb(var(--line) / 1);text-decoration-color:rgb(var(--line) / 1)}.underline-offset-2{text-underline-offset:2px}.underline-offset-4{text-underline-offset:4px}.accent-blue{accent-color:rgb(var(--blue) / 1)}.opacity-0{opacity:0}.opacity-100{opacity:1}.opacity-60{opacity:.6}.opacity-70{opacity:.7}.shadow{--tw-shadow:0 1px 3px 0 #0000001a, 0 1px 2px -1px #0000001a;--tw-shadow-colored:0 1px 3px 0 var(--tw-shadow-color), 0 1px 2px -1px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow,0 0 #0000), var(--tw-ring-shadow,0 0 #0000), var(--tw-shadow)}.shadow-2xl{--tw-shadow:0 25px 50px -12px #00000040;--tw-shadow-colored:0 25px 50px -12px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow,0 0 #0000), var(--tw-ring-shadow,0 0 #0000), var(--tw-shadow)}.shadow-\[0_10px_24px_-20px_rgb\(0_0_0\/0\.2\)\]{--tw-shadow:0 10px 24px -20px #0003;--tw-shadow-colored:0 10px 24px -20px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow,0 0 #0000), var(--tw-ring-shadow,0 0 #0000), var(--tw-shadow)}.shadow-glow{--tw-shadow:0 16px 44px #00000057;--tw-shadow-colored:0 16px 44px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow,0 0 #0000), var(--tw-ring-shadow,0 0 #0000), var(--tw-shadow)}.shadow-lg{--tw-shadow:0 10px 15px -3px #0000001a, 0 4px 6px -4px #0000001a;--tw-shadow-colored:0 10px 15px -3px var(--tw-shadow-color), 0 4px 6px -4px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow,0 0 #0000), var(--tw-ring-shadow,0 0 #0000), var(--tw-shadow)}.shadow-sm{--tw-shadow:0 1px 2px 0 #0000000d;--tw-shadow-colored:0 1px 2px 0 var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow,0 0 #0000), var(--tw-ring-shadow,0 0 #0000), var(--tw-shadow)}.shadow-xl{--tw-shadow:0 20px 25px -5px #0000001a, 0 8px 10px -6px #0000001a;--tw-shadow-colored:0 20px 25px -5px var(--tw-shadow-color), 0 8px 10px -6px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow,0 0 #0000), var(--tw-ring-shadow,0 0 #0000), var(--tw-shadow)}.outline-none{outline-offset:2px;outline:2px solid #0000}.ring-1{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow,0 0 #0000)}.ring-2{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow,0 0 #0000)}.ring-4{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(4px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow,0 0 #0000)}.ring-bg{--tw-ring-opacity:1;--tw-ring-color:rgb(var(--bg) / var(--tw-ring-opacity,1))}.ring-err\/30{--tw-ring-color:rgb(var(--err) / .3)}.ring-line\/35{--tw-ring-color:rgb(var(--line) / .35)}.ring-manager\/60{--tw-ring-color:rgb(var(--role-manager) / .6)}.ring-ok\/30{--tw-ring-color:rgb(var(--ok) / .3)}.ring-offset-1{--tw-ring-offset-width:1px}.ring-offset-panel{--tw-ring-offset-color:rgb(var(--panel) / 1)}.blur{--tw-blur:blur(8px);filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.backdrop-blur{--tw-backdrop-blur:blur(8px);-webkit-backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia);backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia)}.backdrop-blur-sm{--tw-backdrop-blur:blur(4px);-webkit-backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia);backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia)}.transition{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,-webkit-backdrop-filter,backdrop-filter;transition-duration:.15s;transition-timing-function:cubic-bezier(.4,0,.2,1)}.transition-\[width\,transform\,visibility\]{transition-property:width,transform,visibility;transition-duration:.15s;transition-timing-function:cubic-bezier(.4,0,.2,1)}.transition-\[width\]{transition-property:width;transition-duration:.15s;transition-timing-function:cubic-bezier(.4,0,.2,1)}.transition-all{transition-property:all;transition-duration:.15s;transition-timing-function:cubic-bezier(.4,0,.2,1)}.transition-colors{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-duration:.15s;transition-timing-function:cubic-bezier(.4,0,.2,1)}.transition-opacity{transition-property:opacity;transition-duration:.15s;transition-timing-function:cubic-bezier(.4,0,.2,1)}.transition-shadow{transition-property:box-shadow;transition-duration:.15s;transition-timing-function:cubic-bezier(.4,0,.2,1)}.transition-transform{transition-property:transform;transition-duration:.15s;transition-timing-function:cubic-bezier(.4,0,.2,1)}.duration-150{transition-duration:.15s}.duration-200{transition-duration:.2s}.duration-500{transition-duration:.5s}.duration-\[250ms\]{transition-duration:.25s}.duration-panel{transition-duration:.22s}.ease-panel{transition-timing-function:cubic-bezier(.4,0,.2,1)}@layer reset{.integrated-workbench,.integrated-workbench *,.integrated-workbench :before,.integrated-workbench :after{box-sizing:border-box}.integrated-workbench button,.integrated-workbench input,.integrated-workbench textarea,.integrated-workbench select{font:inherit;color:inherit}.integrated-workbench button{border:0}.integrated-workbench button:not(:disabled),.integrated-workbench select:not(:disabled){cursor:pointer}.integrated-workbench button:disabled{cursor:not-allowed;opacity:.48}.integrated-workbench a{color:inherit}}@layer base,components;@layer pages{.ros-app{background:rgb(var(--bg));width:100vw;height:100dvh;overflow:hidden}.ros-topbar{z-index:40;height:var(--topbar);border-bottom:1px solid rgb(var(--border));background:rgb(var(--surface) / .96);-webkit-backdrop-filter:blur(12px);backdrop-filter:blur(12px);align-items:center;gap:11px;padding:0 18px;display:flex;position:relative}.ros-topbar--hub{padding-inline:max(20px,50vw - 620px)}.ros-topbar__divider{background:rgb(var(--border));width:1px;height:24px}.ros-topbar>strong{font-size:13px}.ros-topbar__spacer{flex:1}.ros-topbar__menu{display:none}.back-to-projects{color:rgb(var(--muted));background:0 0;align-items:center;gap:5px;font-size:12px;display:flex}.back-to-projects:hover{color:rgb(var(--text))}.workspace-project-select{align-items:center;gap:8px;min-width:230px;max-width:390px;display:flex;position:relative}.workspace-project-select select{appearance:none;text-overflow:ellipsis;background:0 0;border:0;outline:none;width:100%;padding-right:20px;font-size:13px;font-weight:640}.workspace-project-select>svg{color:rgb(var(--faint));pointer-events:none;position:absolute;right:0}.ros-workspace{height:calc(100dvh - var(--topbar));grid-template-columns:var(--sidebar) minmax(0, 1fr);display:grid}.ros-sidebar{border-right:1px solid rgb(var(--border));background:rgb(var(--surface));flex-direction:column;min-height:0;padding:12px;display:flex}.ros-sidebar__mobile-brand{display:none}.ros-sidebar__projects{min-height:40px;color:rgb(var(--muted));text-align:left;background:0 0;border-radius:10px;align-items:center;gap:8px;padding:0 11px;font-size:12px;font-weight:600;display:flex}.ros-sidebar__projects:hover{background:rgb(var(--surface-2));color:rgb(var(--text))}.ros-sidebar nav{flex:1;min-height:0;padding-top:13px;overflow-y:auto}.ros-sidebar nav section+section{margin-top:18px}.ros-sidebar nav h2{color:rgb(var(--faint));letter-spacing:.13em;text-transform:uppercase;margin:0 0 5px;padding:0 11px;font-size:9px;font-weight:710}.ros-sidebar nav button{width:100%;min-height:39px;color:rgb(var(--muted));text-align:left;background:0 0;border-radius:10px;align-items:center;gap:9px;padding:0 11px;transition:background .15s,color .15s;display:flex;position:relative}.ros-sidebar nav button:hover{background:rgb(var(--surface-2));color:rgb(var(--text))}.ros-sidebar nav button.is-active{background:rgb(var(--accent));color:rgb(var(--accent-fg));box-shadow:var(--shadow-1)}.ros-sidebar nav button span{font-size:12px;font-weight:580}.ros-sidebar nav button i{background:rgb(var(--green));width:6px;height:6px;box-shadow:0 0 0 3px rgb(var(--green) / .12);border-radius:50%;margin-left:auto}.ros-sidebar__runtime{border:1px solid rgb(var(--border));background:rgb(var(--surface-2) / .55);border-radius:12px;padding:12px}.ros-sidebar__runtime>div{align-items:center;gap:7px;display:flex}.ros-sidebar__runtime strong{font-size:11px}.ros-sidebar__runtime p{color:rgb(var(--muted));margin:5px 0 8px;font-size:10px}.ros-sidebar__runtime small{border-top:1px solid rgb(var(--border));color:rgb(var(--faint));font-family:var(--mono);padding-top:8px;font-size:8.5px;display:block}.ros-content{min-width:0;min-height:0;overflow:auto}.ros-page,.overview-page,.page{min-width:0;min-height:100%;padding:24px 28px 32px}.ros-page-header{justify-content:space-between;align-items:flex-start;gap:24px;margin-bottom:20px;display:flex}.ros-page-header h1{letter-spacing:-.03em;margin:0 0 5px;font-size:24px;font-weight:690}.ros-page-header p{max-width:780px;color:rgb(var(--muted));margin:0;font-size:12px;line-height:1.55}.boot-state{place-content:center;width:100%;height:100%;display:grid}.mobile-scrim{display:none}.project-canvas{height:calc(100dvh - var(--topbar));overflow-y:auto}.project-hub{max-width:1240px;margin:0 auto;padding:48px 24px 72px}.project-hub__hero{justify-content:space-between;align-items:flex-start;gap:28px;margin-bottom:30px;display:flex}.project-hub__hero h1{letter-spacing:-.04em;margin:2px 0 7px;font-size:32px;font-weight:710}.project-hub__hero p{max-width:660px;color:rgb(var(--muted));margin:0;font-size:13px;line-height:1.6}.project-hub__summary{grid-template-columns:repeat(3,1fr);gap:12px;margin-bottom:34px;display:grid}.project-hub__summary>div{border:1px solid rgb(var(--border));background:rgb(var(--surface));min-height:82px;box-shadow:var(--shadow-1);border-radius:14px;grid-template-columns:38px minmax(0,1fr) auto;align-items:center;gap:10px;padding:16px;display:grid}.project-hub__summary svg{color:rgb(var(--muted))}.project-hub__summary span{color:rgb(var(--muted));font-size:11px}.project-hub__summary strong{font-size:21px;font-weight:680}.project-hub__toolbar{justify-content:space-between;align-items:center;gap:16px;margin-bottom:14px;display:flex}.project-hub__toolbar h2{margin:0;font-size:16px}.project-grid{grid-template-columns:repeat(3,minmax(0,1fr));gap:14px;display:grid}.project-card{border:1px solid rgb(var(--border));background:rgb(var(--surface));min-height:264px;color:rgb(var(--text));text-align:left;box-shadow:var(--shadow-1);border-radius:16px;flex-direction:column;padding:18px;transition:transform .18s,border-color .18s,box-shadow .18s;display:flex}.project-card:hover{border-color:rgb(var(--border-strong));box-shadow:var(--shadow-2)}.project-card--skeleton{background:rgb(var(--surface-2));animation:1.5s infinite skeleton}.project-card__top{justify-content:space-between;align-items:center;display:flex}.project-card__mark{background:rgb(var(--surface-2));width:42px;height:42px;color:rgb(var(--muted));border-radius:12px;place-items:center;display:grid}.project-card__mark.is-live{background:rgb(var(--green-bg));color:rgb(var(--green))}.project-card__copy{min-height:84px;margin-top:16px}.project-card__copy h3{margin:0;font-size:16px;font-weight:660;line-height:1.35}.project-card__copy p{color:rgb(var(--muted));-webkit-line-clamp:3;-webkit-box-orient:vertical;margin:7px 0 0;font-size:11px;line-height:1.5;display:-webkit-box;overflow:hidden}.project-card__facts{grid-template-columns:repeat(3,1fr);gap:8px;margin-top:12px;display:grid}.project-card__facts>div{background:rgb(var(--surface-2));border-radius:9px;padding:8px}.project-card__facts span{color:rgb(var(--faint));font-size:8px;display:block}.project-card__facts strong{text-overflow:ellipsis;white-space:nowrap;margin-top:2px;font-size:10px;display:block;overflow:hidden}.project-card__footer{border-top:1px solid rgb(var(--border));align-items:center;gap:10px;margin-top:auto;padding-top:13px;display:flex}.project-card__footer code{min-width:0;color:rgb(var(--faint));font-family:var(--mono);text-overflow:ellipsis;white-space:nowrap;flex:1;font-size:8px;overflow:hidden}.project-card__footer span{color:rgb(var(--blue));align-items:center;gap:4px;font-size:10px;font-weight:610;display:flex}.project-inbox-cta{border:1px solid rgb(var(--border));background:rgb(var(--surface));text-align:left;width:100%;box-shadow:var(--shadow-1);border-radius:16px;grid-template-columns:48px minmax(0,1fr) 24px;align-items:center;gap:14px;margin-top:18px;padding:18px;display:grid}.project-inbox-cta>span{background:rgb(var(--rose-bg));width:46px;height:46px;color:rgb(var(--rose));border-radius:13px;place-items:center;display:grid}.project-inbox-cta strong{font-size:13px}.project-inbox-cta p{color:rgb(var(--muted));margin:4px 0 0;font-size:11px}.project-inbox-cta>svg{color:rgb(var(--faint))}.overview-page{max-width:1280px;margin:0 auto}.overview-hero{border:1px solid rgb(var(--border));background:rgb(var(--surface));box-shadow:var(--shadow-1);border-radius:16px;grid-template-columns:minmax(0,1.4fr) minmax(360px,.8fr);gap:18px;padding:26px;display:grid}.overview-hero__badges{gap:7px;display:flex}.overview-hero__copy h1{letter-spacing:-.035em;margin:14px 0 8px;font-size:27px}.overview-hero__copy p{max-width:760px;color:rgb(var(--muted));-webkit-line-clamp:4;-webkit-box-orient:vertical;margin:0 0 14px;font-size:12px;line-height:1.6;display:-webkit-box;overflow:hidden}.overview-hero__copy>code{color:rgb(var(--faint));font-family:var(--mono);font-size:9px}.overview-hero__stats{grid-template-columns:1fr;gap:8px;display:grid}.overview-hero__stats>div{border:1px solid rgb(var(--border));background:rgb(var(--surface) / .8);border-radius:12px;grid-template-columns:100px minmax(0,1fr);align-items:center;padding:11px 13px;display:grid}.overview-hero__stats span{color:rgb(var(--muted));font-size:10px}.overview-hero__stats strong{text-overflow:ellipsis;white-space:nowrap;font-size:14px;overflow:hidden}.overview-hero__stats small{color:rgb(var(--faint));grid-column:2;font-size:8.5px}.overview-section-heading{justify-content:space-between;margin:30px 0 12px;display:flex}.overview-section-heading h2{margin:0;font-size:17px}.overview-section-heading p{color:rgb(var(--muted));margin:4px 0 0;font-size:11px}.module-grid{grid-template-columns:repeat(2,minmax(0,1fr));gap:12px;display:grid}.module-card{border:1px solid rgb(var(--border));background:rgb(var(--surface));text-align:left;min-height:132px;box-shadow:var(--shadow-1);border-radius:14px;grid-template-columns:44px minmax(0,1fr) 20px;align-items:start;gap:12px;padding:16px;transition:transform .15s,border-color .15s,box-shadow .15s;display:grid}.module-card:hover{border-color:rgb(var(--border-strong));box-shadow:var(--shadow-2);transform:translateY(-2px)}.module-card__icon{background:rgb(var(--surface-2));width:42px;height:42px;color:rgb(var(--muted));border-radius:11px;place-items:center;display:grid}.module-card__icon--blue{background:rgb(var(--blue-bg));color:rgb(var(--blue))}.module-card__icon--violet{background:rgb(var(--violet-bg));color:rgb(var(--violet))}.module-card__icon--indigo{background:rgb(var(--blue-bg));color:rgb(var(--violet))}.module-card__icon--rose{background:rgb(var(--rose-bg));color:rgb(var(--rose))}.module-card__icon--emerald{background:rgb(var(--green-bg));color:rgb(var(--green))}.module-card__icon--amber{background:rgb(var(--amber-bg));color:rgb(var(--amber))}.module-card h3{margin:2px 0 5px;font-size:13px}.module-card p{color:rgb(var(--muted));margin:0;font-size:10px;line-height:1.5}.module-card>svg{color:rgb(var(--faint));margin-top:13px}.overview-lower{grid-template-columns:1fr 1fr;gap:12px;margin-top:12px;display:grid}.overview-mission>div{color:rgb(var(--blue));text-transform:uppercase;align-items:center;gap:6px;font-size:10px;font-weight:650;display:flex}.overview-mission h3{margin:10px 0 5px;font-size:15px}.overview-mission p{color:rgb(var(--muted));margin:0 0 14px;font-size:11px;line-height:1.5}.copilot-v2{flex-direction:column;height:100%;display:flex;overflow:hidden}.copilot-v2 .ros-page-header{flex:none}.pending-question-banner{border:1px solid rgb(var(--amber) / .22);background:rgb(var(--amber-bg));color:rgb(var(--amber));border-radius:12px;flex:none;align-items:center;gap:10px;margin-bottom:12px;padding:10px 12px;display:flex}.pending-question-banner>div{flex:1}.pending-question-banner strong{font-size:11px}.pending-question-banner p{margin:2px 0 0;font-size:10px}.copilot-v2__layout{flex:1;grid-template-columns:minmax(0,1fr) 330px;gap:12px;min-width:0;min-height:0;display:grid}.copilot-v2__thread{border:1px solid rgb(var(--border));background:rgb(var(--surface));min-width:0;min-height:0;box-shadow:var(--shadow-1);border-radius:16px;flex-direction:column;display:flex;overflow:hidden}.copilot-v2__messages{flex:1;min-height:0;padding:22px 18px 12px;overflow-y:auto}.copilot-empty{text-align:center;max-width:660px;margin:9vh auto 0}.copilot-empty h2{margin:12px 0 4px;font-size:19px}.copilot-empty>p{color:rgb(var(--muted));margin:0 0 18px;font-size:11px}.copilot-empty>div{grid-template-columns:repeat(3,1fr);gap:8px;display:grid}.copilot-empty button{border:1px solid rgb(var(--border));background:rgb(var(--surface));color:rgb(var(--muted));text-align:left;border-radius:11px;padding:11px;font-size:10px;line-height:1.45}.copilot-empty button:hover{border-color:rgb(var(--blue) / .3);background:rgb(var(--blue-bg));color:rgb(var(--text))}.message{max-width:820px;margin:0 auto 18px}.message--user{background:rgb(var(--surface-2));border-radius:16px 5px 16px 16px;max-width:620px;margin-right:max(0px,50% - 410px);padding:11px 14px}.message--user>div:first-child{align-items:center;gap:7px;margin-bottom:4px;display:flex}.message--user span{font-size:10px;font-weight:650}.message time{color:rgb(var(--faint));font-family:var(--mono);font-size:8.5px}.message .markdown{font-size:12.5px}.message--argus{grid-template-columns:34px minmax(0,1fr);gap:10px;display:grid}.message--argus>div{min-width:0}.message--argus header{align-items:center;gap:7px;min-height:24px;margin-bottom:5px;display:flex}.message--argus header strong{font-size:11px}.message--stream>div{border-left:2px solid rgb(var(--blue) / .25);padding-left:12px}.phase-trail{margin:5px 0 10px;padding:0;list-style:none}.phase-trail li{color:rgb(var(--faint));font-family:var(--mono);gap:7px;padding:2px 0;font-size:9px;display:flex}.phase-trail li span{color:rgb(var(--green))}.phase-trail li.is-active{color:rgb(var(--blue))}.phase-trail li.is-active span{animation:1s infinite blink}.copilot-composer-dock{border-top:1px solid rgb(var(--border));flex:none;padding:12px 18px 10px}.copilot-composer{border:1px solid rgb(var(--border-strong));background:rgb(var(--surface));max-width:820px;box-shadow:var(--shadow-2);border-radius:14px;align-items:flex-end;gap:7px;margin:0 auto;padding:7px;display:flex}.copilot-composer textarea{resize:none;background:0 0;border:0;outline:none;flex:1;min-height:36px;max-height:150px;padding:8px 3px;font-size:12px;line-height:1.5}.composer-tool{width:35px;height:35px;color:rgb(var(--muted));background:0 0;border-radius:9px;flex:0 0 35px;place-items:center;display:grid}.composer-tool:hover{background:rgb(var(--surface-2))}.optimize-button{background:rgb(var(--violet-bg));height:35px;color:rgb(var(--violet));border-radius:9px;align-items:center;gap:5px;padding:0 10px;font-size:10px;font-weight:650;display:flex}.send-button{background:rgb(var(--accent));width:35px;height:35px;color:rgb(var(--accent-fg));border-radius:9px;flex:0 0 35px;place-items:center;display:grid}.send-button.is-stop{background:rgb(var(--red-bg));color:rgb(var(--red))}.copilot-composer-dock>small{max-width:820px;color:rgb(var(--faint));text-align:center;margin:5px auto 0;font-size:8.5px;display:block}.attachment-chips{flex-wrap:wrap;gap:6px;max-width:820px;margin:0 auto 7px;display:flex}.attachment-chips>span{border:1px solid rgb(var(--border));background:rgb(var(--surface-2));border-radius:8px;align-items:center;gap:5px;padding:5px 7px;font-size:9px;display:flex}.attachment-chips button{color:rgb(var(--faint));background:0 0;place-items:center;display:grid}.copilot-v2__aside{min-width:0;min-height:0;overflow:hidden}.copilot-trace{border:1px solid rgb(var(--border));background:rgb(var(--surface));height:100%;box-shadow:var(--shadow-1);border-radius:16px;overflow:hidden}.copilot-trace__header{border-bottom:1px solid rgb(var(--border));justify-content:space-between;align-items:center;min-height:58px;padding:12px 15px;display:flex}.copilot-trace__header>div{flex-direction:column;display:flex}.copilot-trace__header span{color:rgb(var(--faint));letter-spacing:.12em;font-size:8.5px;font-weight:700}.copilot-trace__header strong{margin-top:2px;font-size:13px}.copilot-trace__roles{max-height:calc(100% - 58px);padding:6px;overflow:auto}.copilot-trace__roles section{border-radius:9px}.copilot-trace__roles section>button{text-align:left;background:0 0;border-radius:9px;grid-template-columns:10px minmax(0,1fr) auto 14px;align-items:center;gap:7px;width:100%;min-height:42px;padding:0 9px;display:grid}.copilot-trace__roles section>button:hover,.copilot-trace__roles section.is-open>button{background:rgb(var(--surface-2))}.copilot-trace__roles strong{text-transform:capitalize;font-size:11px}.copilot-trace__roles small{color:rgb(var(--faint));font-family:var(--mono);font-size:9px}.copilot-trace__roles section.is-open>button svg{transform:rotate(180deg)}.role-orb{background:rgb(var(--faint));border-radius:50%;width:7px;height:7px}.role-orb--manager{background:rgb(var(--manager))}.role-orb--planner{background:rgb(var(--planner))}.role-orb--engineer{background:rgb(var(--engineer))}.role-orb--reviewer{background:rgb(var(--reviewer))}.copilot-trace__events{border-left:1px solid rgb(var(--border));max-height:340px;margin:0 10px 7px 14px;padding-left:9px;overflow:auto}.copilot-trace__events article{padding:6px 3px}.copilot-trace__events time{color:rgb(var(--faint));font-family:var(--mono);font-size:8px}.copilot-trace__events strong{margin:2px 0;font-size:9.5px;display:block}.copilot-trace__events code{color:rgb(var(--muted));font-family:var(--mono);-webkit-line-clamp:2;overflow-wrap:anywhere;-webkit-box-orient:vertical;font-size:8.5px;line-height:1.4;display:-webkit-box;overflow:hidden}.copilot-trace__events p{color:rgb(var(--faint));font-size:9px}.modal-backdrop{z-index:100;background:#00000052;place-items:center;padding:16px;display:grid;position:fixed;inset:0}.prompt-optimizer{overscroll-behavior:contain;border:1px solid rgb(var(--border-strong) / .8);background:rgb(var(--overlay));border-radius:16px;width:min(980px,96vw);max-height:90vh;animation:.2s cubic-bezier(.2,.8,.2,1) prompt-optimizer-enter;overflow:auto;box-shadow:0 24px 80px #0003,0 2px 10px #00000014}.prompt-optimizer>header{border-bottom:1px solid rgb(var(--border));justify-content:space-between;padding:18px 20px;display:flex}.prompt-optimizer header span{color:rgb(var(--violet));letter-spacing:.13em;font-size:9px;font-weight:700}.prompt-optimizer h2{margin:3px 0;font-size:18px}.prompt-optimizer header p{color:rgb(var(--muted));margin:0;font-size:10px}.prompt-optimizer__compare{grid-template-columns:1fr 1fr;gap:12px;padding:16px;display:grid}.prompt-optimizer__compare>div{border:1px solid rgb(var(--border));background:rgb(var(--surface));border-radius:12px;flex-direction:column;min-height:280px;display:flex;overflow:hidden}.prompt-optimizer__compare label{border-bottom:1px solid rgb(var(--border));color:rgb(var(--muted));padding:9px 12px;font-size:10px;font-weight:650}.prompt-optimizer__compare pre{font-family:var(--font);white-space:pre-wrap;flex:1;margin:0;padding:13px;font-size:11px;line-height:1.6;overflow:auto}.optimizer-thinking{color:rgb(var(--violet));align-items:center;gap:8px;margin:auto;font-size:11px;display:flex}.optimizer-changes,.optimizer-questions{border:1px solid rgb(var(--border));border-radius:11px;margin:0 16px 12px;padding:10px 12px}.optimizer-changes strong,.optimizer-questions strong{margin-bottom:6px;font-size:10px;display:block}.optimizer-changes span{color:rgb(var(--muted));align-items:center;gap:5px;font-size:9.5px;display:flex}.optimizer-changes svg{color:rgb(var(--green))}.optimizer-questions{border-color:rgb(var(--amber) / .2);background:rgb(var(--amber-bg));color:rgb(var(--amber))}.optimizer-questions p{margin:3px 0;font-size:9.5px}.prompt-optimizer>.inline-error{margin:0 16px 12px}.prompt-optimizer>footer{border-top:1px solid rgb(var(--border));justify-content:flex-end;gap:8px;padding:13px 16px;display:flex}.literature-stats{grid-template-columns:repeat(4,1fr);gap:10px;margin-bottom:12px;display:grid}.literature-stats>div{border:1px solid rgb(var(--border));background:rgb(var(--surface));box-shadow:var(--shadow-1);border-radius:13px;align-items:center;gap:10px;padding:12px;display:flex}.stat-icon{background:rgb(var(--surface-2));width:36px;height:36px;color:rgb(var(--muted));border-radius:10px;place-items:center;display:grid}.stat-icon--blue{background:rgb(var(--blue-bg));color:rgb(var(--blue))}.stat-icon--green{background:rgb(var(--green-bg));color:rgb(var(--green))}.stat-icon--amber{background:rgb(var(--amber-bg));color:rgb(var(--amber))}.stat-icon--violet{background:rgb(var(--violet-bg));color:rgb(var(--violet))}.literature-stats p{color:rgb(var(--muted));margin:0;font-size:9.5px}.literature-stats strong{color:rgb(var(--text));margin-top:2px;font-size:17px;display:block}.literature-v2__layout{grid-template-columns:220px minmax(420px,1fr) 340px;gap:12px;min-width:0;min-height:720px;display:grid}.literature-v2__sidebar{align-self:start}.library-tabs{padding:0 7px 8px}.library-tabs button{width:100%;min-height:38px;color:rgb(var(--muted));background:0 0;border-radius:9px;justify-content:space-between;align-items:center;padding:0 10px;font-size:11px;display:flex}.library-tabs button:hover{background:rgb(var(--surface-2))}.library-tabs button.is-active{background:rgb(var(--accent));color:rgb(var(--accent-fg))}.library-tabs small{font-family:var(--mono);font-size:9px}.literature-source-note{border-top:1px solid rgb(var(--border));color:rgb(var(--muted));gap:8px;padding:12px;display:flex}.literature-source-note div{min-width:0}.literature-source-note strong{font-size:9px;display:block}.literature-source-note p{font-family:var(--mono);text-overflow:ellipsis;white-space:nowrap;margin:3px 0 0;font-size:7.5px;overflow:hidden}.literature-v2__main{min-width:0}.literature-list-header{justify-content:space-between;align-items:center;min-height:58px;margin-bottom:9px;display:flex}.literature-list-header h2{margin:0;font-size:15px}.literature-list-header p{color:rgb(var(--muted));margin:3px 0 0;font-size:9.5px}.paper-grid{grid-template-columns:repeat(2,minmax(0,1fr));gap:10px;display:grid}.paper-card{border:1px solid rgb(var(--border));background:rgb(var(--surface));min-height:214px;color:rgb(var(--text));text-align:left;box-shadow:var(--shadow-1);border-radius:14px;flex-direction:column;padding:14px;transition:transform .15s,border-color .15s,box-shadow .15s;display:flex}.paper-card:hover{border-color:rgb(var(--border-strong));box-shadow:var(--shadow-2);transform:translateY(-2px)}.paper-card.is-selected{border-color:rgb(var(--blue) / .35);box-shadow:0 0 0 3px rgb(var(--blue) / .07)}.paper-card__meta{justify-content:space-between;align-items:center;gap:8px;display:flex}.paper-card__year{color:rgb(var(--faint));font-size:9px}.paper-card h3{-webkit-line-clamp:3;-webkit-box-orient:vertical;margin:11px 0 5px;font-size:13px;line-height:1.4;display:-webkit-box;overflow:hidden}.paper-card__authors{color:rgb(var(--faint));text-overflow:ellipsis;white-space:nowrap;margin:0;font-size:9px;overflow:hidden}.paper-card__summary{color:rgb(var(--muted));-webkit-line-clamp:3;-webkit-box-orient:vertical;margin:8px 0;font-size:9.5px;line-height:1.5;display:-webkit-box;overflow:hidden}.paper-card__footer{border-top:1px solid rgb(var(--border));align-items:center;gap:8px;margin-top:auto;padding-top:9px;display:flex}.paper-card__footer code{min-width:0;color:rgb(var(--faint));text-overflow:ellipsis;white-space:nowrap;flex:1;font-size:7.5px;overflow:hidden}.paper-card__footer span{color:rgb(var(--blue));font-size:9px}.source-file-grid{gap:8px;display:grid}.source-file-grid article{border:1px solid rgb(var(--border));background:rgb(var(--surface));border-radius:12px;grid-template-columns:30px minmax(0,1fr) auto;align-items:center;gap:8px;padding:11px;display:grid}.source-file-grid article>div{flex-direction:column;min-width:0;display:flex}.source-file-grid strong{font-size:10px}.source-file-grid code{color:rgb(var(--faint));text-overflow:ellipsis;white-space:nowrap;font-size:8px;overflow:hidden}.source-file-grid time{color:rgb(var(--faint));font-size:8px}.literature-v2__detail{align-content:start;gap:10px;display:grid}.paper-detail{padding-bottom:13px}.paper-detail>:not(.empty-state){margin-inline:14px}.paper-detail__top{justify-content:space-between;align-items:center;padding-top:14px;display:flex}.paper-detail__top>span{color:rgb(var(--faint));font-size:9px}.paper-detail h2{font-size:15px;line-height:1.4;margin:12px 14px 5px!important}.paper-detail__authors{color:rgb(var(--muted));font-size:9px}.paper-detail__body{border-top:1px solid rgb(var(--border));max-height:300px;padding-top:10px;overflow:auto;margin-top:12px!important}.paper-detail__body h3{margin:0 0 5px;font-size:10px}.paper-detail__body p,.paper-detail__body .markdown{color:rgb(var(--muted));font-size:9.5px;line-height:1.55}.paper-detail__source{border-top:1px solid rgb(var(--border));flex-direction:column;padding-top:9px;display:flex;margin-top:11px!important}.paper-detail__source span{color:rgb(var(--faint));font-size:8px}.paper-detail__source code{text-overflow:ellipsis;white-space:nowrap;margin-top:3px;font-size:8px;overflow:hidden}.paper-detail>.button{width:calc(100% - 28px);margin:11px 14px 0!important}.retrieval-panel>div{max-height:260px;padding:6px;overflow:auto}.retrieval-panel article{border-radius:8px;grid-template-columns:22px minmax(0,1fr) auto;align-items:center;gap:6px;padding:6px;display:grid}.retrieval-panel article:hover{background:rgb(var(--surface-2))}.retrieval-panel article>div{flex-direction:column;min-width:0;display:flex}.retrieval-panel strong,.retrieval-panel code{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.retrieval-panel code,.retrieval-panel time{color:rgb(var(--faint));font-family:var(--mono);font-size:7.5px}.literature-ask{padding-bottom:12px}.literature-ask textarea{resize:vertical;border:1px solid rgb(var(--border-strong));background:rgb(var(--surface));border-radius:9px;outline:0;width:calc(100% - 24px);margin:11px 12px 7px;padding:8px;font-size:10px;line-height:1.45}.literature-ask>.button{width:calc(100% - 24px);margin-inline:12px}.literature-ask .manager-mini-result{margin-inline:12px}.intake-steps{border:1px solid rgb(var(--border));background:rgb(var(--surface));border-radius:13px;grid-template-columns:repeat(4,1fr);margin-bottom:12px;padding:8px;display:grid}.intake-steps>div{color:rgb(var(--faint));border-radius:9px;align-items:center;gap:7px;padding:7px 10px;display:flex;position:relative}.intake-steps>div>span{background:rgb(var(--surface-2));border-radius:8px;place-items:center;width:26px;height:26px;display:grid}.intake-steps strong{font-size:10px}.intake-steps>div>svg{color:rgb(var(--faint));position:absolute;right:-7px}.intake-steps .is-active{background:rgb(var(--blue-bg));color:rgb(var(--blue))}.intake-steps .is-done{color:rgb(var(--green))}.intake-steps .is-done>span{background:rgb(var(--green-bg))}.inbox-v2__layout{grid-template-columns:220px minmax(360px,1fr) minmax(340px,.92fr);gap:12px;min-width:0;min-height:700px;display:grid}.inbox-sources{align-self:stretch}.inbox-sources>div{padding:6px}.inbox-sources>div>button{text-align:left;background:0 0;border-radius:10px;grid-template-columns:30px minmax(0,1fr);align-items:center;gap:7px;width:100%;padding:8px;display:grid}.inbox-sources>div>button:hover,.inbox-sources>div>button.is-active{background:rgb(var(--surface-2))}.inbox-item-icon{background:rgb(var(--rose-bg));width:28px;height:28px;color:rgb(var(--rose));border-radius:8px;place-items:center;display:grid}.inbox-sources button>div{flex-direction:column;min-width:0;display:flex}.inbox-sources strong,.inbox-sources small{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.inbox-sources strong{font-size:10px}.inbox-sources small{color:rgb(var(--faint));font-size:8px}.inbox-input{flex-direction:column;display:flex}.inbox-input__form{flex-direction:column;flex:1;min-height:0;padding:16px;display:flex}.inbox-input__actions{justify-content:space-between;gap:8px;margin-top:11px;display:flex}.inbox-output{grid-template-rows:minmax(280px,.85fr) minmax(400px,1.15fr);gap:12px;min-width:0;display:grid}.knowledge-grid{max-height:360px;padding:8px;overflow:auto}.knowledge-grid article{border-radius:10px;grid-template-columns:30px minmax(0,1fr);gap:8px;padding:8px;display:grid}.knowledge-grid article:hover{background:rgb(var(--surface-2))}.knowledge-grid article>span{background:rgb(var(--violet-bg));width:28px;height:28px;color:rgb(var(--violet));border-radius:8px;place-items:center;display:grid}.knowledge-grid .markdown{color:rgb(var(--muted));margin-top:3px;font-size:9px;line-height:1.45}.first-prompt{flex-direction:column;display:flex}.first-prompt>textarea{resize:none;background:rgb(var(--surface-2) / .45);min-height:200px;font-family:var(--mono);border:0;outline:0;flex:1;padding:14px;font-size:9.5px;line-height:1.6}.dispatch-mode{border-top:1px solid rgb(var(--border));grid-template-columns:1fr 1fr;gap:4px;padding:8px;display:grid}.dispatch-mode button{color:rgb(var(--muted));background:0 0;border-radius:8px;padding:7px;font-size:9.5px}.dispatch-mode button.is-active{background:rgb(var(--accent));color:rgb(var(--accent-fg))}.new-project-fields{grid-template-columns:.7fr 1.3fr;gap:7px;padding:0 8px 8px;display:grid}.first-prompt>.button{width:calc(100% - 16px);margin:0 8px 8px}.first-prompt .manager-mini-result{margin:0 8px 8px}.workspace-connector{grid-template-columns:34px minmax(0,1fr) auto;align-items:center;gap:9px;margin-bottom:12px;padding:10px 13px;display:grid}.workspace-connector>svg{color:rgb(var(--muted))}.workspace-connector>div:nth-child(2)>span{color:rgb(var(--faint));letter-spacing:.12em;font-size:8px;font-weight:700}.workspace-connector>div:nth-child(2)>div{gap:7px;margin-top:3px;display:flex}.workspace-connector input{min-width:0;font-family:var(--mono);background:0 0;border:0;outline:0;flex:1;font-size:10px}.workspace-connector__state{align-items:center;gap:7px;display:flex}.workspace-connector__state small{color:rgb(var(--faint));font-family:var(--mono);font-size:8px}.ide-v2__shell{grid-template-rows:minmax(0,1fr) 170px;grid-template-columns:230px minmax(390px,1fr) 330px;gap:10px;min-width:0;height:720px;display:grid}.ide-v2__explorer{flex-direction:column;grid-area:1/1/3;display:flex}.workspace-tree{flex:1;min-height:0;padding:5px;overflow:auto}.workspace-node>button{width:100%;min-height:28px;color:rgb(var(--muted));text-align:left;background:0 0;border-radius:6px;align-items:center;gap:4px;display:flex}.workspace-node>button:hover,.workspace-node>button.is-selected{background:rgb(var(--surface-2));color:rgb(var(--text))}.workspace-node>button.is-selected{color:rgb(var(--blue))}.workspace-node button>span:not(.node-spacer){font-family:var(--mono);text-overflow:ellipsis;white-space:nowrap;font-size:8.5px;overflow:hidden}.workspace-node button>small{color:rgb(var(--faint));margin-left:auto;font-size:7px}.node-spacer{width:13px}.source-control-button{border-top:1px solid rgb(var(--border));min-height:42px;color:rgb(var(--muted));text-align:left;background:0 0;align-items:center;gap:7px;padding:0 12px;display:flex}.source-control-button span{flex:1;font-size:10px;font-weight:600}.ide-v2__center{flex-direction:column;grid-area:1/2;min-width:0;display:flex}.editor-tabs{border-bottom:1px solid rgb(var(--border));flex:0 0 42px;height:42px;display:flex}.editor-tabs button{max-width:60%;color:rgb(var(--muted));font-family:var(--mono);background:0 0;border-bottom:2px solid #0000;align-items:center;gap:5px;padding:0 12px;font-size:8.5px;display:flex}.editor-tabs button.is-active{border-bottom-color:rgb(var(--accent));color:rgb(var(--text))}.editor-surface{background:rgb(var(--surface-2) / .35);flex:1;min-width:0;min-height:0;overflow:hidden}.workspace-code,.workspace-diff{width:100%;height:100%;font-family:var(--mono);tab-size:2;white-space:pre;margin:0;padding:16px;font-size:9px;line-height:1.62;overflow:auto}.workspace-pdf{background:#fff;border:0;width:100%;height:100%}.workspace-image{-o-object-fit:contain;object-fit:contain;max-width:100%;max-height:100%;margin:auto;padding:16px;display:block}.editor-loading{color:rgb(var(--muted));padding:20px;font-size:11px}.workspace-git{height:100%;overflow:auto}.workspace-git__summary{grid-template-columns:1fr 1fr;gap:7px;padding:9px;display:grid}.workspace-git__summary>div{border:1px solid rgb(var(--border));background:rgb(var(--surface));border-radius:9px;padding:8px}.workspace-git__summary span{color:rgb(var(--faint));font-size:8px;display:block}.workspace-git__summary strong{font-family:var(--mono);margin-top:2px;font-size:10px;display:block}.git-status-list{border-block:1px solid rgb(var(--border));color:rgb(var(--muted));font-family:var(--mono);white-space:pre-wrap;margin:0;padding:10px;font-size:8.5px}.ide-v2__assistant{flex-direction:column;grid-area:1/3/3;display:flex}.coding-context{border-bottom:1px solid rgb(var(--border));background:rgb(var(--surface-2) / .55);flex-direction:column;padding:9px 12px;display:flex}.coding-context span{color:rgb(var(--faint));font-size:8px}.coding-context code{text-overflow:ellipsis;white-space:nowrap;margin-top:3px;font-size:8.5px;overflow:hidden}.coding-response{flex:1;min-height:0;padding:12px;overflow:auto}.coding-response .markdown{font-size:10.5px}.coding-composer{border-top:1px solid rgb(var(--border));padding:9px}.coding-composer textarea{resize:vertical;border:1px solid rgb(var(--border-strong));background:rgb(var(--surface));border-radius:9px;outline:0;width:100%;padding:8px;font-size:10px;line-height:1.45}.coding-composer button{margin-top:7px}.ide-v2__terminal{color:#d6dce5;background:#0d1117;border:1px solid #1e293b;border-radius:12px;grid-area:2/2;min-width:0;min-height:0;overflow:hidden}.ide-v2__terminal>header{color:#94a3b8;border-bottom:1px solid #ffffff14;align-items:center;gap:7px;height:31px;padding:0 10px;display:flex}.ide-v2__terminal>header strong{letter-spacing:.1em;font-size:8px}.ide-v2__terminal>header span{margin-left:auto;font-size:8px}.ide-v2__terminal>div{height:calc(100% - 31px);padding:6px 10px;overflow:auto}.ide-v2__terminal article{font-family:var(--mono);grid-template-columns:52px 52px 10px minmax(0,1fr);gap:5px;padding:2px 0;font-size:8px;line-height:1.4;display:grid}.ide-v2__terminal time{color:#64748b}.terminal-role{font-weight:500}.terminal-role--manager{color:rgb(var(--role-manager))}.terminal-role--planner{color:rgb(var(--role-planner))}.terminal-role--engineer{color:rgb(var(--role-engineer))}.terminal-role--reviewer{color:rgb(var(--role-reviewer))}.ide-v2__terminal article>span{color:#4ade80}.ide-v2__terminal code{overflow-wrap:anywhere;white-space:pre-wrap}.ide-v2__terminal p{color:#64748b;font-family:var(--mono);font-size:9px}.paper-v2__shell{grid-template-columns:230px minmax(420px,1fr) 350px;gap:12px;min-width:0;height:760px;display:grid}.paper-v2__files{flex-direction:column;display:flex}.paper-v2__files>nav{border-bottom:1px solid rgb(var(--border));padding:6px;display:flex}.paper-v2__files>nav button{color:rgb(var(--muted));background:0 0;border-radius:8px;flex-direction:column;flex:1;align-items:center;gap:3px;padding:6px 3px;font-size:8px;display:flex}.paper-v2__files>nav button.is-active{background:rgb(var(--accent));color:rgb(var(--accent-fg))}.paper-v2__files nav small{font-family:var(--mono)}.paper-file-list{flex:1;min-height:0;padding:5px;overflow:auto}.paper-file-list>button{width:100%;color:rgb(var(--muted));text-align:left;background:0 0;border-radius:9px;grid-template-columns:20px minmax(0,1fr) auto;align-items:center;gap:6px;padding:8px;display:grid}.paper-file-list>button:hover,.paper-file-list>button.is-active{background:rgb(var(--surface-2))}.paper-file-list>button.is-active{color:rgb(var(--blue))}.paper-file-list button>div{flex-direction:column;min-width:0;display:flex}.paper-file-list strong,.paper-file-list code{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.paper-file-list strong{font-size:9.5px}.paper-file-list code,.paper-file-list small{color:rgb(var(--faint));font-size:7.5px}.paper-watch-root{border-top:1px solid rgb(var(--border));padding:9px 11px}.paper-watch-root span{color:rgb(var(--faint));font-size:8px;display:block}.paper-watch-root code{text-overflow:ellipsis;white-space:nowrap;margin-top:3px;font-size:7.5px;display:block;overflow:hidden}.paper-v2__editor{flex-direction:column;display:flex}.paper-v2__editor>header{min-height:49px;padding:8px 12px}.paper-v2__editor>header>div{flex-direction:column;min-width:0;display:flex}.paper-v2__editor>header strong{font-size:11px}.paper-v2__editor>header code{color:rgb(var(--faint));text-overflow:ellipsis;white-space:nowrap;font-size:8px;overflow:hidden}.paper-v2__editor>header>span{color:rgb(var(--faint));font-size:8px}.paper-v2__preview{flex:1;min-height:0;overflow:hidden}.paper-markdown-preview{height:100%;padding:24px 30px 50px;overflow:auto}.paper-markdown-preview .markdown{font-size:12.5px}.paper-source-preview{background:rgb(var(--surface-2) / .35);width:100%;height:100%;font-family:var(--mono);white-space:pre-wrap;margin:0;padding:18px;font-size:9.5px;line-height:1.65;overflow:auto}.paper-live-pdf{background:#fff;border:0;width:100%;height:100%}.paper-live-image{-o-object-fit:contain;object-fit:contain;max-width:100%;max-height:100%;margin:auto;padding:18px;display:block}.paper-v2__editor>footer{border-top:1px solid rgb(var(--border));height:30px;color:rgb(var(--faint));font-family:var(--mono);justify-content:space-between;align-items:center;padding:0 11px;font-size:8px;display:flex}.paper-v2__assistant{flex-direction:column;display:flex}.paper-context{border-bottom:1px solid rgb(var(--border));background:rgb(var(--surface-2) / .5);flex-direction:column;padding:9px 12px;display:flex}.paper-context span{color:rgb(var(--faint));font-size:8px}.paper-context code{text-overflow:ellipsis;white-space:nowrap;margin-top:3px;font-size:8px;overflow:hidden}.paper-quick-actions{grid-template-columns:repeat(3,1fr);gap:5px;padding:9px;display:grid}.paper-quick-actions button{border:1px solid rgb(var(--border));background:rgb(var(--surface));color:rgb(var(--muted));border-radius:8px;padding:6px;font-size:8px}.paper-quick-actions button:hover{border-color:rgb(var(--blue) / .3);color:rgb(var(--blue))}.paper-ai-output{border-top:1px solid rgb(var(--border));flex:1;min-height:0;padding:12px;overflow:auto}.paper-ai-output .markdown{font-size:10.5px}.paper-ai-composer{border-top:1px solid rgb(var(--border));padding:9px}.paper-ai-composer textarea{resize:vertical;border:1px solid rgb(var(--border-strong));background:rgb(var(--surface));border-radius:9px;outline:0;width:100%;padding:8px;font-size:10px;line-height:1.45}.paper-ai-composer button{margin-top:7px}.review-mode-tabs{grid-template-columns:1fr 1fr;gap:10px;margin-bottom:12px;display:grid}.review-mode-tabs>button{border:1px solid rgb(var(--border));background:rgb(var(--surface));min-height:72px;color:rgb(var(--muted));text-align:left;box-shadow:var(--shadow-1);border-radius:14px;grid-template-columns:38px minmax(0,1fr) auto;align-items:center;gap:10px;padding:12px 15px;display:grid}.review-mode-tabs>button.is-active{border-color:rgb(var(--blue) / .3);background:rgb(var(--blue-bg) / .45);color:rgb(var(--text));box-shadow:0 0 0 3px rgb(var(--blue) / .06)}.review-mode-tabs>button>svg{color:rgb(var(--blue))}.review-mode-tabs button>div{flex-direction:column;display:flex}.review-mode-tabs strong{font-size:12px}.review-mode-tabs small{color:rgb(var(--muted));margin-top:3px;font-size:9px}.process-review-layout{grid-template-rows:minmax(580px,auto) auto;grid-template-columns:260px minmax(400px,1fr) 330px;gap:12px;display:grid}.review-rounds>div{max-height:650px;padding:5px;overflow:auto}.review-rounds>div>button{text-align:left;background:0 0;border-radius:9px;grid-template-columns:30px minmax(0,1fr);gap:7px;width:100%;padding:8px;display:grid}.review-rounds>div>button:hover,.review-rounds>div>button.is-active{background:rgb(var(--surface-2))}.review-state{background:rgb(var(--surface-2));border-radius:8px;place-items:center;width:28px;height:28px;display:grid}.review-state--danger{background:rgb(var(--red-bg));color:rgb(var(--red))}.review-state--success{background:rgb(var(--green-bg));color:rgb(var(--green))}.review-state--warn{background:rgb(var(--amber-bg));color:rgb(var(--amber))}.review-rounds button>div{flex-direction:column;min-width:0;display:flex}.review-rounds small{color:rgb(var(--faint));margin-top:2px;font-size:8px}.process-report{flex-direction:column;display:flex}.process-report>article{padding:18px;overflow:auto}.process-report__meta{border-bottom:1px solid rgb(var(--border));color:rgb(var(--faint));justify-content:space-between;margin-bottom:14px;padding-bottom:9px;font-size:9px;display:flex}.process-report .markdown{font-size:11.5px}.review-live{overflow:auto}.process-verdict-card{border:1px solid rgb(var(--border));background:rgb(var(--surface));border-radius:14px;grid-column:1/-1;align-items:flex-start;gap:11px;padding:14px;display:flex}.process-verdict-card__icon{background:rgb(var(--surface-2));border-radius:10px;flex:0 0 38px;place-items:center;width:38px;height:38px;display:grid}.process-verdict-card__icon--danger{background:rgb(var(--red-bg));color:rgb(var(--red))}.process-verdict-card__icon--success{background:rgb(var(--green-bg));color:rgb(var(--green))}.process-verdict-card span{color:rgb(var(--faint));font-size:8px}.process-verdict-card strong{margin-top:2px;font-size:13px;display:block}.process-verdict-card p{color:rgb(var(--muted));margin:4px 0 0;font-size:10px}.final-review-layout{grid-template-columns:250px minmax(420px,1fr) 340px;gap:12px;min-height:680px;display:grid}.final-review-files>div{padding:5px}.final-review-files>div>button{text-align:left;background:0 0;border-radius:9px;grid-template-columns:24px minmax(0,1fr);gap:7px;width:100%;padding:8px;display:grid}.final-review-files>div>button:hover,.final-review-files>div>button.is-active{background:rgb(var(--surface-2))}.final-review-files button>div{flex-direction:column;display:flex}.final-review-files strong{font-size:9.5px}.final-review-files small{color:rgb(var(--faint));font-size:8px}.final-review-report{flex-direction:column;display:flex}.final-review-report>article{padding:20px;overflow:auto}.final-review-report .markdown{font-size:11.5px}.final-review-form>div{padding:14px}.final-review-form .field+.field{margin-top:11px}.final-review-warning{border:1px solid rgb(var(--amber) / .2);background:rgb(var(--amber-bg));color:rgb(var(--amber));border-radius:10px;gap:7px;margin:11px 0;padding:9px;display:flex}.final-review-warning p{margin:0;font-size:9px;line-height:1.45}.page--experiments{max-width:1440px;margin:0 auto}.mission-hero{justify-content:space-between;align-items:flex-start;gap:24px;margin-bottom:16px;display:flex}.mission-hero__main{min-width:0;max-width:980px}.mission-hero__eyebrow{color:rgb(var(--faint));font-family:var(--mono);flex-wrap:wrap;align-items:center;gap:8px;font-size:8.5px;display:flex}.mission-hero h1{letter-spacing:-.035em;margin:10px 0 6px;font-size:26px;line-height:1.25}.mission-hero__objective{color:rgb(var(--muted));-webkit-line-clamp:3;-webkit-box-orient:vertical;font-size:11px;line-height:1.55;display:-webkit-box;overflow:hidden}.mission-hero__controls{flex-wrap:wrap;flex:none;gap:7px;display:flex}.metric-grid{grid-template-columns:repeat(6,minmax(0,1fr));gap:9px;margin-bottom:12px;display:grid}.metric-card{border:1px solid rgb(var(--border));background:rgb(var(--surface));min-width:0;box-shadow:var(--shadow-1);border-radius:13px;gap:10px;padding:13px;display:flex}.metric-card__icon{background:rgb(var(--surface-2));width:34px;height:34px;color:rgb(var(--muted));border-radius:10px;flex:0 0 34px;place-items:center;display:grid}.metric-card__copy{flex-direction:column;min-width:0;display:flex}.metric-card__copy>span{color:rgb(var(--muted));font-size:8.5px}.metric-card__copy strong{text-overflow:ellipsis;white-space:nowrap;margin:3px 0 1px;font-size:15px;overflow:hidden}.metric-card__copy small{color:rgb(var(--faint));text-overflow:ellipsis;white-space:nowrap;font-size:8px;overflow:hidden}.text-live,.text-success{color:rgb(var(--green))}.text-info{color:rgb(var(--blue))}.text-danger{color:rgb(var(--red))}.text-warn{color:rgb(var(--amber))}.experiment-workspace{grid-template-columns:240px minmax(440px,1fr) 300px;align-items:start;gap:12px;display:grid}.experiment-center,.experiment-side{gap:12px;min-width:0;display:grid}.task-list{padding:6px}.task-row{text-align:left;background:0 0;border-radius:9px;grid-template-columns:25px minmax(0,1fr);gap:6px;width:100%;padding:9px;display:grid;position:relative}.task-row:hover,.task-row.is-selected{background:rgb(var(--surface-2))}.task-row__state{z-index:1;border:1px solid rgb(var(--border-strong));background:rgb(var(--surface));width:21px;height:21px;color:rgb(var(--faint));border-radius:50%;place-items:center;display:grid;position:relative}.task-row__state--success{background:rgb(var(--green-bg));color:rgb(var(--green))}.task-row__state--live{color:rgb(var(--green))}.task-row__state--danger{background:rgb(var(--red-bg));color:rgb(var(--red))}.task-row__rail{background:rgb(var(--border));width:1px;position:absolute;top:29px;bottom:-13px;left:25px}.task-row__content{flex-direction:column;min-width:0;display:flex}.task-row__content strong{-webkit-line-clamp:2;-webkit-box-orient:vertical;font-size:10px;line-height:1.4;display:-webkit-box;overflow:hidden}.task-row__content small{color:rgb(var(--faint));font-family:var(--mono);margin-top:3px;font-size:8px}.current-task__topline{align-items:center;gap:7px;display:flex}.current-task__topline code{color:rgb(var(--faint));font-size:8px}.current-task h2{margin:10px 0 6px;font-size:16px;line-height:1.38}.current-task>p{color:rgb(var(--muted));margin:0;font-size:10.5px;line-height:1.55}.current-task__facts{grid-template-columns:1fr 1fr;gap:8px;margin-top:13px;display:grid}.current-task__facts>div{border:1px solid rgb(var(--border));background:rgb(var(--surface-2) / .5);border-radius:10px;padding:9px}.current-task__facts span{color:rgb(var(--faint));font-size:8px}.current-task__facts p{color:rgb(var(--muted));-webkit-line-clamp:3;-webkit-box-orient:vertical;margin:4px 0 0;font-size:9px;line-height:1.45;display:-webkit-box;overflow:hidden}.live-action{border-top:1px solid rgb(var(--border));background:rgb(var(--green-bg) / .55);gap:9px;margin:14px -16px -16px;padding:10px 16px;display:flex}.live-action__pulse{background:rgb(var(--green));border-radius:50%;flex:0 0 7px;width:7px;height:7px;margin-top:4px}.live-action>div{flex-direction:column;min-width:0;display:flex}.live-action span{color:rgb(var(--green));font-size:8px}.live-action strong{font-size:10px}.live-action code{color:rgb(var(--muted));-webkit-line-clamp:2;-webkit-box-orient:vertical;font-size:8px;display:-webkit-box;overflow:hidden}.role-pipeline{gap:6px;display:grid}.role-pipeline__step{flex-direction:column;align-items:center;display:flex}.role-pipeline__arrow{color:rgb(var(--faint));transform:rotate(90deg)}.role-card{border:1px solid rgb(var(--border));border-left:3px solid rgb(var(--faint));background:rgb(var(--surface-2) / .45);border-radius:11px;width:100%;padding:9px}.role-card--manager{border-left-color:rgb(var(--manager))}.role-card--planner{border-left-color:rgb(var(--planner))}.role-card--engineer{border-left-color:rgb(var(--engineer))}.role-card--reviewer{border-left-color:rgb(var(--reviewer))}.role-card.is-active{background:rgb(var(--blue-bg))}.role-card__top{grid-template-columns:27px minmax(0,1fr) auto;align-items:center;gap:7px;display:grid}.role-card__avatar{background:rgb(var(--surface));border-radius:8px;place-items:center;width:26px;height:26px;font-size:9px;font-weight:700;display:grid}.role-card__top>div{flex-direction:column;min-width:0;display:flex}.role-card__top strong{font-size:10px}.role-card__top small{color:rgb(var(--faint));font-size:8px}.role-card>p{color:rgb(var(--muted));margin:6px 0 0;font-size:9px}.role-card__recent{border-top:1px solid rgb(var(--border));color:rgb(var(--faint));text-overflow:ellipsis;white-space:nowrap;margin-top:6px;padding-top:5px;font-size:8px;overflow:hidden}.diagnosis-list{gap:7px;display:grid}.diagnosis{border:1px solid rgb(var(--border));color:rgb(var(--muted));border-radius:10px;gap:7px;padding:9px;display:flex}.diagnosis strong{color:rgb(var(--text));font-size:9.5px;display:block}.diagnosis p{margin:3px 0 0;font-size:8.5px}.diagnosis--success{border-color:rgb(var(--green) / .2);background:rgb(var(--green-bg));color:rgb(var(--green))}.diagnosis--danger{border-color:rgb(var(--red) / .2);background:rgb(var(--red-bg));color:rgb(var(--red))}.diagnosis--warn{border-color:rgb(var(--amber) / .2);background:rgb(var(--amber-bg));color:rgb(var(--amber))}:root{--font:"Inter Variable", "Noto Sans SC Variable", "Geist Variable", "PingFang SC", "Microsoft YaHei", sans-serif}.ros-page:not(.copilot-v2),.overview-page,.page--experiments{font-size:15px}.ros-page:not(.copilot-v2) .ros-page-header h1{font-size:27px}.ros-page:not(.copilot-v2) .ros-page-header p{font-size:13.5px;line-height:1.65}.copilot-v2 .ros-page-header h1{font-size:24px}.copilot-v2 .ros-page-header p{font-size:12px}.ros-page:not(.copilot-v2) .ros-card>header h2,.overview-page .panel__title{font-size:14px}.ros-page:not(.copilot-v2) .ros-card>header span{font-size:9.5px}.project-hub__hero p,.overview-hero__copy p{font-size:13px}.module-card{min-height:148px;padding:19px}.module-card h3{font-size:14px}.module-card p{font-size:11.5px;line-height:1.6}.copilot-v2__layout{grid-template-columns:minmax(0,1fr) 380px}.copilot-trace-v2{flex-direction:column;display:flex}.team-pipeline{flex:none;gap:0;padding:10px 12px;display:grid}.team-pipeline>div{color:rgb(var(--muted));border-radius:9px;grid-template-columns:10px 72px minmax(0,1fr);align-items:center;gap:7px;padding:7px 8px;display:grid;position:relative}.team-pipeline>div.is-active{background:rgb(var(--blue-bg));color:rgb(var(--text))}.team-pipeline>div.is-done{color:rgb(var(--text))}.team-pipeline strong{text-transform:capitalize;font-size:10px}.team-pipeline small{text-overflow:ellipsis;white-space:nowrap;font-size:8.5px;overflow:hidden}.team-pipeline b{display:none}.current-operation{border-block:1px solid rgb(var(--border));background:rgb(var(--green-bg) / .55);flex:none;grid-template-columns:32px minmax(0,1fr);gap:8px;padding:11px 14px;display:grid}.current-operation>span{background:rgb(var(--green-bg));width:30px;height:30px;color:rgb(var(--green));border-radius:9px;place-items:center;display:grid}.current-operation>div{flex-direction:column;min-width:0;display:flex}.current-operation small{color:rgb(var(--green));font-size:8.5px}.current-operation strong{margin:2px 0;font-size:10.5px}.current-operation code{color:rgb(var(--muted));text-overflow:ellipsis;white-space:nowrap;font-size:8.5px;overflow:hidden}.activity-filters{border-bottom:1px solid rgb(var(--border));color:rgb(var(--faint));flex:none;align-items:center;gap:4px;padding:8px 10px;display:flex}.activity-filters button{color:rgb(var(--muted));background:0 0;border-radius:7px;padding:5px 8px;font-size:9px}.activity-filters button.is-active{background:rgb(var(--accent));color:rgb(var(--accent-fg))}.visual-activity-timeline{flex:1;min-height:0;padding:6px;overflow:auto}.visual-activity-timeline>button{text-align:left;background:0 0;border-radius:9px;grid-template-columns:29px minmax(0,1fr);gap:7px;width:100%;padding:7px;display:grid}.visual-activity-timeline>button:hover,.visual-activity-timeline>button.is-open{background:rgb(var(--surface-2))}.activity-icon{background:rgb(var(--surface-2));width:27px;height:27px;color:rgb(var(--muted));border-radius:8px;place-items:center;display:grid}.activity-icon--manager{background:rgb(var(--blue-bg));color:rgb(var(--manager))}.activity-icon--planner{background:rgb(var(--violet-bg));color:rgb(var(--planner))}.activity-icon--engineer{background:rgb(var(--green-bg));color:rgb(var(--engineer))}.activity-icon--reviewer{background:rgb(var(--amber-bg));color:rgb(var(--reviewer))}.visual-activity-timeline button>div{min-width:0}.visual-activity-timeline button>div>div{align-items:center;gap:6px;display:flex}.visual-activity-timeline strong{text-overflow:ellipsis;white-space:nowrap;font-size:9.5px;overflow:hidden}.visual-activity-timeline time{color:rgb(var(--faint));font-family:var(--mono);margin-left:auto;font-size:7.5px}.visual-activity-timeline p{color:rgb(var(--muted));font-family:var(--mono);-webkit-line-clamp:2;overflow-wrap:anywhere;-webkit-box-orient:vertical;margin:2px 0 0;font-size:8px;line-height:1.45;display:-webkit-box;overflow:hidden}.visual-activity-timeline button.is-open p{-webkit-line-clamp:8}.visual-activity-timeline button>div>code{border:1px solid rgb(var(--border));background:rgb(var(--surface));max-height:220px;color:rgb(var(--muted));white-space:pre-wrap;border-radius:7px;margin-top:6px;padding:7px;font-size:7.5px;display:block;overflow:auto}.activity-empty{color:rgb(var(--faint));text-align:center;padding:24px;font-size:10px}.literature-v2__layout{grid-template-columns:230px minmax(500px,1fr) 370px;gap:14px}.literature-stats>div{min-height:78px;padding:15px}.literature-stats p{font-size:11px}.literature-stats strong{font-size:20px}.library-tabs button{min-height:43px;font-size:12px}.search-field input{font-size:13px}.literature-list-header h2{font-size:17px}.literature-list-header p{font-size:11px}.paper-grid{gap:12px}.paper-card{min-height:242px;padding:17px}.paper-card h3{margin-top:13px;font-size:14.5px;line-height:1.48}.paper-card__authors{font-size:10.5px}.paper-card__summary{-webkit-line-clamp:4;font-size:11px;line-height:1.6}.paper-card__year{font-size:10px}.paper-card__footer code{font-size:8.5px}.paper-card__footer span{font-size:10.5px}.paper-detail h2{font-size:17px}.paper-detail__authors{font-size:10.5px}.paper-detail__body h3{font-size:11.5px}.paper-detail__body p,.paper-detail__body .markdown{font-size:11px;line-height:1.65}.paper-detail__source code{font-size:9px}.retrieval-panel strong{font-size:9.5px}.retrieval-panel code,.retrieval-panel time{font-size:8px}.inbox-v2__layout{grid-template-columns:230px minmax(430px,1.08fr) minmax(380px,.92fr);gap:14px}.inbox-input__form{padding:18px}.inbox-input .field>span{font-size:12px}.inbox-input textarea{font-size:13px;line-height:1.65}.inbox-upload-types{border:1px dashed rgb(var(--border-strong));background:rgb(var(--surface-2) / .45);border-radius:11px;grid-template-columns:repeat(3,auto) minmax(0,1fr);align-items:center;gap:7px;margin-top:10px;padding:9px 11px;display:grid}.inbox-upload-types>span{background:rgb(var(--surface));color:rgb(var(--muted));border-radius:7px;align-items:center;gap:4px;padding:5px 7px;font-size:9px;display:flex}.inbox-upload-types p{color:rgb(var(--faint));margin:0;font-size:9px;line-height:1.4}.inbox-attachment-list{gap:6px;margin-top:9px;display:grid}.inbox-attachment-list>span{border:1px solid rgb(var(--border));background:rgb(var(--surface));color:rgb(var(--violet));border-radius:9px;grid-template-columns:24px minmax(0,1fr) 24px;align-items:center;gap:7px;padding:7px 9px;display:grid}.inbox-attachment-list>span>div{flex-direction:column;min-width:0;display:flex}.inbox-attachment-list strong{color:rgb(var(--text));text-overflow:ellipsis;white-space:nowrap;font-size:10px;overflow:hidden}.inbox-attachment-list small{color:rgb(var(--faint));font-size:8px}.inbox-attachment-list button{color:rgb(var(--faint));background:0 0;place-items:center;display:grid}.knowledge-grid strong{font-size:11.5px}.knowledge-grid .markdown{font-size:10.5px;line-height:1.55}.first-prompt>textarea{font-size:10.5px}.ide-v3{--vscode-bg:var(--surface);--vscode-side:var(--panel);--vscode-panel:var(--bg);--vscode-line:var(--line);--vscode-text:var(--ink);--vscode-muted:var(--ink-faint);--vscode-blue:var(--blue);--vscode-hover:var(--conversation-user);--vscode-selected:var(--conversation-argus)}.ide-v3 :is(.vscode-shell,.vscode-sidebar,.vscode-editor,.vscode-activitybar,.vscode-terminal,.vscode-code,.vscode-statusbar,.workspace-node>button){transition:background-color .16s,color .16s,border-color .16s}.ide-v3 .workspace-connector{font-size:13px}.vscode-shell{border:1px solid rgb(var(--vscode-line));background:rgb(var(--vscode-bg));min-width:0;height:760px;color:rgb(var(--vscode-text));box-shadow:var(--shadow-2);border-radius:12px;grid-template-rows:minmax(0,1fr) 190px 22px;grid-template-columns:44px 245px minmax(480px,1fr) 330px;display:grid;overflow:hidden}.vscode-activitybar{background:rgb(var(--vscode-panel));flex-direction:column;grid-area:1/1/3;align-items:center;gap:3px;padding-top:5px;display:flex}.vscode-activitybar button{width:44px;height:44px;color:rgb(var(--vscode-muted));background:0 0;border-left:2px solid #0000;place-items:center;display:grid;position:relative}.vscode-activitybar button:hover,.vscode-activitybar button.is-active{color:rgb(var(--vscode-blue));background:rgb(var(--vscode-selected))}.vscode-activitybar button.is-active{border-left-color:rgb(var(--vscode-blue))}.vscode-activitybar i{background:rgb(var(--blue-deep));color:#fff;text-align:center;border-radius:999px;min-width:16px;height:16px;font-size:8px;font-style:normal;line-height:16px;position:absolute;bottom:3px;right:3px}.vscode-sidebar{border-right:1px solid rgb(var(--vscode-line));background:rgb(var(--vscode-side));flex-direction:column;grid-area:1/2/3;min-width:0;display:flex}.vscode-sidebar>header{justify-content:space-between;align-items:center;height:36px;padding:0 10px 0 14px;display:flex}.vscode-sidebar>header span{letter-spacing:.08em;font-size:9px}.vscode-sidebar>header button{color:rgb(var(--vscode-muted));background:0 0;place-items:center;display:grid}.vscode-root{background:rgb(var(--vscode-panel));text-transform:uppercase;align-items:center;gap:4px;height:25px;padding:0 7px;font-size:9px;display:flex}.vscode-sidebar .workspace-tree{background:rgb(var(--vscode-side))}.vscode-sidebar .workspace-node>button{color:rgb(var(--vscode-text))}.vscode-sidebar .workspace-node>button:hover{background:rgb(var(--vscode-hover))}.vscode-sidebar .workspace-node>button.is-selected{background:rgb(var(--vscode-selected));color:rgb(var(--vscode-blue));box-shadow:inset 2px 0 rgb(var(--vscode-blue))}.vscode-sidebar .workspace-node button>span:not(.node-spacer){font-size:11px}.vscode-search{padding:10px}.vscode-search label{border:1px solid rgb(var(--vscode-line));background:rgb(var(--vscode-bg));align-items:center;gap:6px;padding:5px 7px;display:flex}.vscode-search input{width:100%;min-width:0;color:rgb(var(--vscode-text));background:0 0;border:0;outline:0;font-size:9px}.vscode-search p{color:rgb(var(--vscode-muted));font-size:9px;line-height:1.5}.vscode-changes{padding:4px;overflow:auto}.vscode-changes button{width:100%;color:rgb(var(--vscode-text));text-align:left;background:0 0;border-radius:3px;grid-template-columns:22px minmax(0,1fr);gap:4px;padding:5px;display:grid}.vscode-changes button:hover{background:rgb(var(--vscode-hover))}.vscode-changes b{color:rgb(var(--role-engineer));font-size:9px}.vscode-changes span{text-overflow:ellipsis;white-space:nowrap;font-size:9px;overflow:hidden}.vscode-editor{background:rgb(var(--vscode-bg));flex-direction:column;grid-area:1/3;min-width:0;display:flex}.vscode-tabs{background:rgb(var(--vscode-panel));flex:0 0 36px;height:36px;display:flex}.vscode-tabs button{border-top:1px solid rgb(var(--vscode-blue));background:rgb(var(--vscode-bg));min-width:180px;max-width:60%;color:rgb(var(--vscode-text));align-items:center;gap:6px;padding:0 10px;font-size:9px;display:flex}.vscode-tabs button>span{color:rgb(var(--vscode-muted));margin-left:auto}.vscode-breadcrumbs{border-bottom:1px solid rgb(var(--vscode-line));height:28px;color:rgb(var(--vscode-muted));flex:0 0 28px;align-items:center;padding:0 11px;font-size:8.5px;display:flex;overflow:hidden}.vscode-breadcrumbs span{white-space:nowrap;align-items:center;display:flex}.vscode-editor-surface{flex:1;min-height:0;overflow:hidden}.vscode-editor-surface .empty-state{color:rgb(var(--vscode-text))}.vscode-editor-surface .empty-state__icon{border-color:rgb(var(--vscode-line));background:rgb(var(--vscode-side))}.vscode-code{background:rgb(var(--vscode-bg));height:100%;font-family:var(--mono);grid-template-columns:48px minmax(0,1fr);font-size:12px;line-height:1.7;display:grid;overflow:auto}.vscode-line-numbers{background:rgb(var(--vscode-bg));color:rgb(var(--vscode-muted));-webkit-user-select:none;user-select:none;flex-direction:column;align-items:flex-end;padding:12px 9px;display:flex;position:sticky;left:0}.vscode-line-numbers span{flex:none;height:1.7em}.vscode-code pre{min-width:max-content;color:rgb(var(--vscode-text));tab-size:2;white-space:pre;margin:0;padding:12px 18px 60px 8px}.vscode-editor-surface .workspace-pdf,.vscode-editor-surface .workspace-image{background:rgb(var(--vscode-bg))}.vscode-source-control{border-left:1px solid rgb(var(--vscode-line));background:rgb(var(--vscode-side));flex-direction:column;grid-area:1/4;min-width:0;display:flex}.vscode-source-control>header{border-bottom:1px solid rgb(var(--vscode-line));justify-content:space-between;align-items:center;height:49px;padding:0 10px;display:flex}.vscode-source-control>header>div{flex-direction:column;min-width:0;display:flex}.vscode-source-control header span{color:rgb(var(--vscode-muted));letter-spacing:.08em;font-size:8px}.vscode-source-control header strong{margin-top:2px;font-size:10px}.vscode-sc-tabs{border-bottom:1px solid rgb(var(--vscode-line));height:31px;display:flex}.vscode-sc-tabs button{color:rgb(var(--vscode-muted));background:0 0;border-bottom:1px solid #0000;flex:1;font-size:9px}.vscode-sc-tabs button.is-active{border-bottom-color:rgb(var(--vscode-blue));color:rgb(var(--vscode-text))}.vscode-git-content{flex:1;min-height:0;overflow:auto}.vscode-status,.vscode-diff{color:rgb(var(--vscode-text));font-family:var(--mono);white-space:pre-wrap;margin:0;padding:10px;font-size:8.5px;line-height:1.55}.vscode-status{border-bottom:1px solid rgb(var(--vscode-line));color:rgb(var(--vscode-text))}.vscode-commits{padding:5px}.vscode-commits article{grid-template-columns:22px minmax(0,1fr);gap:5px;padding:6px;display:grid}.vscode-commits strong{text-overflow:ellipsis;white-space:nowrap;font-size:9px;display:block;overflow:hidden}.vscode-commits small{color:rgb(var(--vscode-muted));font-size:7.5px}.vscode-terminal{border-top:1px solid rgb(var(--vscode-line));background:rgb(var(--vscode-panel));flex-direction:column;grid-area:2/3/auto/5;min-width:0;min-height:0;display:flex}.vscode-terminal>header{flex:0 0 31px;justify-content:space-between;align-items:center;height:31px;padding:0 10px;display:flex}.vscode-terminal header>div{gap:13px;display:flex}.vscode-terminal header button{height:31px;color:rgb(var(--vscode-muted));background:0 0;border-bottom:1px solid #0000;font-size:8px}.vscode-terminal header button.is-active{border-bottom-color:rgb(var(--vscode-blue));color:rgb(var(--vscode-text))}.vscode-terminal header>span{color:rgb(var(--vscode-muted));align-items:center;gap:4px;font-size:8px;display:flex}.vscode-terminal>div{flex:1;min-height:0;padding:5px 10px;overflow:auto}.vscode-terminal article{font-family:var(--mono);grid-template-columns:52px 52px 10px minmax(0,1fr);gap:5px;padding:2px 0;font-size:8.5px;line-height:1.45;display:grid}.vscode-terminal time{color:rgb(var(--vscode-muted));font-variant-numeric:tabular-nums}.vscode-terminal article>span{color:rgb(var(--role-engineer))}.vscode-terminal code{overflow-wrap:anywhere;white-space:pre-wrap}.vscode-terminal p{color:rgb(var(--vscode-muted));font-family:var(--mono);font-size:9px}.vscode-statusbar{border-top:1px solid rgb(var(--vscode-line));background:rgb(var(--vscode-panel));color:rgb(var(--vscode-muted));grid-area:3/1/auto/5;align-items:center;gap:15px;padding:0 8px;font-size:8px;display:flex}.vscode-statusbar span{align-items:center;gap:4px;display:flex}.vscode-statusbar span:nth-child(2){margin-right:auto}.paper-root-bar{grid-template-columns:30px minmax(0,1fr) auto 34px;align-items:center;gap:8px;margin-bottom:12px;padding:9px 12px;display:grid}.paper-root-bar>div{flex-direction:column;display:flex}.paper-root-bar span{color:rgb(var(--faint));letter-spacing:.11em;font-size:8.5px;font-weight:700}.paper-root-bar input{font-family:var(--mono);background:0 0;border:0;outline:0;margin-top:2px;font-size:10.5px}.paper-v3__shell{grid-template-columns:245px minmax(470px,1.25fr) minmax(390px,.9fr);gap:14px;min-width:0;height:780px;display:grid}.paper-v3__sources{flex-direction:column;display:flex}.paper-source-group{padding:7px}.paper-source-group+.paper-source-group{border-top:1px solid rgb(var(--border))}.paper-source-group h3{color:rgb(var(--muted));letter-spacing:.08em;align-items:center;gap:5px;margin:3px 5px 7px;font-size:9.5px;display:flex}.paper-source-group>button{width:100%;color:rgb(var(--muted));text-align:left;background:0 0;border-radius:9px;grid-template-columns:22px minmax(0,1fr) auto;align-items:center;gap:6px;padding:8px;display:grid}.paper-source-group>button:hover,.paper-source-group>button.is-active{background:rgb(var(--surface-2))}.paper-source-group>button.is-active{color:rgb(var(--blue))}.paper-source-group button>div{flex-direction:column;min-width:0;display:flex}.paper-source-group strong,.paper-source-group code{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.paper-source-group strong{font-size:10.5px}.paper-source-group code,.paper-source-group small{color:rgb(var(--faint));font-size:8px}.paper-source-group>p{color:rgb(var(--faint));padding:8px;font-size:10px}.paper-v3__sources>footer{border-top:1px solid rgb(var(--border));margin-top:auto;padding:9px 11px}.paper-v3__sources footer span{color:rgb(var(--faint));font-size:8px;display:block}.paper-v3__sources footer code{text-overflow:ellipsis;white-space:nowrap;margin-top:3px;font-size:8px;display:block;overflow:hidden}.paper-v3__source{flex-direction:column;display:flex}.paper-v3__source>header{min-height:50px;padding:8px 12px}.paper-v3__source header>div{flex-direction:column;min-width:0;display:flex}.paper-v3__source header strong{font-size:12px}.paper-v3__source header code{color:rgb(var(--faint));text-overflow:ellipsis;white-space:nowrap;font-size:8.5px;overflow:hidden}.paper-v3__source header>span{color:rgb(var(--faint));font-size:8.5px}.paper-v3__source>div{flex:1;min-height:0;overflow:hidden}.paper-v3__source>footer,.paper-v3__outputs>footer{border-top:1px solid rgb(var(--border));height:31px;color:rgb(var(--faint));font-family:var(--mono);justify-content:space-between;align-items:center;padding:0 11px;font-size:8.5px;display:flex}.latex-source{background:rgb(var(--surface-2) / .38);height:100%;font-family:var(--mono);grid-template-columns:48px minmax(0,1fr);font-size:10.5px;line-height:1.65;display:grid;overflow:auto}.latex-line-numbers{background:rgb(var(--surface-2));color:rgb(var(--faint));-webkit-user-select:none;user-select:none;flex-direction:column;align-items:flex-end;padding:14px 9px;display:flex;position:sticky;left:0}.latex-line-numbers span{height:17.325px}.latex-source pre{white-space:pre;min-width:max-content;margin:0;padding:14px 18px 50px 8px}.paper-v3__outputs{flex-direction:column;display:flex}.paper-v3__outputs>nav{border-bottom:1px solid rgb(var(--border));grid-template-columns:repeat(3,1fr);padding:6px;display:grid}.paper-v3__outputs>nav button{color:rgb(var(--muted));background:0 0;border-radius:8px;justify-content:center;align-items:center;gap:4px;padding:7px 4px;font-size:10px;display:flex}.paper-v3__outputs>nav button.is-active{background:rgb(var(--accent));color:rgb(var(--accent-fg))}.paper-v3__outputs nav small{font-family:var(--mono)}.paper-output-surface{flex:1;min-height:0;overflow:hidden}.paper-output-surface>embed{background:#fff;border:0;width:100%;height:calc(100% - 34px)}.pdf-switcher{border-bottom:1px solid rgb(var(--border));height:34px;padding:4px;display:flex;overflow-x:auto}.pdf-switcher button{color:rgb(var(--muted));background:0 0;border-radius:6px;flex:none;padding:0 8px;font-size:8.5px}.pdf-switcher button.is-active{background:rgb(var(--surface-2));color:rgb(var(--text))}.paper-figure-grid{grid-template-columns:1fr 1fr;align-content:start;gap:8px;height:100%;padding:9px;display:grid;overflow:auto}.paper-figure-grid figure,.paper-figure-grid article{border:1px solid rgb(var(--border));background:rgb(var(--surface));border-radius:10px;min-width:0;margin:0;padding:7px}.paper-figure-grid img{-o-object-fit:contain;object-fit:contain;background:rgb(var(--surface-2));width:100%;height:150px}.paper-figure-grid figcaption{text-overflow:ellipsis;white-space:nowrap;margin-top:5px;font-size:8.5px;overflow:hidden}.paper-figure-grid article{min-height:120px;color:rgb(var(--muted));text-align:center;flex-direction:column;justify-content:center;align-items:center;display:flex}.paper-figure-grid article strong{margin:7px 0 3px;font-size:10px}.paper-figure-grid article code{max-width:100%;color:rgb(var(--faint));text-overflow:ellipsis;white-space:nowrap;font-size:7.5px;overflow:hidden}.paper-reference-list{padding:7px}.paper-reference-list button{text-align:left;background:0 0;border-radius:8px;grid-template-columns:24px minmax(0,1fr);gap:7px;width:100%;padding:8px;display:grid}.paper-reference-list button:hover{background:rgb(var(--surface-2))}.paper-reference-list button>div{flex-direction:column;min-width:0;display:flex}.paper-reference-list strong{font-size:10px}.paper-reference-list code{color:rgb(var(--faint));text-overflow:ellipsis;white-space:nowrap;font-size:8px;overflow:hidden}.review-flow{grid-template-columns:repeat(4,1fr);gap:8px;margin-bottom:12px;display:grid}.review-flow>div{border:1px solid rgb(var(--border));background:rgb(var(--surface));min-height:68px;color:rgb(var(--muted));border-radius:12px;grid-template-columns:25px 24px minmax(0,1fr);align-items:center;gap:7px;padding:10px;display:grid;position:relative}.review-flow>div.is-active{border-color:rgb(var(--blue) / .3);background:rgb(var(--blue-bg));color:rgb(var(--blue))}.review-flow>div.is-done{color:rgb(var(--green))}.review-flow>div>span{background:rgb(var(--surface-2));border-radius:7px;place-items:center;width:23px;height:23px;font-size:9px;font-weight:700;display:grid}.review-flow>div>div{flex-direction:column;display:flex}.review-flow strong{color:rgb(var(--text));font-size:11px}.review-flow small{margin-top:2px;font-size:8.5px}.review-flow b{z-index:2;color:rgb(var(--faint));font-weight:400;position:absolute;right:-8px}.process-review-layout,.final-review-layout{min-height:650px}.review-rounds strong{font-size:10.5px}.review-rounds small{font-size:9px}.process-report .markdown,.final-review-report .markdown{font-size:12.5px;line-height:1.72}.final-review-form .field>span{font-size:11.5px}.final-review-form select,.final-review-form textarea{font-size:12px}.pdf-canvas-viewer{background:#525256;flex-direction:column;height:calc(100% - 34px);display:flex;overflow:hidden}.pdf-canvas-toolbar{background:rgb(var(--surface));flex:0 0 37px;align-items:center;gap:6px;min-height:37px;padding:0 8px;display:flex}.pdf-canvas-toolbar strong{text-overflow:ellipsis;white-space:nowrap;flex:1;min-width:0;font-size:9px;overflow:hidden}.pdf-canvas-toolbar span{color:rgb(var(--muted));font-size:8.5px}.pdf-canvas-toolbar button{border:1px solid rgb(var(--border));background:rgb(var(--surface-2));min-width:27px;height:25px;color:rgb(var(--muted));border-radius:6px;padding:0 6px;font-size:8px}.pdf-canvas-scroll{text-align:center;flex:1;min-height:0;padding:14px;overflow:auto}.pdf-canvas-scroll canvas{background:#fff;max-width:none;display:inline-block;box-shadow:0 3px 18px #00000059}.pdf-canvas-viewer>.inline-error{margin:10px}.custom-project-switcher{min-width:280px;max-width:430px;position:relative}.project-switcher-trigger{text-align:left;background:0 0;border:1px solid #0000;border-radius:10px;grid-template-columns:8px minmax(0,1fr) 16px;align-items:center;gap:9px;width:100%;min-height:38px;padding:0 9px;transition:background .15s,border-color .15s;display:grid}.project-switcher-trigger:hover,.project-switcher-trigger.is-open{border-color:rgb(var(--border));background:rgb(var(--surface-2))}.project-switcher-trigger strong{text-overflow:ellipsis;white-space:nowrap;font-size:13px;overflow:hidden}.project-switcher-trigger>svg{color:rgb(var(--faint));transition:transform .15s}.project-switcher-trigger.is-open>svg{transform:rotate(180deg)}.project-switcher-popover{z-index:100;border:1px solid rgb(var(--border));background:rgb(var(--overlay));width:min(440px,100vw - 28px);box-shadow:var(--shadow-3);border-radius:14px;animation:.14s ease-out popoverIn;position:absolute;top:calc(100% + 8px);left:0;overflow:hidden}.project-switcher-popover>header{border-bottom:1px solid rgb(var(--border));flex-direction:column;padding:12px 14px;display:flex}.project-switcher-popover header span{color:rgb(var(--faint));letter-spacing:.13em;font-size:8.5px;font-weight:700}.project-switcher-popover header strong{margin-top:2px;font-size:13px}.project-switcher-popover>div{max-height:390px;padding:6px;overflow:auto}.project-switcher-popover>div>button{width:100%;color:rgb(var(--text));text-align:left;background:0 0;border-radius:10px;grid-template-columns:38px minmax(0,1fr) 18px;align-items:center;gap:9px;padding:9px;display:grid}.project-switcher-popover>div>button:hover{background:rgb(var(--surface-2))}.project-switcher-popover>div>button.is-selected{background:rgb(var(--blue-bg))}.project-option-icon{background:rgb(var(--surface-2));width:36px;height:36px;color:rgb(var(--muted));border-radius:10px;place-items:center;display:grid}.project-option-icon.is-live{background:rgb(var(--green-bg));color:rgb(var(--green))}.project-option-copy{grid-template-columns:minmax(0,1fr) auto;gap:2px 8px;min-width:0;display:grid}.project-option-copy strong{text-overflow:ellipsis;white-space:nowrap;font-size:11.5px;overflow:hidden}.project-option-copy small{color:rgb(var(--faint));font-family:var(--mono);text-overflow:ellipsis;white-space:nowrap;grid-column:1/-1;font-size:7.5px;overflow:hidden}.project-option-copy em{color:rgb(var(--muted));white-space:nowrap;grid-area:1/2;font-size:8px;font-style:normal}.project-option-status{background:rgb(var(--faint));border-radius:50%;justify-self:center;width:7px;height:7px}.project-option-status.is-live{background:rgb(var(--green));box-shadow:0 0 0 4px rgb(var(--green) / .1)}.project-switcher-popover>footer{border-top:1px solid rgb(var(--border));background:rgb(var(--surface-2) / .55);color:rgb(var(--faint));justify-content:space-between;padding:8px 14px;font-size:8.5px;display:flex}.experiment-v3{max-width:1480px;margin:0 auto}.experiment-header-actions{flex-wrap:wrap;justify-content:flex-end;gap:7px;display:flex}.experiment-progress-hero{border:1px solid rgb(var(--border));background:rgb(var(--surface));box-shadow:var(--shadow-1);border-radius:16px;grid-template-columns:minmax(0,1fr) 170px;gap:18px;padding:22px 24px 0;display:grid;overflow:hidden}.progress-hero-main{min-width:0}.progress-live-line{color:rgb(var(--muted));flex-wrap:wrap;align-items:center;gap:8px;font-size:10px;display:flex}.progress-live-line>span{border-left:1px solid rgb(var(--border));text-transform:capitalize;padding-left:8px}.progress-hero-main h2{letter-spacing:-.025em;-webkit-line-clamp:2;-webkit-box-orient:vertical;margin:12px 0 10px;font-size:21px;line-height:1.35;display:-webkit-box;overflow:hidden}.current-step-callout{border:1px solid rgb(var(--green) / .18);background:rgb(var(--green-bg) / .62);border-radius:12px;grid-template-columns:38px minmax(0,1fr);gap:9px;padding:10px 12px;display:grid}.current-step-callout>span{background:rgb(var(--green-bg));width:36px;height:36px;color:rgb(var(--green));border-radius:10px;place-items:center;display:grid}.current-step-callout>div{flex-direction:column;min-width:0;display:flex}.current-step-callout small{color:rgb(var(--green));font-size:9px;font-weight:650}.current-step-callout strong{margin:2px 0;font-size:12px}.current-step-callout code{color:rgb(var(--muted));text-overflow:ellipsis;white-space:nowrap;font-size:8.5px;overflow:hidden}.progress-number{flex-direction:column;align-self:center;align-items:flex-end;padding-right:4px;display:flex}.progress-number>span{color:rgb(var(--blue));letter-spacing:.08em;font-size:9px;font-weight:700}.progress-number strong{letter-spacing:-.06em;margin:2px 0;font-size:43px;font-weight:720}.progress-number small{color:rgb(var(--muted));font-size:9.5px}.truthful-progress{grid-column:1/-1;margin-top:3px}.truthful-progress__track{background:rgb(var(--surface-3));border-radius:999px;height:13px;position:relative;overflow:visible}.truthful-progress__track .confirmed{background:rgb(var(--blue));border-radius:999px;transition:width .5s;position:absolute;inset:0 auto 0 0}.truthful-progress__track .estimated-range{border:1px dashed rgb(var(--blue) / .65);background:rgb(var(--blue) / .1);border-radius:999px;position:absolute;inset-block:1px}.truthful-progress__track i{background:rgb(var(--accent));width:2px;height:21px;box-shadow:0 0 0 3px rgb(var(--surface));border-radius:2px;transition:left .5s;position:absolute;top:-4px}.truthful-progress__legend{color:rgb(var(--muted));flex-wrap:wrap;align-items:center;gap:12px;padding:7px 1px 12px;font-size:8.5px;display:flex}.truthful-progress__legend span{align-items:center;gap:4px;display:flex}.truthful-progress__legend span:last-child{color:rgb(var(--faint));margin-left:auto}.truthful-progress__legend b{border-radius:3px;width:8px;height:8px}.confirmed-dot{background:rgb(var(--blue))}.range-dot{border:1px dashed rgb(var(--blue));background:rgb(var(--blue) / .12)}.progress-metrics{border-top:1px solid rgb(var(--border));grid-column:1/-1;grid-template-columns:repeat(4,1fr);margin-inline:-24px;display:grid}.progress-metrics>div{border-right:1px solid rgb(var(--border));flex-direction:column;min-width:0;padding:13px 18px;display:flex}.progress-metrics>div:last-child{border-right:0}.progress-metrics span{color:rgb(var(--muted));align-items:center;gap:5px;font-size:9px;display:flex}.progress-metrics strong{text-overflow:ellipsis;white-space:nowrap;margin:5px 0 2px;font-size:16px;overflow:hidden}.progress-metrics small{color:rgb(var(--faint));-webkit-line-clamp:2;-webkit-box-orient:vertical;font-size:8.5px;line-height:1.4;display:-webkit-box;overflow:hidden}.confidence-high{color:rgb(var(--green))}.confidence-medium{color:rgb(var(--amber))}.confidence-low{color:rgb(var(--red))}.research-stage-rail{border:1px solid rgb(var(--border));background:rgb(var(--surface));border-radius:14px;grid-template-columns:repeat(7,1fr);gap:5px;margin:12px 0;padding:8px;display:grid}.research-stage-rail>div{color:rgb(var(--faint));border-radius:9px;align-items:center;gap:6px;padding:7px 9px;display:flex;position:relative}.research-stage-rail>div>span{background:rgb(var(--surface-2));border-radius:8px;flex:0 0 24px;place-items:center;width:24px;height:24px;font-size:9px;font-weight:700;display:grid}.research-stage-rail strong{font-size:9px}.research-stage-rail>div>svg{z-index:2;position:absolute;right:-6px}.research-stage-rail>div.is-done{color:rgb(var(--green))}.research-stage-rail>div.is-done>span{background:rgb(var(--green-bg))}.research-stage-rail>div.is-active{background:rgb(var(--blue-bg));color:rgb(var(--blue))}.research-stage-rail>div.is-active>span{background:rgb(var(--blue));color:#fff}.experiment-v3-grid{grid-template-columns:245px minmax(450px,1fr) 315px;align-items:start;gap:12px;display:grid}.experiment-task-route>div{max-height:720px;padding:6px;overflow:auto}.experiment-task-route>div>button{text-align:left;background:0 0;border-radius:10px;grid-template-columns:30px minmax(0,1fr);gap:7px;width:100%;padding:9px;display:grid}.experiment-task-route>div>button:hover,.experiment-task-route>div>button.is-active{background:rgb(var(--surface-2))}.task-state{border:1px solid rgb(var(--border));background:rgb(var(--surface));width:28px;height:28px;color:rgb(var(--faint));border-radius:9px;place-items:center;display:grid}.task-state--live{border-color:rgb(var(--green) / .25);background:rgb(var(--green-bg));color:rgb(var(--green))}.task-state--success{background:rgb(var(--green-bg));color:rgb(var(--green))}.task-state--danger{background:rgb(var(--red-bg));color:rgb(var(--red))}.task-state--warn{background:rgb(var(--amber-bg));color:rgb(var(--amber))}.experiment-task-route button>div{flex-direction:column;min-width:0;display:flex}.experiment-task-route strong{-webkit-line-clamp:2;-webkit-box-orient:vertical;font-size:10.5px;line-height:1.4;display:-webkit-box;overflow:hidden}.experiment-task-route small{color:rgb(var(--faint));margin-top:3px;font-size:8.5px}.experiment-v3-center,.experiment-v3-side{gap:12px;min-width:0;display:grid}.checkpoint-list{grid-template-columns:repeat(5,1fr);gap:0;padding:14px;display:grid}.checkpoint{text-align:center;flex-direction:column;align-items:center;min-width:0;display:flex;position:relative}.checkpoint>span{z-index:2;border:2px solid rgb(var(--surface));background:rgb(var(--surface-2));width:30px;height:30px;color:rgb(var(--faint));box-shadow:0 0 0 1px rgb(var(--border));border-radius:50%;place-items:center;font-size:9px;font-weight:700;display:grid;position:relative}.checkpoint>i{background:rgb(var(--border));height:2px;position:absolute;top:15px;left:calc(50% + 15px);right:calc(15px - 50%)}.checkpoint>div{margin-top:8px;padding-inline:4px}.checkpoint strong{font-size:9.5px;display:block}.checkpoint p{color:rgb(var(--muted));margin:3px 0 0;font-size:8px;line-height:1.4}.checkpoint--done>span{background:rgb(var(--green));color:#fff}.checkpoint--done>i{background:rgb(var(--green))}.checkpoint--active>span{background:rgb(var(--blue));color:#fff;animation:2s infinite livePulse}.checkpoint--blocked>span{background:rgb(var(--red-bg));color:rgb(var(--red))}.selected-task-detail{border-top:1px solid rgb(var(--border));background:rgb(var(--surface-2) / .45);padding:12px 15px}.selected-task-detail>span{color:rgb(var(--faint));font-size:8px}.selected-task-detail strong{margin-top:3px;font-size:11px;display:block}.selected-task-detail p{color:rgb(var(--muted));-webkit-line-clamp:3;-webkit-box-orient:vertical;margin:4px 0 0;font-size:9px;line-height:1.5;display:-webkit-box;overflow:hidden}.experiment-live-events{max-height:560px;overflow:auto}.experiment-team>div{padding:6px}.experiment-team article{border-radius:10px;grid-template-columns:10px minmax(0,1fr) auto;align-items:center;gap:8px;padding:9px;display:grid}.experiment-team article.is-active{background:rgb(var(--blue-bg))}.role-dot{background:rgb(var(--faint));border-radius:50%;width:8px;height:8px}.role-dot--manager{background:rgb(var(--manager))}.role-dot--planner{background:rgb(var(--planner))}.role-dot--engineer{background:rgb(var(--engineer))}.role-dot--reviewer{background:rgb(var(--reviewer))}.experiment-team article>div{min-width:0}.experiment-team strong{text-transform:capitalize;font-size:10.5px}.experiment-team p{color:rgb(var(--muted));text-overflow:ellipsis;white-space:nowrap;margin:2px 0;font-size:8.5px;overflow:hidden}.experiment-team small{color:rgb(var(--faint));font-size:8px}.estimate-note>div{padding:13px}.estimate-note p{color:rgb(var(--muted));margin:0 0 11px;font-size:9.5px;line-height:1.55}.estimate-note p strong{color:rgb(var(--text));margin-bottom:3px;display:block}.estimate-risk,.estimate-ok{border:1px solid rgb(var(--border));border-radius:10px;grid-template-columns:26px minmax(0,1fr);gap:7px;padding:9px;display:grid}.estimate-risk{border-color:rgb(var(--amber) / .22);background:rgb(var(--amber-bg));color:rgb(var(--amber))}.estimate-ok{border-color:rgb(var(--green) / .22);background:rgb(var(--green-bg));color:rgb(var(--green))}.estimate-risk span,.estimate-ok span{flex-direction:column;font-size:8.5px;display:flex}.estimate-risk strong,.estimate-ok strong{margin-bottom:2px;font-size:9.5px}.ide-context-strip{border:1px solid rgb(var(--border));background:rgb(var(--surface));border-radius:10px 10px 0 0;grid-template-columns:18px minmax(150px,240px) minmax(0,1fr) auto auto 28px;align-items:center;gap:8px;min-height:40px;margin-bottom:-1px;padding:5px 8px 5px 11px;display:grid}.ide-context-strip>svg{color:rgb(var(--muted))}.ide-context-strip select{background:0 0;border:0;outline:0;width:100%;font-size:10.5px;font-weight:620}.ide-context-strip code{color:rgb(var(--faint));text-overflow:ellipsis;white-space:nowrap;font-size:8.5px;overflow:hidden}.ide-context-strip small{color:rgb(var(--faint));font-family:var(--mono);font-size:8px}.ide-context-strip>button{background:rgb(var(--surface-2));width:27px;height:27px;color:rgb(var(--muted));border-radius:7px;place-items:center;display:grid}.ide-context-strip+.vscode-shell{border-radius:0 0 12px 12px}.repository-readiness{padding:11px}.repository-readiness h3{color:rgb(var(--vscode-text));margin:0 0 9px;font-size:11px}.repository-readiness dl{gap:5px;margin:0;display:grid}.repository-readiness dl>div{border:1px solid rgb(var(--vscode-line));background:rgb(var(--vscode-bg));border-radius:6px;grid-template-columns:110px minmax(0,1fr) 18px;align-items:center;gap:5px;padding:7px;display:grid}.repository-readiness dt{color:rgb(var(--vscode-muted));align-items:center;gap:5px;font-size:8.5px;display:flex}.repository-readiness dd{color:rgb(var(--vscode-text));font-family:var(--mono);text-overflow:ellipsis;white-space:pre-wrap;margin:0;font-size:7.8px;line-height:1.4;overflow:hidden}.repository-readiness i{border-radius:50%;place-items:center;width:17px;height:17px;font-style:normal;display:grid}.repository-readiness i.ok{background:rgb(var(--role-engineer) / .12);color:rgb(var(--role-engineer))}.repository-readiness i.missing{background:rgb(var(--role-reviewer) / .12);color:rgb(var(--role-reviewer))}.repository-readiness>p{border-top:1px solid rgb(var(--vscode-line));color:rgb(var(--vscode-muted));margin:10px 0 0;padding-top:9px;font-size:8.5px;line-height:1.5}.vscode-terminal>header>strong{color:rgb(var(--vscode-text));letter-spacing:.08em;font-size:8.5px}.paper-root-bar>div{min-width:0}.paper-root-bar select{background:0 0;border:0;outline:0;max-width:260px;margin-top:2px;font-size:10.5px;font-weight:620}.paper-root-bar code{color:rgb(var(--faint));font-family:var(--mono);text-overflow:ellipsis;white-space:nowrap;font-size:8px;overflow:hidden}.figure-loading{background:rgb(var(--surface-2));height:150px;color:rgb(var(--faint));place-items:center;font-size:9px;display:grid}.review-form-row{grid-template-columns:1fr 1fr;gap:8px;margin-top:11px;display:grid}.review-emphasis{border:1px solid rgb(var(--border));border-radius:10px;grid-template-columns:1fr 1fr;gap:5px;margin:11px 0;padding:10px;display:grid}.review-emphasis legend{color:rgb(var(--muted));padding:0 5px;font-size:10px;font-weight:620}.review-emphasis label{color:rgb(var(--muted));border-radius:7px;align-items:center;gap:5px;padding:4px 5px;font-size:8.5px;display:flex}.review-emphasis label:hover{background:rgb(var(--surface-2))}.review-emphasis input{accent-color:rgb(var(--blue))}.project-intake-start{align-items:center;gap:7px;display:flex}.project-intake-start select{border:1px solid rgb(var(--border-strong));background:rgb(var(--surface));border-radius:10px;outline:0;max-width:260px;height:42px;padding:0 9px;font-size:10px}.release-page{max-width:1280px;margin:0 auto}.release-hero{border:1px solid rgb(var(--border));background:rgb(var(--surface));border-radius:16px;grid-template-columns:58px minmax(0,1fr);align-items:center;gap:15px;padding:22px;display:grid}.release-hero>span{background:rgb(var(--surface-2));width:54px;height:54px;color:rgb(var(--text));border-radius:14px;place-items:center;display:grid}.release-hero h2{margin:3px 0 6px;font-size:21px}.release-hero p{max-width:780px;color:rgb(var(--muted));margin:0;font-size:11.5px;line-height:1.6}.release-module-grid{grid-template-columns:repeat(3,1fr);gap:12px;margin:14px 0;display:grid}.release-module{border:1px solid rgb(var(--border));background:rgb(var(--surface));min-height:290px;box-shadow:var(--shadow-1);border-radius:15px;padding:17px}.release-module>header{justify-content:space-between;align-items:center;display:flex}.release-module header>span{background:rgb(var(--surface-2));width:42px;height:42px;color:rgb(var(--muted));border-radius:11px;place-items:center;display:grid}.release-module h3{margin:16px 0 6px;font-size:15px}.release-module>p{min-height:52px;color:rgb(var(--muted));margin:0;font-size:10.5px;line-height:1.55}.release-module ul{border-top:1px solid rgb(var(--border));gap:7px;margin:13px 0 0;padding:13px 0 0;list-style:none;display:grid}.release-module li{color:rgb(var(--muted));align-items:center;gap:6px;font-size:9.5px;display:flex}.release-module li svg{color:rgb(var(--green))}.release-flow{border:1px solid rgb(var(--border));background:rgb(var(--surface));border-radius:14px;grid-template-columns:1fr 20px 1fr 20px 1fr 20px 1fr;align-items:center;padding:12px;display:grid}.release-flow>div{border-radius:10px;grid-template-columns:32px minmax(0,1fr);gap:7px;padding:9px;display:grid}.release-flow>div>svg{color:rgb(var(--blue));grid-row:1/3;align-self:center}.release-flow strong{font-size:10px}.release-flow small{color:rgb(var(--faint));font-size:8px}.release-flow>b{color:rgb(var(--faint));text-align:center;font-weight:400}.release-boundary{border:1px solid rgb(var(--amber) / .22);background:rgb(var(--amber-bg));color:rgb(var(--amber));border-radius:12px;gap:9px;margin-top:12px;padding:12px;display:flex}.release-boundary strong{font-size:10.5px}.release-boundary p{margin:3px 0 0;font-size:9px;line-height:1.5}}@layer responsive{@media (width<=1450px){.metric-grid{grid-template-columns:repeat(3,1fr)}.literature-v2__layout{grid-template-columns:210px minmax(380px,1fr) 310px}.inbox-v2__layout{grid-template-columns:200px minmax(340px,1fr) 320px}.ide-v2__shell{grid-template-columns:210px minmax(360px,1fr) 300px}.paper-v2__shell{grid-template-columns:210px minmax(380px,1fr) 320px}}.integrated-workbench{container-type:inline-size}@container (width<=1100px){.integrated-workbench .experiment-v3-grid{grid-template-columns:220px minmax(0,1fr)}.integrated-workbench .experiment-v3-side{grid-column:1/-1;grid-template-columns:1fr 1fr}.integrated-workbench .research-stage-rail{grid-template-columns:repeat(4,minmax(0,1fr));overflow-x:visible}.integrated-workbench .literature-v2__layout,.integrated-workbench .inbox-v2__layout{grid-template-columns:210px minmax(0,1fr)}.integrated-workbench .literature-v2__detail,.integrated-workbench .inbox-output{grid-column:1/-1}.integrated-workbench .vscode-shell{grid-template-rows:minmax(0,1fr) 180px 340px 22px;grid-template-columns:42px 220px minmax(0,1fr);height:820px}.integrated-workbench .vscode-source-control{border-top:1px solid rgb(var(--vscode-line));border-left:0;grid-area:3/2/auto/4;display:flex}.integrated-workbench .vscode-terminal{grid-column:3}.integrated-workbench .vscode-statusbar{grid-area:4/1/auto/4}.integrated-workbench .paper-v3__shell{grid-template-columns:220px minmax(0,1fr);height:auto}.integrated-workbench .paper-v3__sources,.integrated-workbench .paper-v3__source{min-height:720px}.integrated-workbench .paper-v3__outputs{grid-column:1/-1;min-height:720px}.integrated-workbench .process-review-layout,.integrated-workbench .final-review-layout{grid-template-columns:220px minmax(0,1fr)}.integrated-workbench .review-live,.integrated-workbench .final-review-form{grid-column:1/-1}}@container (width<=700px){.integrated-workbench .ros-page,.integrated-workbench .overview-page,.integrated-workbench .page{padding:16px 16px 28px}.integrated-workbench .ros-page-header{flex-direction:column;gap:12px}.integrated-workbench .header-badges{justify-content:flex-start;width:100%}.integrated-workbench .module-grid,.integrated-workbench .copilot-v2__layout{grid-template-columns:1fr}.integrated-workbench .copilot-v2__aside{display:none}.integrated-workbench .experiment-v3-grid,.integrated-workbench .literature-v2__layout,.integrated-workbench .inbox-v2__layout,.integrated-workbench .process-review-layout,.integrated-workbench .final-review-layout{grid-template-columns:1fr}.integrated-workbench .experiment-v3-side,.integrated-workbench .literature-v2__detail,.integrated-workbench .inbox-output,.integrated-workbench .review-live,.integrated-workbench .final-review-form{grid-column:auto}.integrated-workbench .experiment-v3-side,.integrated-workbench .inbox-output,.integrated-workbench .literature-v2__detail{grid-template-columns:1fr}.integrated-workbench .experiment-header-actions{justify-content:flex-start;width:100%}.integrated-workbench .experiment-header-actions .button{flex:96px;justify-content:center;min-width:0}.integrated-workbench .experiment-progress-hero{grid-template-columns:1fr;gap:12px;padding:18px 16px 0}.integrated-workbench .progress-number{align-items:flex-start;padding-right:0}.integrated-workbench .progress-number strong{font-size:38px}.integrated-workbench .truthful-progress__legend span:last-child{width:100%;margin-left:0}.integrated-workbench .progress-metrics{grid-template-columns:repeat(2,minmax(0,1fr));margin-inline:-16px}.integrated-workbench .progress-metrics>div:nth-child(2){border-right:0}.integrated-workbench .progress-metrics>div:nth-child(-n+2){border-bottom:1px solid rgb(var(--border))}.integrated-workbench .checkpoint-list{grid-template-columns:1fr;gap:8px}.integrated-workbench .checkpoint{text-align:left;grid-template-columns:30px minmax(0,1fr);align-items:center;gap:9px;display:grid}.integrated-workbench .checkpoint>div{margin-top:0;padding-inline:0}.integrated-workbench .checkpoint>i{display:none}.integrated-workbench .research-stage-rail,.integrated-workbench .intake-steps{grid-template-columns:repeat(2,minmax(0,1fr))}.integrated-workbench .intake-steps>div>svg,.integrated-workbench .literature-v2__sidebar{display:none}.integrated-workbench .literature-list-header{align-items:flex-start;gap:10px}.integrated-workbench .paper-grid{grid-template-columns:1fr}.integrated-workbench .paper-card{min-height:0}.integrated-workbench .literature-stats{grid-template-columns:repeat(2,minmax(0,1fr))}.integrated-workbench .ide-context-strip{grid-template-columns:18px minmax(0,1fr) auto 28px}.integrated-workbench .ide-context-strip code,.integrated-workbench .ide-context-strip small{display:none}.integrated-workbench .vscode-shell,.integrated-workbench .paper-v3__shell{flex-direction:column;height:auto;display:flex}.integrated-workbench .vscode-activitybar{flex-direction:row;height:44px}.integrated-workbench .vscode-sidebar{min-height:420px}.integrated-workbench .vscode-editor{min-height:680px}.integrated-workbench .vscode-terminal{min-height:240px}.integrated-workbench .vscode-source-control{min-height:420px}.integrated-workbench .vscode-statusbar{min-height:22px}.integrated-workbench .paper-v3__sources{min-height:480px}.integrated-workbench .paper-v3__source,.integrated-workbench .paper-v3__outputs{min-height:720px}.integrated-workbench .review-flow,.integrated-workbench .release-module-grid,.integrated-workbench .review-mode-tabs{grid-template-columns:1fr}.integrated-workbench .review-mode-tabs>button{min-width:0}.integrated-workbench .review-flow b{display:none}.integrated-workbench .release-flow{grid-template-columns:1fr;gap:5px}.integrated-workbench .release-flow>b{transform:rotate(90deg)}}@media (width<=1180px){:root{--sidebar:204px}.project-grid,.module-grid{grid-template-columns:repeat(2,minmax(0,1fr))}.overview-hero{grid-template-columns:1fr}.overview-hero__stats{grid-template-columns:repeat(3,1fr)}.overview-hero__stats>div{flex-direction:column;align-items:flex-start;display:flex}.literature-v2__layout{grid-template-columns:210px minmax(0,1fr)}.literature-v2__detail{grid-column:1/-1;grid-template-columns:1.2fr 1fr 1fr}.inbox-v2__layout{grid-template-columns:210px minmax(0,1fr)}.inbox-output{grid-column:1/-1;grid-template-rows:520px;grid-template-columns:1fr 1fr}.ide-v2__shell{grid-template-columns:210px minmax(0,1fr)}.ide-v2__assistant{grid-area:auto/1/auto/-1;min-height:480px}.ide-v2__shell{grid-template-rows:570px 170px auto;height:auto}.ide-v2__explorer{grid-row:1/3}.ide-v2__terminal{grid-column:2}.paper-v2__shell{grid-template-columns:210px minmax(0,1fr);height:auto}.paper-v2__files,.paper-v2__editor{min-height:700px}.paper-v2__assistant{grid-column:1/-1;min-height:500px}.process-review-layout{grid-template-columns:240px minmax(0,1fr)}.review-live{grid-column:1/-1;max-height:500px}.final-review-layout{grid-template-columns:230px minmax(0,1fr)}.final-review-form{grid-column:1/-1}.experiment-workspace{grid-template-columns:220px minmax(0,1fr)}.experiment-side{grid-column:1/-1;grid-template-columns:1fr 1fr}}@media (width<=900px){.ros-topbar__menu{display:inline-grid}.ros-topbar .brand-button,.back-to-projects,.ros-topbar__divider{display:none}.workspace-project-select{min-width:0;max-width:280px}.ros-workspace{grid-template-columns:1fr}.ros-sidebar{inset:var(--topbar) auto 0 0;z-index:60;width:250px;transition:transform .2s;position:fixed;transform:translate(-102%);box-shadow:18px 0 50px #00000047}.ros-sidebar.is-mobile-open{transform:translate(0)}.ros-sidebar__mobile-brand{border-bottom:1px solid rgb(var(--border));justify-content:space-between;align-items:center;margin:-12px -12px 10px;padding:11px 12px;display:flex}.mobile-scrim{inset:var(--topbar) 0 0;z-index:55;background:#0000006b;display:block;position:fixed}.ros-page,.overview-page,.page{padding:20px}.project-hub{padding:34px 20px 60px}.project-hub__hero{flex-direction:column}.project-hub__summary{grid-template-columns:1fr}.project-grid{grid-template-columns:1fr 1fr}.overview-lower,.copilot-v2__layout{grid-template-columns:1fr}.copilot-v2__aside{display:none}.literature-stats{grid-template-columns:1fr 1fr}.literature-v2__layout{grid-template-columns:1fr}.literature-v2__sidebar{display:none}.literature-v2__detail{grid-column:auto;grid-template-columns:1fr}.paper-grid,.inbox-v2__layout{grid-template-columns:1fr}.inbox-sources{min-height:260px}.inbox-input{min-height:600px}.inbox-output{grid-column:auto;grid-template-rows:auto;grid-template-columns:1fr}.knowledge-panel,.first-prompt{min-height:460px}.ide-v2__shell{grid-template-columns:200px minmax(0,1fr)}.ide-v2__assistant{grid-column:1/-1}.paper-v2__shell{grid-template-columns:200px minmax(0,1fr)}.paper-v2__assistant{grid-column:1/-1}.process-review-layout,.final-review-layout{grid-template-columns:1fr}.review-rounds{max-height:360px}.review-live,.process-verdict-card,.final-review-form{grid-column:auto}.experiment-workspace{grid-template-columns:1fr}.experiment-side{grid-column:auto;grid-template-columns:1fr}.mission-hero{flex-direction:column}}@media (width<=640px){.ros-topbar{padding-inline:10px}.ros-topbar>.badge{display:none}.workspace-project-select select{font-size:11px}.ros-page,.overview-page,.page{padding:16px}.ros-page-header{flex-direction:column;gap:8px}.ros-page-header h1{font-size:21px}.project-hub{padding-inline:16px}.project-hub__hero h1{font-size:27px}.project-grid,.module-grid{grid-template-columns:1fr}.project-hub__toolbar{flex-direction:column;align-items:stretch}.search-field{min-width:0}.overview-hero{padding:18px}.overview-hero__stats,.overview-lower{grid-template-columns:1fr}.copilot-v2{height:auto;min-height:100%}.copilot-v2__thread{min-height:720px}.copilot-empty>div{grid-template-columns:1fr}.optimize-button{justify-content:center;width:35px;padding:0;font-size:0}.message--user{margin-left:40px}.prompt-optimizer__compare{grid-template-columns:1fr}.prompt-optimizer{max-height:95vh}.literature-stats,.paper-grid{grid-template-columns:1fr}.intake-steps{grid-template-columns:1fr 1fr}.intake-steps>div>svg{display:none}.form-grid,.new-project-fields{grid-template-columns:1fr}.inbox-input__actions{flex-direction:column}.workspace-connector{grid-template-columns:28px minmax(0,1fr)}.workspace-connector__state{grid-column:2}.workspace-connector>div:nth-child(2)>div{flex-direction:column}.ide-v2__shell{flex-direction:column;height:auto;display:flex}.ide-v2__explorer{min-height:400px}.ide-v2__center{min-height:650px}.ide-v2__terminal{min-height:220px}.ide-v2__assistant{min-height:520px}.paper-v2__shell{flex-direction:column;display:flex}.paper-v2__files{min-height:440px}.paper-v2__editor{min-height:700px}.paper-v2__assistant{min-height:560px}.review-mode-tabs{grid-template-columns:1fr}.process-review-layout,.final-review-layout{flex-direction:column;display:flex}.process-report,.final-review-report{min-height:600px}.metric-grid,.current-task__facts{grid-template-columns:1fr}}@media (prefers-reduced-motion:reduce){*,:before,:after{transition-duration:.01ms!important;animation-duration:.01ms!important;animation-iteration-count:1!important}}@media (width<=1450px){.literature-v2__layout{grid-template-columns:220px minmax(440px,1fr) 340px}.inbox-v2__layout{grid-template-columns:210px minmax(390px,1fr) 350px}.vscode-shell{grid-template-columns:42px 225px minmax(420px,1fr) 300px}.paper-v3__shell{grid-template-columns:225px minmax(420px,1fr) 360px}}@media (width<=1180px){.copilot-v2__layout{grid-template-columns:minmax(0,1fr) 340px}.literature-v2__layout{grid-template-columns:220px minmax(0,1fr)}.literature-v2__detail{grid-column:1/-1;grid-template-columns:1.2fr 1fr 1fr}.inbox-v2__layout{grid-template-columns:220px minmax(0,1fr)}.inbox-output{grid-column:1/-1}.vscode-shell{grid-template-rows:minmax(0,1fr) 180px 22px;grid-template-columns:42px 220px minmax(0,1fr);height:820px}.vscode-source-control{display:none}.vscode-terminal{grid-column:3}.vscode-statusbar{grid-column:1/4}.paper-v3__shell{grid-template-columns:220px minmax(0,1fr);height:auto}.paper-v3__sources,.paper-v3__source{min-height:720px}.paper-v3__outputs{grid-column:1/-1;min-height:720px}}@media (width<=900px){.copilot-v2__layout{grid-template-columns:1fr}.copilot-v2__aside{display:none}.literature-v2__layout{grid-template-columns:1fr}.literature-v2__sidebar{display:none}.inbox-v2__layout{grid-template-columns:1fr}.inbox-output{grid-column:auto}.vscode-shell{grid-template-columns:42px 210px minmax(0,1fr)}.paper-v3__shell{grid-template-columns:210px minmax(0,1fr)}.paper-v3__outputs{grid-column:1/-1}}@media (width<=640px){.ros-page:not(.copilot-v2) .ros-page-header h1{font-size:23px}.ros-page:not(.copilot-v2) .ros-page-header p{font-size:12.5px}.vscode-shell{flex-direction:column;height:auto;display:flex}.vscode-activitybar{flex-direction:row;height:44px}.vscode-sidebar{min-height:420px}.vscode-editor{min-height:680px}.vscode-terminal{min-height:240px}.vscode-statusbar{height:22px}.paper-root-bar{grid-template-columns:25px minmax(0,1fr) auto}.paper-root-bar>.icon-button{display:none}.paper-v3__shell{flex-direction:column;display:flex}.paper-v3__sources{min-height:480px}.paper-v3__source,.paper-v3__outputs{min-height:720px}.paper-figure-grid{grid-template-columns:1fr}.review-flow{grid-template-columns:1fr 1fr}.review-flow b{display:none}.inbox-upload-types{grid-template-columns:1fr 1fr 1fr}.inbox-upload-types p{grid-column:1/-1}}@media (width<=1450px){.experiment-v3-grid{grid-template-columns:225px minmax(420px,1fr) 290px}}@media (width<=1180px){.experiment-v3-grid{grid-template-columns:220px minmax(0,1fr)}.experiment-v3-side{grid-column:1/-1;grid-template-columns:1fr 1fr}.research-stage-rail{grid-template-columns:repeat(7,minmax(135px,1fr));overflow-x:auto}}@media (width<=900px){.custom-project-switcher{min-width:0;max-width:320px}.progress-metrics{grid-template-columns:1fr 1fr}.progress-metrics>div:nth-child(2){border-right:0}.progress-metrics>div:nth-child(-n+2){border-bottom:1px solid rgb(var(--border))}.experiment-v3-grid{grid-template-columns:1fr}.experiment-v3-side{grid-column:auto;grid-template-columns:1fr}}@media (width<=640px){.project-switcher-trigger strong{font-size:11px}.project-switcher-popover{top:calc(var(--topbar) + 6px);width:auto;position:fixed;left:8px;right:8px}.experiment-progress-hero{grid-template-columns:1fr;padding:18px 18px 0}.progress-number{align-items:flex-start}.truthful-progress{grid-column:1}.progress-metrics{grid-column:1;margin-inline:-18px}.checkpoint-list{grid-template-columns:1fr;gap:6px}.checkpoint{text-align:left;grid-template-columns:34px minmax(0,1fr);align-items:center;min-height:50px;display:grid}.checkpoint>div{margin-top:0}.checkpoint>i{width:2px;height:auto;top:30px;bottom:-8px;left:15px}.checkpoint p{font-size:8.5px}}@media (width<=900px){.release-module-grid{grid-template-columns:1fr}.release-flow{grid-template-columns:1fr;gap:5px}.release-flow>b{transform:rotate(90deg)}.project-intake-start{flex-direction:column;align-items:stretch}.project-intake-start select{max-width:none}}@media (width<=640px){.ide-context-strip{grid-template-columns:18px minmax(0,1fr) auto 28px}.ide-context-strip code,.ide-context-strip small{display:none}.review-form-row,.review-emphasis,.release-hero{grid-template-columns:1fr}}@media (width<=1180px){.vscode-shell{grid-template-rows:minmax(0,1fr) 180px 340px 22px}.vscode-source-control{border-top:1px solid rgb(var(--vscode-line));border-left:0;grid-area:3/2/auto/4;display:flex}.vscode-statusbar{grid-row:4}}@media (width<=900px){.literature-v2__sidebar{display:block}.literature-v2__sidebar .library-tabs{grid-template-columns:repeat(4,1fr);gap:5px;display:grid}.literature-v2__sidebar .library-tabs button{justify-content:center;gap:7px}.literature-source-note{display:none}}@media (width<=640px){.literature-v2__sidebar .library-tabs{grid-template-columns:1fr 1fr}.vscode-source-control{min-height:420px}}@media (width<=900px){.copilot-v2{height:auto;min-height:100%;overflow:visible}.copilot-v2__layout{flex-direction:column;display:flex}.copilot-v2__thread{min-height:720px}.copilot-v2__aside{min-height:540px;display:block}}}@keyframes prompt-optimizer-enter{0%{opacity:0;transform:translateY(8px)scale(.992)}to{opacity:1;transform:translateY(0)scale(1)}}@keyframes livePulse{0%,to{box-shadow:0 0 0 0 rgb(var(--green) / .25)}50%{box-shadow:0 0 0 5px rgb(var(--green) / 0)}}@keyframes blink{50%{opacity:.35}}@keyframes skeleton{to{background-position:-120% 0}}@keyframes popoverIn{0%{opacity:0;transform:translateY(-5px)scale(.985)}to{opacity:1;transform:translateY(0)scale(1)}}.integrated-workbench button{padding:revert-layer}.integrated-workbench .literature-v2__sidebar .search-field{width:calc(100% - 24px);min-width:0;max-width:none}.integrated-workbench .literature-v2__main{border:1px solid rgb(var(--border));background:rgb(var(--surface));box-shadow:var(--shadow-1);border-radius:16px;padding:16px;overflow:hidden}.integrated-workbench .literature-list-header{border-bottom:1px solid rgb(var(--border));min-height:0;margin-bottom:14px;padding-bottom:14px}.integrated-workbench .paper-grid{gap:14px}.integrated-workbench button.paper-card{border-color:rgb(var(--border-strong));background:rgb(var(--surface-2) / .42);width:100%;min-width:0;min-height:242px;box-shadow:none;padding:17px;overflow:hidden}.integrated-workbench .paper-card__meta{flex-wrap:wrap;align-items:flex-start;min-width:0}.integrated-workbench .paper-card__year{text-overflow:ellipsis;white-space:nowrap;min-width:0;margin-left:auto;overflow:hidden}.integrated-workbench .paper-card__footer{min-width:0}.integrated-workbench .paper-card__footer>span{white-space:nowrap;flex:none}.integrated-workbench .release-module>header .badge{flex-shrink:0}@container (width<=700px){.integrated-workbench .literature-v2__main{padding:12px}.integrated-workbench .literature-list-header{margin-bottom:12px;padding-bottom:12px}.integrated-workbench button.paper-card{min-height:0;padding:15px}}.placeholder\:text-ink-faint::placeholder{--tw-text-opacity:1;color:rgb(var(--ink-faint) / var(--tw-text-opacity,1))}.first\:mt-0:first-child{margin-top:0}.last\:mb-0:last-child{margin-bottom:0}.last\:border-0:last-child{border-width:0}.last\:border-b-0:last-child{border-bottom-width:0}.last\:pb-0:last-child{padding-bottom:0}.focus-within\:border-blue\/60:focus-within{border-color:rgb(var(--blue) / .6)}.hover\:border-blue:hover{--tw-border-opacity:1;border-color:rgb(var(--blue) / var(--tw-border-opacity,1))}.hover\:border-blue-deep:hover{--tw-border-opacity:1;border-color:rgb(var(--blue-deep) / var(--tw-border-opacity,1))}.hover\:border-blue-sky\/50:hover{border-color:rgb(var(--blue-sky) / .5)}.hover\:border-blue-sky\/60:hover{border-color:rgb(var(--blue-sky) / .6)}.hover\:border-blue\/45:hover{border-color:rgb(var(--blue) / .45)}.hover\:border-blue\/50:hover{border-color:rgb(var(--blue) / .5)}.hover\:border-blue\/60:hover{border-color:rgb(var(--blue) / .6)}.hover\:border-err\/50:hover{border-color:rgb(var(--err) / .5)}.hover\:border-ink-faint:hover{--tw-border-opacity:1;border-color:rgb(var(--ink-faint) / var(--tw-border-opacity,1))}.hover\:border-line\/70:hover{border-color:rgb(var(--line) / .7)}.hover\:border-ok:hover{--tw-border-opacity:1;border-color:rgb(var(--ok) / var(--tw-border-opacity,1))}.hover\:bg-bg:hover{--tw-bg-opacity:1;background-color:rgb(var(--bg) / var(--tw-bg-opacity,1))}.hover\:bg-bg\/30:hover{background-color:rgb(var(--bg) / .3)}.hover\:bg-bg\/60:hover{background-color:rgb(var(--bg) / .6)}.hover\:bg-bg\/70:hover{background-color:rgb(var(--bg) / .7)}.hover\:bg-blue-deep:hover{--tw-bg-opacity:1;background-color:rgb(var(--blue-deep) / var(--tw-bg-opacity,1))}.hover\:bg-blue-deep\/20:hover{background-color:rgb(var(--blue-deep) / .2)}.hover\:bg-blue-deep\/80:hover{background-color:rgb(var(--blue-deep) / .8)}.hover\:bg-blue\/10:hover{background-color:rgb(var(--blue) / .1)}.hover\:bg-blue\/15:hover{background-color:rgb(var(--blue) / .15)}.hover\:bg-err\/10:hover{background-color:rgb(var(--err) / .1)}.hover\:bg-line\/20:hover{background-color:rgb(var(--line) / .2)}.hover\:bg-ok\/10:hover{background-color:rgb(var(--ok) / .1)}.hover\:bg-ok\/15:hover{background-color:rgb(var(--ok) / .15)}.hover\:bg-panel:hover{--tw-bg-opacity:1;background-color:rgb(var(--panel) / var(--tw-bg-opacity,1))}.hover\:bg-panel-raised:hover{--tw-bg-opacity:1;background-color:rgb(var(--panel-raised) / var(--tw-bg-opacity,1))}.hover\:bg-panel\/60:hover{background-color:rgb(var(--panel) / .6)}.hover\:bg-panel\/80:hover{background-color:rgb(var(--panel) / .8)}.hover\:bg-surface:hover{--tw-bg-opacity:1;background-color:rgb(var(--surface) / var(--tw-bg-opacity,1))}.hover\:bg-warn\/10:hover{background-color:rgb(var(--warn) / .1)}.hover\:bg-white\/5:hover{background-color:#ffffff0d}.hover\:text-blue:hover{--tw-text-opacity:1;color:rgb(var(--blue) / var(--tw-text-opacity,1))}.hover\:text-blue-sky:hover{--tw-text-opacity:1;color:rgb(var(--blue-sky) / var(--tw-text-opacity,1))}.hover\:text-err:hover{--tw-text-opacity:1;color:rgb(var(--err) / var(--tw-text-opacity,1))}.hover\:text-gold:hover{--tw-text-opacity:1;color:rgb(var(--gold) / var(--tw-text-opacity,1))}.hover\:text-gold-soft:hover{--tw-text-opacity:1;color:rgb(var(--gold-soft) / var(--tw-text-opacity,1))}.hover\:text-ink:hover{--tw-text-opacity:1;color:rgb(var(--ink) / var(--tw-text-opacity,1))}.hover\:text-ink-dim:hover{--tw-text-opacity:1;color:rgb(var(--ink-dim) / var(--tw-text-opacity,1))}.hover\:text-white:hover{--tw-text-opacity:1;color:rgb(255 255 255/var(--tw-text-opacity,1))}.hover\:decoration-blue:hover{-webkit-text-decoration-color:rgb(var(--blue) / 1);text-decoration-color:rgb(var(--blue) / 1)}.hover\:opacity-100:hover{opacity:1}.focus\:border-blue:focus{--tw-border-opacity:1;border-color:rgb(var(--blue) / var(--tw-border-opacity,1))}.focus\:border-blue-deep:focus{--tw-border-opacity:1;border-color:rgb(var(--blue-deep) / var(--tw-border-opacity,1))}.focus\:border-blue\/60:focus{border-color:rgb(var(--blue) / .6)}.focus-visible\:outline-none:focus-visible{outline-offset:2px;outline:2px solid #0000}.focus-visible\:outline:focus-visible{outline-style:solid}.focus-visible\:outline-2:focus-visible{outline-width:2px}.focus-visible\:outline-offset-2:focus-visible{outline-offset:2px}.focus-visible\:outline-blue:focus-visible{outline-color:rgb(var(--blue) / 1)}.focus-visible\:ring-2:focus-visible{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow,0 0 #0000)}.focus-visible\:ring-blue-sky\/50:focus-visible{--tw-ring-color:rgb(var(--blue-sky) / .5)}.focus-visible\:ring-blue\/50:focus-visible{--tw-ring-color:rgb(var(--blue) / .5)}.active\:bg-panel-raised:active{--tw-bg-opacity:1;background-color:rgb(var(--panel-raised) / var(--tw-bg-opacity,1))}.enabled\:hover\:text-blue-sky:hover:enabled{--tw-text-opacity:1;color:rgb(var(--blue-sky) / var(--tw-text-opacity,1))}.enabled\:focus-visible\:underline:focus-visible:enabled{text-decoration-line:underline}.enabled\:focus-visible\:outline-none:focus-visible:enabled{outline-offset:2px;outline:2px solid #0000}.disabled\:cursor-not-allowed:disabled{cursor:not-allowed}.disabled\:cursor-wait:disabled{cursor:wait}.disabled\:text-ink-faint:disabled{--tw-text-opacity:1;color:rgb(var(--ink-faint) / var(--tw-text-opacity,1))}.disabled\:opacity-35:disabled{opacity:.35}.disabled\:opacity-40:disabled{opacity:.4}.disabled\:opacity-45:disabled{opacity:.45}.disabled\:opacity-50:disabled{opacity:.5}.disabled\:opacity-60:disabled{opacity:.6}.group:focus-within .group-focus-within\:opacity-100{opacity:1}.group:hover .group-hover\:bg-blue\/70{background-color:rgb(var(--blue) / .7)}.group:hover .group-hover\:bg-ink-faint\/30{background-color:rgb(var(--ink-faint) / .3)}.group:hover .group-hover\:opacity-100{opacity:1}.group:focus .group-focus\:bg-blue\/70{background-color:rgb(var(--blue) / .7)}@media (prefers-reduced-motion:reduce){.motion-reduce\:animate-none{animation:none}}@media (width>=640px){.sm\:left-auto{left:auto}.sm\:order-none{order:0}.sm\:block{display:block}.sm\:inline{display:inline}.sm\:h-20{height:5rem}.sm\:max-h-\[88dvh\]{max-height:88dvh}.sm\:w-20{width:5rem}.sm\:w-auto{width:auto}.sm\:max-w-48{max-width:12rem}.sm\:max-w-\[82\%\]{max-width:82%}.sm\:max-w-md{max-width:28rem}.sm\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.sm\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.sm\:grid-cols-\[100px_minmax\(0\,1fr\)\]{grid-template-columns:100px minmax(0,1fr)}.sm\:grid-cols-\[minmax\(0\,1fr\)_auto\]{grid-template-columns:minmax(0,1fr) auto}.sm\:grid-cols-\[minmax\(0\,1fr\)_minmax\(0\,1fr\)_auto\]{grid-template-columns:minmax(0,1fr) minmax(0,1fr) auto}.sm\:flex-nowrap{flex-wrap:nowrap}.sm\:gap-3{gap:.75rem}.sm\:p-3{padding:.75rem}.sm\:p-4{padding:1rem}.sm\:p-5{padding:1.25rem}.sm\:px-4{padding-left:1rem;padding-right:1rem}.sm\:px-5{padding-left:1.25rem;padding-right:1.25rem}.sm\:px-6{padding-left:1.5rem;padding-right:1.5rem}.sm\:pt-14{padding-top:3.5rem}.sm\:text-right{text-align:right}.sm\:opacity-0{opacity:0}.group:focus-within .sm\:group-focus-within\:opacity-100,.group:hover .sm\:group-hover\:opacity-100{opacity:1}}@media (width>=768px){.md\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}}@media (width>=1024px){.lg\:visible{visibility:visible}.lg\:static{position:static}.lg\:z-auto{z-index:auto}.lg\:col-span-2{grid-column:span 2/span 2}.lg\:flex{display:flex}.lg\:grid{display:grid}.lg\:hidden{display:none}.lg\:w-14{width:3.5rem}.lg\:w-\[var\(--preview-width\)\]{width:var(--preview-width)}.lg\:w-\[var\(--sidebar-width\)\]{width:var(--sidebar-width)}.lg\:max-w-\[61\.8vw\]{max-width:61.8vw}.lg\:flex-none{flex:none}.lg\:translate-x-0{--tw-translate-x:0px;transform:translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.lg\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.lg\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.lg\:grid-cols-\[minmax\(0\,1\.15fr\)_minmax\(260px\,0\.85fr\)\]{grid-template-columns:minmax(0,1.15fr) minmax(260px,.85fr)}.lg\:grid-cols-\[minmax\(0\,1\.4fr\)_minmax\(300px\,0\.8fr\)\]{grid-template-columns:minmax(0,1.4fr) minmax(300px,.8fr)}.lg\:grid-cols-\[minmax\(15rem\,0\.72fr\)_minmax\(0\,1\.8fr\)\]{grid-template-columns:minmax(15rem,.72fr) minmax(0,1.8fr)}.lg\:gap-3{gap:.75rem}.lg\:space-y-0>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(0px * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(0px * var(--tw-space-y-reverse))}.lg\:overflow-hidden{overflow:hidden}.lg\:border-b-0{border-bottom-width:0}.lg\:border-r{border-right-width:1px}}@media (width>=1280px){.xl\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.xl\:grid-cols-\[minmax\(0\,1fr\)_minmax\(18rem\,0\.85fr\)\]{grid-template-columns:minmax(0,1fr) minmax(18rem,.85fr)}.xl\:border-b-0{border-bottom-width:0}.xl\:border-r{border-right-width:1px}} diff --git a/frontend/web/dist/assets/index-CWCNOzy_.css b/frontend/web/dist/assets/index-CWCNOzy_.css new file mode 100644 index 000000000..9f25637a4 --- /dev/null +++ b/frontend/web/dist/assets/index-CWCNOzy_.css @@ -0,0 +1 @@ +.conversation-composer{width:100%;max-width:680px;margin:0 auto}.composer-surface{min-width:0}.map-composer{border:1px solid rgb(var(--line) / .8);background:rgb(var(--surface));border-radius:29px;align-items:center;gap:15px;padding:14px 15px 14px 22px;transition:border-color .16s,box-shadow .16s;display:flex;box-shadow:0 9px 28px #233b5510,0 2px 5px #233b5509}.map-composer:focus-within{border-color:rgb(var(--blue) / .5);box-shadow:0 4px 22px rgb(var(--blue) / .08)}.map-composer-brand{color:rgb(var(--ink));flex-shrink:0}.map-attach{border-radius:50%;place-items:center;width:34px;height:34px;transition:background .14s;display:grid}.map-attach:hover,.map-attach:focus-visible{background:rgb(var(--line) / .6);outline:2px solid rgb(var(--blue) / .4);outline-offset:2px}.map-attach:disabled{opacity:.55;cursor:default}.map-composer textarea{resize:none;min-width:0;color:rgb(var(--ink));background:0 0;border:0;outline:none;flex:1;max-height:132px;font-size:15px;line-height:28px}.map-composer textarea::placeholder{color:rgb(var(--ink-faint))}.map-send{background:rgb(var(--blue-deep));color:#fff;border-radius:50%;flex-shrink:0;place-items:center;width:33px;height:33px;transition:width .22s,opacity .15s,background-color .14s;display:grid}.map-send:disabled{background:rgb(var(--line) / .7);color:rgb(var(--ink-faint));cursor:default}.map-send:not(:disabled):hover{background:rgb(var(--blue))}.composer-controls{min-height:30px;color:rgb(var(--ink-faint));flex-wrap:wrap;justify-content:flex-end;align-items:center;gap:10px;padding:5px 12px 0;font-size:11px;display:flex}.composer-controls :is(button,select){background:0 0;border-radius:8px;min-height:28px;padding:4px 8px}.composer-controls :is(button,select):hover{background:rgb(var(--panel));color:rgb(var(--ink))}.map-attachment-tray{overscroll-behavior:contain;flex-wrap:wrap;gap:8px;max-height:140px;padding:0 8px 9px;display:flex;overflow-y:auto}.map-attachment-tray>div{flex:200px;max-width:100%}.map-attachment-notice{background:rgb(var(--surface));color:rgb(var(--err));border-radius:10px;max-height:72px;margin-bottom:6px;padding:7px 12px;font-size:12px;overflow-y:auto}.map-composer-caption{white-space:nowrap;text-overflow:ellipsis;text-align:center;color:rgb(var(--ink-faint));min-height:15px;padding-top:5px;font-size:10px;display:block;overflow:hidden}.map-reference-chips{flex-wrap:wrap;gap:6px;padding:0 16px 7px;display:flex}.map-reference-chips>span{border:1px solid rgb(var(--blue) / .25);background:rgb(var(--surface));max-width:100%;color:rgb(var(--blue));border-radius:9px;align-items:center;gap:9px;padding:5px 9px;font-size:11px;display:flex}.map-reference-chips>span>span{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.composer-surface[data-pending=true] .argus-mark-eye{transform-box:fill-box;transform-origin:50%;animation:1.8s ease-in-out infinite composer-eye-working}@keyframes composer-eye-working{0%,to{transform:rotate(-12deg)}50%{transform:rotate(16deg)}}@media (width<=640px){.map-composer{border-radius:24px;gap:10px;padding:10px 12px}.map-composer textarea{font-size:14px}}@media (prefers-reduced-motion:reduce){.conversation-composer,.map-composer,.map-send{transition:none}.composer-surface .argus-mark-eye{animation:none!important}}.delivery-header{background:linear-gradient(115deg, rgb(var(--ok) / .08), transparent 70%);flex-shrink:0;padding:20px 24px 12px}.delivery-heading{align-items:center;gap:12px;display:flex}.delivery-mark{width:44px;height:44px;color:rgb(var(--ok));background:rgb(var(--ok) / .12);border-radius:14px;place-items:center;display:grid}.delivery-heading p{letter-spacing:.14em;color:rgb(var(--ink-dim));font-size:10px}.delivery-heading h2{margin-top:2px;font-size:20px;font-weight:650}.delivery-return{border:1px solid rgb(var(--line));white-space:nowrap;border-radius:10px;align-self:flex-start;margin-left:auto;padding:10px 12px;font-size:12px}.delivery-return:hover{background:rgb(var(--surface))}.delivery-task-title{text-overflow:ellipsis;white-space:nowrap;margin-top:12px;font-size:13px;overflow:hidden}.delivery-task-select{background:rgb(var(--panel));border-radius:8px;max-width:100%;margin-top:12px;padding:5px;font-size:13px}.delivery-facts{color:rgb(var(--ink-dim));gap:16px;margin-top:8px;font-size:11px;display:flex}.delivery-facts span{align-items:center;gap:5px;display:flex}.delivery-facts span:first-child{color:rgb(var(--ok))}.delivery-summary{color:rgb(var(--ink-dim));margin-top:8px;font-size:12px}.delivery-summary summary{cursor:pointer;width:fit-content;padding:3px 0}.delivery-summary p{white-space:pre-wrap;max-height:16dvh;margin-top:6px;line-height:1.7;overflow-y:auto}.delivery-files{border-bottom:1px solid rgb(var(--line));flex-shrink:0;gap:8px;padding:8px 24px 12px;display:flex;overflow-x:auto}.delivery-files button{border:1px solid rgb(var(--line));white-space:nowrap;border-radius:10px;align-items:center;gap:8px;padding:10px 12px;font-size:12px;display:flex}.delivery-files button span{text-overflow:ellipsis;max-width:240px;overflow:hidden}.delivery-files button[aria-pressed=true]{border-color:rgb(var(--blue) / .5);background:rgb(var(--blue) / .08);color:rgb(var(--blue))}.delivery-files small{opacity:.8;font-size:10px}@media (width<=640px){.delivery-header{padding:14px 14px 8px}.delivery-heading{gap:9px}.delivery-heading h2{font-size:18px}.delivery-return{padding:10px;font-size:11px}.delivery-files{padding:8px 14px}.delivery-files button{padding:9px 11px}}.agent-activity{color:rgb(var(--ink));min-width:0;font-size:12px}.agent-activity-heading{justify-content:space-between;align-items:center;gap:12px;margin-bottom:14px;font-weight:650;display:flex}.agent-activity-heading>span{align-items:center;gap:8px;display:flex}.agent-activity-heading>button{color:rgb(var(--ink-dim));cursor:pointer;background:0 0;border:0;border-radius:9px;place-items:center;padding:8px;display:grid}.agent-activity-tabs{background:rgb(var(--ink)/.045);border-radius:12px;grid-template-columns:repeat(4,minmax(0,1fr));gap:4px;margin-bottom:14px;padding:4px;display:grid}.agent-activity-tabs button{min-height:36px;color:rgb(var(--ink-faint));cursor:pointer;background:0 0;border:0;border-radius:9px;justify-content:center;align-items:center;gap:6px;font-size:12px;transition:background .2s,color .2s;display:flex}.agent-activity-tabs button[aria-pressed=true]{background:rgb(var(--panel));color:rgb(var(--ink));box-shadow:0 2px 8px #16345112}.agent-activity-tabs i{background:rgb(var(--ink-faint)/.4);border-radius:50%;width:5px;height:5px}.agent-activity-tabs i[data-active=true]{background:#56a792;box-shadow:0 0 0 3px #56a79216}.agent-current{border:1px solid rgb(var(--line));background:rgb(var(--bg)/.4);border-radius:14px;padding:16px}.agent-current[data-active=true]{background:linear-gradient(135deg,#629cc40b,#6bb49b08);border-color:#79a8c457}.agent-current-kicker{color:rgb(var(--ink-faint));justify-content:space-between;align-items:center;gap:12px;font-size:11px;display:flex}.agent-current h3{margin:8px 0;font-size:16px;font-weight:650;line-height:1.45}.agent-live-indicator{letter-spacing:1px;color:#397f75;align-items:center;gap:5px;font-size:9px;display:flex}.agent-live-indicator i{background:currentColor;border-radius:50%;width:5px;height:5px;animation:2s ease-in-out infinite agent-live-breathe}.agent-current-summary{color:rgb(var(--ink-dim));overflow-wrap:anywhere;max-height:220px;font-size:13px;line-height:1.7;overflow:auto}.agent-current-summary p{margin:4px 0}.agent-current-meta{color:rgb(var(--ink-faint));flex-wrap:wrap;align-items:center;gap:6px;margin-top:12px;font-size:10px;display:flex}.agent-current-meta span:last-child{margin-left:auto}.agent-records-heading{color:rgb(var(--ink-faint));justify-content:space-between;margin:18px 0 10px;font-size:11px;display:flex}.agent-records{overscroll-behavior:contain;max-height:360px;overflow:auto}.agent-record{grid-template-columns:24px minmax(0,1fr);gap:8px;padding:10px 0;display:grid;position:relative}.agent-record:not(:last-child):before{content:"";background:rgb(var(--line));width:1px;position:absolute;top:31px;bottom:-9px;left:11px}.agent-record-icon{color:#68879e;background:#7099b40e;border:1px solid #7099b426;border-radius:8px;place-items:center;width:24px;height:24px;display:grid}.agent-record[data-active=true] .agent-record-icon{color:#367ea4;background:#7099b418}.agent-record[data-failed=true] .agent-record-icon{color:#b3744e}.agent-record-title{justify-content:space-between;align-items:flex-start;gap:10px;font-size:12px;line-height:1.6;display:flex}.agent-record-title strong{font-weight:550}.agent-record time{color:rgb(var(--ink-faint));font-variant-numeric:tabular-nums;flex-shrink:0;font-size:10px}.agent-record small{color:rgb(var(--ink-faint));font-size:10px}.agent-record summary{color:#5b87a3;cursor:pointer;align-items:center;gap:4px;padding:6px 0;font-size:11px;list-style:none;display:flex}.agent-record summary::-webkit-details-marker{display:none}.agent-record details[open] summary svg{transform:rotate(180deg)}.agent-record-detail{color:rgb(var(--ink-dim));overflow-wrap:anywhere;font-size:12px;line-height:1.7}.agent-record-detail p{margin:4px 0}.agent-records-empty{color:rgb(var(--ink-faint));padding:20px 0;line-height:1.7}@keyframes agent-live-breathe{50%{opacity:.5;box-shadow:0 0 0 4px #56a79214}}@media (width<=640px){.agent-activity-tabs button{min-height:44px}.agent-current-summary{max-height:160px}.agent-records{max-height:32dvh}}@media (prefers-reduced-motion:reduce){.agent-live-indicator i{animation:none}.agent-activity-tabs button{transition:none}}@font-face{font-family:Geist Variable;font-style:normal;font-display:swap;font-weight:100 900;src:url(/assets/geist-cyrillic-ext-wght-normal-DjL33-gN.woff2)format("woff2-variations");unicode-range:U+460-52F,U+1C80-1C8A,U+20B4,U+2DE0-2DFF,U+A640-A69F,U+FE2E-FE2F}@font-face{font-family:Geist Variable;font-style:normal;font-display:swap;font-weight:100 900;src:url(/assets/geist-cyrillic-wght-normal-BEAKL7Jp.woff2)format("woff2-variations");unicode-range:U+301,U+400-45F,U+490-491,U+4B0-4B1,U+2116}@font-face{font-family:Geist Variable;font-style:normal;font-display:swap;font-weight:100 900;src:url(/assets/geist-vietnamese-wght-normal-6IgcOCM7.woff2)format("woff2-variations");unicode-range:U+102-103,U+110-111,U+128-129,U+168-169,U+1A0-1A1,U+1AF-1B0,U+300-301,U+303-304,U+308-309,U+323,U+329,U+1EA0-1EF9,U+20AB}@font-face{font-family:Geist Variable;font-style:normal;font-display:swap;font-weight:100 900;src:url(/assets/geist-latin-ext-wght-normal-DC-KSUi6.woff2)format("woff2-variations");unicode-range:U+100-2BA,U+2BD-2C5,U+2C7-2CC,U+2CE-2D7,U+2DD-2FF,U+304,U+308,U+329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF}@font-face{font-family:Geist Variable;font-style:normal;font-display:swap;font-weight:100 900;src:url(/assets/geist-latin-wght-normal-BgDaEnEv.woff2)format("woff2-variations");unicode-range:U+??,U+131,U+152-153,U+2BB-2BC,U+2C6,U+2DA,U+2DC,U+304,U+308,U+329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD}@font-face{font-family:Geist Mono Variable;font-style:normal;font-display:swap;font-weight:100 900;src:url(/assets/geist-mono-cyrillic-ext-wght-normal-X_5orZeX.woff2)format("woff2-variations");unicode-range:U+460-52F,U+1C80-1C8A,U+20B4,U+2DE0-2DFF,U+A640-A69F,U+FE2E-FE2F}@font-face{font-family:Geist Mono Variable;font-style:normal;font-display:swap;font-weight:100 900;src:url(/assets/geist-mono-cyrillic-wght-normal-DiZS0aHC.woff2)format("woff2-variations");unicode-range:U+301,U+400-45F,U+490-491,U+4B0-4B1,U+2116}@font-face{font-family:Geist Mono Variable;font-style:normal;font-display:swap;font-weight:100 900;src:url(/assets/geist-mono-symbols2-wght-normal-CO5SzqOn.woff2)format("woff2-variations");unicode-range:U+2000-2001,U+2004-2008,U+200A,U+23B8-23BD,U+2500-259F}@font-face{font-family:Geist Mono Variable;font-style:normal;font-display:swap;font-weight:100 900;src:url(/assets/geist-mono-vietnamese-wght-normal-DadHysG0.woff2)format("woff2-variations");unicode-range:U+102-103,U+110-111,U+128-129,U+168-169,U+1A0-1A1,U+1AF-1B0,U+300-301,U+303-304,U+308-309,U+323,U+329,U+1EA0-1EF9,U+20AB}@font-face{font-family:Geist Mono Variable;font-style:normal;font-display:swap;font-weight:100 900;src:url(/assets/geist-mono-latin-ext-wght-normal-Bwz-egvJ.woff2)format("woff2-variations");unicode-range:U+100-2BA,U+2BD-2C5,U+2C7-2CC,U+2CE-2D7,U+2DD-2FF,U+304,U+308,U+329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF}@font-face{font-family:Geist Mono Variable;font-style:normal;font-display:swap;font-weight:100 900;src:url(/assets/geist-mono-latin-wght-normal-XN7g48iV.woff2)format("woff2-variations");unicode-range:U+??,U+131,U+152-153,U+2BB-2BC,U+2C6,U+2DA,U+2DC,U+304,U+308,U+329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD}*,:before,:after,::backdrop{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:#3b82f680;--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }*,:before,:after{box-sizing:border-box;border:0 solid #e5e7eb}:before,:after{--tw-content:""}html,:host{-webkit-text-size-adjust:100%;tab-size:4;font-feature-settings:normal;font-variation-settings:normal;-webkit-tap-highlight-color:transparent;font-family:Geist Variable,PingFang SC,Microsoft YaHei,Noto Sans CJK SC,ui-sans-serif,system-ui,sans-serif;line-height:1.5}body{line-height:inherit;margin:0}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-feature-settings:normal;font-variation-settings:normal;font-family:Geist Mono Variable,SFMono-Regular,Menlo,ui-monospace,monospace;font-size:1em}small{font-size:80%}sub,sup{vertical-align:baseline;font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-feature-settings:inherit;font-variation-settings:inherit;font-family:inherit;font-size:100%;font-weight:inherit;line-height:inherit;letter-spacing:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:#0000;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button{height:auto}::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dl,dd,h1,h2,h3,h4,h5,h6,hr,figure,p,pre{margin:0}fieldset{margin:0;padding:0}legend{padding:0}ol,ul,menu{margin:0;padding:0;list-style:none}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder{opacity:1;color:#9ca3af}textarea::-moz-placeholder{opacity:1;color:#9ca3af}input::placeholder,textarea::placeholder{opacity:1;color:#9ca3af}button,[role=button]{cursor:pointer}:disabled{cursor:default}img,svg,video,canvas,audio,iframe,embed,object{vertical-align:middle;display:block}img,video{max-width:100%;height:auto}[hidden]:where(:not([hidden=until-found])){display:none}.container{width:100%}@media (width>=640px){.container{max-width:640px}}@media (width>=768px){.container{max-width:768px}}@media (width>=1024px){.container{max-width:1024px}}@media (width>=1280px){.container{max-width:1280px}}@media (width>=1536px){.container{max-width:1536px}}.card{background:rgb(var(--surface));box-shadow:none;border:0;border-radius:.5rem}.chip{--tw-bg-opacity:1;background-color:rgb(var(--surface) / var(--tw-bg-opacity,1));border-radius:.375rem;align-items:center;gap:.25rem;padding:.125rem .375rem;font-size:.75rem;line-height:1rem;display:inline-flex}.sr-only{clip:rect(0, 0, 0, 0);white-space:nowrap;border-width:0;width:1px;height:1px;margin:-1px;padding:0;position:absolute;overflow:hidden}.pointer-events-none{pointer-events:none}.\!visible{visibility:visible!important}.visible{visibility:visible}.invisible{visibility:hidden}.collapse{visibility:collapse}.static{position:static}.fixed{position:fixed}.absolute{position:absolute}.relative{position:relative}.inset-0{inset:0}.inset-x-0{left:0;right:0}.inset-y-0{top:0;bottom:0}.inset-y-1{top:.25rem;bottom:.25rem}.inset-y-2{top:.5rem;bottom:.5rem}.-bottom-2\.5{bottom:-.625rem}.-left-0\.5{left:-.125rem}.-top-2\.5{top:-.625rem}.bottom-0{bottom:0}.bottom-4{bottom:1rem}.left-0{left:0}.left-1\/2{left:50%}.left-4{left:1rem}.left-\[0\.6875rem\]{left:.6875rem}.left-\[10\%\]{left:10%}.left-\[5px\]{left:5px}.right-0\.5{right:.125rem}.right-1{right:.25rem}.right-2{right:.5rem}.right-4{right:1rem}.right-9{right:2.25rem}.right-\[10\%\]{right:10%}.top-0\.5{top:.125rem}.top-2{top:.5rem}.top-3{top:.75rem}.top-4{top:1rem}.top-6{top:1.5rem}.z-10{z-index:10}.z-30{z-index:30}.z-40{z-index:40}.z-50{z-index:50}.z-\[100\]{z-index:100}.z-\[70\]{z-index:70}.z-\[90\]{z-index:90}.order-2{order:2}.order-3{order:3}.m-auto{margin:auto}.mx-2{margin-left:.5rem;margin-right:.5rem}.mx-3{margin-left:.75rem;margin-right:.75rem}.mx-auto{margin-left:auto;margin-right:auto}.my-1{margin-top:.25rem;margin-bottom:.25rem}.my-1\.5{margin-top:.375rem;margin-bottom:.375rem}.my-2{margin-top:.5rem;margin-bottom:.5rem}.my-3{margin-top:.75rem;margin-bottom:.75rem}.mb-0\.5{margin-bottom:.125rem}.mb-1{margin-bottom:.25rem}.mb-1\.5{margin-bottom:.375rem}.mb-2{margin-bottom:.5rem}.mb-3{margin-bottom:.75rem}.mb-4{margin-bottom:1rem}.mb-6{margin-bottom:1.5rem}.ml-1{margin-left:.25rem}.ml-1\.5{margin-left:.375rem}.ml-2{margin-left:.5rem}.ml-3{margin-left:.75rem}.ml-auto{margin-left:auto}.mr-1{margin-right:.25rem}.mr-1\.5{margin-right:.375rem}.mr-auto{margin-right:auto}.mt-0\.5{margin-top:.125rem}.mt-1{margin-top:.25rem}.mt-1\.5{margin-top:.375rem}.mt-2{margin-top:.5rem}.mt-3{margin-top:.75rem}.mt-4{margin-top:1rem}.mt-5{margin-top:1.25rem}.mt-6{margin-top:1.5rem}.mt-8{margin-top:2rem}.mt-9{margin-top:2.25rem}.mt-\[7px\]{margin-top:7px}.mt-auto{margin-top:auto}.mt-px{margin-top:1px}.line-clamp-2{-webkit-line-clamp:2;-webkit-box-orient:vertical;display:-webkit-box;overflow:hidden}.line-clamp-3{-webkit-line-clamp:3;-webkit-box-orient:vertical;display:-webkit-box;overflow:hidden}.line-clamp-4{-webkit-line-clamp:4;-webkit-box-orient:vertical;display:-webkit-box;overflow:hidden}.block{display:block}.inline-block{display:inline-block}.inline{display:inline}.flex{display:flex}.inline-flex{display:inline-flex}.table{display:table}.grid{display:grid}.contents{display:contents}.hidden{display:none}.h-1{height:.25rem}.h-1\.5{height:.375rem}.h-10{height:2.5rem}.h-11{height:2.75rem}.h-12{height:3rem}.h-14{height:3.5rem}.h-16{height:4rem}.h-2{height:.5rem}.h-2\.5{height:.625rem}.h-3{height:.75rem}.h-3\.5{height:.875rem}.h-4{height:1rem}.h-5{height:1.25rem}.h-6{height:1.5rem}.h-7{height:1.75rem}.h-8{height:2rem}.h-9{height:2.25rem}.h-\[1\.4rem\]{height:1.4rem}.h-\[100dvh\]{height:100dvh}.h-\[68vh\]{height:68vh}.h-\[calc\(100\%-1rem\)\]{height:calc(100% - 1rem)}.h-auto{height:auto}.h-full{height:100%}.h-px{height:1px}.max-h-48{max-height:12rem}.max-h-64{max-height:16rem}.max-h-72{max-height:18rem}.max-h-\[100dvh\]{max-height:100dvh}.max-h-\[34rem\]{max-height:34rem}.max-h-\[52vh\]{max-height:52vh}.max-h-\[62vh\]{max-height:62vh}.max-h-\[64vh\]{max-height:64vh}.max-h-\[70dvh\]{max-height:70dvh}.max-h-\[70vh\]{max-height:70vh}.max-h-\[72vh\]{max-height:72vh}.max-h-\[76vh\]{max-height:76vh}.max-h-\[85vh\]{max-height:85vh}.max-h-\[calc\(100dvh-1\.5rem\)\]{max-height:calc(100dvh - 1.5rem)}.max-h-full{max-height:100%}.min-h-0{min-height:0}.min-h-10{min-height:2.5rem}.min-h-11{min-height:2.75rem}.min-h-14{min-height:3.5rem}.min-h-52{min-height:13rem}.min-h-64{min-height:16rem}.min-h-72{min-height:18rem}.min-h-\[3\.25rem\]{min-height:3.25rem}.min-h-\[320px\]{min-height:320px}.min-h-\[34rem\]{min-height:34rem}.min-h-\[60vh\]{min-height:60vh}.min-h-dvh{min-height:100dvh}.min-h-full{min-height:100%}.w-0\.5{width:.125rem}.w-1\.5{width:.375rem}.w-1\/2{width:50%}.w-10{width:2.5rem}.w-11{width:2.75rem}.w-12{width:3rem}.w-14{width:3.5rem}.w-16{width:4rem}.w-2{width:.5rem}.w-2\.5{width:.625rem}.w-20{width:5rem}.w-3{width:.75rem}.w-3\.5{width:.875rem}.w-4{width:1rem}.w-6{width:1.5rem}.w-64{width:16rem}.w-7{width:1.75rem}.w-8{width:2rem}.w-9{width:2.25rem}.w-\[1\.4rem\]{width:1.4rem}.w-\[min\(30rem\,calc\(100vw-2rem\)\)\]{width:min(30rem,100vw - 2rem)}.w-\[min\(92vw\,42rem\)\]{width:min(92vw,42rem)}.w-full{width:100%}.w-max{width:max-content}.w-px{width:1px}.w-screen{width:100vw}.min-w-0{min-width:0}.min-w-28{min-width:7rem}.min-w-3\.5{min-width:.875rem}.min-w-32{min-width:8rem}.min-w-44{min-width:11rem}.min-w-52{min-width:13rem}.min-w-full{min-width:100%}.min-w-max{min-width:max-content}.max-w-24{max-width:6rem}.max-w-28{max-width:7rem}.max-w-2xl{max-width:42rem}.max-w-3xl{max-width:48rem}.max-w-48{max-width:12rem}.max-w-4xl{max-width:56rem}.max-w-5xl{max-width:64rem}.max-w-64{max-width:16rem}.max-w-6xl{max-width:72rem}.max-w-72{max-width:18rem}.max-w-\[calc\(100\%_-_3rem\)\]{max-width:calc(100% - 3rem)}.max-w-full{max-width:100%}.max-w-lg{max-width:32rem}.max-w-md{max-width:28rem}.max-w-none{max-width:none}.max-w-sm{max-width:24rem}.max-w-xl{max-width:36rem}.flex-1{flex:1}.shrink{flex-shrink:1}.shrink-0{flex-shrink:0}.grow{flex-grow:1}.basis-full{flex-basis:100%}.table-fixed{table-layout:fixed}.border-collapse{border-collapse:collapse}.-translate-x-1\/2{--tw-translate-x:-50%;transform:translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.-translate-x-full{--tw-translate-x:-100%;transform:translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.translate-x-0{--tw-translate-x:0px;transform:translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.-rotate-90{--tw-rotate:-90deg;transform:translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.rotate-180{--tw-rotate:180deg;transform:translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.rotate-90{--tw-rotate:90deg;transform:translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.transform{transform:translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}@keyframes appear{0%{opacity:0;transform:translateY(4px)}to{opacity:1;transform:translateY(0)}}.animate-appear{animation:.2s cubic-bezier(.4,0,.2,1) appear}@keyframes pulse{50%{opacity:.5}}.animate-pulse{animation:2s cubic-bezier(.4,0,.6,1) infinite pulse}@keyframes spin{to{transform:rotate(360deg)}}.animate-spin{animation:1s linear infinite spin}.cursor-col-resize{cursor:col-resize}.cursor-default{cursor:default}.cursor-not-allowed{cursor:not-allowed}.cursor-pointer{cursor:pointer}.select-none{-webkit-user-select:none;user-select:none}.resize-y{resize:vertical}.resize{resize:both}.list-decimal{list-style-type:decimal}.list-disc{list-style-type:disc}.grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.grid-cols-\[16px_minmax\(0\,1fr\)\]{grid-template-columns:16px minmax(0,1fr)}.grid-cols-\[72px_minmax\(0\,1fr\)\]{grid-template-columns:72px minmax(0,1fr)}.grid-cols-\[84px_minmax\(0\,1fr\)_auto\]{grid-template-columns:84px minmax(0,1fr) auto}.grid-rows-\[1fr\]{grid-template-rows:1fr}.flex-col{flex-direction:column}.flex-wrap{flex-wrap:wrap}.place-items-center{place-items:center}.items-start{align-items:flex-start}.items-end{align-items:flex-end}.items-center{align-items:center}.items-baseline{align-items:baseline}.items-stretch{align-items:stretch}.justify-end{justify-content:flex-end}.justify-center{justify-content:center}.justify-between{justify-content:space-between}.gap-0\.5{gap:.125rem}.gap-1{gap:.25rem}.gap-1\.5{gap:.375rem}.gap-2{gap:.5rem}.gap-2\.5{gap:.625rem}.gap-3{gap:.75rem}.gap-4{gap:1rem}.gap-x-2{-moz-column-gap:.5rem;column-gap:.5rem}.gap-x-4{-moz-column-gap:1rem;column-gap:1rem}.gap-x-5{-moz-column-gap:1.25rem;column-gap:1.25rem}.gap-y-1{row-gap:.25rem}.space-y-0>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(0px * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(0px * var(--tw-space-y-reverse))}.space-y-0\.5>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(.125rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.125rem * var(--tw-space-y-reverse))}.space-y-1>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(.25rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.25rem * var(--tw-space-y-reverse))}.space-y-1\.5>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(.375rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.375rem * var(--tw-space-y-reverse))}.space-y-2>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(.5rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.5rem * var(--tw-space-y-reverse))}.space-y-3>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(.75rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.75rem * var(--tw-space-y-reverse))}.space-y-4>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(1rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1rem * var(--tw-space-y-reverse))}.overflow-auto{overflow:auto}.overflow-hidden{overflow:hidden}.overflow-x-auto{overflow-x:auto}.overflow-y-auto{overflow-y:auto}.overflow-x-hidden{overflow-x:hidden}.overscroll-contain{overscroll-behavior:contain}.truncate{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.whitespace-pre-wrap{white-space:pre-wrap}.break-words{overflow-wrap:break-word}.break-all{word-break:break-all}.rounded{border-radius:.25rem}.rounded-2xl{border-radius:1rem}.rounded-3xl{border-radius:1.5rem}.rounded-\[18px\]{border-radius:18px}.rounded-full{border-radius:9999px}.rounded-lg{border-radius:.5rem}.rounded-md{border-radius:.375rem}.rounded-none{border-radius:0}.rounded-xl{border-radius:.75rem}.rounded-r-md{border-top-right-radius:.375rem;border-bottom-right-radius:.375rem}.border{border-width:1px}.border-0{border-width:0}.border-2{border-width:2px}.border-b{border-bottom-width:1px}.border-l{border-left-width:1px}.border-l-2{border-left-width:2px}.border-r{border-right-width:1px}.border-t{border-top-width:1px}.border-blue{--tw-border-opacity:1;border-color:rgb(var(--blue) / var(--tw-border-opacity,1))}.border-blue-deep{--tw-border-opacity:1;border-color:rgb(var(--blue-deep) / var(--tw-border-opacity,1))}.border-blue-deep\/30{border-color:rgb(var(--blue-deep) / .3)}.border-blue-deep\/50{border-color:rgb(var(--blue-deep) / .5)}.border-blue-deep\/60{border-color:rgb(var(--blue-deep) / .6)}.border-blue\/25{border-color:rgb(var(--blue) / .25)}.border-blue\/30{border-color:rgb(var(--blue) / .3)}.border-blue\/35{border-color:rgb(var(--blue) / .35)}.border-blue\/45{border-color:rgb(var(--blue) / .45)}.border-blue\/50{border-color:rgb(var(--blue) / .5)}.border-err{--tw-border-opacity:1;border-color:rgb(var(--err) / var(--tw-border-opacity,1))}.border-err\/30{border-color:rgb(var(--err) / .3)}.border-err\/35{border-color:rgb(var(--err) / .35)}.border-err\/40{border-color:rgb(var(--err) / .4)}.border-err\/50{border-color:rgb(var(--err) / .5)}.border-err\/60{border-color:rgb(var(--err) / .6)}.border-gold\/25{border-color:rgb(var(--gold) / .25)}.border-gold\/30{border-color:rgb(var(--gold) / .3)}.border-gold\/40{border-color:rgb(var(--gold) / .4)}.border-line{--tw-border-opacity:1;border-color:rgb(var(--line) / var(--tw-border-opacity,1))}.border-line\/40{border-color:rgb(var(--line) / .4)}.border-line\/50{border-color:rgb(var(--line) / .5)}.border-line\/60{border-color:rgb(var(--line) / .6)}.border-line\/70{border-color:rgb(var(--line) / .7)}.border-line\/80{border-color:rgb(var(--line) / .8)}.border-ok{--tw-border-opacity:1;border-color:rgb(var(--ok) / var(--tw-border-opacity,1))}.border-ok\/20{border-color:rgb(var(--ok) / .2)}.border-ok\/25{border-color:rgb(var(--ok) / .25)}.border-ok\/30{border-color:rgb(var(--ok) / .3)}.border-ok\/35{border-color:rgb(var(--ok) / .35)}.border-ok\/40{border-color:rgb(var(--ok) / .4)}.border-ok\/45{border-color:rgb(var(--ok) / .45)}.border-ok\/60{border-color:rgb(var(--ok) / .6)}.border-panel{--tw-border-opacity:1;border-color:rgb(var(--panel) / var(--tw-border-opacity,1))}.border-transparent{border-color:#0000}.border-warn\/35{border-color:rgb(var(--warn) / .35)}.border-warn\/40{border-color:rgb(var(--warn) / .4)}.border-warn\/50{border-color:rgb(var(--warn) / .5)}.border-t-blue{--tw-border-opacity:1;border-top-color:rgb(var(--blue) / var(--tw-border-opacity,1))}.bg-bg{--tw-bg-opacity:1;background-color:rgb(var(--bg) / var(--tw-bg-opacity,1))}.bg-bg\/25{background-color:rgb(var(--bg) / .25)}.bg-bg\/30{background-color:rgb(var(--bg) / .3)}.bg-bg\/35{background-color:rgb(var(--bg) / .35)}.bg-bg\/40{background-color:rgb(var(--bg) / .4)}.bg-bg\/50{background-color:rgb(var(--bg) / .5)}.bg-bg\/60{background-color:rgb(var(--bg) / .6)}.bg-bg\/70{background-color:rgb(var(--bg) / .7)}.bg-black{--tw-bg-opacity:1;background-color:rgb(0 0 0/var(--tw-bg-opacity,1))}.bg-black\/20{background-color:#0003}.bg-black\/40{background-color:#0006}.bg-blue{--tw-bg-opacity:1;background-color:rgb(var(--blue) / var(--tw-bg-opacity,1))}.bg-blue-deep{--tw-bg-opacity:1;background-color:rgb(var(--blue-deep) / var(--tw-bg-opacity,1))}.bg-blue-deep\/10{background-color:rgb(var(--blue-deep) / .1)}.bg-blue-deep\/20{background-color:rgb(var(--blue-deep) / .2)}.bg-blue-deep\/5{background-color:rgb(var(--blue-deep) / .05)}.bg-blue-sky{--tw-bg-opacity:1;background-color:rgb(var(--blue-sky) / var(--tw-bg-opacity,1))}.bg-blue\/10{background-color:rgb(var(--blue) / .1)}.bg-blue\/5{background-color:rgb(var(--blue) / .05)}.bg-conversation-user{--tw-bg-opacity:1;background-color:rgb(var(--conversation-user) / var(--tw-bg-opacity,1))}.bg-engineer{--tw-bg-opacity:1;background-color:rgb(var(--role-engineer) / var(--tw-bg-opacity,1))}.bg-err{--tw-bg-opacity:1;background-color:rgb(var(--err) / var(--tw-bg-opacity,1))}.bg-err\/10{background-color:rgb(var(--err) / .1)}.bg-err\/5{background-color:rgb(var(--err) / .05)}.bg-gold{--tw-bg-opacity:1;background-color:rgb(var(--gold) / var(--tw-bg-opacity,1))}.bg-gold\/5{background-color:rgb(var(--gold) / .05)}.bg-gold\/80{background-color:rgb(var(--gold) / .8)}.bg-ink-faint{--tw-bg-opacity:1;background-color:rgb(var(--ink-faint) / var(--tw-bg-opacity,1))}.bg-ink-faint\/40{background-color:rgb(var(--ink-faint) / .4)}.bg-ink-faint\/45{background-color:rgb(var(--ink-faint) / .45)}.bg-ink-faint\/50{background-color:rgb(var(--ink-faint) / .5)}.bg-line{--tw-bg-opacity:1;background-color:rgb(var(--line) / var(--tw-bg-opacity,1))}.bg-line\/30{background-color:rgb(var(--line) / .3)}.bg-line\/40{background-color:rgb(var(--line) / .4)}.bg-line\/55{background-color:rgb(var(--line) / .55)}.bg-line\/60{background-color:rgb(var(--line) / .6)}.bg-line\/70{background-color:rgb(var(--line) / .7)}.bg-line\/80{background-color:rgb(var(--line) / .8)}.bg-ok{--tw-bg-opacity:1;background-color:rgb(var(--ok) / var(--tw-bg-opacity,1))}.bg-ok\/10{background-color:rgb(var(--ok) / .1)}.bg-ok\/15{background-color:rgb(var(--ok) / .15)}.bg-ok\/5{background-color:rgb(var(--ok) / .05)}.bg-panel{--tw-bg-opacity:1;background-color:rgb(var(--panel) / var(--tw-bg-opacity,1))}.bg-panel-raised{--tw-bg-opacity:1;background-color:rgb(var(--panel-raised) / var(--tw-bg-opacity,1))}.bg-panel\/80{background-color:rgb(var(--panel) / .8)}.bg-panel\/85{background-color:rgb(var(--panel) / .85)}.bg-panel\/95{background-color:rgb(var(--panel) / .95)}.bg-surface{--tw-bg-opacity:1;background-color:rgb(var(--surface) / var(--tw-bg-opacity,1))}.bg-surface\/50{background-color:rgb(var(--surface) / .5)}.bg-surface\/60{background-color:rgb(var(--surface) / .6)}.bg-transparent{background-color:#0000}.bg-warn\/10{background-color:rgb(var(--warn) / .1)}.bg-warn\/5{background-color:rgb(var(--warn) / .05)}.bg-white{--tw-bg-opacity:1;background-color:rgb(255 255 255/var(--tw-bg-opacity,1))}.bg-white\/\[0\.03\]{background-color:#ffffff08}.object-contain{-o-object-fit:contain;object-fit:contain}.object-cover{-o-object-fit:cover;object-fit:cover}.p-0{padding:0}.p-1\.5{padding:.375rem}.p-2{padding:.5rem}.p-2\.5{padding:.625rem}.p-3{padding:.75rem}.p-4{padding:1rem}.p-5{padding:1.25rem}.p-6{padding:1.5rem}.p-8{padding:2rem}.px-1{padding-left:.25rem;padding-right:.25rem}.px-1\.5{padding-left:.375rem;padding-right:.375rem}.px-2{padding-left:.5rem;padding-right:.5rem}.px-2\.5{padding-left:.625rem;padding-right:.625rem}.px-3{padding-left:.75rem;padding-right:.75rem}.px-3\.5{padding-left:.875rem;padding-right:.875rem}.px-4{padding-left:1rem;padding-right:1rem}.px-5{padding-left:1.25rem;padding-right:1.25rem}.px-6{padding-left:1.5rem;padding-right:1.5rem}.px-8{padding-left:2rem;padding-right:2rem}.py-0\.5{padding-top:.125rem;padding-bottom:.125rem}.py-1{padding-top:.25rem;padding-bottom:.25rem}.py-1\.5{padding-top:.375rem;padding-bottom:.375rem}.py-10{padding-top:2.5rem;padding-bottom:2.5rem}.py-12{padding-top:3rem;padding-bottom:3rem}.py-16{padding-top:4rem;padding-bottom:4rem}.py-2{padding-top:.5rem;padding-bottom:.5rem}.py-2\.5{padding-top:.625rem;padding-bottom:.625rem}.py-3{padding-top:.75rem;padding-bottom:.75rem}.py-4{padding-top:1rem;padding-bottom:1rem}.py-5{padding-top:1.25rem;padding-bottom:1.25rem}.py-6{padding-top:1.5rem;padding-bottom:1.5rem}.py-8{padding-top:2rem;padding-bottom:2rem}.pb-1{padding-bottom:.25rem}.pb-3{padding-bottom:.75rem}.pb-4{padding-bottom:1rem}.pb-5{padding-bottom:1.25rem}.pb-6{padding-bottom:1.5rem}.pl-0\.5{padding-left:.125rem}.pl-2{padding-left:.5rem}.pl-3{padding-left:.75rem}.pl-3\.5{padding-left:.875rem}.pl-4{padding-left:1rem}.pl-5{padding-left:1.25rem}.pl-7{padding-left:1.75rem}.pr-10{padding-right:2.5rem}.pr-14{padding-right:3.5rem}.pr-\[4\.75rem\]{padding-right:4.75rem}.pt-0\.5{padding-top:.125rem}.pt-1\.5{padding-top:.375rem}.pt-10{padding-top:2.5rem}.pt-2{padding-top:.5rem}.pt-3{padding-top:.75rem}.pt-4{padding-top:1rem}.pt-5{padding-top:1.25rem}.text-left{text-align:left}.text-center{text-align:center}.text-right{text-align:right}.align-top{vertical-align:top}.font-mono{font-family:Geist Mono Variable,SFMono-Regular,Menlo,ui-monospace,monospace}.font-sans{font-family:Geist Variable,PingFang SC,Microsoft YaHei,Noto Sans CJK SC,ui-sans-serif,system-ui,sans-serif}.text-3xl{font-size:1.875rem;line-height:2.25rem}.text-\[10px\]{font-size:10px}.text-\[11px\]{font-size:11px}.text-\[13px\]{font-size:13px}.text-\[15px\]{font-size:15px}.text-\[8px\]{font-size:8px}.text-\[9px\]{font-size:9px}.text-base{font-size:1rem;line-height:1.5rem}.text-lg{font-size:1.125rem;line-height:1.75rem}.text-sm{font-size:.875rem;line-height:1.25rem}.text-xl{font-size:1.25rem;line-height:1.75rem}.text-xs{font-size:.75rem;line-height:1rem}.font-bold{font-weight:700}.font-medium{font-weight:500}.font-normal{font-weight:400}.font-semibold{font-weight:600}.uppercase{text-transform:uppercase}.capitalize{text-transform:capitalize}.normal-case{text-transform:none}.italic{font-style:italic}.ordinal{--tw-ordinal:ordinal;font-variant-numeric:var(--tw-ordinal) var(--tw-slashed-zero) var(--tw-numeric-figure) var(--tw-numeric-spacing) var(--tw-numeric-fraction)}.tabular-nums{--tw-numeric-spacing:tabular-nums;font-variant-numeric:var(--tw-ordinal) var(--tw-slashed-zero) var(--tw-numeric-figure) var(--tw-numeric-spacing) var(--tw-numeric-fraction)}.leading-4{line-height:1rem}.leading-5{line-height:1.25rem}.leading-6{line-height:1.5rem}.leading-\[1\.625\]{line-height:1.625}.leading-none{line-height:1}.leading-relaxed{line-height:1.625}.leading-snug{line-height:1.375}.leading-tight{line-height:1.25}.tracking-\[-0\.01em\]{letter-spacing:-.01em}.tracking-\[0\.06em\]{letter-spacing:.06em}.tracking-\[0\.08em\]{letter-spacing:.08em}.tracking-\[0\.12em\]{letter-spacing:.12em}.tracking-\[0\.14em\]{letter-spacing:.14em}.tracking-\[0\.15em\]{letter-spacing:.15em}.tracking-\[0\.16em\]{letter-spacing:.16em}.tracking-\[0\.18em\]{letter-spacing:.18em}.tracking-normal{letter-spacing:0}.tracking-tight{letter-spacing:-.025em}.tracking-wide{letter-spacing:.025em}.tracking-wider{letter-spacing:.05em}.tracking-widest{letter-spacing:.1em}.text-bg{--tw-text-opacity:1;color:rgb(var(--bg) / var(--tw-text-opacity,1))}.text-blue{--tw-text-opacity:1;color:rgb(var(--blue) / var(--tw-text-opacity,1))}.text-blue-sky{--tw-text-opacity:1;color:rgb(var(--blue-sky) / var(--tw-text-opacity,1))}.text-blue\/75{color:rgb(var(--blue) / .75)}.text-err{--tw-text-opacity:1;color:rgb(var(--err) / var(--tw-text-opacity,1))}.text-gold{--tw-text-opacity:1;color:rgb(var(--gold) / var(--tw-text-opacity,1))}.text-ink{--tw-text-opacity:1;color:rgb(var(--ink) / var(--tw-text-opacity,1))}.text-ink-dim{--tw-text-opacity:1;color:rgb(var(--ink-dim) / var(--tw-text-opacity,1))}.text-ink-faint{--tw-text-opacity:1;color:rgb(var(--ink-faint) / var(--tw-text-opacity,1))}.text-manager{--tw-text-opacity:1;color:rgb(var(--role-manager) / var(--tw-text-opacity,1))}.text-ok{--tw-text-opacity:1;color:rgb(var(--ok) / var(--tw-text-opacity,1))}.text-warn{--tw-text-opacity:1;color:rgb(var(--warn) / var(--tw-text-opacity,1))}.text-white{--tw-text-opacity:1;color:rgb(255 255 255/var(--tw-text-opacity,1))}.underline{text-decoration-line:underline}.line-through{text-decoration-line:line-through}.decoration-blue\/35{-webkit-text-decoration-color:rgb(var(--blue) / .35);text-decoration-color:rgb(var(--blue) / .35)}.decoration-line{-webkit-text-decoration-color:rgb(var(--line) / 1);text-decoration-color:rgb(var(--line) / 1)}.underline-offset-2{text-underline-offset:2px}.underline-offset-4{text-underline-offset:4px}.accent-blue{accent-color:rgb(var(--blue) / 1)}.opacity-0{opacity:0}.opacity-100{opacity:1}.opacity-60{opacity:.6}.opacity-70{opacity:.7}.shadow{--tw-shadow:0 1px 3px 0 #0000001a, 0 1px 2px -1px #0000001a;--tw-shadow-colored:0 1px 3px 0 var(--tw-shadow-color), 0 1px 2px -1px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow,0 0 #0000), var(--tw-ring-shadow,0 0 #0000), var(--tw-shadow)}.shadow-2xl{--tw-shadow:0 25px 50px -12px #00000040;--tw-shadow-colored:0 25px 50px -12px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow,0 0 #0000), var(--tw-ring-shadow,0 0 #0000), var(--tw-shadow)}.shadow-\[0_10px_24px_-20px_rgb\(0_0_0\/0\.2\)\]{--tw-shadow:0 10px 24px -20px #0003;--tw-shadow-colored:0 10px 24px -20px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow,0 0 #0000), var(--tw-ring-shadow,0 0 #0000), var(--tw-shadow)}.shadow-glow{--tw-shadow:0 16px 44px #00000057;--tw-shadow-colored:0 16px 44px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow,0 0 #0000), var(--tw-ring-shadow,0 0 #0000), var(--tw-shadow)}.shadow-lg{--tw-shadow:0 10px 15px -3px #0000001a, 0 4px 6px -4px #0000001a;--tw-shadow-colored:0 10px 15px -3px var(--tw-shadow-color), 0 4px 6px -4px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow,0 0 #0000), var(--tw-ring-shadow,0 0 #0000), var(--tw-shadow)}.shadow-sm{--tw-shadow:0 1px 2px 0 #0000000d;--tw-shadow-colored:0 1px 2px 0 var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow,0 0 #0000), var(--tw-ring-shadow,0 0 #0000), var(--tw-shadow)}.shadow-xl{--tw-shadow:0 20px 25px -5px #0000001a, 0 8px 10px -6px #0000001a;--tw-shadow-colored:0 20px 25px -5px var(--tw-shadow-color), 0 8px 10px -6px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow,0 0 #0000), var(--tw-ring-shadow,0 0 #0000), var(--tw-shadow)}.outline-none{outline-offset:2px;outline:2px solid #0000}.ring-1{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow,0 0 #0000)}.ring-2{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow,0 0 #0000)}.ring-4{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(4px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow,0 0 #0000)}.ring-bg{--tw-ring-opacity:1;--tw-ring-color:rgb(var(--bg) / var(--tw-ring-opacity,1))}.ring-err\/30{--tw-ring-color:rgb(var(--err) / .3)}.ring-line\/35{--tw-ring-color:rgb(var(--line) / .35)}.ring-manager\/60{--tw-ring-color:rgb(var(--role-manager) / .6)}.ring-ok\/30{--tw-ring-color:rgb(var(--ok) / .3)}.ring-offset-1{--tw-ring-offset-width:1px}.ring-offset-panel{--tw-ring-offset-color:rgb(var(--panel) / 1)}.blur{--tw-blur:blur(8px);filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.backdrop-blur{--tw-backdrop-blur:blur(8px);-webkit-backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia);backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia)}.backdrop-blur-sm{--tw-backdrop-blur:blur(4px);-webkit-backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia);backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia)}.transition{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,-webkit-backdrop-filter,backdrop-filter;transition-duration:.15s;transition-timing-function:cubic-bezier(.4,0,.2,1)}.transition-\[width\,transform\,visibility\]{transition-property:width,transform,visibility;transition-duration:.15s;transition-timing-function:cubic-bezier(.4,0,.2,1)}.transition-\[width\]{transition-property:width;transition-duration:.15s;transition-timing-function:cubic-bezier(.4,0,.2,1)}.transition-all{transition-property:all;transition-duration:.15s;transition-timing-function:cubic-bezier(.4,0,.2,1)}.transition-colors{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-duration:.15s;transition-timing-function:cubic-bezier(.4,0,.2,1)}.transition-opacity{transition-property:opacity;transition-duration:.15s;transition-timing-function:cubic-bezier(.4,0,.2,1)}.transition-shadow{transition-property:box-shadow;transition-duration:.15s;transition-timing-function:cubic-bezier(.4,0,.2,1)}.transition-transform{transition-property:transform;transition-duration:.15s;transition-timing-function:cubic-bezier(.4,0,.2,1)}.duration-150{transition-duration:.15s}.duration-200{transition-duration:.2s}.duration-500{transition-duration:.5s}.duration-\[250ms\]{transition-duration:.25s}.duration-panel{transition-duration:.22s}.ease-panel{transition-timing-function:cubic-bezier(.4,0,.2,1)}:root{--lightningcss-light:initial;--lightningcss-dark: ;color-scheme:light;--bg:245 245 247;--surface:255 255 255;--panel:250 250 252;--panel-raised:255 255 255;--line:232 232 235;--ink:29 29 31;--ink-dim:80 80 84;--ink-faint:99 99 102;--blue:0 102 204;--blue-deep:0 82 172;--blue-sky:0 102 204;--gold:0 102 204;--gold-soft:0 102 204;--gold-deep:0 82 172;--ok:0 102 204;--warn:99 99 102;--err:29 29 31;--role-manager:37 99 235;--role-planner:124 58 237;--role-engineer:15 118 110;--role-reviewer:180 83 9;--conversation-user:238 238 240;--conversation-argus:246 248 252;--glass:255 255 255;--glass-raised:255 255 255;--glass-edge:224 224 228;--chrome-surface:248 248 250;--brand-body:0 0 0;--brand-eye:255 255 255;--brand-pupil:0 0 0;--brand-highlight:255 255 255}:root[data-theme=dark]{--lightningcss-light: ;--lightningcss-dark:initial;color-scheme:dark;--bg:0 0 0;--surface:22 22 24;--panel:28 28 30;--panel-raised:36 36 38;--line:58 58 60;--ink:245 245 247;--ink-dim:199 199 204;--ink-faint:162 162 167;--blue:64 156 255;--blue-deep:10 102 194;--blue-sky:100 175 255;--gold:64 156 255;--gold-soft:64 156 255;--gold-deep:10 102 194;--ok:64 156 255;--warn:174 174 178;--err:245 245 247;--role-manager:96 165 250;--role-planner:196 181 253;--role-engineer:52 211 153;--role-reviewer:251 191 36;--conversation-user:44 44 46;--conversation-argus:25 31 40;--glass:28 28 30;--glass-raised:36 36 38;--glass-edge:72 72 74;--chrome-surface:22 22 24;--brand-body:215 217 220;--brand-eye:255 255 255;--brand-pupil:32 35 38;--brand-highlight:255 255 255;font-synthesis:none}:root[data-theme-style=gradient]{--ambient-blue:7 95 228;--ambient-gold:207 153 49}:root[data-theme=dark][data-theme-style=gradient]{--ambient-blue:110 168 255;--ambient-gold:237 201 111}html,body,#root{height:100%}body{background:rgb(var(--bg) / 1);color:rgb(var(--ink) / 1);font-optical-sizing:auto;font-feature-settings:"ss01" 1, "cv02" 1, "cv03" 1, "cv04" 1;-webkit-font-smoothing:antialiased;text-rendering:optimizelegibility;margin:0;font-family:Geist Variable,PingFang SC,Microsoft YaHei,Noto Sans CJK SC,ui-sans-serif,system-ui,sans-serif;overflow:hidden}select:not([multiple]){appearance:none;background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16' fill='none'%3E%3Cpath d='m5 6.5 3 3 3-3' stroke='%236e6e73' stroke-width='1.35' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");background-position:right .6rem center;background-repeat:no-repeat;background-size:1rem;transition:border-color .14s,background-color .14s,box-shadow .14s;padding-right:1.9rem!important}:root[data-theme=dark] select:not([multiple]){background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16' fill='none'%3E%3Cpath d='m5 6.5 3 3 3-3' stroke='%23a2a2a7' stroke-width='1.35' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E")}select:not([multiple]):focus-visible{box-shadow:0 0 0 3px rgb(var(--blue) / 10%);border-color:rgb(var(--blue) / 58%)!important}select option,select optgroup{background:rgb(var(--panel-raised));color:rgb(var(--ink))}.workbench-shell{isolation:isolate;background:rgb(var(--bg));height:100dvh}.workbench-shell[data-resizing] [data-resizable-panel]{transition-duration:0s!important}:root[data-theme=dark] .workbench-shell{background:rgb(var(--bg))}:root[data-theme-style=gradient] .workbench-shell{background:radial-gradient(circle at 8% 0%, rgb(var(--ambient-blue) / 15%), transparent 36rem), radial-gradient(circle at 92% 100%, rgb(var(--ambient-gold) / 14%), transparent 34rem), rgb(var(--bg))}:root[data-theme=dark][data-theme-style=gradient] .workbench-shell{background:radial-gradient(circle at 8% 0%, rgb(var(--ambient-blue) / 20%), transparent 38rem), radial-gradient(circle at 92% 100%, rgb(var(--ambient-gold) / 17%), transparent 36rem), rgb(var(--bg))}.ambient-canvas{position:relative}.ambient-canvas:before{content:none}.glass-panel,.glass-panel--side,.glass-panel--main,.glass-panel--raised{border-color:rgb(var(--line));background:rgb(var(--panel));box-shadow:none;-webkit-backdrop-filter:none;backdrop-filter:none}.glass-panel--side{background:rgb(var(--surface) / 94%)}.glass-panel--main{background:rgb(var(--panel) / 96%)}.glass-panel--raised{background:rgb(var(--panel-raised));box-shadow:0 8px 28px #00000014}.chrome-seam-surface{background:rgb(var(--chrome-surface));box-shadow:none;-webkit-backdrop-filter:none;backdrop-filter:none}.glass-card{background:rgb(var(--surface));box-shadow:none;border:0}.mission-status-line{--mission-status-color:var(--blue);border:1px solid rgb(var(--glass-edge) / 52%);border-left:2px solid rgb(var(--mission-status-color) / 82%);background:rgb(var(--glass-raised) / 42%);box-shadow:none;border-radius:.5rem;margin-top:1rem;padding:.75rem .875rem}.mission-status-line__signal{color:rgb(var(--ink));align-items:center;gap:.625rem;font-size:.875rem;font-weight:600;line-height:1.4;display:flex}.mission-status-line__marker{background:rgb(var(--mission-status-color));width:.5rem;height:.5rem;box-shadow:0 0 0 3px rgb(var(--mission-status-color) / 12%);border-radius:999px;flex:none}.mission-status-line__subtitle{color:rgb(var(--ink-dim));margin-top:.375rem;padding-left:1.125rem;font-size:.75rem;line-height:1.5}.mission-status-line[data-tone=done]{--mission-status-color:var(--blue)}.mission-status-line[data-tone=error]{--mission-status-color:var(--err)}.mission-status-line[data-tone=waiting]{--mission-status-color:var(--ink-faint)}.brand-button{z-index:0;isolation:isolate;border:1px solid #0000;border-radius:8px;min-height:32px;padding:.3rem .7rem;font-size:.75rem;font-weight:600;transition:color .18s,box-shadow .18s,filter .18s;position:relative;overflow:hidden}.brand-button:before,.brand-button:after{content:none}.brand-button-primary{border-color:rgb(var(--blue) / 34%);background:rgb(var(--blue) / 8%);color:rgb(var(--blue));box-shadow:none}.brand-button-ghost{color:rgb(var(--ink-dim));background:0 0}.brand-button-danger{border-color:rgb(var(--ink));background:rgb(var(--ink));color:rgb(var(--bg))}.brand-button:disabled{cursor:not-allowed;filter:grayscale(.45);opacity:.42}.panel-header{border-color:rgb(var(--line) / 70%);background:0 0}.modal-scrim{background:#00000052}.brand-modal{border:1px solid rgb(var(--glass-edge) / 80%);background:rgb(var(--panel-raised));box-shadow:0 24px 80px #0000002e,0 2px 10px #00000012}:root[data-theme=dark] .brand-modal{border-color:rgb(var(--glass-edge) / 72%);box-shadow:0 28px 90px #0000008c,0 2px 10px #00000047}.modal-close{z-index:2;background:rgb(var(--conversation-user) / 78%);width:2rem;height:2rem;color:rgb(var(--ink-faint));border:1px solid #0000;border-radius:999px;place-items:center;transition:border-color .14s,background-color .14s,color .14s,transform .14s;display:grid;position:absolute;top:.75rem;right:.75rem}.modal-close svg{fill:none;stroke:currentColor;stroke-linecap:round;stroke-width:1.4px;width:.9rem;height:.9rem}.modal-close:hover{border-color:rgb(var(--line));background:rgb(var(--ink));color:rgb(var(--bg))}.modal-close:active{transform:scale(.94)}.modal-close:focus-visible{outline:2px solid rgb(var(--blue) / 65%);outline-offset:2px}.handshake-mark{color:rgb(var(--ink));box-shadow:none}.handshake-line{background:rgb(var(--blue))}.handshake-node{border-color:rgb(var(--line));background:rgb(var(--surface));box-shadow:none}.icon-control,.compact-control,.send-control{color:rgb(var(--ink-faint));box-shadow:none;background:0 0;border:1px solid #0000;border-radius:8px;transition:border-color .18s,background-color .18s,color .18s,box-shadow .18s}.compact-control{font-size:.75rem}.send-control{border-color:rgb(var(--blue) / 34%);background:rgb(var(--blue) / 8%);color:rgb(var(--blue));box-shadow:none}.session-card{background:0 0;border:1px solid #0000}.session-card[data-active=true]{background:rgb(var(--blue) / 8%);box-shadow:inset 2px 0 0 rgb(var(--blue));border-color:#0000}.workspace-tabs{background:rgb(var(--surface));width:284px;box-shadow:none;border:0;border-radius:8px;grid-template-columns:repeat(4,minmax(0,1fr));padding:2px;display:grid;position:relative}.workspace-tab{z-index:1;height:26px;color:rgb(var(--ink-faint));border-radius:6px;font-size:.75rem;transition:color .2s;position:relative}.workspace-tab[data-selected=true]{color:rgb(var(--ink))}.workspace-tab-indicator{background:rgb(var(--panel-raised));width:calc(25% - 1px);box-shadow:none;border:0;border-radius:6px;transition:transform .2s cubic-bezier(.2,.8,.2,1);position:absolute;top:2px;bottom:2px;left:2px}.workspace-tabs[data-active=activity] .workspace-tab-indicator{transform:translate(100%)}.workspace-tabs[data-active=workbench] .workspace-tab-indicator{transform:translate(200%)}.workspace-tabs[data-active=map] .workspace-tab-indicator{transform:translate(300%)}.workbench-module-tab{min-height:30px;color:rgb(var(--ink-faint));border:1px solid #0000;border-radius:.5rem;align-items:center;gap:.35rem;padding:.35rem .6rem;font-size:.72rem;transition:border-color .16s,background .16s,color .16s;display:inline-flex}.workbench-module-tab:hover{border-color:rgb(var(--glass-edge) / 55%);background:rgb(var(--glass-raised) / 45%);color:rgb(var(--ink))}.workbench-module-tab[data-selected=true]{border-color:rgb(var(--blue) / 35%);background:rgb(var(--blue) / 8%);color:rgb(var(--ink));box-shadow:none}.role-log-group{transition:background-color .2s,box-shadow .2s;position:relative}.role-log-group:before{content:"";opacity:0;background:rgb(var(--blue));border-radius:999px;width:2px;transition:opacity .2s,box-shadow .2s;position:absolute;inset:5px auto 5px 0}.role-log-group[data-open=true]{background:rgb(var(--blue) / 4%)}.role-log-group[data-open=true]:before{opacity:1}.role-log-group[data-active=true]:before{box-shadow:none}@media (hover:hover) and (pointer:fine){.icon-control:hover,.compact-control:hover{background-color:rgb(var(--conversation-user));color:rgb(var(--ink));box-shadow:none;border-color:#0000}.session-card:hover{background:rgb(var(--conversation-user) / 55%);border-color:#0000}.brand-button:hover{background:rgb(var(--conversation-user));box-shadow:none;border-color:#0000}.brand-button-primary:hover,.send-control:hover{border-color:rgb(var(--blue-deep));background:rgb(var(--blue-deep));color:#fff}}@media (hover:none),(pointer:coarse){.brand-button:active{filter:brightness(.92)}}.theme-style-option{border:1px solid rgb(var(--line));background:rgb(var(--surface));min-height:72px;color:rgb(var(--ink));text-align:left;border-radius:10px;grid-template-columns:44px minmax(0,1fr) 18px;align-items:center;gap:.75rem;padding:.75rem;transition:border-color .16s,background-color .16s;display:grid;position:relative}.theme-style-option[data-selected=true]{border-color:rgb(var(--blue) / 58%);background:rgb(var(--blue) / 5%)}.theme-style-preview{border:1px solid rgb(var(--line));border-radius:8px;width:44px;height:32px}.theme-style-preview--standard{background:linear-gradient(135deg, rgb(var(--ink)) 0 48%, rgb(var(--blue)) 48% 100%)}.theme-style-preview--gradient{background:linear-gradient(135deg,#075fe4,#0b2e68 54%,#cf9931)}.theme-style-check{border:1px solid rgb(var(--line));color:#0000;border-radius:999px;place-items:center;width:18px;height:18px;font-size:9px;display:grid}.theme-style-option[data-selected=true] .theme-style-check{border-color:rgb(var(--blue));background:rgb(var(--blue));color:#fff}:root{--safe-top:env(safe-area-inset-top,0px);--safe-bottom:env(safe-area-inset-bottom,0px);--safe-left:env(safe-area-inset-left,0px);--safe-right:env(safe-area-inset-right,0px);--mobile-tabbar-height:calc(3.25rem + var(--safe-bottom));--keyboard-inset:0px}.safe-inset-x{padding-left:var(--safe-left);padding-right:var(--safe-right)}.safe-inset-top{padding-top:var(--safe-top)}.safe-inset-bottom{padding-bottom:var(--safe-bottom)}@media (pointer:coarse){.icon-control,.compact-control,.workspace-tab{position:relative}.icon-control:after,.compact-control:after,.workspace-tab:after{content:"";width:max(100%,44px);height:max(100%,44px);position:absolute;top:50%;left:50%;transform:translate(-50%,-50%)}}@media (width<=1023px){.mobile-scroll-region{padding-bottom:calc(var(--mobile-tabbar-height) + .5rem)}}.mobile-tabbar{bottom:var(--keyboard-inset);padding-bottom:var(--safe-bottom);padding-left:var(--safe-left);padding-right:var(--safe-right);transition:bottom .12s ease-out}.composer-dock{padding-bottom:calc(var(--keyboard-inset) + 1.5rem);transition:padding-bottom .12s ease-out}@media (width<=1023px){.composer-dock{padding-bottom:calc(var(--mobile-tabbar-height) + var(--keyboard-inset) + 1.5rem)}}@media (prefers-reduced-motion:reduce){.composer-dock,.mobile-tabbar{transition:none}}@keyframes argus-web-splash-exit{0%,78%{opacity:1}to{opacity:0}}@keyframes argus-web-splash-eye{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.argus-web-splash{z-index:200;cursor:pointer;background:rgb(var(--bg));will-change:opacity;justify-content:center;align-items:center;animation:.82s ease-out forwards argus-web-splash-exit;display:flex;position:fixed;inset:0;overflow:hidden}.argus-web-splash-logo{color:rgb(var(--ink));-webkit-user-select:none;user-select:none}.argus-web-splash-logo .argus-mark-eye{transform-box:fill-box;transform-origin:50%;animation:.68s cubic-bezier(.45,0,.25,1) forwards argus-web-splash-eye}@media (prefers-reduced-motion:reduce){.argus-web-splash-logo .argus-mark-eye{animation:none}}::selection{color:rgb(var(--ink) / 1);background:#3f6f9f8c}button,input,textarea{font:inherit}button{-webkit-tap-highlight-color:transparent}:where(button,input,textarea):focus-visible{outline:2px solid rgb(var(--blue-sky) / 1);outline-offset:2px}@media (prefers-reduced-motion:reduce){*,:before,:after{transition-duration:.01ms!important;animation-duration:.01ms!important;animation-iteration-count:1!important}.scroll-smooth{scroll-behavior:auto!important}.ambient-canvas:before{animation:none!important}}.scroll-thin::-webkit-scrollbar{width:7px;height:7px}.scroll-thin{scrollbar-gutter:stable;scrollbar-width:thin;scrollbar-color:rgb(var(--ink-faint) / 45%) transparent}.scroll-thin::-webkit-scrollbar-thumb{background:rgb(var(--ink-faint) / 38%);border:1px solid rgb(var(--panel) / 80%);border-radius:9999px}.scroll-thin::-webkit-scrollbar-thumb:hover{background:rgb(var(--ink-faint) / 65%)}.scroll-thin::-webkit-scrollbar-track{background:0 0;border-radius:9999px}.slash-completion-menu{overscroll-behavior:contain;max-height:min(22rem,42dvh);overflow-y:auto}:root[data-argus-embedded=true] .ambient-canvas:before{will-change:auto;animation:none;transform:translate(0,0)scale(1.04)}:root[data-argus-embedded=true] :is(.glass-panel,.glass-panel--side,.glass-panel--main,.glass-panel--raised){-webkit-backdrop-filter:blur(8px)saturate(1.06);backdrop-filter:blur(8px)saturate(1.06)}@supports (content-visibility:auto){:root[data-argus-embedded=true] .conversation-thread{content-visibility:auto;contain-intrinsic-size:auto 180px}:root[data-argus-embedded=true] .event-activity-row{content-visibility:auto;contain-intrinsic-size:auto 56px}}.placeholder\:text-ink-faint::placeholder{--tw-text-opacity:1;color:rgb(var(--ink-faint) / var(--tw-text-opacity,1))}.first\:mt-0:first-child{margin-top:0}.last\:mb-0:last-child{margin-bottom:0}.last\:border-0:last-child{border-width:0}.last\:border-b-0:last-child{border-bottom-width:0}.last\:pb-0:last-child{padding-bottom:0}.focus-within\:border-blue\/60:focus-within{border-color:rgb(var(--blue) / .6)}.hover\:border-blue:hover{--tw-border-opacity:1;border-color:rgb(var(--blue) / var(--tw-border-opacity,1))}.hover\:border-blue-deep:hover{--tw-border-opacity:1;border-color:rgb(var(--blue-deep) / var(--tw-border-opacity,1))}.hover\:border-blue-sky\/50:hover{border-color:rgb(var(--blue-sky) / .5)}.hover\:border-blue-sky\/60:hover{border-color:rgb(var(--blue-sky) / .6)}.hover\:border-blue\/45:hover{border-color:rgb(var(--blue) / .45)}.hover\:border-blue\/50:hover{border-color:rgb(var(--blue) / .5)}.hover\:border-blue\/60:hover{border-color:rgb(var(--blue) / .6)}.hover\:border-err\/50:hover{border-color:rgb(var(--err) / .5)}.hover\:border-ink-faint:hover{--tw-border-opacity:1;border-color:rgb(var(--ink-faint) / var(--tw-border-opacity,1))}.hover\:border-line\/70:hover{border-color:rgb(var(--line) / .7)}.hover\:border-ok:hover{--tw-border-opacity:1;border-color:rgb(var(--ok) / var(--tw-border-opacity,1))}.hover\:bg-bg:hover{--tw-bg-opacity:1;background-color:rgb(var(--bg) / var(--tw-bg-opacity,1))}.hover\:bg-bg\/30:hover{background-color:rgb(var(--bg) / .3)}.hover\:bg-bg\/60:hover{background-color:rgb(var(--bg) / .6)}.hover\:bg-bg\/70:hover{background-color:rgb(var(--bg) / .7)}.hover\:bg-blue-deep:hover{--tw-bg-opacity:1;background-color:rgb(var(--blue-deep) / var(--tw-bg-opacity,1))}.hover\:bg-blue-deep\/20:hover{background-color:rgb(var(--blue-deep) / .2)}.hover\:bg-blue-deep\/80:hover{background-color:rgb(var(--blue-deep) / .8)}.hover\:bg-blue\/10:hover{background-color:rgb(var(--blue) / .1)}.hover\:bg-blue\/15:hover{background-color:rgb(var(--blue) / .15)}.hover\:bg-err\/10:hover{background-color:rgb(var(--err) / .1)}.hover\:bg-line\/20:hover{background-color:rgb(var(--line) / .2)}.hover\:bg-ok\/10:hover{background-color:rgb(var(--ok) / .1)}.hover\:bg-ok\/15:hover{background-color:rgb(var(--ok) / .15)}.hover\:bg-panel:hover{--tw-bg-opacity:1;background-color:rgb(var(--panel) / var(--tw-bg-opacity,1))}.hover\:bg-panel-raised:hover{--tw-bg-opacity:1;background-color:rgb(var(--panel-raised) / var(--tw-bg-opacity,1))}.hover\:bg-panel\/60:hover{background-color:rgb(var(--panel) / .6)}.hover\:bg-panel\/80:hover{background-color:rgb(var(--panel) / .8)}.hover\:bg-surface:hover{--tw-bg-opacity:1;background-color:rgb(var(--surface) / var(--tw-bg-opacity,1))}.hover\:bg-warn\/10:hover{background-color:rgb(var(--warn) / .1)}.hover\:bg-white\/5:hover{background-color:#ffffff0d}.hover\:text-blue:hover{--tw-text-opacity:1;color:rgb(var(--blue) / var(--tw-text-opacity,1))}.hover\:text-blue-sky:hover{--tw-text-opacity:1;color:rgb(var(--blue-sky) / var(--tw-text-opacity,1))}.hover\:text-err:hover{--tw-text-opacity:1;color:rgb(var(--err) / var(--tw-text-opacity,1))}.hover\:text-gold:hover{--tw-text-opacity:1;color:rgb(var(--gold) / var(--tw-text-opacity,1))}.hover\:text-gold-soft:hover{--tw-text-opacity:1;color:rgb(var(--gold-soft) / var(--tw-text-opacity,1))}.hover\:text-ink:hover{--tw-text-opacity:1;color:rgb(var(--ink) / var(--tw-text-opacity,1))}.hover\:text-ink-dim:hover{--tw-text-opacity:1;color:rgb(var(--ink-dim) / var(--tw-text-opacity,1))}.hover\:text-white:hover{--tw-text-opacity:1;color:rgb(255 255 255/var(--tw-text-opacity,1))}.hover\:decoration-blue:hover{-webkit-text-decoration-color:rgb(var(--blue) / 1);text-decoration-color:rgb(var(--blue) / 1)}.hover\:opacity-100:hover{opacity:1}.focus\:border-blue:focus{--tw-border-opacity:1;border-color:rgb(var(--blue) / var(--tw-border-opacity,1))}.focus\:border-blue-deep:focus{--tw-border-opacity:1;border-color:rgb(var(--blue-deep) / var(--tw-border-opacity,1))}.focus\:border-blue\/60:focus{border-color:rgb(var(--blue) / .6)}.focus-visible\:outline-none:focus-visible{outline-offset:2px;outline:2px solid #0000}.focus-visible\:outline:focus-visible{outline-style:solid}.focus-visible\:outline-2:focus-visible{outline-width:2px}.focus-visible\:outline-offset-2:focus-visible{outline-offset:2px}.focus-visible\:outline-blue:focus-visible{outline-color:rgb(var(--blue) / 1)}.focus-visible\:ring-2:focus-visible{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow,0 0 #0000)}.focus-visible\:ring-blue-sky\/50:focus-visible{--tw-ring-color:rgb(var(--blue-sky) / .5)}.focus-visible\:ring-blue\/50:focus-visible{--tw-ring-color:rgb(var(--blue) / .5)}.active\:bg-panel-raised:active{--tw-bg-opacity:1;background-color:rgb(var(--panel-raised) / var(--tw-bg-opacity,1))}.enabled\:hover\:text-blue-sky:hover:enabled{--tw-text-opacity:1;color:rgb(var(--blue-sky) / var(--tw-text-opacity,1))}.enabled\:focus-visible\:underline:focus-visible:enabled{text-decoration-line:underline}.enabled\:focus-visible\:outline-none:focus-visible:enabled{outline-offset:2px;outline:2px solid #0000}.disabled\:cursor-not-allowed:disabled{cursor:not-allowed}.disabled\:cursor-wait:disabled{cursor:wait}.disabled\:text-ink-faint:disabled{--tw-text-opacity:1;color:rgb(var(--ink-faint) / var(--tw-text-opacity,1))}.disabled\:opacity-35:disabled{opacity:.35}.disabled\:opacity-40:disabled{opacity:.4}.disabled\:opacity-45:disabled{opacity:.45}.disabled\:opacity-50:disabled{opacity:.5}.disabled\:opacity-60:disabled{opacity:.6}.group:focus-within .group-focus-within\:opacity-100{opacity:1}.group:hover .group-hover\:bg-blue\/70{background-color:rgb(var(--blue) / .7)}.group:hover .group-hover\:bg-ink-faint\/30{background-color:rgb(var(--ink-faint) / .3)}.group:hover .group-hover\:opacity-100{opacity:1}.group:focus .group-focus\:bg-blue\/70{background-color:rgb(var(--blue) / .7)}@media (prefers-reduced-motion:reduce){.motion-reduce\:animate-none{animation:none}}@media (width>=640px){.sm\:left-auto{left:auto}.sm\:order-none{order:0}.sm\:block{display:block}.sm\:inline{display:inline}.sm\:h-20{height:5rem}.sm\:max-h-\[88dvh\]{max-height:88dvh}.sm\:w-20{width:5rem}.sm\:w-auto{width:auto}.sm\:max-w-48{max-width:12rem}.sm\:max-w-\[82\%\]{max-width:82%}.sm\:max-w-md{max-width:28rem}.sm\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.sm\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.sm\:grid-cols-\[100px_minmax\(0\,1fr\)\]{grid-template-columns:100px minmax(0,1fr)}.sm\:grid-cols-\[minmax\(0\,1fr\)_auto\]{grid-template-columns:minmax(0,1fr) auto}.sm\:grid-cols-\[minmax\(0\,1fr\)_minmax\(0\,1fr\)_auto\]{grid-template-columns:minmax(0,1fr) minmax(0,1fr) auto}.sm\:flex-nowrap{flex-wrap:nowrap}.sm\:gap-3{gap:.75rem}.sm\:p-3{padding:.75rem}.sm\:p-4{padding:1rem}.sm\:p-5{padding:1.25rem}.sm\:px-4{padding-left:1rem;padding-right:1rem}.sm\:px-5{padding-left:1.25rem;padding-right:1.25rem}.sm\:px-6{padding-left:1.5rem;padding-right:1.5rem}.sm\:pt-14{padding-top:3.5rem}.sm\:text-right{text-align:right}.sm\:opacity-0{opacity:0}.group:focus-within .sm\:group-focus-within\:opacity-100,.group:hover .sm\:group-hover\:opacity-100{opacity:1}}@media (width>=768px){.md\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}}@media (width>=1024px){.lg\:visible{visibility:visible}.lg\:static{position:static}.lg\:z-auto{z-index:auto}.lg\:col-span-2{grid-column:span 2/span 2}.lg\:flex{display:flex}.lg\:grid{display:grid}.lg\:hidden{display:none}.lg\:w-14{width:3.5rem}.lg\:w-\[var\(--preview-width\)\]{width:var(--preview-width)}.lg\:w-\[var\(--sidebar-width\)\]{width:var(--sidebar-width)}.lg\:max-w-\[61\.8vw\]{max-width:61.8vw}.lg\:flex-none{flex:none}.lg\:translate-x-0{--tw-translate-x:0px;transform:translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.lg\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.lg\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.lg\:grid-cols-\[minmax\(0\,1\.15fr\)_minmax\(260px\,0\.85fr\)\]{grid-template-columns:minmax(0,1.15fr) minmax(260px,.85fr)}.lg\:grid-cols-\[minmax\(0\,1\.4fr\)_minmax\(300px\,0\.8fr\)\]{grid-template-columns:minmax(0,1.4fr) minmax(300px,.8fr)}.lg\:grid-cols-\[minmax\(15rem\,0\.72fr\)_minmax\(0\,1\.8fr\)\]{grid-template-columns:minmax(15rem,.72fr) minmax(0,1.8fr)}.lg\:gap-3{gap:.75rem}.lg\:space-y-0>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(0px * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(0px * var(--tw-space-y-reverse))}.lg\:overflow-hidden{overflow:hidden}.lg\:border-b-0{border-bottom-width:0}.lg\:border-r{border-right-width:1px}}@media (width>=1280px){.xl\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.xl\:grid-cols-\[minmax\(0\,1fr\)_minmax\(18rem\,0\.85fr\)\]{grid-template-columns:minmax(0,1fr) minmax(18rem,.85fr)}.xl\:border-b-0{border-bottom-width:0}.xl\:border-r{border-right-width:1px}} diff --git a/frontend/web/dist/assets/index-CpMiioIG.js b/frontend/web/dist/assets/index-CpMiioIG.js new file mode 100644 index 000000000..ea78709a6 --- /dev/null +++ b/frontend/web/dist/assets/index-CpMiioIG.js @@ -0,0 +1,32 @@ +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/motion-sqs9Ax-g.js","assets/rolldown-runtime-hePW80VL.js","assets/ResearchWorkbenchPanel-B7craOIV.js","assets/icons-2gFhc0pq.js","assets/query-CGMsBv4s.js","assets/play-4uDgOsGD.js","assets/ResearchWorkbenchPanel-BXRghxPt.css","assets/MapPanel-BHfjXA2X.js","assets/markdown-BtnlLdzu.js","assets/markdown-B3MBJsZb.css","assets/MapPanel-7aVAJo-I.css"])))=>i.map(i=>d[i]); +import{r as e,t}from"./rolldown-runtime-hePW80VL.js";import{A as n,C as r,D as i,E as a,O as o,S as s,T as c,_ as l,a as u,b as d,c as f,d as p,f as m,g as h,h as g,i as _,k as v,l as y,m as b,n as x,o as S,p as C,r as w,s as T,t as E,u as D,v as ee,w as O,x as te,y as ne}from"./icons-2gFhc0pq.js";import{_ as k,a as re,b as A,c as j,d as ie,f as ae,h as M,i as oe,l as se,m as N,n as ce,o as le,p as ue,r as de,s as fe,t as P,u as F,v as pe,y as me}from"./query-CGMsBv4s.js";import{i as he,n as ge,r as _e,t as ve}from"./markdown-BtnlLdzu.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var ye=t((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0>>1,a=e[r];if(0>>1;ri(c,n))li(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(li(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=typeof setTimeout==`function`?setTimeout:null,_=typeof clearTimeout==`function`?clearTimeout:null,v=typeof setImmediate<`u`?setImmediate:null;typeof navigator<`u`&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function y(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function b(e){if(h=!1,y(e),!m){if(n(c)!==null)m=!0,k(x);else{var t=n(l);t!==null&&re(b,t.startTime-e)}}}function x(t,i){m=!1,h&&(h=!1,_(w),w=-1),p=!0;var a=f;try{for(y(i),d=n(c);d!==null&&(!(d.expirationTime>i)||t&&!D());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=i);i=e.unstable_now(),typeof s==`function`?d.callback=s:d===n(c)&&r(c),y(i)}else r(c);d=n(c)}if(d!==null)var u=!0;else{var g=n(l);g!==null&&re(b,g.startTime-i),u=!1}return u}finally{d=null,f=a,p=!1}}var S=!1,C=null,w=-1,T=5,E=-1;function D(){return!(e.unstable_now()-Ee||125o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(_(w),w=-1):h=!0,re(b,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,k(x))),r},e.unstable_shouldYield=D,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),be=t(((e,t)=>{t.exports=ye()})),xe=t((e=>{var t=n(),r=be();function i(e){for(var t=`https://reactjs.org/docs/error-decoder.html?invariant=`+e,n=1;n`u`||window.document===void 0||window.document.createElement===void 0),u=Object.prototype.hasOwnProperty,d=/^[: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]*$/,f={},p={};function m(e){return u.call(p,e)?!0:u.call(f,e)?!1:d.test(e)?p[e]=!0:(f[e]=!0,!1)}function h(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?(e=e.toLowerCase().slice(0,5),e!==`data-`&&e!==`aria-`):!n.acceptsBooleans;default:return!1}}function g(e,t,n,r){if(t==null||h(e,t,n,r))return!0;if(r)return!1;if(n!==null)switch(n.type){case 3:return!t;case 4:return!1===t;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}function _(e,t,n,r,i,a,o){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=r,this.attributeNamespace=i,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=a,this.removeEmptyString=o}var v={};`children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style`.split(` `).forEach(function(e){v[e]=new _(e,0,!1,e,null,!1,!1)}),[[`acceptCharset`,`accept-charset`],[`className`,`class`],[`htmlFor`,`for`],[`httpEquiv`,`http-equiv`]].forEach(function(e){var t=e[0];v[t]=new _(t,1,!1,e[1],null,!1,!1)}),[`contentEditable`,`draggable`,`spellCheck`,`value`].forEach(function(e){v[e]=new _(e,2,!1,e.toLowerCase(),null,!1,!1)}),[`autoReverse`,`externalResourcesRequired`,`focusable`,`preserveAlpha`].forEach(function(e){v[e]=new _(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){v[e]=new _(e,3,!1,e.toLowerCase(),null,!1,!1)}),[`checked`,`multiple`,`muted`,`selected`].forEach(function(e){v[e]=new _(e,3,!0,e,null,!1,!1)}),[`capture`,`download`].forEach(function(e){v[e]=new _(e,4,!1,e,null,!1,!1)}),[`cols`,`rows`,`size`,`span`].forEach(function(e){v[e]=new _(e,6,!1,e,null,!1,!1)}),[`rowSpan`,`start`].forEach(function(e){v[e]=new _(e,5,!1,e.toLowerCase(),null,!1,!1)});var y=/[\-:]([a-z])/g;function b(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(y,b);v[t]=new _(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(y,b);v[t]=new _(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(y,b);v[t]=new _(t,1,!1,e,`http://www.w3.org/XML/1998/namespace`,!1,!1)}),[`tabIndex`,`crossOrigin`].forEach(function(e){v[e]=new _(e,1,!1,e.toLowerCase(),null,!1,!1)}),v.xlinkHref=new _(`xlinkHref`,1,!1,`xlink:href`,`http://www.w3.org/1999/xlink`,!0,!1),[`src`,`href`,`action`,`formAction`].forEach(function(e){v[e]=new _(e,1,!1,e.toLowerCase(),null,!0,!0)});function x(e,t,n,r){var i=v.hasOwnProperty(t)?v[t]:null;(i===null?r||!(2s||i[o]!==a[s]){var c=` +`+i[o].replace(` at new `,` at `);return e.displayName&&c.includes(``)&&(c=c.replace(``,e.displayName)),c}while(1<=o&&0<=s);break}}}finally{N=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:``)?se(e):``}function le(e){switch(e.tag){case 5:return se(e.type);case 16:return se(`Lazy`);case 13:return se(`Suspense`);case 19:return se(`SuspenseList`);case 0:case 2:case 15:return e=ce(e.type,!1),e;case 11:return e=ce(e.type.render,!1),e;case 1:return e=ce(e.type,!0),e;default:return``}}function ue(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 T:return`Fragment`;case w:return`Portal`;case D:return`Profiler`;case E:return`StrictMode`;case ne:return`Suspense`;case k:return`SuspenseList`}if(typeof e==`object`)switch(e.$$typeof){case O:return(e.displayName||`Context`)+`.Consumer`;case ee:return(e._context.displayName||`Context`)+`.Provider`;case te:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case re:return t=e.displayName||null,t===null?ue(e.type)||`Memo`:t;case A:t=e._payload,e=e._init;try{return ue(e(t))}catch{}}return null}function de(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`:`ForwardRef(`+e+`)`);case 7:return`Fragment`;case 5:return t;case 4:return`Portal`;case 3:return`Root`;case 6:return`Text`;case 16:return ue(t);case 8:return t===E?`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 fe(e){switch(typeof e){case`boolean`:case`number`:case`string`:case`undefined`:return e;case`object`:return e;default:return``}}function P(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()===`input`&&(t===`checkbox`||t===`radio`)}function F(e){var t=P(e)?`checked`:`value`,n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=``+e[t];if(!e.hasOwnProperty(t)&&n!==void 0&&typeof n.get==`function`&&typeof n.set==`function`){var i=n.get,a=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return i.call(this)},set:function(e){r=``+e,a.call(this,e)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(e){r=``+e},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function pe(e){e._valueTracker||=F(e)}function me(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r=``;return e&&(r=P(e)?e.checked?`true`:`false`:e.value),e=r,e!==n&&(t.setValue(e),!0)}function he(e){if(e||=typeof document<`u`?document:void 0,e===void 0)return null;try{return e.activeElement||e.body}catch{return e.body}}function ge(e,t){var n=t.checked;return M({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function _e(e,t){var n=t.defaultValue==null?``:t.defaultValue,r=t.checked==null?t.defaultChecked:t.checked;n=fe(t.value==null?n:t.value),e._wrapperState={initialChecked:r,initialValue:n,controlled:t.type===`checkbox`||t.type===`radio`?t.checked!=null:t.value!=null}}function ve(e,t){t=t.checked,t!=null&&x(e,`checked`,t,!1)}function ye(e,t){ve(e,t);var n=fe(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`)?Se(e,t.type,n):t.hasOwnProperty(`defaultValue`)&&Se(e,t.type,fe(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function xe(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 Se(e,t,n){(t!==`number`||he(e.ownerDocument)!==e)&&(n==null?e.defaultValue=``+e._wrapperState.initialValue:e.defaultValue!==``+n&&(e.defaultValue=``+n))}var Ce=Array.isArray;function we(e,t,n,r){if(e=e.options,t){t={};for(var i=0;i`+t.valueOf().toString()+``,t=Ae.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function Me(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var Ne={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},Pe=[`Webkit`,`ms`,`Moz`,`O`];Object.keys(Ne).forEach(function(e){Pe.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),Ne[t]=Ne[e]})});function Fe(e,t,n){return t==null||typeof t==`boolean`||t===``?``:n||typeof t!=`number`||t===0||Ne.hasOwnProperty(e)&&Ne[e]?(``+t).trim():t+`px`}function Ie(e,t){for(var n in e=e.style,t)if(t.hasOwnProperty(n)){var r=n.indexOf(`--`)===0,i=Fe(n,t[n],r);n===`float`&&(n=`cssFloat`),r?e.setProperty(n,i):e[n]=i}}var Le=M({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 Re(e,t){if(t){if(Le[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(i(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(i(60));if(typeof t.dangerouslySetInnerHTML!=`object`||!(`__html`in t.dangerouslySetInnerHTML))throw Error(i(61))}if(t.style!=null&&typeof t.style!=`object`)throw Error(i(62))}}function ze(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 Be=null;function Ve(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var He=null,Ue=null,We=null;function Ge(e){if(e=ji(e)){if(typeof He!=`function`)throw Error(i(280));var t=e.stateNode;t&&(t=Ni(t),He(e.stateNode,e.type,t))}}function Ke(e){Ue?We?We.push(e):We=[e]:Ue=e}function qe(){if(Ue){var e=Ue,t=We;if(We=Ue=null,Ge(e),t)for(e=0;e>>=0,e===0?32:31-(xt(e)/St|0)|0}var wt=64,Tt=4194304;function Et(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 Dt(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,i=e.suspendedLanes,a=e.pingedLanes,o=n&268435455;if(o!==0){var s=o&~i;s===0?(a&=o,a!==0&&(r=Et(a))):r=Et(s)}else o=n&~i,o===0?a!==0&&(r=Et(a)):r=Et(o);if(r===0)return 0;if(t!==0&&t!==r&&(t&i)===0&&(i=r&-r,a=t&-t,i>=a||i===16&&a&4194240))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 Nt(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-bt(t),e[t]=n}function Pt(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=Jn),Zn=` `,J=!1;function Qn(e,t){switch(e){case`keyup`:return Kn.indexOf(t.keyCode)!==-1;case`keydown`:return t.keyCode!==229;case`keypress`:case`mousedown`:case`focusout`:return!0;default:return!1}}function Y(e){return e=e.detail,typeof e==`object`&&`data`in e?e.data:null}var $n=!1;function er(e,t){switch(e){case`compositionend`:return Y(t);case`keypress`:return t.which===32?(J=!0,Zn):null;case`textInput`:return e=t.data,e===Zn&&J?null:e;default:return null}}function tr(e,t){if($n)return e===`compositionend`||!qn&&Qn(e,t)?(e=_n(),gn=hn=mn=null,$n=!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}a:{for(;n;){if(n.nextSibling){n=n.nextSibling;break a}n=n.parentNode}n=void 0}n=Cr(n)}}function Tr(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Tr(e,t.parentNode):`contains`in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Er(){for(var e=window,t=he();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href==`string`}catch{n=!1}if(n)e=t.contentWindow;else break;t=he(e.document)}return t}function Dr(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 Or(e){var t=Er(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&Tr(n.ownerDocument.documentElement,n)){if(r!==null&&Dr(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 i=n.textContent.length,a=Math.min(r.start,i);r=r.end===void 0?a:Math.min(r.end,i),!e.extend&&a>r&&(i=r,r=a,a=i),i=wr(n,a);var o=wr(n,r);i&&o&&(e.rangeCount!==1||e.anchorNode!==i.node||e.anchorOffset!==i.offset||e.focusNode!==o.node||e.focusOffset!==o.offset)&&(t=t.createRange(),t.setStart(i.node,i.offset),e.removeAllRanges(),a>r?(e.addRange(t),e.extend(o.node,o.offset)):(t.setEnd(o.node,o.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,Ar=null,jr=null,Mr=null,Nr=!1;function Pr(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Nr||Ar==null||Ar!==he(r)||(r=Ar,`selectionStart`in r&&Dr(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}),Mr&&Sr(Mr,r)||(Mr=r,r=ii(jr,`onSelect`),0Fi||(e.current=Pi[Fi],Pi[Fi]=null,Fi--)}function Ri(e,t){Fi++,Pi[Fi]=e.current,e.current=t}var zi={},Bi=Ii(zi),Vi=Ii(!1),Hi=zi;function Ui(e,t){var n=e.type.contextTypes;if(!n)return zi;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var i={},a;for(a in n)i[a]=t[a];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=i),i}function Wi(e){return e=e.childContextTypes,e!=null}function Gi(){Li(Vi),Li(Bi)}function Ki(e,t,n){if(Bi.current!==zi)throw Error(i(168));Ri(Bi,t),Ri(Vi,n)}function qi(e,t,n){var r=e.stateNode;if(t=t.childContextTypes,typeof r.getChildContext!=`function`)return n;for(var a in r=r.getChildContext(),r)if(!(a in t))throw Error(i(108,de(e)||`Unknown`,a));return M({},n,r)}function Ji(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||zi,Hi=Bi.current,Ri(Bi,e),Ri(Vi,Vi.current),!0}function Yi(e,t,n){var r=e.stateNode;if(!r)throw Error(i(169));n?(e=qi(e,t,Hi),r.__reactInternalMemoizedMergedChildContext=e,Li(Vi),Li(Bi),Ri(Bi,e)):Li(Vi),Ri(Vi,n)}var Xi=null,Zi=!1,Qi=!1;function $i(e){Xi===null?Xi=[e]:Xi.push(e)}function ea(e){Zi=!0,$i(e)}function ta(){if(!Qi&&Xi!==null){Qi=!0;var e=0,t=K;try{var n=Xi;for(K=1;e>=o,i-=o,la=1<<32-bt(t)+i|n<h?(g=d,d=null):g=d.sibling;var _=p(i,d,s[h],c);if(_===null){d===null&&(d=g);break}e&&d&&_.alternate===null&&t(i,d),a=o(_,a,h),u===null?l=_:u.sibling=_,u=_,d=g}if(h===s.length)return n(i,d),_a&&da(i,h),l;if(d===null){for(;hg?(_=h,h=null):_=h.sibling;var y=p(a,h,v.value,l);if(y===null){h===null&&(h=_);break}e&&h&&y.alternate===null&&t(a,h),s=o(y,s,g),d===null?u=y:d.sibling=y,d=y,h=_}if(v.done)return n(a,h),_a&&da(a,g),u;if(h===null){for(;!v.done;g++,v=c.next())v=f(a,v.value,l),v!==null&&(s=o(v,s,g),d===null?u=v:d.sibling=v,d=v);return _a&&da(a,g),u}for(h=r(a,h);!v.done;g++,v=c.next())v=m(h,a,g,v.value,l),v!==null&&(e&&v.alternate!==null&&h.delete(v.key===null?g:v.key),s=o(v,s,g),d===null?u=v:d.sibling=v,d=v);return e&&h.forEach(function(e){return t(a,e)}),_a&&da(a,g),u}function _(e,r,i,o){if(typeof i==`object`&&i&&i.type===T&&i.key===null&&(i=i.props.children),typeof i==`object`&&i){switch(i.$$typeof){case C:a:{for(var c=i.key,l=r;l!==null;){if(l.key===c){if(c=i.type,c===T){if(l.tag===7){n(e,l.sibling),r=a(l,i.props.children),r.return=e,e=r;break a}}else if(l.elementType===c||typeof c==`object`&&c&&c.$$typeof===A&&ja(c)===l.type){n(e,l.sibling),r=a(l,i.props),r.ref=ka(e,l,i),r.return=e,e=r;break a}n(e,l);break}t(e,l),l=l.sibling}i.type===T?(r=Zl(i.props.children,e.mode,o,i.key),r.return=e,e=r):(o=Xl(i.type,i.key,i.props,null,e.mode,o),o.ref=ka(e,r,i),o.return=e,e=o)}return s(e);case w:a:{for(l=i.key;r!==null;){if(r.key===l){if(r.tag===4&&r.stateNode.containerInfo===i.containerInfo&&r.stateNode.implementation===i.implementation){n(e,r.sibling),r=a(r,i.children||[]),r.return=e,e=r;break a}n(e,r);break}t(e,r),r=r.sibling}r=eu(i,e.mode,o),r.return=e,e=r}return s(e);case A:return l=i._init,_(e,r,l(i._payload),o)}if(Ce(i))return h(e,r,i,o);if(ae(i))return g(e,r,i,o);Aa(e,i)}return typeof i==`string`&&i!==``||typeof i==`number`?(i=``+i,r!==null&&r.tag===6?(n(e,r.sibling),r=a(r,i),r.return=e,e=r):(n(e,r),r=$l(i,e.mode,o),r.return=e,e=r),s(e)):n(e,r)}return _}var Na=Ma(!0),Pa=Ma(!1),Fa=Ii(null),Ia=null,La=null,Ra=null;function za(){Ra=La=Ia=null}function Ba(e){var t=Fa.current;Li(Fa),e._currentValue=t}function Va(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)===t?r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t):(e.childLanes|=t,r!==null&&(r.childLanes|=t)),e===n)break;e=e.return}}function Ha(e,t){Ia=e,Ra=La=null,e=e.dependencies,e!==null&&e.firstContext!==null&&((e.lanes&t)!==0&&(Ms=!0),e.firstContext=null)}function Ua(e){var t=e._currentValue;if(Ra!==e){if(e={context:e,memoizedValue:t,next:null},La===null){if(Ia===null)throw Error(i(308));La=e,Ia.dependencies={lanes:0,firstContext:e}}else La=La.next=e}return t}var Wa=null;function Ga(e){Wa===null?Wa=[e]:Wa.push(e)}function Ka(e,t,n,r){var i=t.interleaved;return i===null?(n.next=n,Ga(t)):(n.next=i.next,i.next=n),t.interleaved=n,qa(e,r)}function qa(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 Ja=!1;function Ya(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Xa(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 Za(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function Qa(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,$&2){var i=r.pending;return i===null?t.next=t:(t.next=i.next,i.next=t),r.pending=t,qa(e,n)}return i=r.interleaved,i===null?(t.next=t,Ga(r)):(t.next=i.next,i.next=t),r.interleaved=t,qa(e,n)}function $a(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,n&4194240)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Ft(e,n)}}function eo(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var i=null,a=null;if(n=n.firstBaseUpdate,n!==null){do{var o={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};a===null?i=a=o:a=a.next=o,n=n.next}while(n!==null);a===null?i=a=t:a=a.next=t}else i=a=t;n={baseState:r.baseState,firstBaseUpdate:i,lastBaseUpdate:a,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 to(e,t,n,r){var i=e.updateQueue;Ja=!1;var a=i.firstBaseUpdate,o=i.lastBaseUpdate,s=i.shared.pending;if(s!==null){i.shared.pending=null;var c=s,l=c.next;c.next=null,o===null?a=l:o.next=l,o=c;var u=e.alternate;u!==null&&(u=u.updateQueue,s=u.lastBaseUpdate,s!==o&&(s===null?u.firstBaseUpdate=l:s.next=l,u.lastBaseUpdate=c))}if(a!==null){var d=i.baseState;o=0,u=l=c=null,s=a;do{var f=s.lane,p=s.eventTime;if((r&f)===f){u!==null&&(u=u.next={eventTime:p,lane:0,tag:s.tag,payload:s.payload,callback:s.callback,next:null});a:{var m=e,h=s;switch(f=t,p=n,h.tag){case 1:if(m=h.payload,typeof m==`function`){d=m.call(p,d,f);break a}d=m;break a;case 3:m.flags=m.flags&-65537|128;case 0:if(m=h.payload,f=typeof m==`function`?m.call(p,d,f):m,f==null)break a;d=M({},d,f);break a;case 2:Ja=!0}}s.callback!==null&&s.lane!==0&&(e.flags|=64,f=i.effects,f===null?i.effects=[s]:f.push(s))}else p={eventTime:p,lane:f,tag:s.tag,payload:s.payload,callback:s.callback,next:null},u===null?(l=u=p,c=d):u=u.next=p,o|=f;if(s=s.next,s===null){if(s=i.shared.pending,s===null)break;f=s,s=f.next,f.next=null,i.lastBaseUpdate=f,i.shared.pending=null}}while(1);if(u===null&&(c=d),i.baseState=c,i.firstBaseUpdate=l,i.lastBaseUpdate=u,t=i.shared.interleaved,t!==null){i=t;do o|=i.lane,i=i.next;while(i!==t)}else a===null&&(i.shared.lanes=0);Jc|=o,e.lanes=o,e.memoizedState=d}}function no(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;tn?n:4,e(!0);var r=vo.transition;vo.transition={};try{e(!1),t()}finally{K=n,vo.transition=r}}function as(){return Mo().memoizedState}function os(e,t,n){var r=pl(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},cs(e))ls(t,n);else if(n=Ka(e,t,n,r),n!==null){var i=fl();ml(n,e,r,i),us(n,t,r)}}function ss(e,t,n){var r=pl(e),i={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(cs(e))ls(t,i);else{var a=e.alternate;if(e.lanes===0&&(a===null||a.lanes===0)&&(a=t.lastRenderedReducer,a!==null))try{var o=t.lastRenderedState,s=a(o,n);if(i.hasEagerState=!0,i.eagerState=s,xr(s,o)){var c=t.interleaved;c===null?(i.next=i,Ga(t)):(i.next=c.next,c.next=i),t.interleaved=i;return}}catch{}n=Ka(e,t,i,r),n!==null&&(i=fl(),ml(n,e,r,i),us(n,t,r))}}function cs(e){var t=e.alternate;return e===bo||t!==null&&t===bo}function ls(e,t){wo=Co=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function us(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Ft(e,n)}}var ds={readContext:Ua,useCallback:Do,useContext:Do,useEffect:Do,useImperativeHandle:Do,useInsertionEffect:Do,useLayoutEffect:Do,useMemo:Do,useReducer:Do,useRef:Do,useState:Do,useDebugValue:Do,useDeferredValue:Do,useTransition:Do,useMutableSource:Do,useSyncExternalStore:Do,useId:Do,unstable_isNewReconciler:!1},fs={readContext:Ua,useCallback:function(e,t){return jo().memoizedState=[e,t===void 0?null:t],e},useContext:Ua,useEffect:Jo,useImperativeHandle:function(e,t,n){return n=n==null?null:n.concat([e]),Ko(4194308,4,Qo.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Ko(4194308,4,e,t)},useInsertionEffect:function(e,t){return Ko(4,2,e,t)},useMemo:function(e,t){var n=jo();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=jo();return t=n===void 0?t:n(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=os.bind(null,bo,e),[r.memoizedState,e]},useRef:function(e){var t=jo();return e={current:e},t.memoizedState=e},useState:Uo,useDebugValue:es,useDeferredValue:function(e){return jo().memoizedState=e},useTransition:function(){var e=Uo(!1),t=e[0];return e=is.bind(null,e[1]),jo().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=bo,a=jo();if(_a){if(n===void 0)throw Error(i(407));n=n()}else{if(n=t(),Vc===null)throw Error(i(349));yo&30||Ro(r,t,n)}a.memoizedState=n;var o={value:n,getSnapshot:t};return a.queue=o,Jo(Bo.bind(null,r,o,e),[e]),r.flags|=2048,Wo(9,zo.bind(null,r,o,n,t),void 0,null),n},useId:function(){var e=jo(),t=Vc.identifierPrefix;if(_a){var n=ua,r=la;n=(r&~(1<<32-bt(r)-1)).toString(32)+n,t=`:`+t+`R`+n,n=To++,0<\/script>`,e=e.removeChild(e.firstChild)):typeof r.is==`string`?e=c.createElement(n,{is:r.is}):(e=c.createElement(n),n===`select`&&(c=e,r.multiple?c.multiple=!0:r.size&&(c.size=r.size))):e=c.createElementNS(e,n),e[wi]=t,e[Ti]=r,nc(e,t,!1,!1),t.stateNode=e;a:{switch(c=ze(n,r),n){case`dialog`:Zr(`cancel`,e),Zr(`close`,e),a=r;break;case`iframe`:case`object`:case`embed`:Zr(`load`,e),a=r;break;case`video`:case`audio`:for(a=0;ael&&(t.flags|=128,r=!0,ac(s,!1),t.lanes=4194304)}}else{if(!r){if(e=mo(c),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),ac(s,!0),s.tail===null&&s.tailMode===`hidden`&&!c.alternate&&!_a)return oc(t),null}else 2*W()-s.renderingStartTime>el&&n!==1073741824&&(t.flags|=128,r=!0,ac(s,!1),t.lanes=4194304)}s.isBackwards?(c.sibling=t.child,t.child=c):(n=s.last,n===null?t.child=c:n.sibling=c,s.last=c)}return s.tail===null?(oc(t),null):(t=s.tail,s.rendering=t,s.tail=t.sibling,s.renderingStartTime=W(),t.sibling=null,n=po.current,Ri(po,r?n&1|2:n&1),t);case 22:case 23:return wl(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?Wc&1073741824&&(oc(t),t.subtreeFlags&6&&(t.flags|=8192)):oc(t),null;case 24:return null;case 25:return null}throw Error(i(156,t.tag))}function cc(e,t){switch(ma(t),t.tag){case 1:return Wi(t.type)&&Gi(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return lo(),Li(Vi),Li(Bi),go(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return fo(t),null;case 13:if(Li(po),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(i(340));Ea()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return Li(po),null;case 4:return lo(),null;case 10:return Ba(t.type._context),null;case 22:case 23:return wl(),null;case 24:return null;default:return null}}var lc=!1,uc=!1,dc=typeof WeakSet==`function`?WeakSet:Set,Q=null;function fc(e,t){var n=e.ref;if(n!==null){if(typeof n==`function`)try{n(null)}catch(n){Rl(e,t,n)}else n.current=null}}function pc(e,t,n){try{n()}catch(n){Rl(e,t,n)}}var mc=!1;function hc(e,t){if(fi=q,e=Er(),Dr(e)){if(`selectionStart`in e)var n={start:e.selectionStart,end:e.selectionEnd};else a:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var a=r.anchorOffset,o=r.focusNode;r=r.focusOffset;try{n.nodeType,o.nodeType}catch{n=null;break a}var s=0,c=-1,l=-1,u=0,d=0,f=e,p=null;b:for(;;){for(var m;f!==n||a!==0&&f.nodeType!==3||(c=s+a),f!==o||r!==0&&f.nodeType!==3||(l=s+r),f.nodeType===3&&(s+=f.nodeValue.length),(m=f.firstChild)!==null;)p=f,f=m;for(;;){if(f===e)break b;if(p===n&&++u===a&&(c=s),p===o&&++d===r&&(l=s),(m=f.nextSibling)!==null)break;f=p,p=f.parentNode}f=m}n=c===-1||l===-1?null:{start:c,end:l}}else n=null}n||={start:0,end:0}}else n=null;for(pi={focusedElem:e,selectionRange:n},q=!1,Q=t;Q!==null;)if(t=Q,e=t.child,t.subtreeFlags&1028&&e!==null)e.return=t,Q=e;else for(;Q!==null;){t=Q;try{var h=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(h!==null){var g=h.memoizedProps,_=h.memoizedState,v=t.stateNode;v.__reactInternalSnapshotBeforeUpdate=v.getSnapshotBeforeUpdate(t.elementType===t.type?g:hs(t.type,g),_)}break;case 3:var y=t.stateNode.containerInfo;y.nodeType===1?y.textContent=``:y.nodeType===9&&y.documentElement&&y.removeChild(y.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(i(163))}}catch(e){Rl(t,t.return,e)}if(e=t.sibling,e!==null){e.return=t.return,Q=e;break}Q=t.return}return h=mc,mc=!1,h}function gc(e,t,n){var r=t.updateQueue;if(r=r===null?null:r.lastEffect,r!==null){var i=r=r.next;do{if((i.tag&e)===e){var a=i.destroy;i.destroy=void 0,a!==void 0&&pc(t,n,a)}i=i.next}while(i!==r)}}function _c(e,t){if(t=t.updateQueue,t=t===null?null:t.lastEffect,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 vc(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 yc(e){var t=e.alternate;t!==null&&(e.alternate=null,yc(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[wi],delete t[Ti],delete t[Di],delete t[Oi],delete t[ki])),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 bc(e){return e.tag===5||e.tag===3||e.tag===4}function xc(e){a:for(;;){for(;e.sibling===null;){if(e.return===null||bc(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 a;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function Sc(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=di));else if(r!==4&&(e=e.child,e!==null))for(Sc(e,t,n),e=e.sibling;e!==null;)Sc(e,t,n),e=e.sibling}function Cc(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(Cc(e,t,n),e=e.sibling;e!==null;)Cc(e,t,n),e=e.sibling}var wc=null,Tc=!1;function Ec(e,t,n){for(n=n.child;n!==null;)Dc(e,t,n),n=n.sibling}function Dc(e,t,n){if(vt&&typeof vt.onCommitFiberUnmount==`function`)try{vt.onCommitFiberUnmount(G,n)}catch{}switch(n.tag){case 5:uc||fc(n,t);case 6:var r=wc,i=Tc;wc=null,Ec(e,t,n),wc=r,Tc=i,wc!==null&&(Tc?(e=wc,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):wc.removeChild(n.stateNode));break;case 18:wc!==null&&(Tc?(e=wc,n=n.stateNode,e.nodeType===8?bi(e.parentNode,n):e.nodeType===1&&bi(e,n),on(e)):bi(wc,n.stateNode));break;case 4:r=wc,i=Tc,wc=n.stateNode.containerInfo,Tc=!0,Ec(e,t,n),wc=r,Tc=i;break;case 0:case 11:case 14:case 15:if(!uc&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){i=r=r.next;do{var a=i,o=a.destroy;a=a.tag,o!==void 0&&(a&2||a&4)&&pc(n,t,o),i=i.next}while(i!==r)}Ec(e,t,n);break;case 1:if(!uc&&(fc(n,t),r=n.stateNode,typeof r.componentWillUnmount==`function`))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(e){Rl(n,t,e)}Ec(e,t,n);break;case 21:Ec(e,t,n);break;case 22:n.mode&1?(uc=(r=uc)||n.memoizedState!==null,Ec(e,t,n),uc=r):Ec(e,t,n);break;default:Ec(e,t,n)}}function Oc(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new dc),t.forEach(function(t){var r=Hl.bind(null,e,t);n.has(t)||(n.add(t),t.then(r,r))})}}function kc(e,t){var n=t.deletions;if(n!==null)for(var r=0;ra&&(a=s),r&=~o}if(r=a,r=W()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*Lc(r/1960))-r,10e?16:e,ol===null)var r=!1;else{if(e=ol,ol=null,sl=0,$&6)throw Error(i(331));var a=$;for($|=4,Q=e.current;Q!==null;){var o=Q,s=o.child;if(Q.flags&16){var c=o.deletions;if(c!==null){for(var l=0;lW()-$c?Tl(e,0):Xc|=n),hl(e,t)}function Bl(e,t){t===0&&(e.mode&1?(t=Tt,Tt<<=1,!(Tt&130023424)&&(Tt=4194304)):t=1);var n=fl();e=qa(e,t),e!==null&&(Nt(e,t,n),hl(e,n))}function Vl(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),Bl(e,n)}function Hl(e,t){var n=0;switch(e.tag){case 13:var r=e.stateNode,a=e.memoizedState;a!==null&&(n=a.retryLane);break;case 19:r=e.stateNode;break;default:throw Error(i(314))}r!==null&&r.delete(t),Bl(e,n)}var Ul=function(e,t,n){if(e!==null){if(e.memoizedProps!==t.pendingProps||Vi.current)Ms=!0;else{if((e.lanes&n)===0&&!(t.flags&128))return Ms=!1,tc(e,t,n);Ms=!!(e.flags&131072)}}else Ms=!1,_a&&t.flags&1048576&&fa(t,aa,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;$s(e,t),e=t.pendingProps;var a=Ui(t,Bi.current);Ha(t,n),a=ko(null,t,r,e,a,n);var o=Ao();return t.flags|=1,typeof a==`object`&&a&&typeof a.render==`function`&&a.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,Wi(r)?(o=!0,Ji(t)):o=!1,t.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,Ya(t),a.updater=_s,t.stateNode=a,a._reactInternals=t,xs(t,r,e,n),t=Vs(null,t,r,!0,o,n)):(t.tag=0,_a&&o&&pa(t),Ns(null,t,a,n),t=t.child),t;case 16:r=t.elementType;a:{switch($s(e,t),e=t.pendingProps,a=r._init,r=a(r._payload),t.type=r,a=t.tag=Jl(r),e=hs(r,e),a){case 0:t=zs(null,t,r,e,n);break a;case 1:t=Bs(null,t,r,e,n);break a;case 11:t=Ps(null,t,r,e,n);break a;case 14:t=Fs(null,t,r,hs(r.type,e),n);break a}throw Error(i(306,r,``))}return t;case 0:return r=t.type,a=t.pendingProps,a=t.elementType===r?a:hs(r,a),zs(e,t,r,a,n);case 1:return r=t.type,a=t.pendingProps,a=t.elementType===r?a:hs(r,a),Bs(e,t,r,a,n);case 3:a:{if(Hs(t),e===null)throw Error(i(387));r=t.pendingProps,o=t.memoizedState,a=o.element,Xa(e,t),to(t,r,null,n);var s=t.memoizedState;if(r=s.element,o.isDehydrated){if(o={element:r,isDehydrated:!1,cache:s.cache,pendingSuspenseBoundaries:s.pendingSuspenseBoundaries,transitions:s.transitions},t.updateQueue.baseState=o,t.memoizedState=o,t.flags&256){a=Ss(Error(i(423)),t),t=Us(e,t,r,n,a);break a}if(r!==a){a=Ss(Error(i(424)),t),t=Us(e,t,r,n,a);break a}for(ga=xi(t.stateNode.containerInfo.firstChild),ha=t,_a=!0,va=null,n=Pa(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling}else{if(Ea(),r===a){t=ec(e,t,n);break a}Ns(e,t,r,n)}t=t.child}return t;case 5:return uo(t),e===null&&Sa(t),r=t.type,a=t.pendingProps,o=e===null?null:e.memoizedProps,s=a.children,mi(r,a)?s=null:o!==null&&mi(r,o)&&(t.flags|=32),Rs(e,t),Ns(e,t,s,n),t.child;case 6:return e===null&&Sa(t),null;case 13:return Ks(e,t,n);case 4:return co(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=Na(t,null,r,n):Ns(e,t,r,n),t.child;case 11:return r=t.type,a=t.pendingProps,a=t.elementType===r?a:hs(r,a),Ps(e,t,r,a,n);case 7:return Ns(e,t,t.pendingProps,n),t.child;case 8:return Ns(e,t,t.pendingProps.children,n),t.child;case 12:return Ns(e,t,t.pendingProps.children,n),t.child;case 10:a:{if(r=t.type._context,a=t.pendingProps,o=t.memoizedProps,s=a.value,Ri(Fa,r._currentValue),r._currentValue=s,o!==null){if(xr(o.value,s)){if(o.children===a.children&&!Vi.current){t=ec(e,t,n);break a}}else for(o=t.child,o!==null&&(o.return=t);o!==null;){var c=o.dependencies;if(c!==null){s=o.child;for(var l=c.firstContext;l!==null;){if(l.context===r){if(o.tag===1){l=Za(-1,n&-n),l.tag=2;var u=o.updateQueue;if(u!==null){u=u.shared;var d=u.pending;d===null?l.next=l:(l.next=d.next,d.next=l),u.pending=l}}o.lanes|=n,l=o.alternate,l!==null&&(l.lanes|=n),Va(o.return,n,t),c.lanes|=n;break}l=l.next}}else if(o.tag===10)s=o.type===t.type?null:o.child;else if(o.tag===18){if(s=o.return,s===null)throw Error(i(341));s.lanes|=n,c=s.alternate,c!==null&&(c.lanes|=n),Va(s,n,t),s=o.sibling}else s=o.child;if(s!==null)s.return=o;else for(s=o;s!==null;){if(s===t){s=null;break}if(o=s.sibling,o!==null){o.return=s.return,s=o;break}s=s.return}o=s}}Ns(e,t,a.children,n),t=t.child}return t;case 9:return a=t.type,r=t.pendingProps.children,Ha(t,n),a=Ua(a),r=r(a),t.flags|=1,Ns(e,t,r,n),t.child;case 14:return r=t.type,a=hs(r,t.pendingProps),a=hs(r.type,a),Fs(e,t,r,a,n);case 15:return Is(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,a=t.pendingProps,a=t.elementType===r?a:hs(r,a),$s(e,t),t.tag=1,Wi(r)?(e=!0,Ji(t)):e=!1,Ha(t,n),ys(t,r,a),xs(t,r,a,n),Vs(null,t,r,!0,e,n);case 19:return Qs(e,t,n);case 22:return Ls(e,t,n)}throw Error(i(156,t.tag))};function Wl(e,t){return lt(e,t)}function Gl(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 Kl(e,t,n,r){return new Gl(e,t,n,r)}function ql(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Jl(e){if(typeof e==`function`)return+!!ql(e);if(e!=null){if(e=e.$$typeof,e===te)return 11;if(e===re)return 14}return 2}function Yl(e,t){var n=e.alternate;return n===null?(n=Kl(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 Xl(e,t,n,r,a,o){var s=2;if(r=e,typeof e==`function`)ql(e)&&(s=1);else if(typeof e==`string`)s=5;else a:switch(e){case T:return Zl(n.children,a,o,t);case E:s=8,a|=8;break;case D:return e=Kl(12,n,t,a|2),e.elementType=D,e.lanes=o,e;case ne:return e=Kl(13,n,t,a),e.elementType=ne,e.lanes=o,e;case k:return e=Kl(19,n,t,a),e.elementType=k,e.lanes=o,e;case j:return Ql(n,a,o,t);default:if(typeof e==`object`&&e)switch(e.$$typeof){case ee:s=10;break a;case O:s=9;break a;case te:s=11;break a;case re:s=14;break a;case A:s=16,r=null;break a}throw Error(i(130,e==null?e:typeof e,``))}return t=Kl(s,n,t,a),t.elementType=e,t.type=r,t.lanes=o,t}function Zl(e,t,n,r){return e=Kl(7,e,r,t),e.lanes=n,e}function Ql(e,t,n,r){return e=Kl(22,e,r,t),e.elementType=j,e.lanes=n,e.stateNode={isHidden:!1},e}function $l(e,t,n){return e=Kl(6,e,null,t),e.lanes=n,e}function eu(e,t,n){return t=Kl(4,e.children===null?[]:e.children,e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function tu(e,t,n,r,i){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=Mt(0),this.expirationTimes=Mt(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Mt(0),this.identifierPrefix=r,this.onRecoverableError=i,this.mutableSourceEagerHydrationData=null}function nu(e,t,n,r,i,a,o,s,c){return e=new tu(e,t,n,s,c),t===1?(t=1,!0===a&&(t|=8)):t=0,a=Kl(3,null,null,t),e.current=a,a.stateNode=e,a.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},Ya(a),e}function ru(e,t,n){var r=3{function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=`function`))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=xe()})),Ce=t((e=>{var t=Se();e.createRoot=t.createRoot,e.hydrateRoot=t.hydrateRoot})),we=class extends A{constructor(e={}){super(),this.config=e,this.#e=new Set,this.#t=new Map,this.#n=0}#e;#t;#n;build(e,t,n){let r=new re({client:e,mutationCache:this,mutationId:++this.#n,options:e.defaultMutationOptions(t),state:n});return this.add(r),r}add(e){this.#e.add(e);let t=Te(e);if(typeof t==`string`){let n=this.#t.get(t);n?n.push(e):this.#t.set(t,[e])}this.notify({type:`added`,mutation:e})}remove(e){if(this.#e.delete(e)){let t=Te(e);if(typeof t==`string`){let n=this.#t.get(t);if(n){if(n.length>1){let t=n.indexOf(e);t!==-1&&n.splice(t,1)}else n[0]===e&&this.#t.delete(t)}}}this.notify({type:`removed`,mutation:e})}canRun(e){let t=Te(e);if(typeof t==`string`){let n=this.#t.get(t)?.find(e=>e.state.status===`pending`);return!n||n===e}return!0}runNext(e){let t=Te(e);return typeof t==`string`?(this.#t.get(t)?.find(t=>t!==e&&t.state.isPaused))?.continue()??Promise.resolve():Promise.resolve()}clear(){j.batch(()=>{this.#e.forEach(e=>{this.notify({type:`removed`,mutation:e})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(e){let t={exact:!0,...e};return this.getAll().find(e=>ae(t,e))}findAll(e={}){return this.getAll().filter(t=>ae(e,t))}notify(e){j.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){let e=this.getAll().filter(e=>e.state.isPaused);return j.batch(()=>Promise.all(e.map(e=>e.continue().catch(N))))}};function Te(e){return e.options.scope?.id}var Ee=class extends A{constructor(e={}){super(),this.config=e,this.#e=new Map}#e;build(e,t,n){let r=t.queryKey,i=t.queryHash??ie(r,t),a=this.get(i);return a||(a=new le({client:e,queryKey:r,queryHash:i,options:e.defaultQueryOptions(t),state:n,defaultOptions:e.getQueryDefaults(r)}),this.add(a)),a}add(e){this.#e.has(e.queryHash)||(this.#e.set(e.queryHash,e),this.notify({type:`added`,query:e}))}remove(e){let t=this.#e.get(e.queryHash);t&&(e.destroy(),t===e&&this.#e.delete(e.queryHash),this.notify({type:`removed`,query:e}))}clear(){j.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#e.get(e)}getAll(){return[...this.#e.values()]}find(e){let t={exact:!0,...e};return this.getAll().find(e=>ue(t,e))}findAll(e={}){let t=this.getAll();return Object.keys(e).length>0?t.filter(t=>ue(e,t)):t}notify(e){j.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){j.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){j.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},De=class{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e={}){this.#e=e.queryCache||new Ee,this.#t=e.mutationCache||new we,this.#n=e.defaultOptions||{},this.#r=new Map,this.#i=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#o=me.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#s=fe.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#a--,this.#a===0&&(this.#o?.(),this.#o=void 0,this.#s?.(),this.#s=void 0)}isFetching(e){return this.#e.findAll({...e,fetchStatus:`fetching`}).length}isMutating(e){return this.#t.findAll({...e,status:`pending`}).length}getQueryData(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state.data}ensureQueryData(e){let t=this.defaultQueryOptions(e),n=this.#e.build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(k(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return this.#e.findAll(e).map(({queryKey:e,state:t})=>[e,t.data])}setQueryData(e,t,n){let r=this.defaultQueryOptions({queryKey:e}),i=this.#e.get(r.queryHash)?.state.data,a=se(t,i);if(a!==void 0)return this.#e.build(this,r).setData(a,{...n,manual:!0})}setQueriesData(e,t,n){return j.batch(()=>this.#e.findAll(e).map(({queryKey:e})=>[e,this.setQueryData(e,t,n)]))}getQueryState(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state}removeQueries(e){let t=this.#e;j.batch(()=>{t.findAll(e).forEach(e=>{t.remove(e)})})}resetQueries(e,t){let n=this.#e;return j.batch(()=>(n.findAll(e).forEach(e=>{e.reset()}),this.refetchQueries({type:`active`,...e},t)))}cancelQueries(e,t={}){let n={revert:!0,...t},r=j.batch(()=>this.#e.findAll(e).map(e=>e.cancel(n)));return Promise.all(r).then(N).catch(N)}invalidateQueries(e,t={}){return j.batch(()=>(this.#e.findAll(e).forEach(e=>{e.invalidate()}),e?.refetchType===`none`?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??`active`},t)))}refetchQueries(e,t={}){let n={...t,cancelRefetch:t.cancelRefetch??!0},r=j.batch(()=>this.#e.findAll(e).filter(e=>!e.isDisabled()&&!e.isStatic()).map(e=>{let t=e.fetch(void 0,n);return n.throwOnError||(t=t.catch(N)),e.state.fetchStatus===`paused`?Promise.resolve():t}));return Promise.all(r).then(N)}fetchQuery(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let n=this.#e.build(this,t);return n.isStaleByTime(k(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(N).catch(N)}fetchInfiniteQuery(e){return e._type=`infinite`,this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(N).catch(N)}ensureInfiniteQueryData(e){return e._type=`infinite`,this.ensureQueryData(e)}resumePausedMutations(){return fe.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#n}setDefaultOptions(e){this.#n=e}setQueryDefaults(e,t){this.#r.set(F(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){let t=[...this.#r.values()],n={};return t.forEach(t=>{M(e,t.queryKey)&&Object.assign(n,t.defaultOptions)}),n}setMutationDefaults(e,t){this.#i.set(F(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){let t=[...this.#i.values()],n={};return t.forEach(t=>{M(e,t.mutationKey)&&Object.assign(n,t.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;let t={...this.#n.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||=ie(t.queryKey,t),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!==`always`),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode=`offlineFirst`),t.queryFn===pe&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#n.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}},I=e(n(),1),Oe=e(Ce(),1),ke=class extends Error{status;method;path;constructor(e,t,n,r){super(e),this.name=`ApiError`,this.status=t,this.method=n,this.path=r}};function Ae(e){let t=e.replace(/\s+/g,` `).trim();if(!t)return``;try{let t=JSON.parse(e);for(let e of[`detail`,`error`,`message`]){let n=t[e];if(typeof n==`string`&&n.trim())return n.trim();if(Array.isArray(n)){let e=n.map(e=>e&&typeof e==`object`?String(e.msg??``):``).filter(Boolean);if(e.length)return e.join(`; `)}}}catch{}return t.startsWith(`typeof e==`string`):[],o=Re(r?.major),s=Re(r?.minor);if(!n||!r||!i)return{compatible:!1,reason:`malformed /api/meta response`};if(typeof i.source_root!=`string`||Re(i.pid)===null||typeof i.package_version!=`string`||typeof i.release_id!=`string`)return{compatible:!1,reason:`malformed /api/meta runtime identity`};if(n.service!==`argus-skill-webapi`)return{compatible:!1,reason:`unexpected service ${String(n.service||`unknown`)}`};let c=e;if(r.name!==Pe.name||o!==Pe.major)return{compatible:!1,reason:`protocol ${String(r.name||`unknown`)}/${String(o)} is incompatible with client ${Pe.name}/${Pe.major}`,meta:c};if(s===null||s!a.includes(e));if(l.length>0)return{compatible:!1,reason:`missing capabilities: ${l.join(`, `)}`,meta:c};if(i.source_root_matches_config===!1)return{compatible:!1,reason:`backend is running from a different installation than configured`,meta:c};if(i.release_id!==t.releaseId)return{compatible:!1,reason:`backend and client installations are out of sync; restart or reinstall Argus`,meta:c};if(t.sourceDigest){if(typeof i.runtime_source_digest!=`string`||!i.runtime_source_digest)return{compatible:!1,reason:`backend cannot verify this local installation; restart it from the current checkout`,meta:c};if(i.runtime_source_digest!==t.sourceDigest)return{compatible:!1,reason:`backend is running code from a different local installation; restart it`,meta:c}}return{compatible:!0,reason:``,warning:i.release_matches_source===!1?Fe:void 0,meta:c}}function Be(e,t){let n=ze(e);if(!n.compatible||!n.meta)throw Error(`incompatible Argus API: ${n.reason}`);return n.warning&&t?.(n.warning),n.meta}function Ve(e){let t=Le(e),n=Le(t?.daemon);if(!t||t.schema_version!==7)throw Error(`incompatible snapshot schema: expected 7, got ${String(t?.schema_version??`missing`)}`);if(!n)throw Error(`invalid snapshot: daemon section is missing`);let r=[`global_daily_cap_usd`,`read_status`,`read_error`,`protocol_compatible`,`protocol_error`].filter(e=>!Object.hasOwn(n,e));if(r.length>0)throw Error(`invalid snapshot: daemon fields missing: ${r.join(`, `)}`);let i=[`spend_usd`,`spend_status`,`usage_summary`,`request_usage`,`cost_control`,`daemon_commands`,`observability`,`mission_view`,`partial`,`diagnostics`].filter(e=>!Object.hasOwn(t,e));if(i.length>0)throw Error(`invalid snapshot: fields missing: ${i.join(`, `)}`);if(!Array.isArray(t.diagnostics))throw Error(`invalid snapshot: diagnostics must be an array`);return e}var He=`argus_web_token`,Ue=null;function We(){let e;try{e=new URLSearchParams(window.location.search)}catch{return}let t=e.get(`token`);if(t){Ue=t;try{localStorage.setItem(He,t)}catch{}try{e.delete(`token`);let t=e.toString();window.history.replaceState(null,``,`${window.location.pathname}${t?`?${t}`:``}${window.location.hash}`)}catch{}}}var Ge=()=>{if(Ue)return Ue;try{return new URLSearchParams(window.location.search).get(`token`)||localStorage.getItem(He)}catch{return null}};function Ke(){let e=Ge();return e?{Authorization:`Bearer ${e}`}:{}}function qe(){return Ge()??``}var Je=8e3,Ye=12e3,Xe=class extends Error{constructor(){super(`This browser is not paired with Argus. Reopen it from Argus Desktop or use a fresh pairing link.`),this.name=`PairingRequiredError`}},Ze=class extends Error{method;path;constructor(e,t,n=`could not reach the local Argus service`){super(`${e.toUpperCase()} ${t} ${n}. Make sure Argus Desktop is running, then retry.`),this.name=`LocalArgusUnavailableError`,this.method=e.toUpperCase(),this.path=t}};function L(e){return e instanceof Xe||!!(e&&typeof e==`object`&&Number(e.status)===401)}function Qe(e){return L(e)||e instanceof Ze}async function $e(e,t){try{return await fetch(e,t)}catch(n){throw t.signal?.aborted?n:new Ze(String(t.method??`GET`),e)}}async function et(e,t,n,r){let i=new AbortController,a=t.signal??void 0,o=!1,s=()=>{};if(a){let e=()=>i.abort(a.reason);a.aborted?e():(a.addEventListener(`abort`,e,{once:!0}),s=()=>a.removeEventListener(`abort`,e))}let c,l=(async()=>await r(await $e(e,{...t,signal:i.signal})))(),u=new Promise((e,t)=>{c=setTimeout(()=>{o=!0;let e=Error(`request timed out after ${n}ms`);i.abort(e),t(e)},n)});try{return await Promise.race([l,u])}catch(r){if(o){let r=Math.round(n/1e3);throw new Ze(String(t.method??`GET`),e,`timed out after ${r}s because the local Argus service did not respond`)}throw r}finally{c&&clearTimeout(c),s()}}async function R(e,t,n){return et(e,{headers:Ke(),signal:t},n??Ye,async t=>(await Me(t,`GET`,e),await t.json()))}async function z(e,t,n){let r=await fetch(e,{method:`POST`,headers:{"Content-Type":`application/json`,...Ke()},body:t===void 0?void 0:JSON.stringify(t),signal:n});return await Me(r,`POST`,e),await r.json()}async function tt(e,t,n){let r=await fetch(e,{method:`POST`,headers:Ke(),body:t,signal:n});return await Me(r,`POST`,e),await r.json()}function nt(e){let t=e&&typeof e==`object`?e:{},n=String(t.command_status??``);if(Number(t.rc??0)!==0||n===`failed`||n===`rejected`)throw Error(String(t.error||`daemon command ${n||`failed`}`));return e}async function rt(e,t,n){let r=await fetch(t,{method:e,headers:{"Content-Type":`application/json`,...Ke()},body:n===void 0?void 0:JSON.stringify(n)});return await Me(r,e,t),await r.json()}async function it(e,t){let n=await fetch(e,{headers:Ke(),signal:t});return await Me(n,`GET`,e),n.blob()}var B=(e,t=``)=>`/api/projects/${encodeURIComponent(e)}${t}`,at=()=>globalThis.crypto?.randomUUID?.()??`${Date.now()}-${Math.random()}`,ot;function st(e){return!!(e&&typeof e==`object`&&`aborted`in e&&typeof e.aborted==`boolean`)}function V(e,t,n){let r={text:e};return t?.length&&(r.attachments=t),n&&n!==`auto`&&(r.route_override=n),r}function H(){if(!ot){let e=(async()=>{let e=`/api/meta`,t=await et(e,{headers:Ke()},Je,async t=>{if(t.status===404)throw Error(`incompatible Argus API: service does not expose /api/meta`);return await Me(t,`GET`,e),Be(await t.json(),e=>console.warn(`Argus API compatibility warning: ${e}`))});if(t.authentication?.required&&!t.authentication.authenticated)throw new Xe;return t})();ot=e,e.catch(t=>{ot===e&&!(t instanceof Xe)&&(ot=void 0)})}return ot}function ct(e){let t=[],n;for(;(n=e.indexOf(` + +`))>=0;){let r=e.slice(0,n);e=e.slice(n+2);for(let e of r.split(` +`)){let n=e.trim();if(n.startsWith(`data:`))try{t.push(JSON.parse(n.slice(5).trim()))}catch{}}}return{frames:t,rest:e}}var lt=null,U={liveMap:(e,t,n,r)=>{let i=new URLSearchParams;return n&&i.set(`after`,n),r?.mode===`current`&&(i.set(`since`,String(r.since)),i.set(`event_since`,String(r.eventSince)),r.taskId&&i.set(`start_task`,r.taskId)),R(B(e,`/map`)+(i.size?`?${i}`:``),t)},mapInfo:(e,t)=>R(B(e,`/map-info`),t),mapHistory:(e,t,n,r)=>{let i=new URLSearchParams;return n&&i.set(`after`,n),r&&i.set(`task_after`,r),R(B(e,`/map-history`)+(i.size?`?${i}`:``),t)},mapCopy:(e,t,n,r,i)=>R(`/api/map-copy/${e}/${encodeURIComponent(t)}?locale=${n}${i?`&session_id=${encodeURIComponent(i)}`:``}`,r),generateMapCopy:(e,t,n,r,i)=>z(`/api/map-copy/${e}/${encodeURIComponent(t)}${i?`?session_id=${encodeURIComponent(i)}`:``}`,n,r),mapDatasets:e=>R(`/api/map-datasets`,e),mapDataset:(e,t)=>R(`/api/map-datasets/${encodeURIComponent(e)}`,t),meta:H,projectIndex:async()=>(await H(),R(`/api/projects`,void 0,Ye)),listProjects:async()=>(await H(),R(`/api/projects`,void 0,Ye).then(e=>e.projects)),projectCosts:async e=>(await H(),R(`/api/projects/costs`,e)),createDaemon:async(e,t=``,n=``,r)=>{let i=`/api/daemons`,a={objective:e,name:t,workdir:n,command_id:at(),expected_revision:r},o=()=>fetch(i,{method:`POST`,headers:{"Content-Type":`application/json`,...Ke()},body:JSON.stringify(a),cache:`no-store`}),s=await o();return s.status===400&&/Invalid HTTP request received/i.test(await s.clone().text())&&(s=await o()),await Me(s,`POST`,i),nt(await s.json())},updateProject:(e,t)=>rt(`PATCH`,B(e),{name:t}),deleteProject:e=>rt(`DELETE`,B(e)),snapshot:async(e,t,n=!1)=>(await H(),Ve(await R(B(e,`/snapshot?compact=true&events_limit=1${n?`&prewarm=true`:``}`),t,Ye))),activeSnapshot:async(e,t)=>{let n=lt!==e;n&&(lt=e);try{return await U.snapshot(e,t,n)}catch(t){throw n&<===e&&(lt=null),t}},prefetchSnapshot:(e,t)=>U.snapshot(e,t,!1),status:(e,t)=>R(B(e,`/status`),t),journal:(e,t=20,n)=>R(B(e,`/journal?n=${t}`),n).then(e=>e.journal),doctor:(e,t)=>R(B(e,`/doctor`),t),config:(e,t)=>R(B(e,`/config`),t),identity:(e,t)=>R(B(e,`/identity`),t).then(e=>e.identity),transcript:(e,t=30,n)=>R(B(e,`/transcript?n=${t}`),n).then(e=>e.turns),events:(e,t=80,n)=>R(B(e,`/events?limit=${t}&view=ui`),n).then(e=>e.events),backlogItem:(e,t,n)=>R(B(e,`/backlog/${encodeURIComponent(t)}`),n).then(e=>e.item),artifacts:(e,t)=>R(B(e,`/artifacts`),t).then(e=>e.artifacts),artifact:(e,t,n)=>R(B(e,`/artifact?${new URLSearchParams({path:t})}`),n),artifactPreview:(e,t,n)=>R(B(e,`/artifact/preview?${new URLSearchParams({path:t})}`),n),artifactBundle:(e,t,n)=>it(B(e,`/artifact/bundle?${new URLSearchParams({path:t})}`),n),artifactBlob:(e,t,n=!1,r)=>{let i=new URLSearchParams({path:t});return n&&i.set(`download`,`true`),it(B(e,`/artifact/raw?${i}`),r)},gitDiff:(e,t)=>R(B(e,`/git-diff`),t),metrics:e=>R(`/api/metrics`,e),sourceUpdateStatus:e=>R(`/api/runtime/source-update`,e),checkSourceUpdate:()=>z(`/api/runtime/source-update/check`),applySourceUpdate:()=>z(`/api/runtime/source-update/apply`),resources:e=>R(`/api/system/resources`,e),trash:(e=``,t=100,n=0,r)=>R(`/api/trash?${new URLSearchParams({query:e,limit:String(t),offset:String(n)})}`,r),restoreTrash:e=>z(`/api/trash/${encodeURIComponent(e)}/restore`),addTask:(e,t)=>z(B(e,`/tasks`),{text:t}).then(e=>e.item),abortMission:(e,t)=>z(B(e,`/mission/abort`),{reason:t}),mapNotes:(e,t)=>R(B(e,`/map-notes`),t),addMapNote:(e,t)=>z(B(e,`/map-notes`),t),answerPending:(e,t,n)=>z(B(e,`/backlog/${encodeURIComponent(t)}/answer`),{text:n}),resolveDecision:(e,t,n,r)=>z(B(e,`/decisions/${encodeURIComponent(t)}/resolve`),{option_id:n,note:r}),uploadAttachments:async(e,t,n)=>{await H();let r=new FormData;return t.forEach(e=>r.append(`files`,e,e.name)),tt(B(e,`/attachments`),r,n)},message:(e,t,n)=>{let r=st(n)?n:n?.signal,i=st(n)?void 0:n?.attachments,a=st(n)?void 0:n?.routeOverride;return z(B(e,`/message`),V(t,i,a),r)},messageStream:async(e,t,n,r)=>{let i=st(r)?r:r?.signal,a=st(r)?void 0:r?.attachments,o=st(r)?void 0:r?.routeOverride,s=await fetch(B(e,`/message/stream`),{method:`POST`,headers:{"Content-Type":`application/json`,...Ke()},body:JSON.stringify(V(t,a,o)),signal:i});if(await Me(s,`POST`,B(e,`/message/stream`)),!s.body)throw Error(`Manager stream returned no response body`);let c=!1,l=e=>{if(!i?.aborted){if(e.type===`phase`){let t=Number(e.quiet_s??0);n.onPhase?.(String(e.label??``),String(e.role??`manager`),{heartbeat:e.heartbeat===!0,quietS:Number.isFinite(t)?t:0,kind:String(e.kind??``),detail:String(e.detail??``)})}else e.type===`delta`?n.onDelta?.(String(e.text??``),String(e.message_id??``),String(e.fragment_mode??`auto`)):e.type===`done`?(c=!0,n.onDone?.(e.result??{})):e.type===`error`&&(c=!0,n.onError?.(Error(String(e.error??`stream error`))))}},u=s.body.getReader(),d=new TextDecoder,f=``;for(;;){let{done:e,value:t}=await u.read();if(e)break;f+=d.decode(t,{stream:!0});let n=ct(f);f=n.rest,n.frames.forEach(l)}if(!i?.aborted&&(ct(f+` + +`).frames.forEach(l),!c))throw Error(`Manager stream ended before a terminal event`)},nudge:(e,t)=>z(B(e,`/nudge`),{text:t}),note:(e,t)=>z(B(e,`/note`),{text:t}),previewPlan:(e,t)=>z(B(e,`/plan`),{text:t}),rewritePrompt:(e,t)=>z(B(e,`/prompt/rewrite`),{text:t}),setConfig:(e,t,n)=>z(B(e,`/config/set`),{name:t,value:n}),setBudgets:(e,t)=>z(B(e,`/config/budget`),{values:t}),setIdentity:(e,t)=>z(B(e,`/identity`),{text:t}),resetManager:e=>z(B(e,`/reset`)),skills:(e,t=`ls`)=>z(B(e,`/skills`),{args:t}).then(e=>e.text),setLaunchCwd:(e,t)=>z(B(e,`/launch-cwd`),{launch_cwd:t}),setWorkdir:(e,t)=>z(B(e,`/workdir`),{workdir:t}),disposeBacklog:(e,t,n)=>z(B(e,`/backlog/${encodeURIComponent(t)}/dispose`),{op:n}),stopBacklog:(e,t)=>z(B(e,`/backlog/${encodeURIComponent(t)}/stop`)),setContinuous:(e,t,n=``)=>z(B(e,`/continuous`),{enabled:t,objective:n}).then(e=>{if(!t)return e;if(!e.daemon)throw Error(`daemon start returned no result`);return nt(e.daemon),e}),startDaemon:(e,t)=>z(B(e,`/daemon/start`),{command_id:at(),expected_revision:t}).then(nt),stopDaemon:(e,t=!1,n,r=!1)=>z(B(e,`/daemon/stop`),{drain:t,force:r,command_id:at(),expected_revision:n}).then(nt),replaceDaemon:(e,t,n=!1,r)=>z(B(e,`/daemon/replace`),{victim_sid:t,resume_continuous:n,command_id:at(),expected_revision:r}).then(nt),upgradeDaemon:(e,t)=>z(B(e,`/daemon/upgrade`),{command_id:at(),expected_revision:t}).then(nt)},ut=new Set([4401,4404]);function dt(e,t,n={}){let r=window.location.protocol===`https:`?`wss:`:`ws:`,i=new URLSearchParams;n.replay!=null&&i.set(`replay`,String(n.replay)),i.set(`view`,`ui`);let a=Ge();a&&i.set(`token`,a);let o=`${r}//${window.location.host}${B(e,`/stream`)}?${i}`,s=null,c=!1,l,u=()=>{c||(s=new WebSocket(o),s.onopen=()=>n.onOpen?.(),s.onmessage=e=>{try{let n=JSON.parse(e.data);n&&typeof n==`object`&&t(n)}catch{}},s.onclose=e=>{let t=!ut.has(e.code);n.onClose?.({code:e.code,reason:e.reason,retryable:t}),!c&&t&&(l=setTimeout(u,1e3))},s.onerror=()=>s?.close())};return u(),()=>{c=!0,l&&clearTimeout(l),s?.close()}}var W={accent:`rgb(var(--blue))`,success:`rgb(var(--ok))`,error:`rgb(var(--err))`,warning:`rgb(var(--warn))`,info:`rgb(var(--blue))`,ink:`rgb(var(--ink))`,inkDim:`rgb(var(--ink-dim))`,inkFaint:`rgb(var(--ink-faint))`,role:{manager:`rgb(var(--role-manager))`,planner:`rgb(var(--role-planner))`,engineer:`rgb(var(--role-engineer))`,reviewer:`rgb(var(--role-reviewer))`}};function ft(e){switch(e){case`medium`:return W.inkDim;case`high`:return W.info;case`xhigh`:return W.accent;case`max`:return W.error;default:return W.inkFaint}}var pt=e=>String(e??``).trim(),mt=/^[a-z][a-z -]+ requires an operator-owned decision before continuing\.?$/i,ht=e=>{let t=pt(e);return mt.test(t)?``:t},gt=(e,t)=>{let n=/[\u3400-\u9fff]/.test(`${e}\n${t}`);return{id:`custom`,label:n?`自己输入`:`Write my own answer`,description:n?`直接告诉 Argus 你的决定。`:`Tell Argus your decision directly.`,requires_note:!0}};function _t(e,t){let n=[...e,...t],r=[],i=new Set;for(let e of n){let t=pt(e.id),n=e.operator_decision;if(n&&typeof n==`object`&&!Array.isArray(n)){let a=n,o=pt(a.id);if(!o||i.has(o)||pt(a.status)!==`pending`)continue;i.add(o);let s=pt(a.options_source)===`agent`&&Array.isArray(a.options)?a.options.filter(e=>!!pt(e?.id)&&!!pt(e?.label)).map(e=>({...e,requires_note:e.requires_note===!0})):[];s.push(gt(pt(a.title),pt(a.question))),r.push({id:o,item_id:pt(a.item_id)||t,revision:Number(a.revision??1),status:`pending`,title:pt(a.title)||pt(e.title)||`Decision required`,reason:ht(a.reason),question:pt(a.question)||pt(e.pending_question),evidence:Array.isArray(a.evidence)?a.evidence.filter(e=>pt(e?.label)!==`Acceptance check`):[],options:s,options_source:s.length?`agent`:`none`,selected_option:``,note:``});continue}let a=pt(e.pending_question??e.question??e.text);if(!t||!a)continue;let o=`legacy-${t}`;i.has(o)||(i.add(o),r.push({id:o,item_id:t,revision:1,status:`pending`,title:pt(e.title??e.objective)||`Blocked task`,reason:``,question:a,evidence:[],options:[gt(pt(e.title??e.objective),a)],options_source:`none`,selected_option:``,note:``,legacy:!0}))}return r}var G={AGENT_IO_START:`agent.io.start`,AGENT_IO_STREAM:`agent.io.stream`,AGENT_IO_COMPLETE:`agent.io.complete`,AGENT_IO_ERROR:`agent.io.error`,USAGE_RECORDED:`usage.recorded`,PROVIDER_REQUEST_STARTED:`provider.request.started`,PROVIDER_REQUEST_COMPLETED:`provider.request.completed`,PROVIDER_REQUEST_DENIED:`provider.request.denied`,CODEX_UTIL_COMPLETED:`codex.util.completed`,SKILL_COST_COMPLETED:`skill.cost.completed`,BUDGET_RESERVATION_CREATED:`budget.reservation.created`,BUDGET_RESERVATION_DENIED:`budget.reservation.denied`,BUDGET_RESERVATION_SETTLED:`budget.reservation.settled`,BUDGET_RESERVATION_RELEASED:`budget.reservation.released`,BUDGET_UNPRICED_BLOCKED:`budget.unpriced.blocked`,LOOP_START:`loop.start`,LOOP_DONE:`loop.done`,ROUND_START:`round.start`,ROUND_MAIN_COMPLETED:`round.main.completed`,ROUND_REVIEW_STARTED:`round.review.started`,ROUND_REVIEW_DEFERRED:`round.review.deferred`,ROUND_REVIEW_COMPLETED:`round.review.completed`,ROUND_CHECKPOINT_RECORDED:`round.checkpoint.recorded`,ROUND_CHECKPOINT_FAILED:`round.checkpoint.failed`,ROUND_SECRET_REDACTED:`round.secret_redacted`,ROUND_ESCALATED:`round.escalated`,ROUND_STALL:`round.stall`,ROUND_REVIEWER_BACKEND_FAILURE:`round.reviewer_backend_failure`,ROLE_SESSION_TURN:`role.session.turn`,ENGINEER_PROGRESS:`engineer.progress`,ENGINEER_SKILL_MAINTENANCE_COMPLETED:`engineer.skill_maintenance.completed`,LIFE_STATUS:`life.status`,LIFE_PHASE_STARTED:`life.phase.started`,LIFE_MISSION_STARTED:`life.mission.started`,LIFE_MISSION_COMPLETED:`life.mission.completed`,LIFE_MISSION_FAILED:`life.mission.failed`,LIFE_MISSION_SKIPPED:`life.mission.skipped`,LIFE_MISSION_ORPHANED:`life.mission.orphaned`,LIFE_MISSION_REQUEUED:`life.mission.requeued`,LIFE_MANAGER_INTENT_STARTED:`life.manager.intent.started`,LIFE_MANAGER_INTENT_COMPLETED:`life.manager.intent.completed`,LIFE_MANAGER_INTENT_FAILED:`life.manager.intent.failed`,LIFE_MANAGER_STAGE_DECISION:`life.manager.stage_decision`,LIFE_MANAGER_PLAN_CHALLENGE_DECIDED:`life.manager.plan_challenge.decided`,LIFE_VERTICAL_RESOLVED:`life.vertical.resolved`,LIFE_MANAGER_BACKEND_RESOLVED:`life.manager.backend_resolved`,LIFE_PLANNER_BACKEND_RESOLVED:`life.planner.backend_resolved`,LIFE_ENGINEER_BACKEND_RESOLVED:`life.engineer.backend_resolved`,LIFE_REVIEWER_BACKEND_RESOLVED:`life.reviewer.backend_resolved`,LIFE_CURATOR_BACKEND_RESOLVED:`life.curator.backend_resolved`,LIFE_PLANNER_START:`life.planner.start`,LIFE_PLANNER_NORMALIZED:`life.planner.normalized`,LIFE_PLANNER_TASK_ADDED:`life.planner.task_added`,LIFE_PLANNER_TASK_SKIPPED:`life.planner.task_skipped`,LIFE_PLANNER_VERDICT:`life.planner.verdict`,LIFE_PLANNER_WAITING:`life.planner.waiting`,LIFE_PLANNER_WAITING_WOKEN:`life.planner.waiting_woken`,LIFE_PLANNER_TERMINAL_IDLE:`life.planner.terminal_idle`,LIFE_PLANNER_VERIFICATION_PROBE:`life.planner.verification_probe`,LIFE_PLANNER_STALL_ESCALATION:`life.planner.stall_escalation`,LIFE_PLANNER_DEPENDENCY_DROPPED:`life.planner.dependency_dropped`,LIFE_PLANNER_PARALLEL_DROPPED:`life.planner.parallel_dropped`,LIFE_PLANNER_ERROR:`life.planner.error`,LIFE_RUNTIME_FAILURE_CIRCUIT_OPENED:`life.runtime_failure.circuit_opened`,LIFE_RUNTIME_FAILURE_CIRCUIT_BLOCKED:`life.runtime_failure.circuit_blocked`,LIFE_RUNTIME_FAILURE_CANARY_PASSED:`life.runtime_failure.canary_passed`,LIFE_PLAN_REVISION_PROPOSED:`life.plan.revision.proposed`,LIFE_PLAN_REVISION_REJECTED:`life.plan.revision.rejected`,LIFE_PLAN_REVISION_COMMITTED:`life.plan.revision.committed`,LIFE_PLAN_NODE_SUPERSEDED:`life.plan.node.superseded`,LIFE_RESEARCH_SECOND_READING:`life.research.second_reading`,LIFE_LETTER_WRITTEN:`life.letter.written`,LIFE_BUDGET_PAUSE:`life.budget.pause`,LIFE_LIFECYCLE_BLOCK:`life.lifecycle.block`,LIFE_LIFECYCLE_TRANSITION:`life.lifecycle.transition`,LIFE_INBOX_QUEUED:`life.inbox.queued`,LIFE_INBOX_DRAINED:`life.inbox.drained`,LIFE_OPERATOR_QUESTION_PENDING:`life.operator_question.pending`,LIFE_OPERATOR_QUESTION_ANSWERED:`life.operator_question.answered`,LIFE_DAEMON_IDLE_TIMEOUT:`life.daemon.idle_timeout`,PROJECT_COMPLETED:`project.completed`,PROJECT_COMPLETION_REFUSED:`project.completion_refused`,DAEMON_PARKED:`daemon.parked`,DAEMON_COMMAND_SUBMITTED:`daemon.command.submitted`,DAEMON_COMMAND_COMPLETED:`daemon.command.completed`,DAEMON_COMMAND_REJECTED:`daemon.command.rejected`,IDEA_SEARCH_STARTED:`idea.search.started`,IDEA_SEARCH_COMPLETED:`idea.search.completed`,IDEA_SEARCH_SKIPPED:`idea.search.skipped`,VENUE_RESEARCH_STARTED:`venue.research.started`,VENUE_RESEARCH_COMPLETED:`venue.research.completed`,RESEARCH_ACHIEVEMENT_CERTIFIED:`research.achievement.certified`,SKILL_LIBRARY_AVAILABLE:`skill.library.available`,SKILL_CREATED:`skill.created`,SKILL_UPDATED:`skill.updated`,SKILL_ARCHIVED:`skill.archived`,SKILL_TIDIED:`skill.tidied`,SKILL_HISTORY_COMPRESSED:`skill.history.compressed`,SKILL_EVOLUTION_COMPLETED:`skill.evolution.completed`,WIKI_INITIALIZED:`wiki.initialized`,WIKI_HOOK_WARNING:`wiki.hook.warning`,WIKI_CREATED:`wiki.created`,WIKI_UPDATED:`wiki.updated`,WIKI_RETIRED:`wiki.retired`,WIKI_PROMOTION_PROMOTED:`wiki.promotion.promoted`,WIKI_PROMOTION_DEMOTED:`wiki.promotion.demoted`,WIKI_RETIRED_COMPRESSED:`wiki.retired.compressed`,WIKI_EVOLUTION_COMPLETED:`wiki.evolution.completed`,OPERATOR_ALERT:`operator_alert`},vt={"loop.started":G.LOOP_START,"loop.completed":G.LOOP_DONE,"round.started":G.ROUND_START,"mission.started":G.LIFE_MISSION_STARTED,"mission.completed":G.LIFE_MISSION_COMPLETED,"mission.error":G.LIFE_MISSION_FAILED};G.LIFE_MANAGER_BACKEND_RESOLVED,G.LIFE_PLANNER_BACKEND_RESOLVED,G.LIFE_ENGINEER_BACKEND_RESOLVED,G.LIFE_REVIEWER_BACKEND_RESOLVED,G.LIFE_CURATOR_BACKEND_RESOLVED,G.LOOP_START,G.LOOP_DONE,G.ROUND_START,G.ROUND_MAIN_COMPLETED,G.ROUND_REVIEW_DEFERRED,G.ROUND_REVIEW_COMPLETED,G.ROUND_CHECKPOINT_RECORDED,G.ROUND_CHECKPOINT_FAILED,G.ROUND_SECRET_REDACTED,G.ROUND_ESCALATED,G.ROUND_STALL,G.ROUND_REVIEWER_BACKEND_FAILURE,G.ENGINEER_SKILL_MAINTENANCE_COMPLETED,G.SKILL_LIBRARY_AVAILABLE,G.SKILL_CREATED,G.SKILL_UPDATED,G.SKILL_ARCHIVED,G.SKILL_TIDIED,G.SKILL_HISTORY_COMPRESSED,G.SKILL_EVOLUTION_COMPLETED,G.WIKI_INITIALIZED,G.WIKI_HOOK_WARNING,G.WIKI_CREATED,G.WIKI_UPDATED,G.WIKI_RETIRED,G.WIKI_PROMOTION_PROMOTED,G.WIKI_PROMOTION_DEMOTED,G.WIKI_RETIRED_COMPRESSED,G.WIKI_EVOLUTION_COMPLETED,G.LIFE_MISSION_STARTED,G.LIFE_MISSION_COMPLETED,G.LIFE_MANAGER_INTENT_STARTED,G.LIFE_MANAGER_INTENT_COMPLETED,G.LIFE_MANAGER_INTENT_FAILED,G.LIFE_MANAGER_STAGE_DECISION,G.LIFE_MANAGER_PLAN_CHALLENGE_DECIDED,G.LIFE_VERTICAL_RESOLVED,G.LIFE_PLANNER_START,G.LIFE_PLANNER_TASK_ADDED,G.LIFE_PLANNER_TASK_SKIPPED,G.LIFE_PLANNER_DEPENDENCY_DROPPED,G.LIFE_PLANNER_PARALLEL_DROPPED,G.LIFE_PLANNER_VERDICT,G.LIFE_PLANNER_WAITING,G.LIFE_PLANNER_WAITING_WOKEN,G.LIFE_PLANNER_TERMINAL_IDLE,G.LIFE_PLANNER_VERIFICATION_PROBE,G.LIFE_PLANNER_STALL_ESCALATION,G.LIFE_RUNTIME_FAILURE_CIRCUIT_OPENED,G.LIFE_RUNTIME_FAILURE_CIRCUIT_BLOCKED,G.LIFE_RUNTIME_FAILURE_CANARY_PASSED,G.LIFE_PLAN_REVISION_PROPOSED,G.LIFE_PLAN_REVISION_REJECTED,G.LIFE_PLAN_REVISION_COMMITTED,G.LIFE_PLAN_NODE_SUPERSEDED,G.LIFE_RESEARCH_SECOND_READING,G.LIFE_LETTER_WRITTEN,G.LIFE_BUDGET_PAUSE,G.BUDGET_RESERVATION_DENIED,G.BUDGET_UNPRICED_BLOCKED,G.LIFE_LIFECYCLE_BLOCK,G.LIFE_LIFECYCLE_TRANSITION,G.PROVIDER_REQUEST_STARTED,G.PROVIDER_REQUEST_COMPLETED,G.PROVIDER_REQUEST_DENIED,G.LIFE_INBOX_QUEUED,G.LIFE_INBOX_DRAINED,G.LIFE_DAEMON_IDLE_TIMEOUT,G.PROJECT_COMPLETED,G.PROJECT_COMPLETION_REFUSED,G.DAEMON_PARKED,G.DAEMON_COMMAND_COMPLETED,G.DAEMON_COMMAND_REJECTED,G.IDEA_SEARCH_STARTED,G.IDEA_SEARCH_COMPLETED,G.IDEA_SEARCH_SKIPPED,G.VENUE_RESEARCH_STARTED,G.VENUE_RESEARCH_COMPLETED,G.RESEARCH_ACHIEVEMENT_CERTIFIED,G.OPERATOR_ALERT,G.AGENT_IO_START,G.AGENT_IO_COMPLETE,G.AGENT_IO_ERROR,G.PROVIDER_REQUEST_STARTED,G.PROVIDER_REQUEST_COMPLETED,G.PROVIDER_REQUEST_DENIED,G.USAGE_RECORDED;function yt(e){let t=String(e??``).trim();return vt[t]??t}function bt(e){if(typeof e!=`object`||!e)return JSON.stringify(e);if(Array.isArray(e))return`[${e.map(bt).join(`,`)}]`;let t=e;return`{${Object.keys(t).sort().map(e=>`${JSON.stringify(e)}:${bt(t[e])}`).join(`,`)}}`}function xt(e){let t=2166136261;for(let n=0;n>>0).toString(36)}function St(e){let t=e.event_id??e.id??e.seq??e._offset,n=String(e.type??`event`);return t!=null&&t!==``?`${n}-${String(t)}`:`${n}-${String(e.ts??e.time??``)}-${xt(bt(e))}`}function Ct(e){return e.type===G.ENGINEER_PROGRESS&&e.kind===`reasoning`}function wt(e){if(e.type!==G.ENGINEER_PROGRESS||![`assistant_message`,`agent_message`,`message`].includes(String(e.kind??``)))return!1;let t=String(e.agent_layer??e.actor??``);return String(e.text??``).trimStart().startsWith(`{`)?t===`reviewer`||t===`planner`:!1}var Tt=/^(?:[-*+]\s*)?[`*_]*(?:ARGUS_)?(?:MILESTONE_STATUS|NEXT_OWNER|OPERATOR_QUESTION|OPERATOR_OPTIONS|ROLE_DECISION)[`*_]*\s*[:=]|^(?:final\s+)?decision\s*:\s*$/i;function Et(e){return String(e??``).split(/\r?\n/).filter(e=>!Tt.test(e.trim())).join(` +`).trim()}function Dt(e){let t=String(e.fragment_mode??``);return t===`append`||t===`snapshot`?t:e.replace===!0?`snapshot`:`auto`}function Ot(e,t){let n=Math.min(e.length,t.length);for(let r=n;r>=8;--r)if(e.endsWith(t.slice(0,r)))return r;return 0}function kt(e,t,n=`auto`){let r=(e||``).trim(),i=(t||``).trim();if(!r)return i;if(!i)return r;if(n===`snapshot`)return i;if(r.includes(i))return r;if(n===`append`)return`${r}\n${i}`;if(i.includes(r))return i;let a=Ot(r,i);return a?`${r}${i.slice(a)}`:`${r}\n${i}`}var At=[`all`,`attention`,`milestones`,`messages`],jt=new Set([G.LIFE_MISSION_STARTED,G.LIFE_MISSION_COMPLETED,G.LIFE_MISSION_FAILED,G.LOOP_START,G.LOOP_DONE,G.LIFE_PLANNER_VERDICT,`final.report.ready`,`pptx.report.ready`,`plan.completed`,G.LIFE_BUDGET_PAUSE,G.LIFE_LIFECYCLE_BLOCK]);function Mt(e,t,n=`all`,r=``){let i=yt(e.canonical_type??e.type),a=String(e.kind??``);if(n===`attention`&&![`warn`,`err`].includes(String(t.tone??``))&&e.operator_alert!==!0||n===`milestones`&&!(t.rule&&!i.startsWith(`ui.`))&&!jt.has(i)||n===`messages`&&t.tone!==`bright`&&![`assistant_message`,`agent_message`,`message`].includes(a)&&![`ui.operator`,`ui.argus`].includes(i))return!1;let o=r.trim().toLocaleLowerCase();return!o||[i,a,t.role,t.label,t.text,e.title,e.objective,e.text,e.summary,e.reason,e.error,e.status,e.action_summary,e.command,e.path,Array.isArray(e.tags)?e.tags.join(` `):e.tags].some(e=>String(e??``).toLocaleLowerCase().includes(o))}var Nt=[{id:`status`,name:`/status`,argument:`none`,desc:`roles, queued work, journal, and health`,group:`Everyday`,kind:`panel`},{id:`roles`,name:`/roles`,argument:`none`,desc:`per-role backend / model / effort + live activity`,group:`Everyday`,kind:`panel`},{id:`journal`,name:`/journal`,arg:`[N]`,argument:`optional`,desc:`recent journal entries (default 10)`,group:`Everyday`,kind:`panel`},{id:`backlog`,name:`/backlog`,arg:`[all]`,argument:`optional`,desc:`pending tasks (all = incl. done/skipped)`,group:`Everyday`,kind:`panel`},{id:`artifacts`,name:`/artifacts`,argument:`none`,desc:`result files the Reviewer has checked (Enter previews)`,group:`Everyday`,kind:`panel`},{id:`artifact`,name:`/artifact`,arg:``,argument:`required`,desc:`preview one reviewed result file`,group:`Everyday`,kind:`panel`},{id:`events`,name:`/events`,arg:`[filter] [query]`,argument:`optional`,desc:`search feed: all / watch / milestones / messages`,group:`Everyday`,kind:`panel`},{id:`find`,name:`/find`,arg:``,argument:`required`,desc:`search the current event buffer`,group:`Everyday`,kind:`panel`},{id:`cancel`,name:`/cancel`,argument:`none`,desc:`stop waiting for the current Manager reply`,group:`Everyday`,kind:`local`},{id:`ask`,name:`/ask`,arg:``,argument:`required`,desc:`answer inline — no task queued, no Planner/Engineer/Reviewer`,aliases:[`/chat`],group:`Everyday`,kind:`action`},{id:`crystalpilot`,name:`/crystalpilot`,arg:`[status|off|use ]`,argument:`optional`,desc:`enable crystallography tools in this Argus conversation`,group:`Everyday`,kind:`action`},{id:`task`,name:`/task`,arg:``,argument:`required`,desc:`queue work directly`,aliases:[`/add`],group:`Task management`,kind:`action`},{id:`plan`,name:`/plan`,arg:``,argument:`required`,desc:`preview a Planner-authored execution plan`,group:`Task management`,kind:`action`},{id:`rewrite`,name:`/rewrite`,arg:`[text]`,argument:`optional`,desc:`let the Manager rewrite your prompt before sending`,aliases:[`/refine`],group:`Task management`,kind:`action`},{id:`nudge`,name:`/nudge`,arg:``,argument:`required`,desc:`inject guidance into the running mission`,aliases:[`/inject`,`/notify`],group:`Task management`,kind:`action`},{id:`abort`,name:`/abort`,argument:`none`,desc:`immediately stop the running mission`,group:`Task management`,kind:`action`},{id:`note`,name:`/note`,arg:``,argument:`required`,desc:`append a manual note to the timeline`,group:`Task management`,kind:`action`},{id:`done`,name:`/done`,arg:``,argument:`required`,desc:`mark a task done`,group:`Task management`,kind:`action`},{id:`skip`,name:`/skip`,arg:``,argument:`required`,desc:`skip a task`,aliases:[`/rm`],group:`Task management`,kind:`action`},{id:`stop`,name:`/stop`,arg:``,argument:`required`,desc:`stop a task's auto-iteration`,group:`Task management`,kind:`action`},{id:`item`,name:`/item`,arg:``,argument:`required`,desc:`inspect a full task contract`,group:`Task management`,kind:`panel`},{id:`run`,name:`/run`,argument:`none`,desc:`return to the always-live mission feed`,group:`Task management`,kind:`local`},{id:`new`,name:`/new`,arg:`[objective]`,argument:`optional`,desc:`review, create, and switch to a fresh conversation`,group:`Sessions & diagnostics`,kind:`action`},{id:`daemons`,name:`/daemons`,arg:`[query]`,argument:`optional`,desc:`find every session + switch or create`,group:`Sessions & diagnostics`,kind:`panel`},{id:`resume`,name:`/resume`,arg:`[list|]`,argument:`optional`,desc:`switch to another project/session`,group:`Sessions & diagnostics`,kind:`action`},{id:`attach`,name:`/attach`,arg:``,argument:`required`,desc:`follow another project (read the stream)`,group:`Sessions & diagnostics`,kind:`action`},{id:`rename`,name:`/rename`,arg:``,argument:`required`,desc:`rename the current conversation`,group:`Sessions & diagnostics`,kind:`action`},{id:`doctor`,name:`/doctor`,argument:`none`,desc:`diagnose 'why isn't anything running'`,group:`Sessions & diagnostics`,kind:`panel`},{id:`backend`,name:`/backend`,arg:`[codex|claude|copilot|cursor|opencode|pi|grok|qoder|dsh]`,argument:`optional`,desc:`view or change the shared runner backend`,group:`Configuration`,kind:`action`},{id:`config`,name:`/config`,arg:`[key=value …]`,argument:`optional`,desc:`view or change runtime settings`,group:`Configuration`,kind:`panel`},{id:`identity`,name:`/identity`,arg:`[set ]`,argument:`optional`,desc:`view or replace the operator identity card`,group:`Configuration`,kind:`panel`},{id:`reset`,name:`/reset`,argument:`none`,desc:`drop the warm Manager conversation context`,group:`Configuration`,kind:`action`},{id:`skills`,name:`/skills`,arg:`[ls|promote ]`,argument:`optional`,desc:`inspect or promote runtime skills`,group:`Configuration`,kind:`action`},{id:`clear`,name:`/clear`,argument:`none`,desc:`clear the event feed view`,group:`Other`,kind:`local`},{id:`reconnect`,name:`/reconnect`,argument:`none`,desc:`reconnect the live event stream`,group:`Other`,kind:`local`},{id:`help`,name:`/help`,argument:`none`,desc:`keys + full command reference`,aliases:[`/?`,`/commands`],group:`Other`,kind:`local`},{id:`quit`,name:`/quit`,argument:`none`,desc:`leave the cockpit (background work keeps running)`,aliases:[`/exit`,`/q`],group:`Other`,kind:`local`}];new Map(Nt.map(e=>[e.id,e]));var Pt=new Map;for(let e of Nt)for(let t of[e.name,...e.aliases??[]])Pt.set(t.toLowerCase(),e);function Ft(e){return e.argument===`required`}var K=/^\/[A-Za-z0-9_-]+$/;function It(e){if(!e.startsWith(`/`))return!1;let t=e.indexOf(` `),n=t===-1?e:e.slice(0,t);return K.test(n)}function Lt(e){return e.startsWith(`/`)&&!e.includes(` `)&&!e.slice(1).includes(`/`)}function Rt(e){if(!Lt(e))return[];let t=e.toLowerCase(),n=new Set,r=[];for(let e of Nt)[e.name,...e.aliases??[]].some(e=>e.toLowerCase().startsWith(t))&&!n.has(e.name)&&(n.add(e.name),r.push(e));return r.sort((e,n)=>Number(zt(n,t))-Number(zt(e,t)))}function zt(e,t){return[e.name,...e.aliases??[]].some(e=>e.toLowerCase()===t)}function Bt(e){return e.arg?`${e.name} `:e.name}function Vt(e){let t=e.trim();if(!t)return{filter:`all`,query:``};let[n,...r]=t.split(/\s+/);return n.toLowerCase()===`watch`?{filter:`attention`,query:r.join(` `)}:At.includes(n.toLowerCase())?{filter:n.toLowerCase(),query:r.join(` `)}:{filter:`all`,query:t}}function Ht(e){if(!It(e))return null;let t=e.indexOf(` `),n=(t===-1?e:e.slice(0,t)).toLowerCase(),r=t===-1?``:e.slice(t+1).trim(),i=Pt.get(n)??null;return{cmd:i,name:i?i.name:n,rest:r}}function Ut(e){let t=e.toLowerCase(),n=null,r=0;for(let e of Pt.keys()){let i=Wt(t,e);i>r&&(r=i,n=Pt.get(e).name)}return r>=.6?n:null}function Wt(e,t){return 1-Gt(e,t)/(Math.max(e.length,t.length)||1)}function Gt(e,t){let n=e.length,r=t.length,i=Array.from({length:n+1},(e,t)=>[t,...Array(r).fill(0)]);for(let e=0;e<=r;e+=1)i[0][e]=e;for(let a=1;a<=n;a+=1)for(let n=1;n<=r;n+=1)i[a][n]=Math.min(i[a-1][n]+1,i[a][n-1]+1,i[a-1][n-1]+(e[a-1]===t[n-1]?0:1));return i[n][r]}var Kt=new Set([`done`,`success`,`completed`]),qt=new Set([`research_incomplete`,`paused_no_breakthrough`,`exhausted_current_methods`]),Jt=new Set([`no_progress`,`max_rounds`]),Yt=new Set([`blocked`,`infra_blocked`]),Xt=new Set([`error`,`failed`,`supervisor_error`]),Zt={completed:{glyph:`🎉`,tone:`ok`,missionStatus:`complete`},incomplete:{glyph:`◌`,tone:`warn`,missionStatus:`incomplete`},stalled:{glyph:`⏸`,tone:`warn`,missionStatus:`stalled`},blocked:{glyph:`⛔`,tone:`err`,missionStatus:`blocked`},failed:{glyph:`💥`,tone:`err`,missionStatus:`failed`},ended:{glyph:`■`,tone:`info`,missionStatus:`ended`}},Qt={completed:`Task completed`,incomplete:`Mission incomplete`,stalled:`Mission stalled`,blocked:`Mission blocked`,failed:`Mission failed`,ended:`Mission ended`};function $t(e){return String(e??``).trim().toLowerCase()}function en(e){let t=$t(e);switch(t){case`completed`:case`incomplete`:case`stalled`:case`blocked`:case`failed`:case`ended`:return t;default:return null}}function tn(e){let t=$t(e.status);return e.success===!0||Kt.has(t)?`completed`:qt.has(t)?`incomplete`:Jt.has(t)?`stalled`:Yt.has(t)?`blocked`:Xt.has(t)?`failed`:`ended`}function nn(e){let t=e.outcome;if(t&&typeof t==`object`&&!Array.isArray(t)){let n=t;return{execution_status:$t(n.execution_status)||tn(e),review_status:$t(n.review_status)||`not_assessed`,stage_certification:$t(n.stage_certification)||`not_assessed`,interruption_kind:$t(n.interruption_kind)||`none`,resumable:n.resumable===!0}}return{execution_status:tn(e),review_status:`not_assessed`,stage_certification:`not_assessed`,interruption_kind:$t(e.stop_kind)||`none`,resumable:e.resumable===!0}}function rn(e){if(e.success===!0&&e.campaign_continues===!0)return{outcomeClass:`completed`,label:`Task continued`,glyph:`↻`,tone:`info`,missionStatus:`continued`};let t=en(e.outcome_class)??tn(e),n=String(e.status??``).trim(),r=Zt[t];return{outcomeClass:t,label:t===`completed`&&e.final_submission_certified===!0?`Submission certified`:t===`ended`&&n?`Mission ended · ${n}`:Qt[t],glyph:r.glyph,tone:r.tone,missionStatus:r.missionStatus}}var an=[`manager`,`planner`,`engineer`,`reviewer`],on=new Set([`planner`,`engineer`,`reviewer`]),sn=new Set([`running`,`in_progress`,`claimed`]),q=(e,t)=>String(e[t]??``).trim(),cn=(e,t)=>{let n=Number(e[t]);return Number.isFinite(n)?n:null};function ln(e){let t=[e.route?e.route.toUpperCase():``,e.vertical,e.workflow_mode?e.workflow_mode.toUpperCase():``].filter(Boolean);return e.lifetime===`standing`?t.push(`STANDING · OPEN-ENDED`):e.lifetime===`bounded_increment`?t.push(`BOUNDED INCREMENT`):e.lifetime===`bounded`&&e.continuous?t.push(`BOUNDED · FINITE CONTINUOUS`):e.lifetime&&t.push(e.lifetime.toUpperCase()),t.join(` · `)}function un(e){return JSON.parse(JSON.stringify(e))}function dn(){return{schema_version:6,bootstrapped:!1,mission:{id:``,title:``,objective:``,summary:``,final_output:``,status:`idle`,started_at:null,completed_at:null,elapsed_seconds:0,campaign_started_at:null,campaign_elapsed_seconds:0},stage:{id:``,label:``},routing:{route:``,vertical:``,workflow_mode:``,lifetime:``,continuous:!1,open_ended:!1},round:{current:0,max:0},active_role:``,roles:an.map(e=>({role:e,status:`waiting`,label:`Waiting`,updated_at:0})),role_work:[],dag:[],timeline:[],artifacts:[],learned_skills:[],learned_wiki_pages:[],storage:{project_skill_dir:``,global_skill_dir:``,project_skill_count:0,global_skill_count:0,skill_history_compressed:0,wiki_retired_compressed:0,skill_history_bytes_saved:0,wiki_retired_bytes_saved:0,wiki_paths:[]},achievement:null,review:{status:``,reason:``,rejected_attempts:0},frontier:{change:``,summary:``,updated_at:0},delivery:null,outcome:{},last_event_ts:0,updated_at:0}}function fn(e,t,n,r){if(n==null||n===``)return;let i=e.findIndex(e=>e[t]===n);i>=0?e[i]={...e[i],...r}:e.push(r)}function pn(e,t,n,r,i){if(!an.includes(t))return;n===`active`&&on.has(t)&&e.roles.forEach(e=>{on.has(e.role)&&e.role!==t&&e.status===`active`&&Object.assign(e,{status:`done`,label:`Handed off`,updated_at:i})});let a={role:t,status:n,label:r,updated_at:i};fn(e.roles,`role`,t,a),n===`active`?e.active_role=t:e.active_role===t&&(e.active_role=``)}function mn(e,t,n,r,i=``,a=`neutral`){let o=St(t);if(e.timeline.some(e=>e.id===o))return;let s={id:o,ts:Number(t.ts??Date.now()/1e3),type:yt(t.type),role:n,title:r.slice(0,180),detail:i.slice(0,500),tone:a};[`item_id`,`branch_id`].forEach(e=>{let n=q(t,e);n&&(s[e]=n)}),e.timeline=[...e.timeline,s].slice(-120)}function hn(e,t,n,r,i,a=``,o=``){if(!an.includes(n))return;let s=q(t,`message_id`),c=s?`${n}:${s}`:St(t),l=e.role_work.find(e=>e.id===c),u=l&&l.detail.length>a.length?l.detail:a,d={id:c,ts:Number(t.ts??Date.now()/1e3),role:n,kind:r,title:i.slice(0,240),detail:u.slice(0,4e3),status:o,item_id:q(t,`item_id`),mission_id:e.mission.id,mission_title:e.mission.title.slice(0,240),round_index:cn(t,`round_index`)},f=e.role_work.findIndex(e=>e.id===c);f>=0?e.role_work[f]=d:e.role_work.push(d);let p=new Set;an.forEach(t=>{e.role_work.filter(e=>e.role===t).slice(-40).forEach(e=>p.add(e.id))}),e.role_work=e.role_work.filter(e=>p.has(e.id))}function gn(e){return e===`ok`?`success`:e===`err`?`error`:`info`}var _n={agent_message:`Reporting progress`,assistant_message:`Reporting progress`,command_execution:`Running a command`,reasoning:`Reasoning`,tool_use:`Using a tool`,tool_result:`Inspecting tool output`,codex_idle:`Waiting for model output`};function vn(e,t){let n=yt(t.type),r=Number(t.ts??Date.now()/1e3);if(e.last_event_ts=Math.max(e.last_event_ts,r),n===G.LIFE_MANAGER_INTENT_STARTED)e.mission.id=q(t,`item_id`)||q(t,`intent_id`),e.mission.title=q(t,`objective`).slice(0,240),e.mission.objective=q(t,`objective`),e.mission.summary=``,e.mission.final_output=``,e.mission.started_at=null,e.mission.completed_at=null,e.mission.status=`grounding`,pn(e,`manager`,`active`,`Grounding project`,r),mn(e,t,`manager`,`Project grounding started`,q(t,`objective`)),hn(e,t,`manager`,`grounding`,`Grounding project`,q(t,`objective`),`active`);else if(n===G.LIFE_MANAGER_INTENT_COMPLETED){e.mission.id=q(t,`item_id`),e.mission.title=q(t,`objective`).slice(0,240),e.mission.objective=q(t,`objective`),e.mission.summary=``,e.mission.final_output=``,e.mission.started_at=null,e.mission.completed_at=null,e.mission.status=`framed`,e.routing.route=q(t,`route`)||e.routing.route||`team`,e.routing.vertical=q(t,`vertical`)||e.routing.vertical,e.routing.workflow_mode=q(t,`workflow_mode`)||e.routing.workflow_mode,e.routing.lifetime=q(t,`lifetime`)||e.routing.lifetime,`continuous`in t&&(e.routing.continuous=t.continuous===!0),`open_ended`in t&&(e.routing.open_ended=t.open_ended===!0);let n=q(t,`current_stage`),i=Array.isArray(t.stages)?t.stages:[];if(n)e.stage={id:n,label:n.replaceAll(`_`,` `)};else if(!e.stage.id&&i[0]){let t=String(i[0]);e.stage={id:t,label:t.replaceAll(`_`,` `)}}pn(e,`manager`,`done`,`Goal framed`,r),mn(e,t,`manager`,`Goal framed`,q(t,`reason`),`success`),hn(e,t,`manager`,`decision`,`Goal framed`,q(t,`reason`)||q(t,`execution_task`),`done`)}else if(n===G.LIFE_MANAGER_INTENT_FAILED)e.mission.status=`failed`,pn(e,`manager`,`error`,`Manager routing failed`,r),mn(e,t,`manager`,`Manager routing failed`,q(t,`error`)||q(t,`reason`),`error`),hn(e,t,`manager`,`grounding`,`Manager routing failed`,q(t,`error`)||q(t,`reason`),`error`);else if(n===G.LIFE_MANAGER_STAGE_DECISION){let n=q(t,`target_stage`)||q(t,`stage`)||q(t,`current_stage`);n&&(e.stage={id:n,label:n.replaceAll(`_`,` `)}),pn(e,`manager`,`done`,n?`Stage · ${n}`:`Stage reviewed`,r),mn(e,t,`manager`,n?`Stage → ${n}`:`Stage reviewed`,q(t,`reason`)),hn(e,t,`manager`,`stage_decision`,n?`Stage → ${n}`:`Stage reviewed`,q(t,`reason`),q(t,`action`))}else if(n===G.LIFE_PLANNER_START)pn(e,`planner`,`active`,`Planning next work`,r),hn(e,t,`planner`,`planning`,`Planning next work`,q(t,`objective`),`active`);else if(n===G.LIFE_PLANNER_TASK_ADDED){let n=q(t,`item_id`),i={id:n,title:q(t,`title`),objective:q(t,`objective`),status:`pending`,deps:Array.isArray(t.deps)?t.deps.map(String):[],branch_id:q(t,`branch_id`)||n,parent_branch_id:q(t,`parent_branch_id`)||null};fn(e.dag,`id`,n,i);let a=e.routing.vertical===`research`?`Research branch added`:`Task added`;pn(e,`planner`,`done`,a,r),mn(e,t,`planner`,a,i.title,`info`),hn(e,t,`planner`,`task`,i.title||`Task added`,i.objective,`pending`)}else if(n===G.LIFE_PLANNER_VERDICT){let n=!!t.project_done,i=n&&t.delivery&&typeof t.delivery==`object`&&!Array.isArray(t.delivery)?JSON.parse(JSON.stringify(t.delivery)):null,a=i?`Task completed`:n?`Project reviewed`:`Planning complete`;i&&(e.delivery=i,e.mission.status=`complete`,e.mission.summary=i.summary||``,e.mission.completed_at=r),pn(e,`planner`,`done`,a,r),mn(e,t,`planner`,a,q(t,`reason`),n?`success`:`neutral`),hn(e,t,`planner`,`verdict`,a,q(t,`reason`),n?`done`:`planned`)}else if(n===G.LIFE_PLANNER_WAITING){pn(e,`planner`,`waiting`,`Waiting on external work`,r);let n=q(t,`reason`)||q(t,`waiting_reason`);mn(e,t,`planner`,`Planner waiting`,n),hn(e,t,`planner`,`waiting`,`Planner waiting`,n,`waiting`)}else if(n===G.LIFE_MISSION_STARTED)e.review={status:``,reason:``,rejected_attempts:0},e.delivery=null,e.mission.campaign_started_at??=r,e.mission={...e.mission,id:q(t,`item_id`),title:q(t,`title`),objective:q(t,`objective`),summary:``,final_output:``,status:`working`,started_at:r,completed_at:null},pn(e,`reviewer`,`waiting`,`Waiting for the Engineer to finish`,r),pn(e,`engineer`,`active`,`Starting mission`,r),mn(e,t,`engineer`,`Mission started`,q(t,`title`),`info`),hn(e,t,`engineer`,`task`,q(t,`title`)||`Mission started`,q(t,`objective`),`active`);else if(n===G.ROUND_START)e.round={current:cn(t,`round_index`)??0,max:cn(t,`round_max`)??e.round.max},pn(e,`engineer`,`active`,`Running round ${e.round.current}`,r),mn(e,t,`engineer`,`Round ${e.round.current} started`);else if(n===G.ENGINEER_PROGRESS){let n=q(t,`agent_layer`)||q(t,`actor`)||`engineer`,i=n===`main`?`engineer`:n,a=q(t,`kind`),o=_n[a]??`Working`;pn(e,i,`active`,o,r),i===`engineer`&&[`assistant_message`,`agent_message`,`message`].includes(a)&&t.final_delivery===!0&&e.mission.started_at!=null&&e.mission.completed_at==null&&r>=e.mission.started_at&&(!t.item_id||q(t,`item_id`)===e.mission.id)&&(e.mission.final_output=Et(t.text));let s=q(t,`action_summary`)||q(t,`text`);s&&!Ct(t)&&!wt(t)&&hn(e,t,i,a||`progress`,o,s,`active`),[`reasoning`,`assistant_message`,`agent_message`].includes(a)||mn(e,t,i,o,q(t,`action_summary`)||q(t,`text`))}else if(n===G.ROUND_MAIN_COMPLETED)pn(e,`engineer`,`done`,`Work ready for review`,r),hn(e,t,`engineer`,`handoff`,`Work ready for review`,q(t,`text`)||q(t,`summary`),`done`);else if(n===G.ROUND_REVIEW_STARTED)e.review={status:``,reason:``,rejected_attempts:e.review.rejected_attempts},pn(e,`reviewer`,`active`,`Reviewing benchmark evidence`,r),hn(e,t,`reviewer`,`review`,`Review started`,``,`active`);else if(n===G.ROUND_REVIEW_DEFERRED){let n=q(t,`next_step`);pn(e,`engineer`,`active`,`Continuing before review`,r),pn(e,`reviewer`,`waiting`,`Review deferred for one round`,r),mn(e,t,`engineer`,`Continued before review`,n,`info`)}else if(n===G.ROUND_REVIEW_COMPLETED){let n=t.review_skipped===!0,i=n?`skipped`:q(t,`status`),a=q(t,`reason`);e.review={status:i,reason:a,rejected_attempts:e.review.rejected_attempts+ +!![`continue`,`blocked`].includes(i)};let o=q(t,`frontier_change`);o&&(e.frontier={change:o,summary:q(t,`frontier_summary`),updated_at:r});let s=n?`Review not performed`:i===`done`?`Evidence accepted`:`Attempt rejected`;pn(e,`reviewer`,n?`waiting`:i===`done`?`done`:`rejected`,n?s:i===`done`?`Accepted evidence`:`Requested another attempt`,r),mn(e,t,`reviewer`,s,a,n?`info`:i===`done`?`success`:`error`);let c=q(t,`next_action`);hn(e,t,`reviewer`,n?`review`:`verdict`,s,c?`${a}\n\nNext action: ${c}`:a,i)}else if([G.SKILL_CREATED,G.SKILL_UPDATED].includes(n)){let i=q(t,`skill_id`)||q(t,`name`);i&&(fn(e.learned_skills,`id`,i,{id:i,name:q(t,`name`),version:cn(t,`version`)??1,scope:q(t,`scope`),path:q(t,`path`),status:`active`,updated_at:r,mission_id:e.mission.id,mission_title:e.mission.title}),mn(e,t,`reviewer`,n===G.SKILL_CREATED?`Capability unlocked`:`Capability upgraded`,q(t,`name`),`skill`))}else if(n===G.SKILL_EVOLUTION_COMPLETED)e.storage.project_skill_dir=q(t,`project_skill_dir`)||e.storage.project_skill_dir,e.storage.global_skill_dir=q(t,`global_skill_dir`)||e.storage.global_skill_dir,e.storage.project_skill_count=cn(t,`project_skill_count`)??e.storage.project_skill_count,e.storage.global_skill_count=cn(t,`global_skill_count`)??e.storage.global_skill_count;else if(n===G.SKILL_HISTORY_COMPRESSED)e.storage.skill_history_compressed+=cn(t,`count`)??0,e.storage.skill_history_bytes_saved+=cn(t,`bytes_saved`)??0;else if(n===G.SKILL_TIDIED){let n=q(t,`name`);if(n){let i=e.learned_skills.find(e=>e.name===n),a={source_path:q(t,`path`),source_placement:q(t,`placement`),source_vertical:q(t,`vertical`),updated_at:r};i?Object.assign(i,a):fn(e.learned_skills,`id`,n,{id:n,name:n,version:1,scope:``,path:``,status:`active`,...a}),mn(e,t,`manager`,`Capability promoted to source`,n,`skill`)}}else if([G.WIKI_INITIALIZED,G.WIKI_EVOLUTION_COMPLETED].includes(n)){let n=[...(Array.isArray(t.paths)?t.paths:[]).map(e=>String(e)),q(t,`path`)].filter(Boolean);e.storage.wiki_paths=[...new Set([...e.storage.wiki_paths,...n])]}else if(n===G.WIKI_RETIRED_COMPRESSED)e.storage.wiki_retired_compressed+=cn(t,`count`)??0,e.storage.wiki_retired_bytes_saved+=cn(t,`bytes_saved`)??0;else if([G.WIKI_CREATED,G.WIKI_UPDATED].includes(n)){let i=q(t,`page_id`);i&&(fn(e.learned_wiki_pages,`id`,i,{id:i,title:q(t,`title`)||i,card_type:q(t,`card_type`),status:q(t,`status`)||`scratch`,path:q(t,`path`),updated_at:r}),mn(e,t,`reviewer`,n===G.WIKI_CREATED?`Knowledge captured`:`Knowledge refined`,q(t,`title`)||i,`skill`))}else if(n===G.WIKI_RETIRED){let n=q(t,`page_id`);if(n){let i=e.learned_wiki_pages.find(e=>e.id===n);i?Object.assign(i,{status:`retired`,updated_at:r}):fn(e.learned_wiki_pages,`id`,n,{id:n,title:n,card_type:q(t,`card_type`),status:`retired`,path:``,updated_at:r}),mn(e,t,`reviewer`,`Knowledge retired`,n,`error`)}}else if([G.WIKI_PROMOTION_PROMOTED,G.WIKI_PROMOTION_DEMOTED].includes(n)){let i=q(t,`page_id`);if(i){let a=e.learned_wiki_pages.find(e=>e.id===i);a?Object.assign(a,{status:q(t,`to_status`),updated_at:r}):fn(e.learned_wiki_pages,`id`,i,{id:i,title:i,card_type:q(t,`card_type`),status:q(t,`to_status`),path:``,updated_at:r});let o=n===G.WIKI_PROMOTION_PROMOTED;mn(e,t,`reviewer`,o?`Knowledge promoted`:`Knowledge demoted`,`${i} → ${q(t,`to_status`)}`,o?`success`:`neutral`)}}else if(n===G.RESEARCH_ACHIEVEMENT_CERTIFIED)e.achievement={id:q(t,`achievement_id`),title:q(t,`title`),goal:q(t,`goal`),summary:q(t,`summary`),rejected_attempts:e.review.rejected_attempts,skills_learned:e.learned_skills.filter(e=>e.status===`active`).length,artifacts:e.artifacts.length,elapsed_seconds:e.mission.elapsed_seconds,evidence:Array.isArray(t.evidence)?t.evidence.map(String):[],reviewer_certified:!0,certified_at:r};else if([G.LIFE_MISSION_COMPLETED,G.LIFE_MISSION_FAILED].includes(n)){let i=n===G.LIFE_MISSION_FAILED?rn({...t,outcome_class:`failed`,status:q(t,`status`)||`failed`,success:!1}):rn(t),a=`final_output`in t?q(t,`final_output`):q(t,`item_id`)===e.mission.id&&e.mission.started_at!=null&&(e.mission.completed_at==null||e.mission.completed_at===r)&&e.mission.final_output||``;e.mission.id=q(t,`item_id`)||e.mission.id,e.mission.title=q(t,`title`)||e.mission.title,e.mission.objective=q(t,`objective`)||e.mission.objective,e.mission.summary=q(t,`summary`),e.mission.final_output=a,e.mission.status=i.missionStatus,e.mission.completed_at=r;let o=t.delivery;t.success===!0&&o&&typeof o==`object`&&!Array.isArray(o)?e.delivery=JSON.parse(JSON.stringify(o)):t.success!==!0&&(e.delivery=null),e.outcome=nn(t),pn(e,`engineer`,i.missionStatus===`complete`?`done`:i.missionStatus,i.label,r),mn(e,t,`engineer`,i.label,q(t,`summary`)||q(t,`title`)||q(t,`status`),gn(i.tone)),hn(e,t,`engineer`,`completion`,i.label,q(t,`summary`)||q(t,`title`)||q(t,`status`),i.missionStatus)}return e.updated_at=Date.now()/1e3,e}function yn(e,t,n){let r=t.backlog.find(e=>sn.has(e.status)),i=t.backlog.find(e=>e.status===`pending`),a=t.backlog.find(t=>t.id===e.mission.id),o=r??a,s=!!(r||i||t.continuous?.enabled||t.continuous?.done_reason||t.continuous?.done_at||e.mission.id||![``,`idle`].includes(e.mission.status));t.continuous?.enabled&&(e.routing.route=e.routing.route||`team`,e.routing.continuous=!0,e.routing.open_ended=t.continuous.open_ended===!0,e.routing.lifetime=e.routing.open_ended?`standing`:e.routing.lifetime||`bounded`);let c=o?.objective||o?.title||(t.continuous?.enabled?t.continuous.objective:``)||t.session.objective||(e.mission.id?``:i?.objective)||(e.mission.id?``:i?.title)||e.mission.objective;c&&(e.mission.objective=c,o?e.mission.title=(o.title||c.split(` +`)[0]).slice(0,240):e.mission.title||(e.mission.title=c.split(` +`)[0].slice(0,240))),r?((r.id!==e.mission.id||r.started_ts!=null&&r.started_ts!==e.mission.started_at||e.mission.completed_at!=null)&&(e.mission.summary=``,e.mission.final_output=``,e.mission.started_at=r.started_ts??null,e.mission.completed_at=null),e.mission.id=r.id,e.mission.status=`working`,e.mission.started_at=e.mission.started_at??r.started_ts??null):a?a.status===`pending`&&(e.mission.status=`queued`):t.continuous?.done_reason||t.continuous?.done_at?e.mission.status=`complete`:i||t.continuous?.enabled?e.mission.status=`queued`:t.daemon.alive&&(e.mission.status=`idle`),t.roles.forEach(t=>{t.active?pn(e,t.role,`active`,t.label||t.status||`Working`,Date.now()/1e3-(t.age_s??0)):s||pn(e,t.role,`waiting`,`Waiting`,Date.now()/1e3);let n=e.roles.find(e=>e.role===t.role);n&&Object.assign(n,{backend:t.backend,model:t.model,effort:t.effort})});let l=t.roles.filter(e=>e.active);l.length?e.active_role=l[l.length-1].role:s||(e.active_role=``),t.backlog.forEach(t=>{let n={id:t.id,title:t.title,objective:t.objective,status:t.status,deps:t.deps??[],branch_id:t.id,parent_branch_id:t.deps?.[0]??null,acceptance_check:t.acceptance_check??``,plan_hypothesis:t.plan_hypothesis??``,goal_contribution:t.goal_contribution??``,expected_regressions:t.expected_regressions??``,decision_rule:t.decision_rule??``,non_goals:t.non_goals??[]};fn(e.dag,`id`,n.id,n)});let u=o?.outcome?.execution_status?o.outcome:e.mission.id?void 0:[...t.backlog].filter(e=>e.outcome?.execution_status).sort((e,t)=>Number(e.finished_ts??0)-Number(t.finished_ts??0)).at(-1)?.outcome;return!r&&u&&(e.outcome=nn({outcome:u,status:`done`,success:!0})),n.forEach(t=>{fn(e.artifacts,`path`,t.path,{id:t.path,path:t.path,title:t.name,kind:t.kind,why:t.why,exists:t.exists,storage_path:t.storage_path,source:t.source})}),s}function bn(e,t,n,r){r||(t.roles.forEach(t=>{t.active||pn(e,t.role,`waiting`,`Waiting`,Date.now()/1e3)}),e.active_role=``);let i=Date.now()/1e3,a=e.mission.campaign_started_at??t.session.created??e.mission.started_at;a&&(e.mission.campaign_started_at=a,e.mission.campaign_elapsed_seconds=Math.max(0,i-a)),e.mission.started_at&&e.mission.status===`working`?e.mission.elapsed_seconds=Math.max(0,i-e.mission.started_at):e.mission.started_at&&e.mission.completed_at&&(e.mission.elapsed_seconds=Math.max(0,e.mission.completed_at-e.mission.started_at)),e.achievement?.reviewer_certified&&(e.achievement.elapsed_seconds=e.mission.elapsed_seconds,e.achievement.rejected_attempts=e.review.rejected_attempts,e.achievement.skills_learned=e.learned_skills.filter(e=>e.status===`active`).length,e.achievement.artifacts=n.filter(e=>e.exists).length)}function xn(e,t=[],n=[]){let r=e.mission_view?un(e.mission_view):dn();r.storage??=dn().storage,r.storage.skill_history_compressed??=0,r.storage.wiki_retired_compressed??=0,r.storage.skill_history_bytes_saved??=0,r.storage.wiki_retired_bytes_saved??=0,r.learned_wiki_pages??=[],r.role_work??=[],r.delivery??=null,r.outcome??={};let i=r.last_event_ts,a=yn(r,e,n),o=[...t].sort((e,t)=>Number(e.ts??0)-Number(t.ts??0));return o.filter(e=>e.ts==null||Number(e.ts)>i).forEach(e=>vn(r,e)),r.mission.final_output||(r.mission.final_output=Sn(o,r.mission)),bn(r,e,n,a),r}function Sn(e,t){if(!t.id||[`working`,`queued`,`grounding`,`framed`].includes(t.status))return``;let n=e.reduce(vn,dn()).mission;return n.id!==t.id||n.started_at==null||n.completed_at==null||t.started_at!=null&&n.started_at!==t.started_at||t.completed_at!=null&&n.completed_at!==t.completed_at?``:n.final_output||``}function Cn(e){return String(e||``).replace(/\\([*_`~])/g,`$1`).replace(/\\\\(?=[A-Za-z])/g,`\\`)}function wn(e){let t=Math.max(0,Math.floor(e)),n=Math.floor(t/3600),r=Math.floor(t%3600/60);return n?`${n}h ${r}m`:r?`${r}m`:`${t}s`}function Tn(e){let t=Math.ceil(e);return t<60?`${t}s`:t<3600?`${Math.floor(t/60)}m ${t%60}s`:t<86400?`${Math.floor(t/3600)}h ${Math.floor(t%3600/60)}m`:`${Math.floor(t/86400)}d ${Math.floor(t%86400/3600)}h`}function En(e){let t=(e.label||e.display_name||``).trim();return!!(t&&t!==e.id)}function Dn(e){return[...e].sort((e,t)=>{if(e.daemon_alive!==t.daemon_alive)return e.daemon_alive?-1:1;let n=En(e);return n===En(t)?(t.last_active||0)-(e.last_active||0):n?-1:1})}function On(e){return Dn(e)[0]}function kn(e,t){let n=t?.trim()||null;return n&&e.some(e=>e.id===n)?{id:n,requested:n,recovered:!1}:{id:On(e)?.id??null,requested:n,recovered:!!n}}function An(e,t,n){if(n){let e=t?.trim()||null;return{id:e,requested:e,recovered:!1}}return kn(e,t)}function jn(e,t){let n=t.trim().toLowerCase().split(/\s+/).filter(Boolean);if(!n.length)return!0;let r=e.daemon_alive?`live running`:`stopped idle`,i=[e.id,e.label,e.display_name,e.objective,r].filter(Boolean).join(` `).toLowerCase();return n.every(e=>i.includes(e))}function Mn(e,t){return e.filter(e=>jn(e,t))}var Nn={[G.LIFE_LIFECYCLE_BLOCK]:`block`,[G.ROUND_REVIEWER_BACKEND_FAILURE]:`block`,[G.LIFE_BUDGET_PAUSE]:`warn`,[G.ROUND_STALL]:`warn`,[G.ROUND_ESCALATED]:`warn`,[G.LIFE_PLANNER_STALL_ESCALATION]:`warn`},Pn=new Set([G.BUDGET_RESERVATION_DENIED,G.BUDGET_UNPRICED_BLOCKED]),Fn=new Set([G.LIFE_MISSION_STARTED,G.ROUND_MAIN_COMPLETED,G.LIFE_MISSION_COMPLETED,G.LOOP_DONE,G.ROUND_START,`ui.operator`]),In=new Set([G.BUDGET_RESERVATION_CREATED,G.PROVIDER_REQUEST_STARTED]);function Ln(e){let t=yt(e.canonical_type??e.type);if(e.event_validation?.status===`invalid`)return t===G.ROLE_SESSION_TURN?null:{tone:`warn`,kind:`validation`,text:`invalid event ${t||`unknown`}: ${e.event_validation.errors.join(`; `)}`};if(Pn.has(t))return{tone:`block`,kind:`budget`,text:`Budget exhausted or blocked — ${String(e.reason??e.text??t).trim()}`};let n=e.operator_alert===!0?`block`:Nn[t];return n?{tone:n,text:String(e.text??e.reason??t).trim()}:null}function Rn(e){let t=null;for(let n of e){let e=yt(n.canonical_type??n.type),r=Ln(n);r?t=r:(t?.kind===`validation`||t?.kind===`budget`&&In.has(e)||t&&t.kind!==`budget`&&Fn.has(e))&&(t=null)}return t}var zn=new Set([`done`,`completed`,`failed`,`skipped`]);function Bn(e){return zn.has(e.status)}function Vn(e,t){return e.filter(e=>Bn(e)===t)}Math.max(...[` ╭───────────────────────────────────────────────────────────────────────────────────╮╮`,` │ ││`,` │ ◉ argus-skill · Autonomous Work Lab ││`,` │ ││`,` ╰───────────────────────────────────────────────────────────────────────────────────╯│`,` │`].map(e=>[...e].length));var Hn=[`⠋`,`⠙`,`⠹`,`⠸`,`⠼`,`⠴`,`⠦`,`⠧`,`⠇`,`⠏`];function Un(e){return Hn[e%Hn.length]}var Wn=()=>Date.now()/1e3;function Gn(e){return e.trim().replace(/[.…]+$/u,``).toLowerCase()}function Kn(e,t,n=Wn()){let r=(t.label??``).trim();if(!r)return e;let i=t.heartbeat===!0,a=e.slice(),o=a[a.length-1];if(o&&!o.endedTs){if(Gn(o.label)===Gn(r)||i&&o.heartbeat)return a[a.length-1]={...o,label:r,detail:t.detail||o.detail,kind:t.kind||o.kind,heartbeat:i,endedTs:0},a;a[a.length-1]={...o,endedTs:n}}return a.push({id:`${a.length}:${r}:${n}`,role:(t.role||`manager`).trim()||`manager`,label:r,detail:(t.detail||``).trim(),kind:(t.kind||``).trim(),startedTs:n,endedTs:0,heartbeat:i}),a}function qn(e,t=Wn()){if(e.length===0)return[];let n=e.slice(),r=n[n.length-1];return r&&!r.endedTs&&(n[n.length-1]={...r,endedTs:t}),n}function Jn(e,t=6){let n=Math.max(1,t);return e.length<=n?e:e.slice(e.length-n)}function Yn(e,t=Wn()){let n=e.endedTs||t;return Math.max(0,n-e.startedTs)}function Xn(e){if(!Number.isFinite(e)||e<1)return``;if(e<60)return`${Math.floor(e)}s`;let t=Math.floor(e/60),n=Math.floor(e%60);return n?`${t}m${n}s`:`${t}m`}function Zn(e,t=!1,n=!1){return(t||n)&&e.toLowerCase()===`r`}function J(e,t){let n=(e||``).replace(/```[a-z]*\n?/gi,``).replace(/\[([^\]]+)\]\([^)]+\)/g,`[$1]`).trim();return n.length<=t?n:n.slice(0,t-1).trimEnd()+`…`}var Qn=e=>String(e??``).split(` +`)[0]?.trim()??``,Y=(e,t)=>String(e[t]??``);function $n(e,t){let n=(e,n)=>t===`zh-CN`?n:e,r=Y(e,`phase`),i=Y(e,`cause`)||Y(e,`backend_error`),a=Y(e,`error`);if(!r||!i)return`${n(`routing failed`,`分流失败`)} ${J(a,140)}`;let o={backend:n(`backend`,`后端`),parse:n(`parse`,`解析`),contract:n(`contract:`,`契约:`),timeout:n(`timeout`,`超时`)},s=Number(e.attempts||0),c=s>1?n(` (attempt ${s})`,` (第${s}次尝试)`):``,l=`${n(`routing failed`,`分流失败`)} · ${o[r]||r} ${i}${c}`;return a?`${l} · ${n(`raw`,`原始错误`)}: ${a}`:l}var er=e=>{let t=e,n=t.round_index??t.round;return typeof n==`string`||typeof n==`number`?n:`?`},tr={manager:`Manager`,planner:`Planner`,engineer:`Engineer`,reviewer:`Reviewer`,critic:`Critic`,system:`Argus`},nr={manager:`Manager`,planner:`Planner`,engineer:`Engineer`,reviewer:`Reviewer`,critic:`Critic`,system:`Argus`},rr=e=>({bright:W.ink,dim:W.inkDim,accent:W.accent,ok:W.success,warn:W.warning,err:W.error,info:W.info})[e];function ir(e,t=`en`){let n=Y(e,`type`),r=(e,n)=>t===`zh-CN`?n:e,i=e=>(t===`zh-CN`?nr:tr)[e]||e;if(n===`ui.operator`){let t=Et(Y(e,`text`));return t?{role:`operator`,label:r(`You`,`你`),glyph:`›`,text:t,tone:`bright`,rule:!0}:null}if(n===`ui.argus`){let t=Y(e,`text`);return t?{role:`manager`,label:`Argus`,glyph:`◆`,text:t,tone:`bright`,rule:!0}:null}if(n===`engineer.progress`){let t=Y(e,`kind`),n=Y(e,`agent_layer`)||`engineer`,a=Qn(e.text??e.action_summary);if(t===`reasoning`){let t=J(Y(e,`text`),280);return t?{role:n,label:i(n),glyph:`∴`,text:t,tone:`dim`,reasoning:!0}:null}if(t===`assistant_message`||t===`agent_message`||t===`message`){if(wt(e))return null;let t=Et(Y(e,`text`));return t?{role:n,label:i(n),glyph:`▌`,text:t,tone:`bright`}:null}if(t===`command_execution`){let t=Y(e,`text`)||Y(e,`command`)||Y(e,`action_summary`);return t?{role:n,label:i(n),glyph:`▸ $`,text:t,tone:`dim`}:null}if(t===`file_change`){let t=Y(e,`text`)||Y(e,`action_summary`);return{role:n,label:i(n),glyph:`✎`,text:t||r(`(file change)`,`(文件变更)`),tone:`dim`}}if(t===`tool_use`){let t=Y(e,`text`)||Y(e,`action_summary`);return{role:n,label:i(n),glyph:`⚙`,text:t||r(`(tool)`,`(工具)`),tone:`dim`}}return a?{role:n,label:i(n),glyph:`▸`,text:J(a,160),tone:`dim`}:null}if(n===`life.manager.intent.started`)return{role:`manager`,label:`Manager`,glyph:`🧭`,text:r(`classifying request…`,`判断任务归属…`),tone:`info`};if(n===`life.manager.intent.completed`)return{role:`manager`,label:`Manager`,glyph:`🧭`,text:`→ ${ln({route:Y(e,`route`)||`team`,vertical:Y(e,`vertical`),workflow_mode:Y(e,`workflow_mode`),lifetime:Y(e,`lifetime`),continuous:e.continuous===!0,open_ended:e.open_ended===!0})||Y(e,`kind`)||r(`resolved`,`已确定`)}`,tone:`info`};if(n===`life.manager.intent.failed`)return{role:`manager`,label:`Manager`,glyph:`⚠`,text:$n(e,t),tone:`err`};if(n===`life.manager.stage_decision`){let t=Y(e,`target_stage`)||Y(e,`stage`)||Y(e,`current_stage`);return{role:`manager`,label:`Manager`,glyph:`🧭`,text:`${Y(e,`action`)}${t?` → ${t}`:``} ${J(Y(e,`reason`),120)}`,tone:`info`}}if(n===`life.research.second_reading`){let t=Y(e,`agent_layer`)||`manager`,n=J(Y(e,`supported`),160),a=r(`reread the evidence and reworked the plan`,`重读了证据并重排了计划`);return{role:t,label:i(t),glyph:`📖`,text:n?`${a} · ${n}`:a,tone:`info`}}if(n===`life.letter.written`){let t=Y(e,`agent_layer`)||`manager`;return{role:t,label:i(t),glyph:`✉`,text:r(`wrote you a letter`,`给你写了一封信`),tone:`accent`}}if(n===`life.planner.start`)return{role:`planner`,label:`Planner`,glyph:`📋`,text:`${r(`planning`,`正在规划`)} ${J(Y(e,`objective`),140)}`,tone:`accent`};if(n===`life.planner.verdict`)return Y(e,`status`)===`done`||e.project_done===!0?{role:`planner`,label:`Planner`,glyph:`🏁`,text:r(`project done`,`项目已完成`),tone:`ok`}:{role:`planner`,label:`Planner`,glyph:`📋`,text:r(`queued ${Y(e,`queued`)||Y(e,`n`)||`next`} task(s)`,`已加入 ${Y(e,`queued`)||Y(e,`n`)||`下一`} 个任务`),tone:`accent`};if(n===`life.planner.task_added`)return{role:`planner`,label:`Planner`,glyph:`+`,text:`${r(`added`,`已添加`)} ${J(Y(e,`title`)||Y(e,`objective`),140)}`,tone:`accent`};if(n===`life.planner.task_skipped`)return{role:`planner`,label:`Planner`,glyph:`⏭`,text:`${r(`skipped duplicate`,`已跳过重复任务`)} ${J(Y(e,`title`),120)}`,tone:`dim`};if(n===`life.planner.error`)return{role:`planner`,label:`Planner`,glyph:`⚠`,text:`${r(`planner error`,`Planner 错误`)} ${J(Y(e,`error`)||Y(e,`text`),140)}`,tone:`err`};if(n===`life.mission.started`||n===`mission.started`)return{role:`engineer`,label:`Engineer`,glyph:`🚀`,text:J(Y(e,`title`)||Y(e,`objective`)||Y(e,`text`)||r(`mission started`,`任务已开始`),160),tone:`info`,rule:!0};if(n===`round.started`||n===`round.start`)return{role:`engineer`,label:`Engineer`,glyph:`──`,text:r(`round ${er(e)}`,`第 ${er(e)} 轮`),tone:`dim`,rule:!0};if(n===`life.phase.started`){let t=Y(e,`label`)||Y(e,`phase`);if(!t)return null;let n=Y(e,`agent_layer`)||`engineer`;return{role:n,label:i(n),glyph:`🔄`,text:r(`entering ${t}`,`进入 ${t}`),tone:`info`}}if(n===`round.review.started`)return{role:`reviewer`,label:`Reviewer`,glyph:`🔄`,text:r(`review round ${er(e)}`,`审核第 ${er(e)} 轮`),tone:`info`};if(n===`round.review.deferred`)return{role:`engineer`,label:`Engineer`,glyph:`↪`,text:r(`continues before review · ${J(Y(e,`next_step`),160)}`,`审核前继续执行 · ${J(Y(e,`next_step`),160)}`),tone:`info`};if(n===`round.main.completed`)return{role:`engineer`,label:`Engineer`,glyph:`✅`,text:r(`round ${er(e)} completed`,`第 ${er(e)} 轮已完成`),tone:`info`};if(n===`round.review.completed`){if(e.review_skipped===!0)return{role:`reviewer`,label:`Reviewer`,glyph:`↪`,text:`${r(`review not performed`,`审查未执行`)} · ${J(Y(e,`reason`),160)}`,tone:`info`};let t=Y(e,`status`),n=t===`done`?`ok`:t===`blocked`||t===`no_progress`?`err`:`warn`;return{role:`reviewer`,label:`Reviewer`,glyph:t===`done`?`✅`:t===`blocked`||t===`no_progress`?`⛔`:`↻`,text:`${t||`?`} · ${J(Y(e,`reason`),160)}`,tone:n}}if(n===`life.iteration.critic`)return{role:`critic`,label:`Critic`,glyph:`👔`,text:`${Y(e,`decision`)||``} ${J(Y(e,`reason`),140)}`,tone:`info`};if(n===`life.iteration.continued`)return{role:`critic`,label:`Critic`,glyph:`🔁`,text:r(`queued next iteration`,`已加入下一轮迭代`),tone:`dim`};if(n===`life.mission.completed`||n===`mission.completed`||n===`loop.completed`){let t=rn(e),n=J(Y(e,`summary`),240);return{role:`engineer`,label:`Engineer`,glyph:t.glyph,text:n?`${t.label} · ${n}`:t.label,tone:t.tone,rule:!0}}if(n===`life.mission.failed`||n===`mission.error`)return{role:`engineer`,label:`Engineer`,glyph:`❌`,text:`${r(`mission failed`,`任务失败`)} ${J(Y(e,`reason`)||Y(e,`error`),140)}`,tone:`err`,rule:!0};if(n===`loop.start`)return{role:`engineer`,label:`Engineer`,glyph:`▶`,text:J(Y(e,`text`)||Y(e,`objective`),160),tone:`info`};if(n===`loop.done`)return{role:`engineer`,label:`Engineer`,glyph:`🏁`,text:`${r(`loop done`,`循环完成`)} ${J(Y(e,`text`),120)}`,tone:`dim`};if(n===`life.inbox.queued`)return{role:`system`,label:r(`You`,`你`),glyph:`📥`,text:`${r(`nudge`,`追加指导`)} · ${J(Y(e,`text`),160)}`,tone:`accent`};if(n===`final.report.ready`||n===`pptx.report.ready`)return{role:`system`,label:`Argus`,glyph:`📄`,text:r(`report ready`,`报告已就绪`),tone:`accent`};if(n===`plan.completed`)return{role:`planner`,label:`Planner`,glyph:`📋`,text:r(`plan completed`,`计划已完成`),tone:`accent`};if(n===`daemon.stopping`)return{role:`system`,label:`Argus`,glyph:`🛑`,text:r(`stopping`,`正在停止`),tone:`err`};if(n===`round.reviewer_backend_failure`)return{role:`system`,label:r(`Notice`,`通知`),glyph:`!`,text:r(`reviewer backend down — holding · ${J(Y(e,`text`),150)}`,`Reviewer 后端不可用 — 已暂停 · ${J(Y(e,`text`),150)}`),tone:`err`,rule:!0};if(n===`round.stall`)return{role:`system`,label:r(`Notice`,`通知`),glyph:`!`,text:J(Y(e,`text`)||r(`no forward progress`,`没有取得进展`),170),tone:`warn`};if(n===`round.escalated`)return{role:`system`,label:r(`Notice`,`通知`),glyph:`!`,text:J(Y(e,`text`)||r(`soft round limit — escalating external blockers`,`达到软轮次上限 — 正在升级外部阻塞`),170),tone:`warn`};if(n===`life.planner.stall_escalation`)return{role:`system`,label:r(`Notice`,`通知`),glyph:`!`,text:`${r(`planner stalled`,`Planner 停滞`)} — ${J(Y(e,`reason`)||Y(e,`text`),150)}`,tone:`warn`};if(n===`life.budget.pause`)return{role:`system`,label:r(`Watch`,`监控`),glyph:`⏸`,text:r(`budget cap reached — paused · ${J(Y(e,`text`)||Y(e,`reason`),140)}`,`已达到预算上限 — 已暂停 · ${J(Y(e,`text`)||Y(e,`reason`),140)}`),tone:`warn`};if(n===`budget.reservation.denied`)return{role:`system`,label:r(`Budget`,`预算`),glyph:`$`,text:`${r(`budget denied`,`预算申请被拒绝`)} — ${J(Y(e,`reason`)||Y(e,`text`),150)}`,tone:`err`,rule:!0};if(n===`budget.unpriced.blocked`)return{role:`system`,label:r(`Budget`,`预算`),glyph:`$`,text:`${r(`budget blocked by unresolved cost`,`预算因成本未确定而阻塞`)} — ${J(Y(e,`reason`)||Y(e,`text`),150)}`,tone:`err`,rule:!0};if(n===`life.lifecycle.block`)return null;if(n===`life.daemon.idle_timeout`)return{role:`system`,label:r(`Watch`,`监控`),glyph:`🟦`,text:J(Y(e,`text`)||r(`idle timeout — standing by`,`空闲超时 — 正在待命`),150),tone:`dim`};if(n===`round.watchdog.restart_requested`)return{role:`system`,label:r(`Watch`,`监控`),glyph:`🔄`,text:r(`stall caught — restarting the round · ${J(Y(e,`reason`),160)}`,`检测到停滞 — 正在重启本轮 · ${J(Y(e,`reason`),160)}`),tone:`warn`};if(n===`engineer.failure_nudge`)return{role:`engineer`,label:`Engineer`,glyph:`⚠`,text:`${r(`repeated tool failure`,`工具重复失败`)} — ${J(Y(e,`text`)||Y(e,`reason`),160)}`,tone:`warn`};if(n===`mission.idle`)return{role:`system`,label:`Argus`,glyph:`🟦`,text:J(Y(e,`text`)||r(`idle — awaiting the next mission`,`空闲 — 正在等待下一个任务`),160),tone:`dim`};if(e.operator_alert===!0){let t=J(Y(e,`text`)||Y(e,`reason`)||n,170);if(t)return{role:`system`,label:r(`Notice`,`通知`),glyph:`!`,text:t,tone:`err`,rule:!0}}return null}function ar(e,t){return St(e)}function or(e,t,n){e.setQueryData([`snapshot`,t],e=>e&&{...e,session:{...e.session,display_name:n}}),e.setQueryData([`projects`],e=>e&&{...e,projects:e.projects.map(e=>e.id===t?{...e,display_name:n,label:n||e.objective||e.id}:e)})}var sr=15e3,cr=5e3,lr=8e3,ur=2e3,dr=1e4,fr=1e4;function pr(e,t){return!L(t)&&e<1}function mr(e){return!L(e)&&cr}function hr(e){return e?.projects.some(e=>e.daemon_alive)?ur:sr}function gr(e){return e?.daemon.alive?ur:lr}var _r=()=>ce({queryKey:[`projects`],queryFn:U.projectIndex,refetchInterval:e=>hr(e.state.data)}),vr=()=>ce({queryKey:[`project-costs`],queryFn:({signal:e})=>U.projectCosts(e),retry:pr,refetchInterval:e=>mr(e.state.error),refetchIntervalInBackground:!1}),yr=e=>ce({queryKey:[`snapshot`,e],queryFn:({signal:t})=>U.activeSnapshot(e,t),enabled:!!e,refetchInterval:e=>gr(e.state.data)}),br=(e,t=30,n=!0)=>ce({queryKey:[`journal`,e,t],queryFn:({signal:n})=>U.journal(e,t,n),enabled:!!e&&n,refetchInterval:n?8e3:!1}),xr=(e,t)=>ce({queryKey:[`doctor`,e],queryFn:({signal:t})=>U.doctor(e,t),enabled:!!e&&t}),Sr=(e,t)=>ce({queryKey:[`config`,e],queryFn:({signal:t})=>U.config(e,t),enabled:!!e&&t}),Cr=(e,t)=>ce({queryKey:[`identity`,e],queryFn:({signal:t})=>U.identity(e,t),enabled:!!e&&t}),wr=(e,t,n=30)=>ce({queryKey:[`transcript`,e,n],queryFn:({signal:t})=>U.transcript(e,n,t),enabled:!!e&&t}),Tr=(e,t=!0)=>ce({queryKey:[`artifacts`,e],queryFn:({signal:t})=>U.artifacts(e,t),enabled:!!e&&t,refetchInterval:t?dr:!1}),Er=(e,t,n=null)=>ce({queryKey:[`artifact`,e,t,n],queryFn:({signal:n})=>U.artifact(e,t,n),enabled:!!e&&!!t,refetchInterval:e=>t&&/(?:^|[\\/])REVIEW\.md$/i.test(t)&&!L(e.state.error)?2e3:!1}),Dr=(e,t=!0)=>ce({queryKey:[`git-diff`,e],queryFn:({signal:t})=>U.gitDiff(e,t),enabled:!!e&&t,refetchInterval:t?fr:!1}),Or=(e,t)=>ce({queryKey:[`backlog-item`,e,t],queryFn:({signal:n})=>U.backlogItem(e,t,n),enabled:!!e&&!!t});function kr(e,t){let n=oe(),r=e=>{n.invalidateQueries({queryKey:[`snapshot`,e]}),n.invalidateQueries({queryKey:[`status`,e]}),n.invalidateQueries({queryKey:[`projects`]}),n.invalidateQueries({queryKey:[`backlog-item`,e]})},i=()=>r(e);return{addTask:P({mutationFn:t=>U.addTask(e,t),onSuccess:i}),nudge:P({mutationFn:t=>U.nudge(e,t)}),note:P({mutationFn:t=>U.note(e,t)}),startDaemon:P({mutationFn:()=>U.startDaemon(e,t),onSuccess:i}),stopDaemon:P({mutationFn:n=>U.stopDaemon(e,n,t),onSuccess:i}),forceStopDaemon:P({mutationFn:()=>U.stopDaemon(e,!1,t,!0),onSuccess:i}),updateProject:P({mutationFn:e=>U.updateProject(e.sid,e.name),onSuccess:e=>{or(n,e.sid,e.name),r(e.sid)}}),deleteProject:P({mutationFn:()=>U.deleteProject(e),onSuccess:async()=>{let t=e;if(t){let e=e=>e.queryKey.some(e=>e===t);await n.cancelQueries({predicate:e}),n.removeQueries({predicate:e})}await n.invalidateQueries({queryKey:[`projects`]})}}),disposeBacklog:P({mutationFn:t=>U.disposeBacklog(e,t.id,t.op),onSuccess:i}),stopBacklog:P({mutationFn:t=>U.stopBacklog(e,t),onSuccess:i}),setContinuous:P({mutationFn:t=>U.setContinuous(e,t.enabled,t.objective??``),onSuccess:i})}}var Ar=2e3;function jr(e,t){if(t.kind===`reset`)return{sid:t.sid,events:[],seen:new Set};if(t.sid!==e.sid)return e;if(t.kind===`seed`){let n=new Set,r=[];[...t.events,...e.events].forEach((e,t)=>{let i=ar(e,t);n.has(i)||(n.add(i),r.push(e))});let i=r.slice(-2e3);return{sid:e.sid,events:i,seen:new Set(i.map((e,t)=>ar(e,t)))}}let n=t.kind===`push`?[t.ev]:t.events,r=null,i=null;for(let t of n){let n=r??e.events,a=i??e.seen,o=ar(t,n.length);a.has(o)||((!r||!i)&&(r=[...e.events],i=new Set(e.seen)),i.add(o),r.push(t))}return!r||!i?e:(r.length>Ar&&r.splice(0,r.length-Ar).forEach((e,t)=>i.delete(ar(e,t))),{sid:e.sid,events:r,seen:i})}var Mr=new Set([`manager.live_view.updated`,`round.review.completed`,`life.mission.completed`]);function Nr(e){for(let t=e.length-1;t>=0;--t){let n=e[t],r=String(n.type??``);if(Mr.has(r)||r===`engineer.progress`&&n.kind===`file_change`)return ar(n,t)}return``}var Pr=new Set([`life.operator_question.pending`,`life.operator_question.answered`,`life.planner.task_added`,`life.planner.verdict`,`life.mission.started`,`life.mission.completed`,`life.mission.failed`,`round.review.completed`]);function Fr(e){for(let t=e.length-1;t>=0;--t){let n=e[t];if(Pr.has(String(n.type??``)))return ar(n,t)}return``}function Ir(e,t=0){let[n,r]=(0,I.useReducer)(jr,{sid:null,events:[],seen:new Set}),[i,a]=(0,I.useState)({sid:null,connected:!1}),o=(0,I.useRef)(e);return o.current=e,(0,I.useEffect)(()=>{if(r({kind:`reset`,sid:e}),a({sid:e,connected:!1}),!e)return;let t=!1,n=new AbortController,i=[],s,c=()=>{if(s=void 0,t||o.current!==e||i.length===0){i=[];return}let n=i;i=[],r({kind:`push-many`,sid:e,events:n})};U.events(e,120,n.signal).then(n=>{!t&&o.current===e&&r({kind:`seed`,sid:e,events:n})}).catch(()=>{});let l=dt(e,n=>{!t&&o.current===e&&(i.push(n),s===void 0&&(s=window.setTimeout(c,40)))},{replay:40,onOpen:()=>{!t&&o.current===e&&a({sid:e,connected:!0})},onClose:()=>{!t&&o.current===e&&a({sid:e,connected:!1})}});return()=>{t=!0,n.abort(),s!==void 0&&window.clearTimeout(s),i=[],l()}},[e,t]),{events:n.sid===e?n.events:[],connected:i.sid===e&&i.connected}}var Lr=`argus.message.route.v2`;function Rr(){try{let e=localStorage.getItem(Lr);if(e===`auto`||e===`chat`||e===`task`)return e}catch{}return`auto`}var X=v();function zr(e){return!Number.isFinite(e)||e<=0?`$0.00`:e>=100?`$${e.toFixed(0)}`:e>=10?`$${e.toFixed(1)}`:e>=1?`$${e.toFixed(2)}`:`$${e.toFixed(3)}`}function Br({settledUsd:e,knownUsd:t=0,status:n=`empty`}){let r=typeof e==`number`&&Number.isFinite(e)?e:t,i=n===`partial`||n===`unpriced`;return`${zr(Math.max(0,r||0))}${i?`+`:``}`}function Vr({settledUsd:e,knownUsd:t,status:n,calls:r=0,premiumRequests:i=0,live:a=!1,compact:o=!1}){let s=Br({settledUsd:e,knownUsd:t,status:n}),c=[`Cumulative settled project spend`,`${r} model call${r===1?``:`s`}`,i>0?`${i.toFixed(1)} premium requests`:``,n&&n!==`empty`?`pricing: ${n}`:``].filter(Boolean).join(` · `);return(0,X.jsxs)(`span`,{title:c,"aria-label":`Project spend ${s}`,className:`inline-flex shrink-0 items-center rounded-full border border-gold/25 bg-gold/8 font-mono tabular-nums text-gold ${o?`h-6 gap-1 px-2 text-[10px]`:`h-5 gap-1 px-1.5 text-[9px]`}`,children:[a?(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`h-1.5 w-1.5 animate-pulse rounded-full bg-gold/80`}):null,(0,X.jsx)(`span`,{children:s})]})}var Hr=`argus.locale`,Ur={"language.english":`English`,"handshake.connecting":`Getting Argus ready`,"handshake.service":`Service`,"handshake.project":`Project`,"handshake.ready":`Ready`,"handshake.title":`Getting Argus ready`,"handshake.detail":`Reopening your workspace…`,"splash.starting":`Argus starting`,"rail.workbench":`Workbench`,"rail.sessionsShortcut":`Sessions · Ctrl/⌘ P`,"panel.backlog":`Backlog`,"panel.activity":`Activity`,"panel.journal":`Journal`,"panel.roles":`Roles`,"panel.project":`Project`,"panel.liveView":`Manager live project view`,"stream.jumpToLatest":`Jump to latest`,"stream.toggleReasoning":`Show or hide agent reasoning (⌘T)`,"stream.reasoning":`Reasoning`,"stream.noLogs":`No activity yet`,"stream.system":`Argus updates`,"stream.autonomous":`Background activity`,"stream.backgroundWork":`Argus is working in the background`,"stream.ready":`Argus is ready. Ask a question or assign work.`,"newDaemon.workdirPlaceholder":`Blank → ~/.argus-skill/workspaces/`,"operations.resetManager":`Reset Manager context`,"language.chinese":`中文`,"language.switchTo":`Switch to {language}`,"common.loading":`Loading…`,"common.retry":`Retry`,"common.save":`Save`,"common.cancel":`Cancel`,"common.close":`Close`,"common.settings":`Settings`,"common.ready":`Ready`,"common.live":`Live`,"common.reconnecting":`Reconnecting`,"common.stale":`Snapshot stale`,"common.degraded":`Snapshot degraded`,"common.external":`External`,"common.pause":`Pause`,"common.run":`Run`,"common.local":`Local`,"common.all":`All`,"common.unassigned":`Unassigned`,"common.closeSessions":`Close sessions`,"common.resizeSessions":`Resize sessions`,"common.resizePreview":`Resize preview`,"common.expandPreview":`Expand preview`,"time.justNow":`just now`,"time.minutesAgo":`{count}m ago`,"time.hoursAgo":`{count}h ago`,"time.yesterdayAt":`Yesterday at {time}`,"connection.pairingTitle":`This browser is not paired with Argus`,"connection.pairingDetail":`Close this tab and reopen the workbench from Argus Desktop, or open a fresh pairing link.`,"connection.pairAgain":`Pair again`,"connection.pairingInput":`Pairing link or token`,"connection.pairingPlaceholder":`Paste a fresh pairing link or token`,"connection.pairingInvalid":`Enter a valid pairing link or token.`,"connection.connect":`Connect`,"connection.unreachableTitle":`The local Argus service is unavailable`,"connection.unreachableDetail":`Keep Argus Desktop running, wait for the local service to become ready, then retry.`,"sidebar.collapse":`Collapse sessions`,"sidebar.expand":`Expand sessions`,"sidebar.create":`Create session`,"sidebar.find":`Find a session`,"sidebar.clearSearch":`Clear search`,"sidebar.refreshFailed":`Refresh failed · retry`,"sidebar.noSessions":`No sessions`,"sidebar.noMatches":`No sessions matching "{query}"`,"sidebar.unnamedSession":`Unnamed session`,"sidebar.daemonAlive":`Argus running`,"sidebar.updateRequired":`Update required`,"sidebar.updateAvailable":`Update available`,"sidebar.updateAvailableHint":`The executor is still running with a different release from this page.`,"sidebar.stopped":`stopped`,"sidebar.runningFor":`running · {uptime}`,"sidebar.manage":`Manage {name}`,"sidebar.manageHint":`Rename, pause, or delete`,"sidebar.resume":`Resume`,"sidebar.resumeHint":`Resume work in {workdir}`,"sidebar.resumeSuccess":`Session resumed.`,"sidebar.resumeFailed":`Could not resume session: {error}`,"sidebar.modelLoading":`Loading backend and model…`,"sidebar.modelUnavailable":`Backend and model unavailable`,"sidebar.defaultModel":`default model`,"sidebar.openSettings":`Open settings`,"sidebar.theme":`{current} theme; switch to {next}`,"landing.selectOrCreate":`Select a session from the sidebar, or create a new one.`,"landing.noSessions":`No sessions yet. Create one to begin.`,"landing.select":`Select session`,"landing.new":`New session`,"topbar.openSessions":`Open sessions`,"topbar.externallyManaged":`Externally managed`,"topbar.pauseDaemon":`Pause Argus`,"topbar.runDaemon":`Run Argus`,"topbar.roleActive":`{role} is active`,"topbar.roleIdle":`{role} is idle`,"topbar.externalDaemonHint":`Argus is managed outside this app and must be controlled there.`,"topbar.manageSession":`Manage session`,"topbar.showPreview":`Show preview`,"topbar.showActivity":`Show activity`,"mobile.views":`Views`,"mobile.sessions":`Sessions`,"mobile.mission":`Mission`,"mobile.activity":`Activity`,"mobile.workbench":`Workbench`,"mobile.map":`Map`,"mobile.preview":`Preview`,"chat.working":`Argus is working on your message`,"chat.workingQuiet":`Argus is working on your message · Still working; no new update for {quiet}s`,"chat.stopWaitingHint":`Esc stop waiting`,"chat.messageArgus":`message Argus`,"chat.selectSession":`Select a session…`,"chat.placeholder":`Ask a question or assign work`,"chat.routeLabel":`message category`,"chat.routeHint":`Task skips category classification but still uses Manager → Planner → Engineer → Reviewer`,"chat.routeTask":`Task`,"chat.routeAuto":`Auto`,"chat.routeChat":`Chat`,"chat.attach":`attach files`,"chat.attachHint":`PNG, JPEG, WebP, PDF, Markdown/text, JSON, CSV · up to {count} files, {perFile} each, {total} total`,"chat.attachDrop":`Drop files to attach`,"chat.attachRemove":`remove attachment {name}`,"chat.attachUnsupported":`{name} is not supported. Use PNG, JPEG, WebP, PDF, Markdown/text, JSON, or CSV.`,"chat.attachTooLarge":`{name} exceeds the {size} per-file limit.`,"chat.attachTooMany":`You can attach up to {count} files per message.`,"chat.attachTotalTooLarge":`Attachments exceed the {size} total limit.`,"chat.attachmentUploadFailed":`Attachment upload failed: {error}`,"chat.uploadingAttachments":`Uploading attachments`,"chat.rewriteHint":`Let the Manager rewrite this prompt into a brief the team can act on. Nothing is sent — the rewrite lands back in this box for you to edit.`,"chat.rewriteLabel":`rewrite prompt with the Manager`,"chat.rewriting":`rewriting`,"chat.rewrite":`✦ Rewrite`,"chat.stopWaiting":`stop waiting`,"chat.stopWaitingTitle":`stop waiting for this reply; server-side work may continue`,"chat.send":`send message`,"copy.message":`Copy`,"copy.code":`Copy code`,"copy.copied":`Copied`,"help.title":`Keyboard shortcuts`,"help.commands":`Commands`,"help.palette":`command palette`,"help.sessions":`toggle sessions`,"help.managerChat":`focus Manager chat`,"help.rewrite":`rewrite the current prompt before sending`,"help.reasoning":`toggle agent reasoning`,"help.kiosk":`toggle kiosk (read-only) mode`,"help.composer":`focus the composer`,"help.send":`send message`,"help.newline":`insert newline`,"help.thisHelp":`this help`,"help.escape":`close overlay / stop waiting in composer`,"palette.placeholder":`Type a command or search…`,"palette.noMatches":`no matching commands`,"palette.navigate":`↑↓ navigate`,"palette.run":`↵ run`,"palette.close":`esc close`,"palette.view":`View`,"palette.action":`Action`,"palette.project":`Project`,"palette.newDaemon":`New session`,"palette.openTranscript":`Open Transcript`,"palette.openProject":`Open Project`,"palette.projectHint":`work · memory · agents`,"palette.openOperations":`Open Operations`,"palette.operationsHint":`session controls`,"palette.hideReasoning":`Hide reasoning`,"palette.showReasoning":`Show reasoning`,"palette.exitKiosk":`Exit kiosk mode`,"palette.enterKiosk":`Enter kiosk mode`,"palette.messageArgus":`Message Argus…`,"palette.stopWaiting":`Stop waiting for Manager reply`,"palette.stopContinuous":`Stop continuous campaign`,"palette.startContinuous":`Start continuous campaign`,"palette.stopDaemon":`Pause Argus`,"palette.startDaemon":`Run Argus`,"slash.suggestions":`Slash command suggestions`,"mission.roleActive":`{role} active`,"mission.overview":`mission overview`,"mission.operations":`Operations`,"role.manager":`Manager`,"role.planner":`Planner`,"role.engineer":`Engineer`,"role.reviewer":`Reviewer`,"role.critic":`Critic`,"role.system":`Argus`,"role.operator":`You`,"doctor.title":`Doctor`,"doctor.subtitle":`Argus status checks + recommended root-cause fix`,"doctor.recommended":`recommended fix`,"doctor.loadError":`Couldn’t load diagnostics.`,"doctor.empty":`No diagnostic data available`,"doctor.daemonLog":`Daemon log`,"settings.subtitle":`effective roles, budgets, and essential controls`,"settings.loadError":`Couldn’t load configuration.`,"settings.empty":`No configuration found`,"settings.quickConfig":`Quick Config`,"settings.appearance":`Appearance`,"settings.appearanceHint":`Choose the interface colour treatment. Logos and icons always remain monochrome.`,"settings.themeStyle":`Theme colour`,"settings.themeStyle.standard":`Standard`,"settings.themeStyle.standardHint":`Quiet black, white, grey, and blue.`,"settings.themeStyle.gradient":`Gradient`,"settings.themeStyle.gradientHint":`The classic Argus blue-to-gold background.`,"settings.backend":`Backend`,"settings.backendLabel.copilot":`GitHub Copilot`,"settings.backendLabel.codex":`Codex`,"settings.backendLabel.claude":`Claude`,"settings.backendLabel.cursor":`Cursor`,"settings.backendLabel.opencode":`OpenCode`,"settings.backendLabel.pi":`Pi`,"settings.backendLabel.grok":`Grok`,"settings.backendLabel.qoder":`Qoder`,"settings.backendLabel.dsh":`DSH`,"settings.backendSwitched":`Backend saved as {backend}. Restart Argus to apply.`,"settings.backendUnsupported":`Unsupported backend ({backend})`,"settings.backendUnavailable":`Backend unavailable`,"settings.model":`Model`,"settings.applyModel":`Apply`,"settings.modelPlaceholder":`auto (backend default)`,"settings.connection":`Connection`,"settings.webApi":`Web + REST API`,"settings.eventStream":`Live updates`,"settings.taskDaemon":`Background work`,"settings.taskDaemonValue":`Local process · events.jsonl · no TCP port`,"settings.budgetTitle":`Budget and quota limits`,"settings.budgetHint":`Set 0 for an uncapped provider-call limit where supported.`,"settings.saveBudgets":`Save budget limits`,"settings.budget.global":`Host-global daily`,"settings.budget.codex":`Codex calls / day`,"settings.budget.copilot":`Copilot calls / day`,"settings.budget.premium":`Copilot premium / day`,"settings.required":`{field} is required`,"settings.budgetSaved":`Budget limits saved. Restart active sessions to apply their limits.`,"settings.unit.usd":`USD`,"settings.unit.calls":`calls`,"settings.unit.requests":`requests`,"settings.advanced":`Advanced`,"settings.advancedHint":`Connection details, environment overrides, and effective raw configuration`,"settings.overrideTitle":`Environment override`,"settings.overrideHint":`Set a specific config alias or environment-variable key.`,"settings.namePlaceholder":`name or alias, e.g. manager_model`,"settings.valuePlaceholder":`value`,"settings.applyAdvanced":`Apply environment override`,"settings.applied":`Applied. Restart affected sessions to use the new settings.`,"settings.rolesTitle":`Effective roles`,"settings.rawConfig":`Raw configuration`,"settings.group.limits":`Limits`,"settings.group.safety":`Safety`,"settings.group.interface":`Interface`,"settings.knob.activeDaemons":`Active session limit`,"settings.knob.activeDaemonsDoc":`Maximum background sessions running on this host.`,"settings.knob.unpricedCalls":`Calls without pricing`,"settings.knob.unpricedCallsDoc":`Whether calls with unresolved pricing are blocked or allowed.`,"settings.knob.safeMode":`Safe mode`,"settings.knob.safeModeDoc":`Enable extra-conservative runtime guardrails.`,"settings.knob.telegram":`Telegram`,"settings.knob.telegramDoc":`Enable the Telegram notification bridge.`,"settings.knob.showReasoning":`Show reasoning`,"settings.knob.showReasoningDoc":`Stream role reasoning into the activity view.`,"settings.source.notApplicable":`Not applicable for this model`,"settings.source.vaultDefault":`Capability vault / default`,"settings.source.default":`Default`,"settings.source.saved":`Saved override`,"settings.source.environment":`Environment variable`,"settings.source.hostConfig":`Host configuration`,"settings.source.other":`Resolved configuration`,"settings.value.block":`Block calls`,"settings.value.allow":`Allow calls`,"settings.value.enabled":`Enabled`,"settings.value.disabled":`Disabled`,"settings.effort.low":`Low effort`,"settings.effort.medium":`Medium effort`,"settings.effort.high":`High effort`,"settings.effort.xhigh":`Extra-high effort`,"settings.role.curator":`Curator`,"settings.role.managerDoc":`Routes conversations and tasks, and approves reusable skills.`,"settings.role.plannerDoc":`Queues new work and decides when the project is ready to finish.`,"settings.role.engineerDoc":`Writes code and runs commands.`,"settings.role.reviewerDoc":`Reads completed work and decides whether it holds.`,"settings.role.curatorDoc":`Maintains and distills the reusable skill pool.`,"settings.footer":`Human-readable labels are shown with raw keys. The full registry remains available via`,"identity.title":`Identity`,"identity.subtitle":`who argus is working for on this project`,"identity.placeholder":`Describe who Argus is working for and durable preferences…`,"identity.save":`Save identity`,"identity.saved":`Identity saved.`,"transcript.title":`Transcript`,"transcript.subtitle":`recent operator ↔ argus turns · reply from the composer`,"transcript.empty":`no conversation turns yet`,"transcript.operator":`operator`,"new.createDaemon":`Create session`,"new.subtitle":`Creates an isolated timeline and Manager context.`,"new.close":`close create session`,"new.name":`Name`,"new.optional":`(optional)`,"new.namePlaceholder":`e.g. AAAI embodiment paper`,"new.workdir":`Output workdir`,"new.workdirHint":`Agents write code, papers, reports, and experiment outputs here. Internal memory stays under the session state directory.`,"new.objective":`Objective`,"new.objectivePlaceholder":`Leave blank to start with a conversation, or describe a campaign to start immediately.`,"new.startsAfterCreate":`Campaign starts after session creation`,"new.idleUntilMessage":`Idle until the first message`,"new.startsHint":`The session opens immediately while Argus prepares the work in the background.`,"new.idleHint":`Background work starts after your first message, when needed.`,"new.shortcut":`Ctrl/⌘+Enter to create`,"new.creating":`Creating…`,"new.createAndStart":`Create and start`,"manage.daemon":`Manage session`,"manage.displayName":`Display name`,"manage.executor":`Background work`,"manage.running":`Running`,"manage.runningExternally":`Running externally`,"manage.paused":`Stopped`,"manage.pauseHint":`Interrupt the current operation and keep progress resumable.`,"manage.stopNow":`Stop now`,"manage.stopNowHint":`Immediately interrupt this verified daemon so the session can be deleted.`,"manage.externalHint":`This session is managed outside this app.`,"manage.resumeHint":`Resume queued research work.`,"manage.working":`Working…`,"manage.resume":`Resume`,"manage.deleteSession":`Delete session`,"manage.deleteHint":`Deleted sessions move to the trash and remain recoverable. Stop background work first.`,"manage.delete":`Delete…`,"manage.confirmQuestion":`Move this session to trash?`,"manage.confirmDelete":`Confirm delete`,"decision.operator":`Operator decision`,"decision.required":`Decision required`,"decision.whyBlocked":`Why work is blocked`,"decision.evidence":`Evidence`,"decision.notePlaceholder":`Add the guidance the Manager should apply…`,"decision.resumeHint":`The Manager applies your choice before work resumes.`,"decision.later":`Later`,"decision.applying":`Applying…`,"decision.stopCampaign":`Stop campaign`,"decision.useOption":`Use this option`,"decision.sendAnswer":`Send answer`,"decision.noteRequired":`Add the required details before sending this choice.`,"artifact.preview":`Result preview`,"artifact.title":`Result`,"artifact.approvedEvidence":`evidence the Reviewer has checked`,"artifact.downloading":`Downloading…`,"artifact.download":`Download`,"artifact.open":`Open`,"artifact.close":`close result preview`,"artifact.unavailable":`preview unavailable`,"artifact.empty":`(empty file)`,"artifact.truncated":`preview truncated · download to inspect the complete file`,"artifact.htmlTooLarge":`HTML preview is too large to render safely. Download the complete file.`,"artifact.pdfDisabled":`Inline PDF preview is disabled by this browser.`,"artifact.openPdf":`Open PDF`,"artifact.noPreview":`This file type has no safe inline preview.`,"artifact.downloadHint":`Download it to inspect with a local application.`,"task.details":`Task details`,"task.stopLoop":`stop loop`,"task.done":`done`,"task.skip":`skip`,"task.close":`close task details`,"task.waitingOnYou":`Waiting on you`,"task.objective":`Objective`,"task.noObjective":`(no objective recorded)`,"task.untitled":`Untitled task`,"task.priority":`priority`,"task.started":`started`,"task.finished":`finished`,"task.outcome":`Outcome`,"task.iteration":`Iteration`,"task.mode":`mode`,"task.autoIterate":`auto-iterate`,"task.singlePass":`single pass`,"task.cycles":`cycles`,"task.cost":`cost`,"task.lastError":`Last error`,"task.notes":`Notes`,"task.dependsOn":`depends on`,"task.dependsOnCount":`Depends on {count} earlier tasks`,"pending.reviewRespond":`Review and respond`,"pending.showOnMap":`Show on map`,"backlog.active":`Active · {count}`,"backlog.history":`History · {count}`,"backlog.noHistory":`No completed work yet`,"backlog.empty":`Nothing queued. Argus is ready for new work.`,"backlog.viewDetails":`View full task details`,"backlog.iterating":`Repeating`,"backlog.stopIterating":`Stop repeating`,"backlog.stop":`Stop`,"backlog.markDone":`Mark done`,"backlog.remove":`Remove`,"mission.achievement":`Argus achievement`,"mission.elapsed":`Elapsed`,"mission.rejectedAttempts":`{count} rejected attempts`,"mission.skillsLearned":`{count} skills learned`,"mission.artifacts":`{count} files produced`,"mission.waiting":`Waiting for a mission`,"mission.statusActive":`{role} — {work}`,"mission.statusWaiting":`Ready when you are — assign a mission to begin.`,"mission.statusDone":`{outcome} — finished in {elapsed}.`,"mission.continuousDone":`Continuous run finished`,"mission.resumeContinuous":`Resume`,"mission.control":`Mission control`,"mission.attentionHealth":`System error — health is degraded.`,"mission.attentionFailed":`Mission failed — check the task below.`,"mission.deliveryFailed":`Task failed at delivery — execution could not start or finish.`,"mission.attentionStepFailed":`A step failed — check the task below.`,"mission.attentionPaused":`Mission is paused — waiting for your input.`,"mission.showObjective":`Show full objective`,"mission.showFullOutput":`View full output`,"mission.stage":`Stage`,"mission.campaign":`Campaign`,"mission.totalElapsed":`Total elapsed`,"mission.round":`Round`,"mission.mode":`Mode`,"mission.summary":`Mission summary`,"mission.deliveryCertified":`Delivery approved`,"mission.taskCompleted":`Task completed`,"mission.openResult":`Open result`,"mission.viewTask":`View task`,"mission.taskPlan":`Task plan`,"mission.team":`AI research team`,"mission.waitingShort":`Waiting`,"mission.roleWork":`Role work`,"mission.showMore":`Show more`,"mission.showLess":`Show less`,"mission.done":`Done`,"mission.inProgress":`In progress`,"mission.failed":`Failed`,"mission.bannerPaused":`Mission is paused — waiting for your input.`,"mission.bannerError":`System error — health is degraded.`,"mission.bannerStepFailed":`A step failed: {step}`,"mission.elapsedAgo":`{elapsed} ago`,"mission.filteredBy":`filtered by {task} · clear`,"mission.allVisible":`all visible missions`,"mission.roundNumber":`round {count}`,"mission.noRoleWork":`No persisted {role} work for this selection yet.`,"mission.researchDag":`Task route`,"mission.active":`active`,"mission.noDag":`The Planner has not added tasks to the route yet.`,"mission.workingHypothesis":`Working hypothesis · can be revised`,"mission.goalContribution":`How this supports the goal`,"mission.temporaryRegressions":`Expected temporary tradeoffs`,"mission.decisionRule":`When to revise, split, or stop`,"mission.acceptance":`What counts as done`,"mission.nonGoals":`Non-goals`,"mission.capabilities":`Capabilities`,"mission.capabilitiesUnlocked":`Capabilities unlocked`,"mission.learnedCapability":`Learned capability`,"mission.learnedDuring":`Learned during {mission}`,"mission.skillUnavailable":`Skill content is not available in this snapshot.`,"mission.contentTruncated":`Content preview truncated`,"mission.knowledgeRetained":`Knowledge retained`,"mission.selfEvolution":`Saved project knowledge`,"mission.knowledgeSaved":`Argus saved these capabilities and notes for future work on this project.`,"mission.noCapabilities":`No capabilities learned yet.`,"mission.replay":`Mission replay`,"mission.replayTimeline":`Replay mission timeline`,"mission.roleFailed":`{role} failed`,"mission.showingLatestEvent":`Showing latest event`,"mission.showingLastEvents":`Showing last {count} events`,"mission.waitingEvents":`Waiting for structured research events.`,"mission.startsAfter":`Starts after {count} earlier tasks`,"mission.hiddenTasks":`{count} earlier tasks hidden · {failed} blocked or failed · {skipped} skipped`,"mission.projectFilesChanged":`Project files changed`,"mission.reviewInIde":`Open the IDE to review the diff`,"research.currentWork":`Current work`,"research.dagProgress":`Task route progress`,"research.verifiedOutputs":`Verified outputs`,"research.recentMilestones":`Recent milestones`,"research.liveProgress":`Live progress`,"research.artifact":`Research result`,"research.canvas":`Manager live research canvas`,"research.previewArtifact":`Preview the result`,"research.openLarge":`Open large preview`,"research.collapse":`Collapse preview`,"research.unavailable":`Manager live view is temporarily unavailable.`,"research.noPreview":`No preview`,"research.waiting":`Waiting…`,"research.updating":`Updating…`,"research.fileUnavailable":`Preview unavailable for this file.`,"research.eventSourced":`event-sourced mission state`,"research.downloadFailed":`download failed`,"operations.title":`Operations`,"operations.work":`Work`,"operations.runtime":`Runtime`,"operations.system":`System`,"operations.recovery":`Recovery`,"operations.workInput":`Work input`,"operations.workHint":`Queue work, guide the active task, save a note, or preview a plan without dispatching it.`,"operations.action.task":`Task`,"operations.action.nudge":`Guide`,"operations.action.note":`Note`,"operations.action.plan":`Plan`,"operations.planPlaceholder":`Objective to preview; preview never queues work`,"operations.actionPlaceholder":`{action} text`,"operations.previewPlan":`Preview plan`,"operations.submitAction":`Submit {action}`,"operations.runtimeHint":`Change where this session runs, reset Manager context, or safely restart the session.`,"operations.workdir":`Working directory`,"operations.workdirUpdated":`Working directory updated.`,"operations.applyWorkdir":`Apply working directory`,"operations.replaceSlot":`Replace an active session`,"operations.sourceUpdate":`Argus source version`,"operations.pullLatest":`Pull latest version`,"operations.updateChecking":`Checking published branch…`,"operations.updateRunning":`Updating…`,"operations.updateAvailable":`Update available`,"operations.updateCurrent":`Up to date`,"operations.updateUnavailable":`This checkout cannot be updated safely.`,"operations.currentRevision":`Current`,"operations.latestRevision":`Latest`,"operations.updatePhase":`Phase`,"operations.updateRestart":`Source updated. Restart the cockpit, then use the reload button to move active daemons to the new release at a safe task boundary.`,"operations.skills":`Skills`,"operations.runSkill":`Run skill command`,"operations.metrics":`System metrics`,"operations.trash":`Recoverable trash`,"operations.searchTrash":`Search trash`,"operations.trashEmpty":`Trash is empty.`,"resource.title":`Resources`,"resource.loading":`Loading resource status…`,"resource.devices":`Devices: {count}`,"resource.inUse":`In use · {count}`,"resource.queue":`Queue · {count}`,"resource.none":`None`,"resource.timeLeft":`{ttl} left`,"resource.noIntent":`No purpose recorded`,"resource.yieldRequest":`Resource release requested · {reason}`,"resource.queuePosition":`Queue position {position}`,"label.status.inProgress":`In progress`,"label.status.waiting":`Waiting`,"label.status.completed":`Completed`,"label.status.blocked":`Blocked`,"label.status.failed":`Failed`,"label.status.needsChanges":`Needs changes`,"label.status.skipped":`Skipped`,"label.status.paused":`Paused`,"label.status.available":`Available`,"label.status.unavailable":`Unavailable`,"label.status.inaccessible":`Not accessible`,"label.status.limited":`Limited`,"label.status.healthy":`Healthy`,"label.status.updated":`Status updated`,"label.role.manager":`Manager`,"label.role.planner":`Planner`,"label.role.engineer":`Engineer`,"label.role.reviewer":`Reviewer`,"label.role.argus":`Argus`,"label.role.you":`You`,"label.work.task":`Task`,"label.work.action":`Work step`,"label.work.handoff":`Notes for the next step`,"label.work.review":`Review`,"label.work.planning":`Planning`,"label.work.update":`Update`,"label.stage.scope":`Scope`,"label.stage.research":`Research`,"label.stage.implementation":`Implementation`,"label.stage.experiment":`Experiments`,"label.stage.analysis":`Analysis`,"label.stage.writing":`Writing`,"label.stage.review":`Final review`,"label.stage.delivery":`Delivery`,"label.stage.unstaged":`Unstaged`,"label.frontier.reopened":`An earlier task was reopened`,"label.frontier.added":`A new task was added`,"label.frontier.completed":`A task path was completed`,"label.frontier.revised":`The task plan was revised`,"label.frontier.narrowed":`The task scope was narrowed`,"label.frontier.expanded":`The task scope was expanded`,"label.frontier.updated":`The task plan was updated`,"label.priority":`Priority {priority}`,"label.outcome.workCompleted":`Work completed`,"label.outcome.workPaused":`Work paused`,"label.outcome.workBlocked":`Work blocked`,"label.outcome.workFailed":`Work failed`,"label.outcome.workEnded":`Work ended`,"label.outcome.workIncomplete":`Work incomplete`,"label.outcome.workStalled":`Work stalled`,"label.outcome.workUpdated":`Work status updated`,"label.outcome.reviewPassed":`Review passed`,"label.outcome.reviewNeedsChanges":`Review requested changes`,"label.outcome.reviewBlocked":`Review blocked`,"label.outcome.reviewOutdated":`Review is out of date`,"label.outcome.reviewPending":`Review pending`,"label.outcome.stageApproved":`Stage approved`,"label.outcome.stageNotApproved":`Stage not approved`,"label.outcome.stageRevoked":`Stage approval revoked`,"label.outcome.stageNotNeeded":`Stage decision not needed`,"label.outcome.stagePending":`Stage decision pending`,"label.outcome.budgetPaused":`Paused by budget limit`,"label.outcome.waitingForYou":`Waiting for your response`,"label.outcome.stoppedByYou":`Stopped by you`,"label.outcome.pausedByYou":`Paused by you`,"label.outcome.sessionPaused":`Session paused`,"label.outcome.serviceUnavailable":`Service unavailable`,"label.outcome.serviceCoolingDown":`Service temporarily paused`,"label.outcome.temporaryIssue":`Paused by a temporary issue`,"label.outcome.serviceError":`Stopped by a service error`,"label.outcome.needsPlan":`A new plan is needed`,"label.outcome.canResume":`Can resume`,"label.routing.team":`Team workflow`,"label.routing.individual":`Individual workflow`,"label.routing.research":`Research`,"label.routing.software":`Software work`,"label.routing.staged":`Step by step`,"label.routing.flexible":`Flexible workflow`,"label.routing.ongoing":`Ongoing`,"label.routing.defined":`Defined scope`,"label.resource.nvidiaGpu":`NVIDIA GPU`,"label.resource.amdGpu":`AMD GPU`,"label.resource.appleGpu":`Apple GPU`,"label.resource.cpu":`CPU`,"label.resource.accelerator":`Accelerator`,"label.resource.enforced":`Limits enforced`,"label.resource.advisory":`Recommendations only`,"label.resource.released":`Resources released`,"label.resource.kept":`Resources kept`},Wr={"language.english":`English`,"handshake.connecting":`正在准备 Argus`,"handshake.service":`服务`,"handshake.project":`项目`,"handshake.ready":`就绪`,"handshake.title":`正在准备 Argus`,"handshake.detail":`正在恢复你的工作区…`,"splash.starting":`Argus 启动中`,"rail.workbench":`工作台`,"rail.sessionsShortcut":`会话 · Ctrl/⌘ P`,"panel.backlog":`待办`,"panel.activity":`动态`,"panel.journal":`日志`,"panel.roles":`角色`,"panel.project":`项目`,"panel.liveView":`Manager 实时项目视图`,"stream.jumpToLatest":`跳到最新`,"stream.toggleReasoning":`显示或隐藏 Agent 推理(⌘T)`,"stream.reasoning":`推理`,"stream.noLogs":`暂无活动`,"stream.system":`Argus 动态`,"stream.autonomous":`后台活动`,"stream.backgroundWork":`Argus 正在后台工作`,"stream.ready":`Argus 已就绪。你可以提问或安排下一项工作。`,"newDaemon.workdirPlaceholder":`留空 → ~/.argus-skill/workspaces/`,"operations.resetManager":`重置 Manager 上下文`,"language.chinese":`中文`,"language.switchTo":`切换到{language}`,"common.loading":`加载中…`,"common.retry":`重试`,"common.save":`保存`,"common.cancel":`取消`,"common.close":`关闭`,"common.settings":`设置`,"common.ready":`就绪`,"common.live":`实时`,"common.reconnecting":`正在重连`,"common.stale":`快照已过期`,"common.degraded":`快照异常`,"common.external":`外部`,"common.pause":`暂停`,"common.run":`运行`,"common.local":`本地`,"common.all":`全部`,"common.unassigned":`未分配`,"common.closeSessions":`关闭会话列表`,"common.resizeSessions":`调整会话列表宽度`,"common.resizePreview":`调整预览区域宽度`,"common.expandPreview":`展开预览`,"time.justNow":`刚刚`,"time.minutesAgo":`{count}分钟前`,"time.hoursAgo":`{count}小时前`,"time.yesterdayAt":`昨天 {time}`,"connection.pairingTitle":`此浏览器尚未与 Argus 配对`,"connection.pairingDetail":`请关闭此标签页,然后从 Argus Desktop 重新打开工作台,或使用新的配对链接。`,"connection.pairAgain":`重新配对`,"connection.pairingInput":`配对链接或令牌`,"connection.pairingPlaceholder":`粘贴新的配对链接或令牌`,"connection.pairingInvalid":`请输入有效的配对链接或令牌。`,"connection.connect":`连接`,"connection.unreachableTitle":`Argus 本地服务当前不可达`,"connection.unreachableDetail":`请保持 Argus Desktop 运行,等待本地服务就绪后再重试。`,"sidebar.collapse":`收起会话`,"sidebar.expand":`展开会话`,"sidebar.create":`创建会话`,"sidebar.find":`查找会话`,"sidebar.clearSearch":`清除搜索`,"sidebar.refreshFailed":`刷新失败 · 重试`,"sidebar.noSessions":`暂无会话`,"sidebar.noMatches":`没有匹配"{query}"的会话`,"sidebar.unnamedSession":`未命名会话`,"sidebar.daemonAlive":`Argus 运行中`,"sidebar.updateRequired":`需要更新`,"sidebar.updateAvailable":`可更新`,"sidebar.updateAvailableHint":`后台仍在运行,执行器与网页版本不同。`,"sidebar.stopped":`已停止`,"sidebar.runningFor":`运行中 · {uptime}`,"sidebar.manage":`管理 {name}`,"sidebar.manageHint":`重命名、暂停或删除`,"sidebar.resume":`继续`,"sidebar.resumeHint":`在 {workdir} 中继续工作`,"sidebar.resumeSuccess":`会话已恢复。`,"sidebar.resumeFailed":`无法恢复会话:{error}`,"sidebar.modelLoading":`正在加载后端和模型…`,"sidebar.modelUnavailable":`后端和模型信息不可用`,"sidebar.defaultModel":`默认模型`,"sidebar.openSettings":`打开设置`,"sidebar.theme":`{current}主题;切换到{next}主题`,"landing.selectOrCreate":`从侧边栏选择一个会话,或创建新会话。`,"landing.noSessions":`还没有会话。创建一个即可开始。`,"landing.select":`选择会话`,"landing.new":`新建会话`,"topbar.openSessions":`打开会话列表`,"topbar.externallyManaged":`由外部管理`,"topbar.pauseDaemon":`暂停 Argus`,"topbar.runDaemon":`运行 Argus`,"topbar.roleActive":`{role} 活跃中`,"topbar.roleIdle":`{role} 空闲`,"topbar.externalDaemonHint":`Argus 由此应用之外的服务管理,请前往相应位置控制。`,"topbar.manageSession":`管理会话`,"topbar.showPreview":`显示预览`,"topbar.showActivity":`显示动态`,"mobile.views":`视图`,"mobile.sessions":`会话`,"mobile.mission":`任务`,"mobile.activity":`动态`,"mobile.workbench":`工作台`,"mobile.map":`地图`,"mobile.preview":`预览`,"chat.working":`Argus 正在处理你的消息`,"chat.workingQuiet":`Argus 正在处理你的消息 · 仍在处理中,{quiet} 秒暂无新进展`,"chat.stopWaitingHint":`按 Esc 停止等待`,"chat.messageArgus":`向 Argus 发送消息`,"chat.selectSession":`请选择会话…`,"chat.placeholder":`提问或安排工作`,"chat.routeLabel":`消息类型`,"chat.routeHint":`任务模式跳过消息分类,但仍严格经过 Manager → Planner → Engineer → Reviewer`,"chat.routeTask":`任务`,"chat.routeAuto":`自动`,"chat.routeChat":`对话`,"chat.attach":`添加文件`,"chat.attachHint":`支持 PNG、JPEG、WebP、PDF、Markdown/文本、JSON、CSV · 每条消息最多 {count} 个文件,单个 {perFile},总计 {total}`,"chat.attachDrop":`拖放文件以添加附件`,"chat.attachRemove":`移除附件 {name}`,"chat.attachUnsupported":`{name} 不受支持。请使用 PNG、JPEG、WebP、PDF、Markdown/文本、JSON 或 CSV。`,"chat.attachTooLarge":`{name} 超过单文件大小限制 {size}。`,"chat.attachTooMany":`每条消息最多只能附带 {count} 个文件。`,"chat.attachTotalTooLarge":`附件总大小超过 {size} 限制。`,"chat.attachmentUploadFailed":`附件上传失败:{error}`,"chat.uploadingAttachments":`正在上传附件`,"chat.rewriteHint":`让 Manager 将提示词改写为团队可执行的任务说明。不会直接发送,改写结果会回到输入框供你编辑。`,"chat.rewriteLabel":`使用 Manager 改写提示词`,"chat.rewriting":`正在改写`,"chat.rewrite":`✦ 改写`,"chat.stopWaiting":`停止等待`,"chat.stopWaitingTitle":`停止等待此回复;服务端工作可能仍会继续`,"chat.send":`发送消息`,"copy.message":`复制`,"copy.code":`复制代码`,"copy.copied":`已复制`,"help.title":`键盘快捷键`,"help.commands":`命令`,"help.palette":`打开命令面板`,"help.sessions":`展开或收起会话`,"help.managerChat":`聚焦 Manager 对话框`,"help.rewrite":`发送前改写当前提示词`,"help.reasoning":`显示或隐藏 Agent 推理`,"help.kiosk":`切换只读展示模式`,"help.composer":`聚焦输入框`,"help.send":`发送消息`,"help.newline":`插入换行`,"help.thisHelp":`打开此帮助`,"help.escape":`关闭浮层或停止等待`,"palette.placeholder":`输入命令或搜索…`,"palette.noMatches":`没有匹配的命令`,"palette.navigate":`↑↓ 导航`,"palette.run":`↵ 执行`,"palette.close":`Esc 关闭`,"palette.view":`视图`,"palette.action":`操作`,"palette.project":`项目`,"palette.newDaemon":`新建会话`,"palette.openTranscript":`打开对话记录`,"palette.openProject":`打开项目`,"palette.projectHint":`工作 · 记忆 · Agent`,"palette.openOperations":`打开运行控制`,"palette.operationsHint":`会话控制`,"palette.hideReasoning":`隐藏推理`,"palette.showReasoning":`显示推理`,"palette.exitKiosk":`退出展示模式`,"palette.enterKiosk":`进入展示模式`,"palette.messageArgus":`向 Argus 发送消息…`,"palette.stopWaiting":`停止等待 Manager 回复`,"palette.stopContinuous":`停止持续任务`,"palette.startContinuous":`启动持续任务`,"palette.stopDaemon":`暂停 Argus`,"palette.startDaemon":`运行 Argus`,"slash.suggestions":`Slash 命令建议`,"mission.roleActive":`{role} 正在工作`,"mission.overview":`任务概览`,"mission.operations":`运行控制`,"role.manager":`Manager`,"role.planner":`Planner`,"role.engineer":`Engineer`,"role.reviewer":`Reviewer`,"role.critic":`Critic`,"role.system":`Argus`,"role.operator":`你`,"doctor.title":`诊断`,"doctor.subtitle":`Argus 状态检查与推荐的根因修复方案`,"doctor.recommended":`推荐修复`,"doctor.loadError":`无法加载诊断数据。`,"doctor.empty":`诊断暂无数据`,"doctor.daemonLog":`后台进程日志`,"settings.subtitle":`生效中的角色、预算和关键控制项`,"settings.loadError":`无法加载配置。`,"settings.empty":`未找到配置`,"settings.quickConfig":`快速配置`,"settings.appearance":`外观`,"settings.appearanceHint":`选择界面主题色。Logo 与图标始终保持黑白,不参与渐变。`,"settings.themeStyle":`主题色`,"settings.themeStyle.standard":`标准`,"settings.themeStyle.standardHint":`克制的黑、白、灰与蓝色。`,"settings.themeStyle.gradient":`渐变`,"settings.themeStyle.gradientHint":`经典 Argus 蓝金渐变背景。`,"settings.backend":`后端`,"settings.backendLabel.copilot":`GitHub Copilot`,"settings.backendLabel.codex":`Codex`,"settings.backendLabel.claude":`Claude`,"settings.backendLabel.cursor":`Cursor`,"settings.backendLabel.opencode":`OpenCode`,"settings.backendLabel.pi":`Pi`,"settings.backendLabel.grok":`Grok`,"settings.backendLabel.qoder":`Qoder`,"settings.backendLabel.dsh":`DSH`,"settings.backendSwitched":`后端已保存为{backend}。重启 Argus 后生效。`,"settings.backendUnsupported":`不支持的后端({backend})`,"settings.backendUnavailable":`后端信息不可用`,"settings.model":`模型`,"settings.applyModel":`应用`,"settings.modelPlaceholder":`auto(后端默认模型)`,"settings.connection":`连接`,"settings.webApi":`Web + REST API`,"settings.eventStream":`实时动态`,"settings.taskDaemon":`后台工作`,"settings.taskDaemonValue":`本地进程 · events.jsonl · 无 TCP 端口`,"settings.budgetTitle":`预算和配额限制`,"settings.budgetHint":`支持时,将调用限制设为 0 表示不设上限。`,"settings.saveBudgets":`保存预算限制`,"settings.budget.global":`主机全局每日预算`,"settings.budget.codex":`Codex 每日调用`,"settings.budget.copilot":`Copilot 每日调用`,"settings.budget.premium":`Copilot 每日 Premium 请求`,"settings.required":`必须填写{field}`,"settings.budgetSaved":`预算限制已保存。请重启活动会话以应用限制。`,"settings.unit.usd":`美元`,"settings.unit.calls":`次调用`,"settings.unit.requests":`次请求`,"settings.advanced":`高级设置`,"settings.advancedHint":`连接详情、环境变量覆盖和生效中的原始配置`,"settings.overrideTitle":`环境变量覆盖`,"settings.overrideHint":`设置特定的配置别名或环境变量键。`,"settings.namePlaceholder":`名称或别名,例如 manager_model`,"settings.valuePlaceholder":`值`,"settings.applyAdvanced":`应用环境变量覆盖`,"settings.applied":`设置已应用。请重启受影响的会话以使用新设置。`,"settings.rolesTitle":`生效中的角色`,"settings.rawConfig":`原始配置`,"settings.group.limits":`限制`,"settings.group.safety":`安全`,"settings.group.interface":`界面`,"settings.knob.activeDaemons":`活动会话上限`,"settings.knob.activeDaemonsDoc":`此主机上可同时运行的后台会话数量上限。`,"settings.knob.unpricedCalls":`未定价调用`,"settings.knob.unpricedCallsDoc":`未能确定价格的调用是阻止还是允许。`,"settings.knob.safeMode":`安全模式`,"settings.knob.safeModeDoc":`启用更保守的运行时保护措施。`,"settings.knob.telegram":`Telegram`,"settings.knob.telegramDoc":`启用 Telegram 通知桥接。`,"settings.knob.showReasoning":`显示推理`,"settings.knob.showReasoningDoc":`在活动视图中显示角色推理过程。`,"settings.source.notApplicable":`不适用于此模型`,"settings.source.vaultDefault":`能力库 / 默认值`,"settings.source.default":`默认值`,"settings.source.saved":`已保存的覆盖值`,"settings.source.environment":`环境变量`,"settings.source.hostConfig":`主机配置`,"settings.source.other":`解析后的配置`,"settings.value.block":`阻止调用`,"settings.value.allow":`允许调用`,"settings.value.enabled":`已启用`,"settings.value.disabled":`已停用`,"settings.effort.low":`低推理强度`,"settings.effort.medium":`中等推理强度`,"settings.effort.high":`高推理强度`,"settings.effort.xhigh":`超高推理强度`,"settings.role.curator":`知识维护`,"settings.role.managerDoc":`分流对话和任务,并批准可复用技能。`,"settings.role.plannerDoc":`安排后续工作,并判断项目何时可以收尾。`,"settings.role.engineerDoc":`编写代码并运行命令。`,"settings.role.reviewerDoc":`审读已完成的工作,判断其是否成立。`,"settings.role.curatorDoc":`维护并提炼可复用技能库。`,"settings.footer":`配置项同时显示易读标签和原始键。完整配置仍可通过以下命令查看:`,"identity.title":`身份`,"identity.subtitle":`本项目中 Argus 服务的对象`,"identity.placeholder":`描述 Argus 正在为谁工作,以及需要长期遵循的偏好…`,"identity.save":`保存身份`,"identity.saved":`身份已保存。`,"transcript.title":`对话记录`,"transcript.subtitle":`近期操作者 ↔ Argus 对话 · 请从输入框继续回复`,"transcript.empty":`暂无对话记录`,"transcript.operator":`操作者`,"new.createDaemon":`创建会话`,"new.subtitle":`创建隔离的时间线和 Manager 上下文。`,"new.close":`关闭创建会话窗口`,"new.name":`名称`,"new.optional":`(可选)`,"new.namePlaceholder":`例如:AAAI 具身智能论文`,"new.workdir":`输出工作目录`,"new.workdirHint":`Agent 会在这里写入代码、论文、报告和实验结果。内部记忆仍保存在会话状态目录中。`,"new.objective":`目标`,"new.objectivePlaceholder":`留空则从对话开始,也可以填写一个立即启动的持续任务。`,"new.startsAfterCreate":`创建会话后立即启动任务`,"new.idleUntilMessage":`收到第一条消息前保持空闲`,"new.startsHint":`会话会立即打开,Argus 将在后台准备相关工作。`,"new.idleHint":`收到第一条消息后,Argus 会按需启动后台工作。`,"new.shortcut":`按 Ctrl/⌘+Enter 创建`,"new.creating":`正在创建…`,"new.createAndStart":`创建并启动`,"manage.daemon":`管理会话`,"manage.displayName":`显示名称`,"manage.executor":`后台工作`,"manage.running":`运行中`,"manage.runningExternally":`由外部运行`,"manage.paused":`未运行`,"manage.pauseHint":`中断当前操作并保留可恢复的进度。`,"manage.stopNow":`立即停止`,"manage.stopNowHint":`立即中断这个已验证的 daemon,停止后即可删除会话。`,"manage.externalHint":`此会话由此应用之外的服务管理。`,"manage.resumeHint":`继续执行队列中的研究工作。`,"manage.working":`处理中…`,"manage.resume":`继续`,"manage.deleteSession":`删除会话`,"manage.deleteHint":`删除的会话会移入回收站,之后仍可恢复。请先停止后台工作。`,"manage.delete":`删除…`,"manage.confirmQuestion":`将此会话移入回收站?`,"manage.confirmDelete":`确认删除`,"decision.operator":`操作者决策`,"decision.required":`需要你的决策`,"decision.whyBlocked":`工作被阻塞的原因`,"decision.evidence":`证据`,"decision.notePlaceholder":`添加 Manager 应采用的指导…`,"decision.resumeHint":`Manager 会在恢复工作前应用你的选择。`,"decision.later":`稍后处理`,"decision.applying":`正在应用…`,"decision.stopCampaign":`停止持续任务`,"decision.useOption":`使用此选项`,"decision.sendAnswer":`发送回答`,"decision.noteRequired":`这个选项需要补充说明后才能提交。`,"artifact.preview":`结果预览`,"artifact.title":`结果`,"artifact.approvedEvidence":`Reviewer 已核实的证据`,"artifact.downloading":`正在下载…`,"artifact.download":`下载`,"artifact.open":`打开`,"artifact.close":`关闭结果预览`,"artifact.unavailable":`无法预览`,"artifact.empty":`(空文件)`,"artifact.truncated":`预览已截断 · 请下载完整文件查看`,"artifact.htmlTooLarge":`HTML 文件过大,无法安全预览。请下载完整文件。`,"artifact.pdfDisabled":`此浏览器已禁用内嵌 PDF 预览。`,"artifact.openPdf":`打开 PDF`,"artifact.noPreview":`此文件类型无法安全地在线预览。`,"artifact.downloadHint":`请下载后使用本地应用查看。`,"task.details":`任务详情`,"task.stopLoop":`停止循环`,"task.done":`完成`,"task.skip":`跳过`,"task.close":`关闭任务详情`,"task.waitingOnYou":`等待你的回复`,"task.objective":`目标`,"task.noObjective":`(未记录目标)`,"task.untitled":`未命名任务`,"task.priority":`优先级`,"task.started":`开始时间`,"task.finished":`完成时间`,"task.outcome":`结果`,"task.iteration":`迭代`,"task.mode":`模式`,"task.autoIterate":`自动迭代`,"task.singlePass":`单次执行`,"task.cycles":`轮次`,"task.cost":`成本`,"task.lastError":`最近错误`,"task.notes":`备注`,"task.dependsOn":`依赖`,"task.dependsOnCount":`依赖前置任务 {count} 项`,"pending.reviewRespond":`查看并回复`,"pending.showOnMap":`在地图上查看`,"backlog.active":`进行中 · {count}`,"backlog.history":`历史记录 · {count}`,"backlog.noHistory":`暂无已完成工作`,"backlog.empty":`队列中没有工作。Argus 已准备好接收新任务。`,"backlog.viewDetails":`查看完整任务详情`,"backlog.iterating":`重复执行中`,"backlog.stopIterating":`停止重复执行`,"backlog.stop":`停止`,"backlog.markDone":`标记为完成`,"backlog.remove":`移除`,"mission.achievement":`Argus 成果`,"mission.elapsed":`耗时`,"mission.rejectedAttempts":`{count} 次方案被拒绝`,"mission.skillsLearned":`学习了 {count} 个 Skill`,"mission.artifacts":`产出 {count} 个文件`,"mission.waiting":`等待任务`,"mission.statusActive":`{role} — {work}`,"mission.statusWaiting":`已准备就绪,请分配一个任务开始工作。`,"mission.statusDone":`{outcome} — 用时 {elapsed}。`,"mission.continuousDone":`连续运行已完成`,"mission.resumeContinuous":`恢复`,"mission.control":`任务控制`,"mission.attentionHealth":`系统出错——运行状态异常。`,"mission.attentionFailed":`任务失败——请查看下方详情。`,"mission.deliveryFailed":`任务在交付阶段失败——执行未能启动或完成。`,"mission.attentionStepFailed":`有一个步骤失败——请查看下方任务。`,"mission.attentionPaused":`任务已暂停——正在等待你的输入。`,"mission.showObjective":`显示完整目标`,"mission.showFullOutput":`查看完整输出`,"mission.stage":`阶段`,"mission.campaign":`持续任务`,"mission.totalElapsed":`总耗时`,"mission.round":`轮次`,"mission.mode":`模式`,"mission.summary":`本次完成`,"mission.deliveryCertified":`交付成果已通过审核`,"mission.taskCompleted":`任务已完成`,"mission.openResult":`打开成果`,"mission.viewTask":`查看任务`,"mission.taskPlan":`任务计划`,"mission.team":`AI 研究团队`,"mission.waitingShort":`等待中`,"mission.roleWork":`角色工作`,"mission.showMore":`显示更多`,"mission.showLess":`收起`,"mission.done":`已完成`,"mission.inProgress":`进行中`,"mission.failed":`失败`,"mission.bannerPaused":`任务已暂停 — 等待你的操作。`,"mission.bannerError":`系统异常 — 健康状态已降级。`,"mission.bannerStepFailed":`某步骤失败:{step}`,"mission.elapsedAgo":`{elapsed} 前`,"mission.filteredBy":`按 {task} 筛选 · 清除`,"mission.allVisible":`全部可见任务`,"mission.roundNumber":`第 {count} 轮`,"mission.noRoleWork":`当前筛选下还没有持久化的 {role} 工作记录。`,"mission.researchDag":`任务路线`,"mission.active":`进行中`,"mission.noDag":`Planner 尚未向路线中添加任务。`,"mission.workingHypothesis":`当前假设 · 可随证据调整`,"mission.goalContribution":`对目标的作用`,"mission.temporaryRegressions":`预期的暂时取舍`,"mission.decisionRule":`何时调整、拆分或停止`,"mission.acceptance":`完成的标准`,"mission.nonGoals":`非目标`,"mission.capabilities":`能力`,"mission.capabilitiesUnlocked":`已解锁能力`,"mission.learnedCapability":`已学习能力`,"mission.learnedDuring":`在“{mission}”期间学习`,"mission.skillUnavailable":`当前快照中没有此 Skill 的内容。`,"mission.contentTruncated":`内容预览已截断`,"mission.knowledgeRetained":`已保留知识`,"mission.selfEvolution":`已保存的项目知识`,"mission.knowledgeSaved":`Argus 已保存这些能力和笔记,供本项目后续工作使用。`,"mission.noCapabilities":`尚未学习新能力。`,"mission.replay":`任务回放`,"mission.replayTimeline":`回放任务时间线`,"mission.roleFailed":`{role} 执行失败`,"mission.showingLatestEvent":`显示最近一条事件`,"mission.showingLastEvents":`显示最近 {count} 条事件`,"mission.waitingEvents":`等待结构化研究事件。`,"mission.startsAfter":`需等待前置任务 {count} 项`,"mission.hiddenTasks":`已隐藏前序任务 {count} 项 · 阻塞或失败 {failed} 项 · 已跳过 {skipped} 项`,"mission.projectFilesChanged":`项目文件有变更`,"mission.reviewInIde":`可打开 IDE 查看差异`,"research.currentWork":`当前工作`,"research.dagProgress":`任务路线进度`,"research.verifiedOutputs":`已验证输出`,"research.recentMilestones":`近期里程碑`,"research.liveProgress":`实时进度`,"research.artifact":`研究成果`,"research.canvas":`Manager 实时研究面板`,"research.previewArtifact":`预览成果`,"research.openLarge":`打开大尺寸预览`,"research.collapse":`收起预览`,"research.unavailable":`Manager 实时视图暂时不可用。`,"research.noPreview":`暂无预览`,"research.waiting":`等待中…`,"research.updating":`正在更新…`,"research.fileUnavailable":`此文件无法预览。`,"research.eventSourced":`基于事件的任务状态`,"research.downloadFailed":`下载失败`,"operations.title":`运行控制`,"operations.work":`工作`,"operations.runtime":`运行时`,"operations.system":`系统`,"operations.recovery":`恢复`,"operations.workInput":`工作输入`,"operations.workHint":`加入工作、指导当前任务、保存备注,或仅预览计划而不分派。`,"operations.action.task":`任务`,"operations.action.nudge":`指导`,"operations.action.note":`备注`,"operations.action.plan":`计划`,"operations.planPlaceholder":`要预览的目标;预览不会加入任务队列`,"operations.actionPlaceholder":`输入 {action} 内容`,"operations.previewPlan":`预览计划`,"operations.submitAction":`提交 {action}`,"operations.runtimeHint":`更改会话运行位置、重置 Manager 上下文,或安全重启会话。`,"operations.workdir":`工作目录`,"operations.workdirUpdated":`工作目录已更新。`,"operations.applyWorkdir":`应用工作目录`,"operations.replaceSlot":`替换活动会话`,"operations.sourceUpdate":`Argus 源码版本`,"operations.pullLatest":`拉取最新版本`,"operations.updateChecking":`正在检查已发布分支…`,"operations.updateRunning":`正在更新…`,"operations.updateAvailable":`有可用更新`,"operations.updateCurrent":`已是最新`,"operations.updateUnavailable":`当前工作树无法安全更新。`,"operations.currentRevision":`当前`,"operations.latestRevision":`最新`,"operations.updatePhase":`阶段`,"operations.updateRestart":`源码已更新。请重启工作台,再使用重载按钮让活动 daemon 在安全任务边界切换到新版本。`,"operations.skills":`Skills`,"operations.runSkill":`运行 Skill 命令`,"operations.metrics":`系统指标`,"operations.trash":`可恢复的回收站`,"operations.searchTrash":`搜索回收站`,"operations.trashEmpty":`回收站为空。`,"resource.title":`资源`,"resource.loading":`正在加载资源状态…`,"resource.devices":`设备:{count}`,"resource.inUse":`使用中 · {count}`,"resource.queue":`等待队列 · {count}`,"resource.none":`无`,"resource.timeLeft":`剩余 {ttl}`,"resource.noIntent":`未记录用途`,"resource.yieldRequest":`收到释放资源请求 · {reason}`,"resource.queuePosition":`队列第 {position} 位`,"label.status.inProgress":`进行中`,"label.status.waiting":`等待中`,"label.status.completed":`已完成`,"label.status.blocked":`已阻塞`,"label.status.failed":`失败`,"label.status.needsChanges":`需要修改`,"label.status.skipped":`已跳过`,"label.status.paused":`已暂停`,"label.status.available":`可用`,"label.status.unavailable":`不可用`,"label.status.inaccessible":`无法访问`,"label.status.limited":`部分受限`,"label.status.healthy":`状态正常`,"label.status.updated":`状态已更新`,"label.role.manager":`Manager`,"label.role.planner":`Planner`,"label.role.engineer":`Engineer`,"label.role.reviewer":`Reviewer`,"label.role.argus":`Argus`,"label.role.you":`你`,"label.work.task":`任务`,"label.work.action":`工作步骤`,"label.work.handoff":`给下一步的说明`,"label.work.review":`审核`,"label.work.planning":`规划`,"label.work.update":`动态`,"label.stage.scope":`范围定义`,"label.stage.research":`研究`,"label.stage.implementation":`方法实现`,"label.stage.experiment":`实验验证`,"label.stage.analysis":`结果分析`,"label.stage.writing":`论文写作`,"label.stage.review":`最终审核`,"label.stage.delivery":`成果交付`,"label.stage.unstaged":`未分阶段`,"label.frontier.reopened":`已重新开启一项前序任务`,"label.frontier.added":`已添加一项新任务`,"label.frontier.completed":`已完成一条任务路径`,"label.frontier.revised":`已调整任务计划`,"label.frontier.narrowed":`已缩小任务范围`,"label.frontier.expanded":`已扩大任务范围`,"label.frontier.updated":`任务计划已更新`,"label.priority":`优先级 {priority}`,"label.outcome.workCompleted":`工作已完成`,"label.outcome.workPaused":`工作已暂停`,"label.outcome.workBlocked":`工作被阻塞`,"label.outcome.workFailed":`工作失败`,"label.outcome.workEnded":`工作已结束`,"label.outcome.workIncomplete":`工作尚未完成`,"label.outcome.workStalled":`工作停滞`,"label.outcome.workUpdated":`工作状态已更新`,"label.outcome.reviewPassed":`审核通过`,"label.outcome.reviewNeedsChanges":`审核要求修改`,"label.outcome.reviewBlocked":`审核被阻塞`,"label.outcome.reviewOutdated":`审核结果已过期`,"label.outcome.reviewPending":`等待审核`,"label.outcome.stageApproved":`阶段已通过`,"label.outcome.stageNotApproved":`阶段未通过`,"label.outcome.stageRevoked":`阶段批准已撤回`,"label.outcome.stageNotNeeded":`无需阶段审核`,"label.outcome.stagePending":`阶段审核待定`,"label.outcome.budgetPaused":`因预算上限暂停`,"label.outcome.waitingForYou":`正在等待你的回复`,"label.outcome.stoppedByYou":`已由你停止`,"label.outcome.pausedByYou":`已由你暂停`,"label.outcome.sessionPaused":`会话已暂停`,"label.outcome.serviceUnavailable":`服务暂不可用`,"label.outcome.serviceCoolingDown":`服务暂时暂停`,"label.outcome.temporaryIssue":`因临时问题暂停`,"label.outcome.serviceError":`因服务错误停止`,"label.outcome.needsPlan":`需要制定新计划`,"label.outcome.canResume":`可以继续`,"label.routing.team":`团队协作`,"label.routing.individual":`单独执行`,"label.routing.research":`研究任务`,"label.routing.software":`软件工作`,"label.routing.staged":`分步执行`,"label.routing.flexible":`灵活流程`,"label.routing.ongoing":`持续进行`,"label.routing.defined":`范围明确`,"label.resource.nvidiaGpu":`NVIDIA GPU`,"label.resource.amdGpu":`AMD GPU`,"label.resource.appleGpu":`Apple GPU`,"label.resource.cpu":`CPU`,"label.resource.accelerator":`加速设备`,"label.resource.enforced":`强制执行限制`,"label.resource.advisory":`仅提供建议`,"label.resource.released":`已释放资源`,"label.resource.kept":`继续占用资源`};function Gr(){try{let e=localStorage.getItem(Hr);if(e===`en`||e===`zh-CN`)return e}catch{}return navigator.language.toLowerCase().startsWith(`zh`)?`zh-CN`:`en`}function Kr(e,t={},n=Gr()){return((n===`zh-CN`?Wr[e]:Ur[e])??e).replace(/\{(\w+)\}/g,(e,n)=>String(t[n]??`{${n}}`))}var qr=(0,I.createContext)({locale:`en`,setLocale:()=>void 0,t:(e,t)=>Kr(e,t,`en`)});function Jr({children:e}){let[t,n]=(0,I.useState)(Gr),r=e=>{try{localStorage.setItem(Hr,e)}catch{}n(e)};(0,I.useEffect)(()=>{document.documentElement.lang=t},[t]);let i=(0,I.useMemo)(()=>({locale:t,setLocale:r,t:(e,n)=>Kr(e,n,t)}),[t]);return(0,X.jsx)(qr.Provider,{value:i,children:e})}function Z(){return(0,I.useContext)(qr)}var Yr=new Set([`running`,`in_progress`,`claimed`]);function Xr(e){return e.find(e=>e.active)??e.find(e=>e.role===`manager`)}function Zr({snap:e,streamOk:t,onStart:n,onStop:i,onManage:a,onOpenSessions:c,mobileView:l,onToggleMobileView:u,busy:d,snapshotStale:f=!1,readOnly:p=!1,missionView:m}){let{t:h}=Z(),g=Xr(e.roles),_=[`complete`,`completed`,`done`,`success`].includes(String(m?.mission.status||``).toLowerCase()),v=e.daemon.alive&&!_?m?.roles.find(e=>e.role===m.active_role):void 0,y=v?.role||g?.role||`manager`,b=e.daemon.alive&&(v?v.status===`active`:!!g?.active),x=e.backlog.find(e=>Yr.has(e.status)),S=v?.label||x?.title||x?.objective||(_?m?.mission.summary||m?.mission.title:``)||e.session.objective||h(`common.ready`),C=!!(e.partial||e.observability?.slo.status===`degraded`),w=e.daemon.alive&&e.daemon.control_available===!1,T=w?h(`topbar.externallyManaged`):e.daemon.alive?h(`topbar.pauseDaemon`):h(`topbar.runDaemon`),E=C?[...(e.diagnostics??[]).map(e=>`${e.section}: ${e.message}`),...e.observability?.slo.violations??[]].join(` +`)||h(`common.degraded`):h(f?`common.stale`:t?`common.live`:`common.reconnecting`);return(0,X.jsxs)(`header`,{className:`chrome-seam-surface glass-panel glass-panel--raised flex h-12 min-w-0 shrink-0 items-center gap-2 border-b px-3 sm:gap-3 sm:px-4`,children:[c?(0,X.jsx)(`button`,{type:`button`,onClick:c,"aria-label":h(`topbar.openSessions`),className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-md text-ink-faint hover:bg-bg hover:text-ink lg:hidden`,children:(0,X.jsx)(`svg`,{viewBox:`0 0 16 16`,"aria-hidden":`true`,className:`h-4 w-4`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.25`,children:(0,X.jsx)(`path`,{d:`M2.5 4h11M2.5 8h11M2.5 12h11`})})}):null,(0,X.jsx)(`div`,{className:`hidden min-w-0 max-w-28 truncate text-sm font-semibold text-ink sm:block`,children:e.session.display_name||e.session.id}),(0,X.jsx)(`span`,{className:`hidden h-4 w-px shrink-0 bg-line/40 sm:block`}),(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[(0,X.jsx)(`span`,{"data-role-dot":y,"aria-label":h(b?`topbar.roleActive`:`topbar.roleIdle`,{role:y}),className:`h-2 w-2 shrink-0 rounded-full ${b?`animate-pulse motion-reduce:animate-none`:``}`,style:{background:W.role[y]||`rgb(var(--ink-faint))`}}),(0,X.jsx)(`span`,{className:`hidden shrink-0 text-xs font-semibold capitalize text-ink-dim sm:inline`,children:y}),(0,X.jsx)(`span`,{className:`truncate text-xs text-ink-faint`,children:S})]}),(0,X.jsx)(`span`,{title:E,className:`h-2 w-2 shrink-0 rounded-full transition-shadow duration-150 ${C||f?`bg-err ring-1 ring-err/30 ring-offset-1 ring-offset-panel`:t?`bg-ok ring-1 ring-ok/30 ring-offset-1 ring-offset-panel`:`bg-ink-faint/50`}`,children:(0,X.jsx)(`span`,{className:`sr-only`,children:E})}),(0,X.jsx)(Vr,{settledUsd:e.spend_usd,knownUsd:e.usage_summary?.known_cost_usd,status:e.spend_status,calls:e.usage_summary?.call_count,premiumRequests:e.usage_summary?.premium_requests,live:e.daemon.alive,compact:!0}),u?(0,X.jsx)(`button`,{type:`button`,onClick:u,"aria-label":h(l===`activity`?`topbar.showPreview`:`topbar.showActivity`),title:h(l===`activity`?`topbar.showPreview`:`topbar.showActivity`),className:`icon-control flex h-8 w-8 shrink-0 items-center justify-center lg:hidden`,children:(0,X.jsx)(`svg`,{viewBox:`0 0 16 16`,"aria-hidden":`true`,className:`h-4 w-4`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.25`,children:l===`activity`?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`rect`,{x:`2`,y:`2.5`,width:`12`,height:`11`,rx:`1.5`}),(0,X.jsx)(`path`,{d:`M9.5 2.75v10.5`})]}):(0,X.jsx)(`path`,{d:`M3 4h10M3 8h10M3 12h7`})})}):null,p?null:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`button`,{type:`button`,disabled:d||w,onClick:e.daemon.alive?i:n,"aria-label":T,title:w?h(`topbar.externalDaemonHint`):T,className:`compact-control flex h-8 shrink-0 items-center gap-1 px-2 disabled:opacity-40`,children:[(0,X.jsx)(o,{icon:e.daemon.alive?s:r,className:`h-3 w-3`}),(0,X.jsx)(`span`,{className:`hidden sm:inline`,children:w?h(`common.external`):e.daemon.alive?h(`common.pause`):h(`common.run`)})]}),(0,X.jsx)(`button`,{type:`button`,"aria-label":h(`topbar.manageSession`),title:h(`topbar.manageSession`),onClick:a,className:`icon-control flex h-8 w-8 shrink-0 items-center justify-center text-sm tracking-widest`,children:`···`})]})]})}function Qr(e){let t=new Set;return[e.primary_target,...e.targets].filter(e=>!e?.path||t.has(e.path)?!1:(t.add(e.path),!0))}function $r(e,t){if(t===`research`)for(let t of e){let e=Qr(t).find(e=>/(?:^|\/)paper\/main\.pdf$/i.test(e.path.replace(/\\/g,`/`)));if(e)return{receipt:t,path:e.path}}let n=e[0];return n?{receipt:n,path:Qr(n)[0]?.path||null}:null}function ei(e){return e.replace(/\s*\bRESULT\s*=\s*/g,` + +`).replace(/\s*\b(?:STATUS|REVIEW_STATUS)\s*=\s*\S+/g,``).trim()}function ti(e,t,n){let r=n.reduce((e,t)=>t.type===`ui.operator`?Math.max(e,Number(t.ts)||0):e,0),i=t&&(e===void 0||t.delivered_at>r)?t:null;return e?i&&i.delivered_at>e.delivered_at?i:e:i}function ni(e,t){if(!t)return!1;let n=new Set([t]),r=[t];for(let t=0;te.id!==t&&n.has(e.id)&&[`pending`,`running`,`in_progress`,`claimed`].includes(e.status))}var ri=`modulepreload`,ii=function(e){return`/`+e},ai={},oi=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?import.meta.resolve(e):new URL(e,import.meta.url).href}r=o(t.map(t=>{if(t=ii(t,n),t=s(t),t in ai)return;ai[t]=!0;let r=t.endsWith(`.css`);for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}let i=document.createElement(`link`);if(i.rel=r?`stylesheet`:ri,r||(i.as=`script`),i.crossOrigin=``,i.href=t,a&&i.setAttribute(`nonce`,a),document.head.appendChild(i),r)return new Promise((e,n)=>{i.addEventListener(`load`,e),i.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},si={all:`(min-width: 0px)`,reduceMotion:`(prefers-reduced-motion: reduce)`};function ci(e,t,n=[]){let r=(0,I.useRef)(t);r.current=t,(0,I.useEffect)(()=>{let t=!1,n=null;return oi(()=>import(`./motion-sqs9Ax-g.js`).then(e=>e.t).then(i=>{if(t||!e.current)return;let a=i.gsap;n=a.matchMedia(),n.add(si,e=>r.current(a,!!e.conditions?.reduceMotion),e.current)}),__vite__mapDeps([0,1])),()=>{t=!0,n?.revert()}},n)}function li(e){if(!e)return`—`;let t=Date.now()/1e3,n=Math.max(0,t-e);return n<5?`just now`:n<60?`${Math.floor(n)}s ago`:n<3600?`${Math.floor(n/60)}m ago`:n<86400?`${Math.floor(n/3600)}h ago`:`${Math.floor(n/86400)}d ago`}function ui(e){if(e==null||e<0)return`—`;let t=Math.floor(e/86400),n=Math.floor(e%86400/3600),r=Math.floor(e%3600/60);return t?`${t}d ${n}h`:n?`${n}h ${r}m`:r?`${r}m`:`${Math.floor(e)}s`}function di(e,t=2){return e==null||!isFinite(e)?`$0.00`:`$${e.toFixed(t)}`}function fi(e){if(!Number.isFinite(e)||e<=0)return`0 B`;let t=[`B`,`KB`,`MB`,`GB`],n=Math.min(Math.floor(Math.log(e)/Math.log(1024)),t.length-1),r=e/1024**n;return`${r>=10||n===0?r.toFixed(0):r.toFixed(1)} ${t[n]}`}function pi(e){let t=e.ts??e.time,n=null;if(typeof t==`number`)n=t>0xe8d4a51000?t:t*1e3;else if(typeof t==`string`){let e=Date.parse(t);isNaN(e)||(n=e)}if(n==null)return``;let r=new Date(n),i=e=>String(e).padStart(2,`0`);return`${i(r.getHours())}:${i(r.getMinutes())}:${i(r.getSeconds())}`}function mi(e){return e instanceof Error?e.message:String(e||`Unknown error`)}function hi(e,t){let n=mi(e);return t?`Reply interrupted after a partial response: ${n}`:`Message failed before a response was received: ${n}`}function gi({ok:e,pulse:t=!1,title:n}){return(0,X.jsx)(`span`,{title:n,className:`inline-block h-1.5 w-1.5 rounded-full transition-shadow duration-150 ${e?`bg-ok ring-1 ring-ok/30 ring-offset-1 ring-offset-panel`:`bg-ink-faint/50`}`,"data-live":e&&t?`true`:void 0})}function _i({children:e,color:t,className:n=``}){return(0,X.jsx)(`span`,{className:`chip text-ink-dim ${n}`,style:t?{color:t,borderColor:`${t}44`}:void 0,children:e})}function vi({children:e,onClick:t,variant:n=`ghost`,disabled:r,title:i,className:a=``}){return(0,X.jsx)(`button`,{type:`button`,title:i,disabled:r,onClick:t,className:`brand-button ${{ghost:`brand-button-ghost`,primary:`brand-button-primary`,danger:`brand-button-danger`}[n]} ${a}`,children:e})}function yi({title:e,right:t}){return(0,X.jsxs)(`div`,{className:`panel-header flex min-h-11 items-center justify-between border-b px-4`,children:[(0,X.jsx)(`span`,{className:`text-sm font-medium text-ink-dim`,children:e}),t]})}function bi(){return(0,X.jsx)(`span`,{className:`inline-block h-3 w-3 animate-spin rounded-full border-2 border-line border-t-blue`})}function xi({children:e}){return(0,X.jsx)(`div`,{className:`px-3 py-6 text-center text-xs text-ink-faint`,children:e})}async function Si(e){try{if(navigator.clipboard?.writeText)return await navigator.clipboard.writeText(e),!0}catch{}try{let t=document.createElement(`textarea`);t.value=e,t.setAttribute(`readonly`,``),t.style.position=`fixed`,t.style.opacity=`0`,document.body.appendChild(t),t.select();let n=document.execCommand(`copy`);return t.remove(),n}catch{return!1}}function Ci({text:e,label:t,copiedLabel:n,className:r=``}){let[i,a]=(0,I.useState)(!1),o=(0,I.useRef)();(0,I.useEffect)(()=>()=>{o.current&&clearTimeout(o.current)},[]);let s=async()=>{await Si(e)&&(a(!0),o.current&&clearTimeout(o.current),o.current=setTimeout(()=>a(!1),1600))};return(0,X.jsxs)(`button`,{type:`button`,onClick:()=>void s(),"aria-label":i?n:t,title:i?n:t,className:`inline-flex h-7 items-center gap-1 rounded-md border border-line/60 bg-panel/85 px-2 text-[10px] text-ink-faint shadow-sm backdrop-blur transition hover:border-blue/45 hover:text-blue focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue/50 ${r}`,children:[i?(0,X.jsx)(`svg`,{viewBox:`0 0 16 16`,"aria-hidden":`true`,className:`h-3.5 w-3.5`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.7`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,X.jsx)(`path`,{d:`m3.5 8.5 2.7 2.7 6.3-6.4`})}):(0,X.jsxs)(`svg`,{viewBox:`0 0 16 16`,"aria-hidden":`true`,className:`h-3.5 w-3.5`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.4`,children:[(0,X.jsx)(`rect`,{x:`5.2`,y:`5.2`,width:`7.2`,height:`7.2`,rx:`1.2`}),(0,X.jsx)(`path`,{d:`M10.8 5.2V3.8a1.2 1.2 0 0 0-1.2-1.2H3.8a1.2 1.2 0 0 0-1.2 1.2v5.8a1.2 1.2 0 0 0 1.2 1.2h1.4`})]}),(0,X.jsx)(`span`,{children:i?n:t})]})}function wi(e){return typeof e==`string`||typeof e==`number`?String(e):Array.isArray(e)?e.map(wi).join(``):(0,I.isValidElement)(e)?wi(e.props.children):``}function Ti(e){let t=String(e||``).trim();try{t=decodeURIComponent(t)}catch{}if(/^file:/i.test(t))try{let e=new URL(t);if(e.hostname&&e.hostname!==`localhost`)return``;t=e.pathname}catch{return``}else if(/^[a-z][a-z0-9+.-]*:/i.test(t)&&!/^[a-z]:[\\/]/i.test(t))return``;for(t=t.split(`#`,1)[0].split(`?`,1)[0].replaceAll(`\\`,`/`),/^\/[a-z]:\//i.test(t)&&(t=t.slice(1));t.startsWith(`./`);)t=t.slice(2);return t.replace(/\/{2,}/g,`/`)}function Ei(e,t){return!e||!t?!1:/^[a-z]:\//i.test(e)||/^[a-z]:\//i.test(t)?e.toLowerCase()===t.toLowerCase():e===t}function Di(e,t=[]){let n=Ti(e||``);if(!n)return null;for(let e of t){let t=Ti(e.path),r=Ti(e.storage_path||``);if(Ei(n,t)||Ei(n.replace(/^\//,``),t)||Ei(n,r))return e.path}return null}function Oi({src:e,alt:t}){let[n,r]=(0,I.useState)(!1);return n||!e?(0,X.jsxs)(`span`,{className:`text-xs text-ink-faint`,children:[`Image unavailable`,t?` · ${t}`:``]}):(0,X.jsx)(`img`,{src:e,alt:t||``,loading:`lazy`,decoding:`async`,onError:()=>r(!0),className:`my-2 h-auto max-w-full rounded-lg`})}function ki({children:e,artifacts:t=[],onOpenArtifact:n}){let{t:r}=Z();return(0,X.jsx)(he,{remarkPlugins:[_e,[ge,{backslashDelimiters:!0,singleDollarTextMath:!1}]],rehypePlugins:[ve],components:{h1:({children:e})=>(0,X.jsx)(`h1`,{className:`mb-2 mt-3 text-base font-semibold text-ink first:mt-0`,children:e}),h2:({children:e})=>(0,X.jsx)(`h2`,{className:`mb-1.5 mt-3 text-sm font-semibold text-ink first:mt-0`,children:e}),h3:({children:e})=>(0,X.jsx)(`h3`,{className:`mb-1 mt-2 text-sm font-medium text-ink first:mt-0`,children:e}),p:({children:e})=>(0,X.jsx)(`p`,{className:`my-1.5 whitespace-pre-wrap break-words leading-[1.625] first:mt-0 last:mb-0`,children:e}),ul:({children:e})=>(0,X.jsx)(`ul`,{className:`my-2 list-disc space-y-1 pl-5`,children:e}),ol:({children:e})=>(0,X.jsx)(`ol`,{className:`my-2 list-decimal space-y-1 pl-5`,children:e}),li:({children:e})=>(0,X.jsx)(`li`,{className:`pl-0.5`,children:e}),blockquote:({children:e})=>(0,X.jsx)(`blockquote`,{className:`my-2 border-l border-blue/50 pl-3 text-ink-dim`,children:e}),hr:()=>(0,X.jsx)(`hr`,{className:`my-3 border-line/60`}),a:({href:e,title:r,children:i})=>{let a=Di(e,t),o=a?t.find(e=>e.path===a):void 0;return a&&n?(0,X.jsx)(`a`,{href:e,"data-artifact-path":a,title:o?.storage_path||a,onClick:e=>{e.preventDefault(),n(a)},className:`cursor-pointer text-blue underline decoration-blue/35 underline-offset-2 hover:decoration-blue`,children:i}):(0,X.jsx)(`a`,{href:e,title:r,target:`_blank`,rel:`noreferrer`,className:`text-blue underline decoration-blue/35 underline-offset-2 hover:decoration-blue`,children:i})},code:({className:e,children:t,...n})=>{let r=!!e||String(t).includes(` +`);return(0,X.jsx)(`code`,{...n,className:r?`block min-w-0 whitespace-pre-wrap break-words font-mono text-xs text-ink ${e??``}`:`break-all rounded bg-bg px-1.5 py-0.5 font-mono text-xs text-ink`,children:t})},pre:({children:e})=>(0,X.jsxs)(`pre`,{className:`group/code relative my-2 max-w-full overflow-x-hidden whitespace-pre-wrap break-words rounded-lg border border-line/50 bg-bg px-3 pb-3 pt-10`,children:[(0,X.jsx)(Ci,{text:I.Children.toArray(e).map(wi).join(``),label:r(`copy.code`),copiedLabel:r(`copy.copied`),className:`absolute right-2 top-2`}),e]}),table:({children:e})=>(0,X.jsx)(`table`,{className:`my-2 w-full table-fixed border-collapse text-left text-xs`,children:e}),th:({children:e})=>(0,X.jsx)(`th`,{className:`break-words border border-line/60 bg-bg px-2 py-1.5 font-semibold text-ink`,children:e}),td:({children:e})=>(0,X.jsx)(`td`,{className:`break-words border border-line/60 px-2 py-1.5 align-top`,children:e}),strong:({children:e})=>(0,X.jsx)(`strong`,{className:`font-semibold text-ink`,children:e}),img:({src:e,alt:t})=>(0,X.jsx)(Oi,{src:e,alt:t})},children:e})}function Ai({size:e,className:t=`text-ink`}){return(0,X.jsxs)(`svg`,{"data-logo":`rounded-mark`,viewBox:`0 0 512 512`,role:`img`,"aria-label":`Argus`,style:{width:e,height:e},className:`argus-brand-mark shrink-0 ${t}`,children:[(0,X.jsx)(`path`,{d:`M352 112q0-30 30-30h28q30 0 30 30v320h-88v-52q-46 62-129 62Q66 442 66 266T228 88q80 0 124 56v-32ZM140 266q46-80 102-80t110 80q-54 80-110 80t-102-80Z`,fill:`rgb(var(--brand-body))`,fillRule:`evenodd`}),(0,X.jsx)(`path`,{d:`M140 266q46-80 102-80t110 80q-54 80-110 80t-102-80Z`,fill:`rgb(var(--brand-eye))`}),(0,X.jsxs)(`g`,{className:`argus-mark-eye`,children:[(0,X.jsx)(`circle`,{cx:`244`,cy:`266`,r:`42`,fill:`rgb(var(--brand-pupil))`}),(0,X.jsx)(`circle`,{cx:`262`,cy:`248`,r:`12`,fill:`rgb(var(--brand-highlight))`})]})]})}function ji({size:e}){return(0,X.jsxs)(`svg`,{"data-logo":`rounded-horizontal`,viewBox:`150 40 1160 390`,role:`img`,"aria-label":`Argus`,style:{width:e*2.75,height:e},className:`shrink-0 text-ink`,children:[(0,X.jsxs)(`g`,{className:`argus-brand-mark`,transform:`translate(180 92) scale(.54)`,children:[(0,X.jsx)(`path`,{d:`M352 112q0-30 30-30h28q30 0 30 30v320h-88v-52q-46 62-129 62Q66 442 66 266T228 88q80 0 124 56v-32ZM140 266q46-80 102-80t110 80q-54 80-110 80t-102-80Z`,fill:`rgb(var(--brand-body))`,fillRule:`evenodd`}),(0,X.jsx)(`path`,{d:`M140 266q46-80 102-80t110 80q-54 80-110 80t-102-80Z`,fill:`rgb(var(--brand-eye))`}),(0,X.jsx)(`circle`,{cx:`244`,cy:`266`,r:`42`,fill:`rgb(var(--brand-pupil))`}),(0,X.jsx)(`circle`,{cx:`262`,cy:`248`,r:`12`,fill:`rgb(var(--brand-highlight))`})]}),(0,X.jsxs)(`g`,{fill:`rgb(var(--brand-body))`,children:[(0,X.jsx)(`path`,{d:`M383 556Q394 556 409 555Q424 554 433 552L422 412Q415 414 401.5 415.5Q388 417 378 417Q340 417 305 403.5Q270 390 248.5 360Q227 330 227 278V0H78V546H191L213 454H220Q244 496 286 526Q328 556 383 556Z`,transform:`translate(444 334) scale(.36 -.36)`}),(0,X.jsx)(`path`,{d:`M255 556Q356 556 413 476H417L429 546H555V-1Q555-118 486-179Q417-240 282-240Q224-240 174.5-233Q125-226 78-208V-89Q179-131 291-131Q406-131 406-7V4Q406 21 407.5 39Q409 57 410 71H406Q378 28 339 9Q300-10 251-10Q154-10 99.5 64.5Q45 139 45 272Q45 406 101 481Q157 556 255 556ZM302 435Q197 435 197 270Q197 107 304 107Q361 107 388.5 139.5Q416 172 416 253V271Q416 359 389 397Q362 435 302 435Z`,transform:`translate(617.52 334) scale(.36 -.36)`}),(0,X.jsx)(`path`,{d:`M579 546V0H465L445 70H437Q411 28 365.5 9Q320-10 269-10Q181-10 128 37.5Q75 85 75 190V546H224V227Q224 169 245 139Q266 109 312 109Q380 109 405 155.5Q430 202 430 289V546Z`,transform:`translate(855.48 334) scale(.36 -.36)`}),(0,X.jsx)(`path`,{d:`M459 162Q459 79 400.5 34.5Q342-10 226-10Q169-10 128-2.5Q87 5 46 22V145Q90 125 141 112Q192 99 231 99Q275 99 293.5 112Q312 125 312 146Q312 160 304.5 171Q297 182 272 196Q247 210 194 232Q143 254 110 275.5Q77 297 61 327.5Q45 358 45 404Q45 480 104 518Q163 556 261 556Q312 556 358 546Q404 536 453 513L408 406Q368 423 332 434.5Q296 446 259 446Q193 446 193 410Q193 397 201.5 386.5Q210 376 234.5 364Q259 352 307 332Q354 313 388 292.5Q422 272 440.5 241.5Q459 211 459 162Z`,transform:`translate(1102.08 334) scale(.36 -.36)`})]})]})}function Mi({size:e=20,tag:t,compact:n=!1}){return(0,X.jsxs)(`span`,{className:`inline-flex select-none items-center gap-2.5`,children:[n?(0,X.jsx)(Ai,{size:e}):(0,X.jsx)(ji,{size:e}),t&&!n?(0,X.jsx)(`span`,{className:`text-xs font-medium uppercase tracking-[0.08em] text-ink-faint`,children:t}):null]})}var Ni={active:`label.status.inProgress`,claimed:`label.status.inProgress`,in_progress:`label.status.inProgress`,running:`label.status.inProgress`,working:`label.status.inProgress`,pending:`label.status.waiting`,queued:`label.status.waiting`,waiting:`label.status.waiting`,idle:`label.status.waiting`,accepted:`label.status.completed`,complete:`label.status.completed`,completed:`label.status.completed`,done:`label.status.completed`,success:`label.status.completed`,blocked:`label.status.blocked`,failed:`label.status.failed`,error:`label.status.failed`,rejected:`label.status.needsChanges`,continue:`label.status.needsChanges`,skipped:`label.status.skipped`,paused:`label.status.paused`,stopped:`label.status.paused`,cancelled:`label.status.paused`,aborted:`label.status.paused`,not_started:`label.status.waiting`,available:`label.status.available`,absent:`label.status.unavailable`,inaccessible:`label.status.inaccessible`,degraded:`label.status.limited`,healthy:`label.status.healthy`},Pi={manager:`label.role.manager`,planner:`label.role.planner`,engineer:`label.role.engineer`,reviewer:`label.role.reviewer`,system:`label.role.argus`,operator:`label.role.you`},Fi={completed:`label.outcome.workCompleted`,done:`label.outcome.workCompleted`,success:`label.outcome.workCompleted`,paused:`label.outcome.workPaused`,blocked:`label.outcome.workBlocked`,failed:`label.outcome.workFailed`,error:`label.outcome.workFailed`,aborted:`label.outcome.workEnded`,ended:`label.outcome.workEnded`,incomplete:`label.outcome.workIncomplete`,research_incomplete:`label.outcome.workIncomplete`,paused_no_breakthrough:`label.outcome.workIncomplete`,exhausted_current_methods:`label.outcome.workIncomplete`,stalled:`label.outcome.workStalled`,no_progress:`label.outcome.workStalled`,max_rounds:`label.outcome.workStalled`,infra_blocked:`label.outcome.workBlocked`,supervisor_error:`label.outcome.workFailed`},Ii={accepted:`label.outcome.reviewPassed`,done:`label.outcome.reviewPassed`,passed:`label.outcome.reviewPassed`,continue:`label.outcome.reviewNeedsChanges`,rejected:`label.outcome.reviewNeedsChanges`,blocked:`label.outcome.reviewBlocked`,stale:`label.outcome.reviewOutdated`,pending:`label.outcome.reviewPending`,pending_review:`label.outcome.reviewPending`},Li={certified:`label.outcome.stageApproved`,not_certified:`label.outcome.stageNotApproved`,revoked:`label.outcome.stageRevoked`,intentionally_skipped:`label.outcome.stageNotNeeded`,deferred:`label.outcome.stagePending`},Ri={budget_exhausted:`label.outcome.budgetPaused`,budget_pause:`label.outcome.budgetPaused`,operator_input_required:`label.outcome.waitingForYou`,operator_abort:`label.outcome.stoppedByYou`,operator_pause:`label.outcome.pausedByYou`,daemon_shutdown:`label.outcome.sessionPaused`,backend_unavailable:`label.outcome.serviceUnavailable`,provider_cooldown:`label.outcome.serviceCoolingDown`,provider_fence:`label.outcome.serviceUnavailable`,transient_error:`label.outcome.temporaryIssue`,permanent_error:`label.outcome.serviceError`,planner_empty_plan:`label.outcome.needsPlan`},zi={cuda:`label.resource.nvidiaGpu`,rocm:`label.resource.amdGpu`,mps:`label.resource.appleGpu`,cpu:`label.resource.cpu`};function Bi(e,t){return t(Ni[String(e??``).toLowerCase()]??`label.status.updated`)}function Vi(e,t){return t(Pi[String(e??``).toLowerCase()]??`label.role.argus`)}function Hi(e,t){return t(`label.priority`,{priority:e})}function Ui(e,t){if(!e?.execution_status)return[];let n=[t(Fi[e.execution_status.toLowerCase()]??`label.outcome.workUpdated`)],r=Ii[String(e.review_status??``).toLowerCase()],i=Li[String(e.stage_certification??``).toLowerCase()],a=Ri[String(e.interruption_kind??``).toLowerCase()];return r&&n.push(t(r)),i&&n.push(t(i)),a&&n.push(t(a)),e.resumable&&n.push(t(`label.outcome.canResume`)),n}function Wi(e,t){return t(zi[e.toLowerCase()]??`label.resource.accelerator`)}function Gi(e,t){return t(e===`strict`?`label.resource.enforced`:`label.resource.advisory`)}function Ki(e,t){return t(e===`yield`?`label.resource.released`:`label.resource.kept`)}var qi=[`manager`,`planner`,`engineer`,`reviewer`],Ji=/Info: (?:Operation cancelled by user|Response was interrupted due to a server error\. Retrying\.\.\.)/gi;function Yi(e){let t=new Map;return e.forEach(e=>{let n=String(e.type??``);if(n===`life.mission.completed`||n===`mission.completed`){t.clear();return}let r=String(e.call_id??``);r&&(n===`provider.request.started`?t.set(r,e):(n===`provider.request.completed`||n===`provider.request.denied`)&&t.delete(r))}),Array.from(t.values()).at(-1)??null}function Xi({ev:e,r:t,first:n,last:r}){let i=W.role[t.role]??W.inkFaint,a=rr(t.tone);return(0,X.jsxs)(`div`,{className:`event-activity-row group relative grid grid-cols-[16px_minmax(0,1fr)] gap-3 px-4 py-3 transition-colors hover:bg-bg/70 ${r?`animate-appear`:``} ${t.reasoning?`opacity-60`:``}`,style:t.rule?{marginTop:4}:void 0,children:[(0,X.jsxs)(`div`,{className:`relative flex justify-center`,children:[n?null:(0,X.jsx)(`span`,{className:`absolute -top-2.5 h-4 w-px bg-line/60`}),r?null:(0,X.jsx)(`span`,{className:`absolute -bottom-2.5 top-2 w-px bg-line/60`}),(0,X.jsx)(`span`,{className:`relative z-10 mt-1.5 h-2 w-2 rounded-full border-2 border-panel`,style:{backgroundColor:i,boxShadow:`0 0 0 1px ${i}55`}})]}),(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(`span`,{className:`truncate text-xs font-semibold uppercase tracking-[0.06em]`,style:{color:i},title:t.label,children:t.label}),(0,X.jsx)(`span`,{className:`text-xs`,style:{color:a},children:t.glyph}),(0,X.jsx)(`time`,{className:`ml-auto font-mono text-xs tabular-nums text-ink-faint opacity-0 transition-opacity group-hover:opacity-100`,children:pi(e)})]}),(0,X.jsx)(`div`,{className:`mt-0.5 whitespace-pre-wrap break-words text-sm leading-5 ${t.reasoning?`italic`:``}`,style:{color:a},children:t.text})]})]})}function Zi({ev:e,r:t,artifacts:n,onOpenArtifact:r}){let{t:i}=Z(),a=String(e.type)===`ui.operator`,o=Number(e.response_latency_ms??0),s=!a&&o>=100?` · ${(o/1e3).toFixed(1)}s`:``,c=(0,I.useRef)(null);return ci(c,(e,t)=>{c.current&&(t||e.fromTo(c.current,{autoAlpha:0,x:a?12:0,y:a?0:8},{autoAlpha:1,x:0,y:0,duration:.28,ease:`power2.out`,clearProps:`transform,opacity,visibility`}))}),(0,X.jsx)(`article`,{ref:c,className:`conversation-row group mx-auto w-full max-w-full px-4 py-3 sm:px-6 lg:max-w-[61.8vw]`,children:a?(0,X.jsxs)(`div`,{className:`flex items-end justify-end gap-2`,children:[(0,X.jsx)(Ci,{text:t.text,label:i(`copy.message`),copiedLabel:i(`copy.copied`),className:`opacity-60 sm:opacity-0 sm:group-hover:opacity-100`}),(0,X.jsx)(`time`,{className:`shrink-0 pb-1 font-mono text-[10px] tabular-nums text-ink-faint`,children:pi(e)}),(0,X.jsx)(`div`,{className:`max-w-[calc(100%_-_3rem)] rounded-[18px] bg-conversation-user px-4 py-2.5 text-[15px] leading-relaxed text-ink ring-1 ring-line/35 sm:max-w-[82%]`,children:(0,X.jsx)(ki,{artifacts:n,onOpenArtifact:r,children:t.text})})]}):(0,X.jsxs)(`div`,{className:`flex gap-3`,children:[(0,X.jsx)(`span`,{className:`mt-0.5 flex h-7 w-7 shrink-0 items-center justify-center`,children:(0,X.jsx)(Ai,{size:26,className:`text-ink`})}),(0,X.jsxs)(`div`,{className:`relative min-w-0 flex-1 text-[15px] leading-relaxed text-ink`,children:[(0,X.jsxs)(`div`,{className:`mb-1 flex items-center gap-2`,children:[(0,X.jsx)(`span`,{className:`text-xs font-semibold text-blue`,children:`Argus`}),(0,X.jsx)(Ci,{text:t.text,label:i(`copy.message`),copiedLabel:i(`copy.copied`),className:`ml-auto opacity-60 sm:opacity-0 sm:group-hover:opacity-100`}),(0,X.jsxs)(`time`,{className:`font-mono text-[10px] tabular-nums text-ink-faint`,children:[pi(e),s]})]}),(0,X.jsx)(ki,{artifacts:n,onOpenArtifact:r,children:t.text})]})]})})}function Qi({role:e,rows:t,open:n,active:r,onToggle:i}){let{t:a}=Z(),o=W.role[e],s=(0,I.useRef)(null),c=t[t.length-1]?.r.text.length??0;return(0,I.useEffect)(()=>{if(!n)return;let e=window.requestAnimationFrame(()=>{s.current&&s.current.scrollHeight>s.current.clientHeight&&(s.current.scrollTop=s.current.scrollHeight)});return()=>window.cancelAnimationFrame(e)},[n,t.length,c]),(0,X.jsxs)(`section`,{className:`role-log-group border-b border-line/50`,"data-role":e,"data-open":n?`true`:`false`,"data-active":r?`true`:`false`,children:[(0,X.jsxs)(`button`,{type:`button`,onClick:i,"aria-expanded":n,className:`group flex h-11 w-full items-center gap-2 px-4 text-left transition-colors hover:bg-bg/60`,children:[(0,X.jsx)(`span`,{"data-role-dot":e,"aria-hidden":`true`,className:`h-2 w-2 shrink-0 rounded-full ${r?`animate-pulse motion-reduce:animate-none`:``}`,style:{background:o}}),(0,X.jsx)(`span`,{className:`text-xs font-semibold text-ink-dim`,children:Vi(e,a)}),(0,X.jsx)(`span`,{className:`font-mono text-xs text-ink-faint`,children:t.length}),t.length>0?(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-ink-faint`,children:t[t.length-1].r.text}):(0,X.jsx)(`span`,{className:`flex-1`}),(0,X.jsx)(`svg`,{viewBox:`0 0 16 16`,"aria-hidden":`true`,className:`h-4 w-4 shrink-0 text-ink-faint transition-transform duration-panel ease-panel ${n?`rotate-90`:``}`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,children:(0,X.jsx)(`path`,{d:`m6 3.5 4.5 4.5L6 12.5`})})]}),n?(0,X.jsx)(`div`,{className:`grid grid-rows-[1fr]`,children:(0,X.jsx)(`div`,{className:`min-h-0 overflow-hidden`,children:(0,X.jsx)(`div`,{ref:s,className:`max-h-72 overflow-x-hidden overflow-y-auto border-t border-line/40 scroll-thin`,children:t.length>0?t.map(({ev:e,r:n,key:r},i)=>(0,X.jsx)(Xi,{ev:e,r:n,first:i===0,last:i===t.length-1},r)):(0,X.jsx)(`div`,{className:`px-4 py-3 text-xs text-ink-faint`,children:a(`stream.noLogs`)})})})}):null]})}function $i(e){let t={manager:[],planner:[],engineer:[],reviewer:[]},n=[];return e.forEach(e=>{qi.includes(e.r.role)?t[e.r.role].push(e):n.push(e)}),{roleRows:t,systemRows:n,lastRole:[...e].reverse().find(e=>qi.includes(e.r.role))?.r.role??``}}function ea({rows:e}){let{t}=Z(),[n,r]=(0,I.useState)(!1);return(0,X.jsxs)(`section`,{className:`border-b border-line/50`,"data-system-open":n?`true`:`false`,children:[(0,X.jsxs)(`button`,{type:`button`,"aria-expanded":n,onClick:()=>r(e=>!e),className:`flex h-10 w-full items-center gap-2 px-4 text-left text-xs text-ink-faint hover:bg-bg/60`,children:[(0,X.jsx)(`span`,{children:t(`stream.system`)}),(0,X.jsx)(`span`,{className:`font-mono`,children:e.length}),(0,X.jsx)(`span`,{className:`flex-1`}),(0,X.jsx)(`svg`,{viewBox:`0 0 16 16`,"aria-hidden":`true`,className:`h-4 w-4 shrink-0 transition-transform duration-panel ease-panel ${n?`rotate-90`:``}`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,children:(0,X.jsx)(`path`,{d:`m6 3.5 4.5 4.5L6 12.5`})})]}),n?(0,X.jsx)(`div`,{className:`border-t border-line/40`,children:e.map(({ev:t,r:n,key:r},i)=>(0,X.jsx)(Xi,{ev:t,r:n,first:i===0,last:i===e.length-1},r))}):null]})}function ta({rows:e,live:t}){let{roleRows:n,systemRows:r,lastRole:i}=(0,I.useMemo)(()=>$i(e),[e]),[a,o]=(0,I.useState)(()=>new Set(t&&i?[i]:[])),s=(0,I.useRef)(!1);return(0,I.useEffect)(()=>{!t||!i||s.current||o(new Set([i]))},[i,t]),(0,X.jsxs)(`div`,{className:`bg-bg/25`,children:[qi.map(e=>(0,X.jsx)(Qi,{role:e,rows:n[e],open:a.has(e),active:i===e,onToggle:()=>{s.current=!0,o(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}},e)),r.length>0?(0,X.jsx)(ea,{rows:r}):null]})}function na(e){let t=e.delivery;if(!t||typeof t!=`object`||Array.isArray(t))return null;let n=t;return typeof n.delivery_id!=`string`||!n.delivery_id.trim()?null:n}function ra(e){for(let t=e.length-1;t>=0;--t){let n=e[t];if(n.type===`ui.operator`)return null;let r=na(n);if(r)return r}}function ia({delivery:e,onOpen:t}){let{t:n}=Z(),r=e.kind===`submission_certified`;return(0,X.jsxs)(`aside`,{className:`mx-auto my-3 flex w-full max-w-full gap-3 rounded-lg border border-ok/35 bg-ok/5 px-4 py-3 lg:max-w-[61.8vw]`,children:[(0,X.jsx)(`span`,{className:`flex h-7 w-7 shrink-0 items-center justify-center rounded-full bg-ok/15 font-semibold text-ok`,children:`✓`}),(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-[0.14em] text-ok`,children:n(r?`mission.deliveryCertified`:`mission.taskCompleted`)}),(0,X.jsx)(`div`,{className:`mt-1 truncate text-sm font-semibold text-ink`,title:e.title,children:e.title}),e.summary?(0,X.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-ink-dim`,children:ei(e.summary)}):null,t?(0,X.jsx)(`button`,{type:`button`,onClick:()=>t(e),className:`mt-2 rounded border border-ok/40 px-2 py-1 font-mono text-[10px] text-ok hover:border-ok hover:bg-ok/10`,children:n(e.primary_target?`mission.openResult`:`mission.viewTask`)}):null]})]})}function aa({group:e,latest:t,artifacts:n,onOpenArtifact:r,onOpenDelivery:i}){let a=e=>e.ev.type===`ui.argus`&&/^(info:|operation cancelled|cancelled\b)/i.test(e.r.text.trim()),o=e.rows.filter(e=>e.ev.type===`ui.argus`).map(e=>{let t=e.r.text.match(Ji)??[],n=e.r.text.replace(Ji,``).trim();return{reply:n&&!a(e)?{...e,r:{...e.r,text:n}}:null,messages:a(e)&&t.length===0?[e.r.text]:t}}),s=o.flatMap(e=>e.reply?[e.reply]:[]),c=o.flatMap(e=>e.messages),l=e.rows.filter(({ev:e})=>e.type!==`ui.argus`),u=(()=>{let t=new Set;return e.rows.flatMap(e=>{let n=na(e.ev);return!n||t.has(n.delivery_id)?[]:(t.add(n.delivery_id),[n])})})();return(0,X.jsxs)(`section`,{className:`conversation-thread border-b border-line/60`,children:[(0,X.jsx)(Zi,{ev:e.operator.ev,r:e.operator.r,artifacts:n,onOpenArtifact:r}),s.map(e=>(0,X.jsx)(Zi,{ev:e.ev,r:e.r,artifacts:n,onOpenArtifact:r},e.key)),c.map((t,n)=>(0,X.jsx)(`div`,{className:`mx-auto w-full max-w-full px-6 py-1.5 text-center text-xs text-ink-faint lg:max-w-[61.8vw]`,children:t},`${e.key}-system-${n}`)),u.map(e=>(0,X.jsx)(ia,{delivery:e,onOpen:i},e.delivery_id)),l.length>0?(0,X.jsx)(`div`,{className:`mx-auto w-full max-w-full border-t border-line/40 lg:max-w-[61.8vw]`,children:(0,X.jsx)(ta,{rows:l,live:t})}):null]})}function oa({events:e,connected:t,showReasoning:n,onToggleReasoning:r,embedded:i=!1,showHeader:a=!0,filter:o=`all`,query:s=``,skipFirst:c=0,artifacts:l,onOpenArtifact:u,onOpenDelivery:d}){let{locale:f,t:p}=Z(),[m,h]=(0,I.useState)(!0),[g,_]=(0,I.useState)(()=>Date.now()),v=(0,I.useRef)(null),y=(0,I.useDeferredValue)(e),b=(0,I.useMemo)(()=>Yi(y),[y]);(0,I.useEffect)(()=>{if(!b)return;_(Date.now());let e=window.setInterval(()=>_(Date.now()),1e3);return()=>window.clearInterval(e)},[b]);let x=b?Math.max(0,Math.floor((g-Number(b.ts??0)*1e3)/1e3)):0,S=(0,I.useMemo)(()=>{let e=[],t=new Map,r=0;return(c>0?y.slice(c):y).forEach((i,a)=>{let c=ir(i,f);if(!c)return;if(c.reasoning&&!n){r++;return}if(!Mt(i,c,o,s))return;let l=i,u=String(l.message_id??``),d=!!u&&String(l.type)===`engineer.progress`&&[`assistant_message`,`agent_message`,`message`].includes(String(l.kind));if(d&&t.has(u)){let n=t.get(u);e[n]={...e[n],ev:{...e[n].ev,...i},r:{...e[n].r,...c,text:kt(e[n].r.text,c.text,Dt(i))}};return}let p={ev:i,r:c,key:ar(i,a)};d&&t.set(u,e.length),e.push(p)}),{list:e,hiddenReasoning:r}},[y,n,o,s,c,f]),C=(0,I.useMemo)(()=>{let e=[],t=[],n=null;return S.list.forEach(r=>{r.ev.type===`ui.operator`?(n={key:r.key,operator:r,rows:[]},e.push(n)):n?n.rows.push(r):t.push(r)}),{groups:e,earlier:t}},[S.list]),w=(0,I.useMemo)(()=>y.filter(Ct).length,[y]),T=(0,I.useMemo)(()=>S.list.slice(-20).reduce((e,t)=>e+t.r.text.length,0),[S.list]);return(0,I.useEffect)(()=>{if(!m)return;let e=window.requestAnimationFrame(()=>{v.current&&(v.current.scrollTop=v.current.scrollHeight)});return()=>window.cancelAnimationFrame(e)},[S.list.length,T,m]),(0,I.useEffect)(()=>{let e=v.current;if(!e)return;let t=()=>h(e.scrollHeight-e.scrollTop-e.clientHeight<40);return e.addEventListener(`scroll`,t,{passive:!0}),()=>e.removeEventListener(`scroll`,t)},[]),(0,X.jsxs)(`section`,{className:`relative flex min-h-0 flex-1 flex-col overflow-hidden bg-panel ${i?``:`rounded-lg border border-line/80`}`,children:[a&&(0,X.jsx)(yi,{title:p(`panel.activity`),right:(0,X.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,X.jsxs)(`button`,{onClick:r,className:`rounded px-1.5 py-0.5 text-xs transition-colors ${n?`text-blue-sky`:`text-ink-faint hover:text-ink-dim`}`,title:p(`stream.toggleReasoning`),children:[p(`stream.reasoning`),w?` ·${w}`:``]}),(0,X.jsx)(`span`,{className:`text-xs ${t?`text-ok`:`text-ink-faint`}`,children:t?`● ${p(`common.live`)}`:`○ ${p(`common.reconnecting`)}`})]})}),b?(0,X.jsxs)(`div`,{className:`flex h-9 shrink-0 items-center gap-2 border-b border-line/60 bg-blue-deep/5 px-4 text-xs text-ink-dim`,children:[(0,X.jsx)(`span`,{className:`h-2 w-2 animate-pulse rounded-full bg-blue-sky`}),(0,X.jsx)(`span`,{className:`truncate`,children:p(`stream.backgroundWork`)}),(0,X.jsxs)(`span`,{className:`ml-auto shrink-0 font-mono tabular-nums text-ink-faint`,children:[x,`s`]})]}):null,(0,X.jsx)(`div`,{ref:v,className:`min-h-0 flex-1 overflow-x-hidden overflow-y-auto pb-6 pt-1.5 scroll-thin`,children:S.list.length===0?(0,X.jsx)(xi,{children:p(`stream.ready`)}):(0,X.jsxs)(X.Fragment,{children:[C.earlier.length>0?(0,X.jsxs)(`section`,{className:`mx-auto w-full max-w-full border-b border-line/60 lg:max-w-[61.8vw]`,children:[(0,X.jsxs)(`div`,{className:`flex h-10 items-center gap-2 border-b border-line/40 px-4 text-[10px] font-semibold uppercase tracking-[0.12em] text-ink-faint`,children:[p(`stream.autonomous`),(0,X.jsx)(`span`,{className:`font-mono font-normal tracking-normal`,children:C.earlier.length})]}),(0,X.jsx)(ta,{rows:C.earlier,live:C.groups.length===0})]}):null,C.groups.map((e,t)=>(0,X.jsx)(aa,{group:e,latest:t===C.groups.length-1,artifacts:l,onOpenArtifact:u,onOpenDelivery:d},e.key))]})}),!m&&(0,X.jsx)(`button`,{onClick:()=>{h(!0),v.current?.scrollTo({top:v.current.scrollHeight,behavior:`smooth`})},"aria-label":p(`stream.jumpToLatest`),title:p(`stream.jumpToLatest`),className:`absolute bottom-4 left-1/2 flex h-8 w-8 -translate-x-1/2 items-center justify-center rounded-full border border-line/60 bg-panel text-sm text-ink-dim shadow-glow transition-all duration-200 hover:border-ink-faint hover:text-ink`,children:`↓`})]})}function sa(e){return e.nativeEvent.isComposing||e.keyCode===229}var ca=`operator console`,la={Everyday:`常用`,"Task management":`任务管理`,"Sessions & diagnostics":`会话与诊断`,Configuration:`配置`,Other:`其他`},ua={crystalpilot:`在当前 Argus 会话启用晶体学工具,保持原生界面`,status:`查看角色、队列、日志和健康状态`,roles:`查看各角色的后端、模型、推理强度和实时活动`,journal:`查看近期日志(默认 10 条)`,backlog:`查看待处理任务(all 包含已完成和已跳过)`,artifacts:`查看 Reviewer 批准的结果文件(按 Enter 预览)`,artifact:`预览一个已批准的结果文件`,events:`搜索动态:all / watch / milestones / messages`,find:`搜索当前事件缓冲区`,cancel:`停止等待当前 Manager 回复`,ask:`直接回答,不排任务、不走 Planner/Engineer/Reviewer`,task:`直接加入任务队列`,plan:`预览 Planner 编写的执行计划`,rewrite:`让 Manager 在发送前改写提示词`,nudge:`向正在运行的任务注入指导`,abort:`立即终止正在运行的任务`,note:`向时间线添加手动备注`,done:`将任务标记为完成`,skip:`跳过任务`,stop:`停止任务的自动迭代`,item:`查看完整任务契约`,run:`返回持续更新的任务动态`,new:`检查、创建并切换到新会话`,daemons:`查找全部会话并切换或创建`,resume:`切换到其他项目或会话`,attach:`跟随其他项目并读取其动态`,rename:`重命名当前会话`,doctor:`诊断为什么没有任务运行`,backend:`查看或更改共享 Runner 后端`,config:`查看或更改运行时设置`,identity:`查看或替换操作者身份卡`,reset:`清除 Manager 的热会话上下文`,skills:`查看或提升运行时 Skill`,clear:`清空事件动态视图`,reconnect:`重新连接实时动态`,help:`查看快捷键和完整命令参考`,quit:`离开控制台(后台工作继续运行)`};function da(e,t){return t===`zh-CN`?ua[e.id]:e.id===`reconnect`?`reconnect live activity`:e.desc}function fa(e,t){return t===`zh-CN`?la[e.group]:e.group}function pa(e,t){let n=new Map;for(let r of e){let e=fa(r,t),i=r.aliases?.length?` (= ${r.aliases.join(`, `)})`:``,a=`${r.name}${r.arg?` ${r.arg}`:``}${i}`;n.has(e)||n.set(e,[]),n.get(e).push({label:a,desc:da(r,t)})}return[...n.entries()].map(([e,t])=>({group:e,rows:t}))}var ma=`slash-completion-listbox`;function ha(e,t){return t<=0?0:Math.max(0,Math.min(e,t-1))}function ga(e){return`slash-completion-option-${e}`}function _a({query:e,selected:t,onSelect:n}){let{locale:r,t:i}=Z(),a=Rt(e);if(a.length===0)return null;let o=a.slice(0,8),s=ha(t,o.length);return(0,X.jsx)(`div`,{id:ma,role:`listbox`,"aria-label":i(`slash.suggestions`),className:`slash-completion-menu scroll-thin border-b border-line/40`,children:o.map((e,t)=>(0,X.jsxs)(`button`,{id:ga(e.id),type:`button`,role:`option`,"aria-selected":t===s,onPointerDown:e=>{e.preventDefault(),n(t)},className:`flex w-full items-baseline gap-2 px-3 py-1.5 text-left text-sm transition-colors ${t===s?`bg-blue/10 text-ink`:`text-ink-dim hover:bg-line/20`}`,children:[(0,X.jsx)(`span`,{className:`shrink-0 font-mono text-blue`,children:e.name}),e.arg?(0,X.jsx)(`span`,{className:`shrink-0 font-mono text-xs text-ink-faint`,children:e.arg}):null,(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-ink-faint`,children:da(e,r)})]},e.id))})}var va=10485760,ya=26214400,ba=[`.png`,`.jpg`,`.jpeg`,`.webp`,`.pdf`,`.md`,`.markdown`,`.txt`,`.json`,`.csv`].join(`,`),xa={".png":`image/png`,".jpg":`image/jpeg`,".jpeg":`image/jpeg`,".webp":`image/webp`,".pdf":`application/pdf`,".md":`text/markdown`,".markdown":`text/markdown`,".txt":`text/plain`,".json":`application/json`,".csv":`text/csv`};function Sa(e){let t=String(e||``).trim().toLowerCase(),n=t.lastIndexOf(`.`);return n>=0?t.slice(n):``}function Ca(e){return xa[Sa(e.name)]||String(e.type||``).split(`;`,1)[0].trim()||`application/octet-stream`}function wa(e){return Object.hasOwn(xa,Sa(e.name))}function Ta(e){return Ca(e).startsWith(`image/`)}function Ea(e){return[e.name,String(e.size),Ca(e),String(e.lastModified??``)].join(`::`)}function Da(e,t){let n=[],r=[],i=new Set(e.map(Ea)),a=e.reduce((e,t)=>e+Math.max(0,t.size||0),0),o=e.length;for(let e of t){let t=Ea(e);if(!i.has(t)){if(i.add(t),!wa(e)){r.push({code:`unsupported`,fileName:e.name});continue}if(o>=5){r.push({code:`too-many`,limitCount:5});continue}if(e.size>10485760){r.push({code:`too-large`,fileName:e.name,limitBytes:va});continue}if(a+e.size>26214400){r.push({code:`too-large-total`,limitBytes:ya});continue}n.push(e),a+=e.size,o+=1}}return{accepted:n,issues:r}}function Oa(e){return e?Array.from(e):[]}function ka(e){return Oa(e?.types).map(e=>String(e)).includes(`Files`)||Aa(e).length>0}function Aa(e){let t=Oa(e?.files).filter(e=>e instanceof File);if(t.length)return t;let n=[];for(let t of Oa(e?.items)){if(String(t?.kind||``)!==`file`||typeof t?.getAsFile!=`function`)continue;let e=t.getAsFile();e instanceof File&&n.push(e)}return n}function ja({file:e,removeLabel:t,onRemove:n,disabled:r=!1}){let[i,a]=(0,I.useState)(``);return(0,I.useEffect)(()=>{if(!Ta(e)||typeof URL>`u`||typeof URL.createObjectURL!=`function`){a(``);return}let t=URL.createObjectURL(e);return a(t),()=>URL.revokeObjectURL(t)},[e]),(0,X.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 rounded-2xl border border-line/50 bg-panel/80 px-2.5 py-2 text-xs shadow-[0_10px_24px_-20px_rgb(0_0_0/0.2)]`,children:[i?(0,X.jsx)(`img`,{src:i,alt:``,className:`h-10 w-10 shrink-0 rounded-xl border border-line/40 object-cover`}):null,(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`div`,{className:`truncate font-medium text-ink`,title:e.name,children:e.name}),(0,X.jsxs)(`div`,{className:`truncate text-ink-faint`,children:[fi(e.size),` · `,Ca(e)]})]}),(0,X.jsx)(`button`,{type:`button`,onClick:n,disabled:r,"aria-label":t,title:t,className:`send-control h-8 w-8 shrink-0 rounded-full border-line/60 text-ink-faint hover:border-err/50 hover:bg-err/10 hover:text-err`,children:`×`})]})}var Ma=e=>e.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase(),Na=(...e)=>e.filter((e,t,n)=>!!e&&e.trim()!==``&&n.indexOf(e)===t).join(` `).trim(),Pa={xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`},Fa=(0,I.forwardRef)(({color:e=`currentColor`,size:t=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:i=``,children:a,iconNode:o,...s},c)=>(0,I.createElement)(`svg`,{ref:c,...Pa,width:t,height:t,stroke:e,strokeWidth:r?Number(n)*24/Number(t):n,className:Na(`lucide`,i),...s},[...o.map(([e,t])=>(0,I.createElement)(e,t)),...Array.isArray(a)?a:[a]])),Ia=(e,t)=>{let n=(0,I.forwardRef)(({className:n,...r},i)=>(0,I.createElement)(Fa,{ref:i,iconNode:t,className:Na(`lucide-${Ma(e)}`,n),...r}));return n.displayName=`${e}`,n},La=Ia(`Activity`,[[`path`,{d:`M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2`,key:`169zse`}]]),Ra=Ia(`ArrowUpRight`,[[`path`,{d:`M7 7h10v10`,key:`1tivn9`}],[`path`,{d:`M7 17 17 7`,key:`1vkiza`}]]),za=Ia(`ArrowUp`,[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]),Ba=Ia(`Boxes`,[[`path`,{d:`M2.97 12.92A2 2 0 0 0 2 14.63v3.24a2 2 0 0 0 .97 1.71l3 1.8a2 2 0 0 0 2.06 0L12 19v-5.5l-5-3-4.03 2.42Z`,key:`lc1i9w`}],[`path`,{d:`m7 16.5-4.74-2.85`,key:`1o9zyk`}],[`path`,{d:`m7 16.5 5-3`,key:`va8pkn`}],[`path`,{d:`M7 16.5v5.17`,key:`jnp8gn`}],[`path`,{d:`M12 13.5V19l3.97 2.38a2 2 0 0 0 2.06 0l3-1.8a2 2 0 0 0 .97-1.71v-3.24a2 2 0 0 0-.97-1.71L17 10.5l-5 3Z`,key:`8zsnat`}],[`path`,{d:`m17 16.5-5-3`,key:`8arw3v`}],[`path`,{d:`m17 16.5 4.74-2.85`,key:`8rfmw`}],[`path`,{d:`M17 16.5v5.17`,key:`k6z78m`}],[`path`,{d:`M7.97 4.42A2 2 0 0 0 7 6.13v4.37l5 3 5-3V6.13a2 2 0 0 0-.97-1.71l-3-1.8a2 2 0 0 0-2.06 0l-3 1.8Z`,key:`1xygjf`}],[`path`,{d:`M12 8 7.26 5.15`,key:`1vbdud`}],[`path`,{d:`m12 8 4.74-2.85`,key:`3rx089`}],[`path`,{d:`M12 13.5V8`,key:`1io7kd`}]]),Va=Ia(`Check`,[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]),Ha=Ia(`ChevronDown`,[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]),Ua=Ia(`CircleCheck`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),Wa=Ia(`CircleHelp`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`,key:`1u773s`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),Ga=Ia(`Clock3`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`polyline`,{points:`12 6 12 12 16.5 12`,key:`1aq6pp`}]]),Ka=Ia(`Diamond`,[[`path`,{d:`M2.7 10.3a2.41 2.41 0 0 0 0 3.41l7.59 7.59a2.41 2.41 0 0 0 3.41 0l7.59-7.59a2.41 2.41 0 0 0 0-3.41l-7.59-7.59a2.41 2.41 0 0 0-3.41 0Z`,key:`1f1r0c`}]]),qa=Ia(`Download`,[[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}],[`polyline`,{points:`7 10 12 15 17 10`,key:`2ggqvy`}],[`line`,{x1:`12`,x2:`12`,y1:`15`,y2:`3`,key:`1vk2je`}]]),Ja=Ia(`ExternalLink`,[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`M10 14 21 3`,key:`gplh6r`}],[`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`,key:`a6xqqp`}]]),Ya=Ia(`FileText`,[[`path`,{d:`M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z`,key:`1rqfz7`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`path`,{d:`M10 9H8`,key:`b1mrlr`}],[`path`,{d:`M16 13H8`,key:`t4e002`}],[`path`,{d:`M16 17H8`,key:`z1uh3a`}]]),Xa=Ia(`KeyRound`,[[`path`,{d:`M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z`,key:`1s6t7t`}],[`circle`,{cx:`16.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`w0ekpg`}]]),Za=Ia(`LoaderCircle`,[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`,key:`13zald`}]]),Qa=Ia(`Maximize2`,[[`polyline`,{points:`15 3 21 3 21 9`,key:`mznyad`}],[`polyline`,{points:`9 21 3 21 3 15`,key:`1avn1i`}],[`line`,{x1:`21`,x2:`14`,y1:`3`,y2:`10`,key:`ota7mn`}],[`line`,{x1:`3`,x2:`10`,y1:`21`,y2:`14`,key:`1atl0r`}]]),$a=Ia(`Minimize2`,[[`polyline`,{points:`4 14 10 14 10 20`,key:`11kfnr`}],[`polyline`,{points:`20 10 14 10 14 4`,key:`rlmsce`}],[`line`,{x1:`14`,x2:`21`,y1:`10`,y2:`3`,key:`o5lafz`}],[`line`,{x1:`3`,x2:`10`,y1:`21`,y2:`14`,key:`1atl0r`}]]),eo=Ia(`PackageCheck`,[[`path`,{d:`m16 16 2 2 4-4`,key:`gfu2re`}],[`path`,{d:`M21 10V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l2-1.14`,key:`e7tb2h`}],[`path`,{d:`m7.5 4.27 9 5.15`,key:`1c824w`}],[`polyline`,{points:`3.29 7 12 12 20.71 7`,key:`ousv84`}],[`line`,{x1:`12`,x2:`12`,y1:`22`,y2:`12`,key:`a4e8g8`}]]),to=Ia(`Pause`,[[`rect`,{x:`14`,y:`4`,width:`4`,height:`16`,rx:`1`,key:`zuxfzm`}],[`rect`,{x:`6`,y:`4`,width:`4`,height:`16`,rx:`1`,key:`1okwgv`}]]),no=Ia(`RefreshCw`,[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`,key:`v9h5vc`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`,key:`3uifl3`}],[`path`,{d:`M8 16H3v5`,key:`1cv678`}]]),ro=Ia(`ShieldCheck`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),io=Ia(`Square`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]),ao=Ia(`Terminal`,[[`polyline`,{points:`4 17 10 11 4 5`,key:`akl6gq`}],[`line`,{x1:`12`,x2:`20`,y1:`19`,y2:`19`,key:`q2wloq`}]]),oo=Ia(`X`,[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]);function so(e,t,n){let r=e?.model_revision&&e.model_revision!==n,i={...e?.cards};for(let[n,a]of Object.entries(t.cards)){if(r&&i[n]?.model_revision===e.model_revision)continue;let t=i[n];(!t||(a.copy_revision??0)>(t.copy_revision??0)||(a.copy_revision??0)===(t.copy_revision??0)&&(a.generated_at>t.generated_at||a.generated_at===t.generated_at&&!t.input_revision))&&(i[n]=a)}let a=(t.cache_revision??0)<(e?.cache_revision??0);return{...e,...t,cards:i,cache_revision:Math.max(t.cache_revision??0,e?.cache_revision??0),relations:(r||a)&&e?e.relations:t.relations,available:t.available??!0,...r?{model_revision:e.model_revision,available:e.available}:{}}}function co(e,t,n){let r=n?.cards[e.key],i=t.tasks.find(t=>t.id===e.task_id);if(!r||!i)return!0;let a=[i.id,i.id+`:active`,i.id+`:outcome`].includes(e.key);if(a||!r.task_content_revision||!i.content_revision){if(i.revision&&r.task_revision!==i.revision||a&&r.task_status!==i.status)return!0}else if(r.task_content_revision!==i.content_revision)return!0;let o=r.event_ids||[];return e.event_ids.some(e=>{let n=o.indexOf(e),i=t.events.find(t=>t.id===e);return n<0||r.event_revisions&&i?.revision&&r.event_revisions[n]!==i.revision})||!a&&JSON.stringify(e.event_ids)!==JSON.stringify(o)}var lo=e=>`[[Argus引用 ${JSON.stringify(e)}]]\n`;function uo(e){let t=[];return{refs:t,text:e.split(` +`).filter(e=>{if(e.startsWith(`[[Argus引用 `)&&e.endsWith(`]]`))try{let n=JSON.parse(e.slice(10,-2));if(typeof n.task_id==`string`&&typeof n.source==`string`&&typeof n.task_title==`string`&&(n.part===void 0||Number.isInteger(n.part)&&n.part>0)&&(n.step_title===void 0||typeof n.step_title==`string`)&&(n.step_id===void 0||typeof n.step_id==`string`)&&(n.team_id===void 0||typeof n.team_id==`string`)&&(n.team_task_id===void 0||typeof n.team_task_id==`string`)&&(n.lang===void 0||typeof n.lang==`string`)&&Array.isArray(n.event_ids)&&n.event_ids.every(e=>typeof e==`string`))return t.push(n),!1}catch{}return!0}).join(` +`).replace(/^\n+/,``)}}function fo(e,t,n){let r=e.tasks.find(e=>e.id===n),i=r?[r,...e.tasks.filter(e=>e.id!==n)]:e.tasks,a=(t,n=1/0)=>{let r=Math.max(-1/0,...e.events.filter(e=>e.item_id===t&&e.type===`life.mission.started`&&e.ts<=n).map(e=>e.ts));return e.events.filter(e=>e.item_id===t&&e.ts>=r&&e.ts<=n&&[`round.main.completed`,`round.review.completed`].includes(e.type)).slice(-2).map(e=>e.id)},o=i.map(t=>({key:t.id,task_id:t.id,kind:`task`,event_ids:[...new Set([...a(t.id),...e.events.filter(e=>e.item_id===t.id).slice(-2).map(e=>e.id)])]})),s=r?t.map(e=>({key:e.id,task_id:r.id,kind:e.kind,event_ids:[...new Set([...e.kind===`result`?a(r.id,e.ts):[],...e.eventIds])].slice(-16)})):[];return[...o.slice(0,1),...s,...o.slice(1)]}function po({value:e,onChange:t,inputRef:n,fileInputRef:r,onFiles:i,inputProps:a,onSend:o,onCancel:s,pending:c,disabled:l=!1,controls:u}){let{t:d,locale:f}=Z(),p=f===`zh-CN`,{refs:m,text:h}=uo(e);return(0,I.useEffect)(()=>{let e=n.current;if(!e)return;let t=()=>{e.getClientRects().length&&(e.style.height=`0px`,e.style.height=`${Math.min(132,Math.max(28,e.scrollHeight))}px`)};t();let r=e.clientWidth,i=new ResizeObserver(()=>{e.clientWidth!==r&&(r=e.clientWidth,t())});return i.observe(e),()=>i.disconnect()},[n,h]),(0,X.jsxs)(`div`,{className:`composer-surface`,"data-pending":c,children:[m.length>0&&(0,X.jsx)(`div`,{className:`map-reference-chips`,children:m.map((e,n)=>(0,X.jsxs)(`span`,{children:[(0,X.jsxs)(`span`,{children:[p?`引用`:`Reference`,` · `,e.step_title||e.task_title]}),(0,X.jsx)(`button`,{type:`button`,"aria-label":p?`移除引用`:`Remove reference`,onClick:()=>t(m.filter((e,t)=>t!==n).map(lo).join(``)+h),children:(0,X.jsx)(oo,{size:12})})]},`${e.task_id}:${e.step_id}:${n}`))}),(0,X.jsxs)(`form`,{className:`map-composer`,onSubmit:e=>{e.preventDefault(),!c&&!l&&o()},children:[(0,X.jsx)(`input`,{ref:r,type:`file`,multiple:!0,accept:ba,hidden:!0,disabled:l||c,onChange:i}),(0,X.jsx)(`button`,{type:`button`,className:`map-composer-brand map-attach`,"aria-label":d(`chat.attach`),title:d(`chat.attach`),disabled:l||c,onClick:()=>r.current?.click(),children:(0,X.jsx)(Ai,{size:24})}),(0,X.jsx)(`textarea`,{...a,ref:n,rows:1,value:h,disabled:l,onChange:e=>t(m.map(lo).join(``)+e.target.value),onKeyDown:e=>{a.onKeyDown?.(e),!(e.defaultPrevented||sa(e))&&e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),!c&&!l&&o())}}),(0,X.jsx)(`button`,{type:c?`button`:`submit`,onClick:c?s:void 0,disabled:l||!c&&!h.trim(),"aria-label":c?p?`停止等待`:`Stop waiting`:p?`发送消息`:`Send message`,className:`map-send ${c?`is-pending`:``}`,children:c?(0,X.jsx)(io,{size:15}):(0,X.jsx)(za,{size:20})})]}),u?(0,X.jsx)(`div`,{className:`composer-controls`,children:u}):null]})}function mo(e,t){if(!t.onRewrite||!Zn(e.key,e.ctrlKey,e.metaKey))return!1;e.preventDefault();let n=t.value.trim();return n&&!t.disabled&&!t.pending&&!t.rewriting&&t.onRewrite(n),!0}function ho({value:e,onChange:t,onSend:n,onCancel:r,disabled:i,pending:a,focusSignal:o,attachments:s,onAttachmentsChange:c,steps:l=[],onRewrite:u,rewriting:d=!1,slashSelection:f,onSlashSelectionChange:p,routeOverride:m=`auto`,onRouteOverrideChange:h}){let{t:g}=Z(),_=(0,I.useRef)(null),v=(0,I.useRef)(null),y=(0,I.useRef)(!1),[b,x]=(0,I.useState)(0),[S,C]=(0,I.useState)(!1),[w,T]=(0,I.useState)(``),[E,D]=(0,I.useState)(0),[ee,O]=(0,I.useState)(!1);(0,I.useEffect)(()=>{if(!a&&!d)return;let e=setInterval(()=>x(e=>e+1),1e3);return()=>clearInterval(e)},[a,d]),(0,I.useEffect)(()=>{o&&!i&&_.current?.focus()},[o,i]);let te=Jn(l),ne=Date.now()/1e3,k=Rt(e).slice(0,8),re=k.length>0&&!S,A=re?ha(f,k.length):0,j=re?k[A]:void 0,ie=e=>{let n=k[e];n&&(t(Bt(n)),n.argument===`none`&&C(!0),p(0),_.current?.focus())},ae=async()=>{if(!(!e.trim()||a||i||d||y.current)){y.current=!0;try{await n(e.trim(),s)&&(p(0),C(!1),T(``))}finally{y.current=!1}}},M=e=>{if(!e.length||i||a||y.current)return;let{accepted:t,issues:n}=Da(s,e);t.length&&c([...s,...t]),T(n.map(e=>e.code===`unsupported`?g(`chat.attachUnsupported`,{name:e.fileName}):e.code===`too-large`?g(`chat.attachTooLarge`,{name:e.fileName,size:fi(e.limitBytes)}):e.code===`too-many`?g(`chat.attachTooMany`,{count:e.limitCount}):g(`chat.attachTotalTooLarge`,{size:fi(e.limitBytes)})).join(` `))},oe=(e,t)=>{ka(e.dataTransfer)&&(e.preventDefault(),D(e=>Math.max(0,e+t)))};return(0,X.jsxs)(`div`,{className:`conversation-composer flex flex-col ${E>0?`rounded-3xl ring-2 ring-manager/60`:``}`,"data-compact":!ee&&!e.trim()&&!s.length&&!a&&!d&&!w&&!E,onFocusCapture:()=>O(!0),onBlurCapture:e=>O(e.currentTarget.contains(e.relatedTarget)),onDragEnter:e=>oe(e,1),onDragOver:e=>oe(e,0),onDragLeave:e=>oe(e,-1),onDrop:e=>{ka(e.dataTransfer)&&(e.preventDefault(),D(0),M(Aa(e.dataTransfer)))},children:[a?(0,X.jsxs)(`div`,{className:`px-3 py-2`,children:[te.length?(0,X.jsx)(`ol`,{className:`mt-1.5 space-y-0.5`,children:te.map((e,t)=>{let n=t===te.length-1&&!e.endedTs,r=Xn(Yn(e,ne));return(0,X.jsxs)(`li`,{className:`flex min-w-0 items-baseline gap-2 text-xs`,children:[(0,X.jsx)(`span`,{className:`shrink-0 font-mono ${n?`text-manager`:`text-ok`}`,children:n?Un(b):`✓`}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono ${n?`text-ink`:`text-ink-faint`}`,title:e.detail||e.label,children:e.label}),r?(0,X.jsx)(`span`,{className:`shrink-0 font-mono tabular-nums text-ink-faint`,children:r}):null]},e.id)})}):null,(0,X.jsx)(`div`,{className:`mt-1 text-xs text-ink-faint`,children:g(`chat.stopWaitingHint`)})]}):null,re?(0,X.jsx)(_a,{query:e,selected:A,onSelect:ie}):null,s.length||w||E>0?(0,X.jsxs)(`div`,{className:`px-3 py-2`,children:[E>0?(0,X.jsx)(`div`,{className:`mb-2 text-xs text-manager`,children:g(`chat.attachDrop`)}):null,(0,X.jsx)(`div`,{className:`map-attachment-tray`,children:s.map((e,t)=>(0,X.jsx)(ja,{file:e,removeLabel:g(`chat.attachRemove`,{name:e.name}),onRemove:()=>{c(s.filter(t=>t!==e)),T(``)}},`${e.name}:${e.lastModified}:${t}`))}),(0,X.jsx)(`div`,{className:`text-xs ${w?`text-err`:`text-ink-faint`}`,children:w||g(`chat.attachHint`,{count:5,perFile:fi(10485760),total:fi(26214400)})})]}):null,(0,X.jsx)(po,{value:e,onChange:e=>{t(e),p(0),C(!1)},inputRef:_,fileInputRef:v,onFiles:e=>{M(Array.from(e.target.files??[])),e.target.value=``},onSend:()=>void ae(),onCancel:r,pending:a,disabled:i,inputProps:{onPaste:e=>{let t=Aa(e.clipboardData);t.length&&(e.preventDefault(),M(t))},onKeyDown:t=>{sa(t)||mo(t,{value:e,disabled:i,pending:a,rewriting:d,onRewrite:u})||(re?t.key===`ArrowDown`||t.key===`ArrowUp`?(t.preventDefault(),p(ha(A+(t.key===`ArrowDown`?1:-1),k.length))):t.key===`Tab`||t.key===`Enter`&&!t.shiftKey?(t.preventDefault(),ie(A)):t.key===`Escape`&&(t.preventDefault(),C(!0)):t.key===`Escape`&&a?(t.preventDefault(),r()):t.key===`Enter`&&!t.shiftKey&&(t.preventDefault(),ae()))},"aria-label":g(`chat.messageArgus`),"aria-keyshortcuts":`Control+R Meta+R`,"aria-controls":re?ma:void 0,"aria-expanded":re,"aria-activedescendant":j?ga(j.id):void 0,placeholder:g(i?`chat.selectSession`:`chat.placeholder`)},controls:(0,X.jsxs)(X.Fragment,{children:[h?(0,X.jsxs)(`select`,{value:m,onChange:e=>h(e.target.value),disabled:i||a,title:g(`chat.routeHint`),"aria-label":g(`chat.routeLabel`),children:[(0,X.jsx)(`option`,{value:`task`,children:g(`chat.routeTask`)}),(0,X.jsx)(`option`,{value:`auto`,children:g(`chat.routeAuto`)}),(0,X.jsx)(`option`,{value:`chat`,children:g(`chat.routeChat`)})]}):null,u?(0,X.jsx)(`button`,{type:`button`,onClick:()=>u(e.trim()),disabled:i||a||d||!e.trim(),title:`Ctrl/⌘+R · ${g(`chat.rewriteHint`)}`,"aria-label":g(`chat.rewriteLabel`),"aria-keyshortcuts":`Control+R Meta+R`,children:d?`${Un(b)} ${g(`chat.rewriting`)}`:g(`chat.rewrite`)}):null]})})]})}function go({open:e,onClose:t,children:n,label:r,width:i=`max-w-2xl`,align:a=`center`,viewport:o=!1,showClose:s=!0,style:c}){let{t:l}=Z(),u=(0,I.useRef)(null),d=(0,I.useRef)(null),f=(0,I.useRef)(t);return f.current=t,ci(u,(t,n)=>{if(!(!e||!u.current||!d.current)){if(n){t.set([d.current,u.current],{clearProps:`all`});return}t.timeline({defaults:{overwrite:`auto`}}).fromTo(d.current,{autoAlpha:0},{autoAlpha:1,duration:.14,ease:`power1.out`},0).fromTo(u.current,{autoAlpha:0,y:a===`top`?-6:8,scale:.992},{autoAlpha:1,y:0,scale:1,duration:.2,ease:`power3.out`,clearProps:`transform,opacity,visibility`},.03)}},[e,a]),(0,I.useEffect)(()=>{if(!e)return;let t=document.activeElement instanceof HTMLElement?document.activeElement:null,n=window.requestAnimationFrame(()=>{(u.current?.querySelector(`[data-autofocus]`)??u.current?.querySelector(`input:not([disabled]), textarea:not([disabled]), select:not([disabled]), button:not([disabled]), [href], [tabindex]:not([tabindex="-1"])`)??u.current)?.focus()}),r=e=>{if(e.key===`Escape`){e.preventDefault(),f.current();return}if(e.key!==`Tab`||!u.current)return;let t=Array.from(u.current.querySelectorAll(`input:not([disabled]), textarea:not([disabled]), select:not([disabled]), button:not([disabled]), [href], [tabindex]:not([tabindex="-1"])`)).filter(e=>e.getAttribute(`aria-hidden`)!==`true`);if(t.length===0){e.preventDefault(),u.current.focus();return}let n=t[0],r=t[t.length-1];e.shiftKey&&(document.activeElement===n||!u.current.contains(document.activeElement))?(e.preventDefault(),r.focus()):!e.shiftKey&&document.activeElement===r&&(e.preventDefault(),n.focus())};return window.addEventListener(`keydown`,r),()=>{window.cancelAnimationFrame(n),window.removeEventListener(`keydown`,r),t?.isConnected&&t.focus()}},[e]),e?(0,X.jsxs)(`div`,{className:`fixed inset-0 z-50 flex ${a===`top`?`items-start pt-3 sm:pt-14`:`items-center`} justify-center ${o?`p-0`:`p-3 sm:p-4`}`,onPointerDown:t,children:[(0,X.jsx)(`div`,{ref:d,className:`modal-scrim absolute inset-0`}),(0,X.jsxs)(`div`,{ref:u,role:`dialog`,"aria-modal":`true`,"aria-label":r,tabIndex:-1,style:c,className:`brand-modal glass-panel glass-panel--raised relative z-10 w-full overscroll-contain ${i} scroll-thin ${o?`flex h-[100dvh] max-h-[100dvh] flex-col overflow-hidden rounded-none`:`max-h-[calc(100dvh-1.5rem)] overflow-x-hidden overflow-y-auto rounded-2xl sm:max-h-[88dvh]`}`,onPointerDown:e=>e.stopPropagation(),children:[!o&&s?(0,X.jsx)(`button`,{type:`button`,"data-modal-close":!0,onClick:t,"aria-label":l(`common.close`),className:`modal-close`,children:(0,X.jsx)(`svg`,{viewBox:`0 0 16 16`,"aria-hidden":`true`,children:(0,X.jsx)(`path`,{d:`m4 4 8 8m0-8-8 8`})})}):null,n]})]}):null}function _o({title:e,sub:t}){return(0,X.jsxs)(`div`,{className:`px-6 pb-3 pr-14 pt-5`,children:[(0,X.jsx)(`h2`,{className:`text-base font-semibold tracking-[-0.01em] text-ink`,children:e}),t&&(0,X.jsx)(`p`,{className:`mt-1 text-sm text-ink-faint`,children:t})]})}function vo(e,t,n,r=`en`){return e.map(e=>({id:`command-${e.id}`,label:da(e,r),hint:`${e.name}${e.arg?` ${e.arg}`:``}`,group:fa(e,r),keywords:[e.name,...e.aliases??[]].join(` `),run:()=>Ft(e)?n(`${e.name} `):t(e.name)}))}function yo(e,t){let n=t.trim().toLowerCase().split(/\s+/).filter(Boolean);return n.length?e.filter(e=>{let t=`${e.label} ${e.group} ${e.hint??``} ${e.keywords??``}`.toLowerCase();return n.every(e=>t.includes(e))}):e}function bo({open:e,onClose:t,items:n}){let{t:r}=Z(),[i,a]=(0,I.useState)(``),[o,s]=(0,I.useState)(0),c=(0,I.useRef)(null),l=(0,I.useRef)(null);(0,I.useEffect)(()=>{e&&(a(``),s(0),setTimeout(()=>c.current?.focus(),0))},[e]);let u=(0,I.useMemo)(()=>yo(n,i),[i,n]);(0,I.useEffect)(()=>{o>=u.length&&s(Math.max(0,u.length-1))},[u.length,o]),(0,I.useEffect)(()=>{l.current?.scrollIntoView({block:`nearest`})},[e,i,o]);let d=e=>{e&&(t(),e.run())},f=e=>{sa(e)||(e.key===`ArrowDown`?(e.preventDefault(),u.length&&s(e=>Math.min(u.length-1,e+1))):e.key===`ArrowUp`?(e.preventDefault(),s(e=>Math.max(0,e-1))):e.key===`Enter`&&(e.preventDefault(),d(u[o])))},p=[];for(let e of u){let t=p.find(t=>t.name===e.group);t||(t={name:e.group,items:[]},p.push(t)),t.items.push(e)}let m=-1;return(0,X.jsxs)(go,{open:e,onClose:t,label:r(`help.palette`),width:`max-w-xl`,align:`top`,children:[(0,X.jsx)(`div`,{className:`border-b border-line px-4 py-3`,children:(0,X.jsx)(`input`,{ref:c,value:i,onChange:e=>a(e.target.value),onKeyDown:f,placeholder:r(`palette.placeholder`),role:`combobox`,"aria-expanded":e,"aria-autocomplete":`list`,"aria-controls":`command-palette-results`,"aria-activedescendant":u[o]?`palette-${u[o].id}`:void 0,className:`w-full bg-transparent font-mono text-sm text-ink outline-none placeholder:text-ink-faint`})}),(0,X.jsxs)(`div`,{id:`command-palette-results`,role:`listbox`,className:`max-h-[52vh] overflow-y-auto scroll-thin py-1.5`,children:[u.length===0&&(0,X.jsx)(`div`,{className:`px-4 py-6 text-center text-xs text-ink-faint`,children:r(`palette.noMatches`)}),p.map(e=>(0,X.jsxs)(`div`,{className:`mb-1`,children:[(0,X.jsx)(`div`,{className:`px-4 py-1 text-[10px] font-semibold uppercase tracking-wider text-ink-faint`,children:e.name}),e.items.map(e=>{m++;let t=m===o;return(0,X.jsxs)(`button`,{id:`palette-${e.id}`,ref:t?l:void 0,role:`option`,"aria-selected":t,onMouseEnter:()=>s(u.indexOf(e)),onClick:()=>d(e),className:`flex w-full items-center justify-between px-4 py-1.5 text-left text-sm transition-colors ${t?`bg-blue-deep/20 text-ink`:`text-ink-dim hover:bg-panel/60`}`,children:[(0,X.jsx)(`span`,{children:e.label}),e.hint&&(0,X.jsx)(`span`,{className:`font-mono text-[11px] text-ink-faint`,children:e.hint})]},e.id)})]},e.name))]}),(0,X.jsxs)(`div`,{className:`flex items-center gap-3 border-t border-line px-4 py-1.5 text-[10px] text-ink-faint`,children:[(0,X.jsx)(`span`,{children:r(`palette.navigate`)}),(0,X.jsx)(`span`,{children:r(`palette.run`)}),(0,X.jsx)(`span`,{children:r(`palette.close`)})]})]})}var xo=[{keys:`⌘K / Ctrl+K`,desc:`help.palette`},{keys:`⌘B / Ctrl+B`,desc:`help.sessions`},{keys:`⌘J / Ctrl+J`,desc:`help.managerChat`},{keys:`⌘R / Ctrl+R`,desc:`help.rewrite`},{keys:`⌘T / Ctrl+T`,desc:`help.reasoning`},{keys:`⌘. / Ctrl+.`,desc:`help.kiosk`},{keys:`/`,desc:`help.composer`},{keys:`↵ Enter`,desc:`help.send`},{keys:`Shift+Enter`,desc:`help.newline`},{keys:`?`,desc:`help.thisHelp`},{keys:`Esc`,desc:`help.escape`}];function So({open:e,onClose:t}){let{locale:n,t:r}=Z(),i=pa(Nt,n);return(0,X.jsxs)(go,{open:e,onClose:t,label:r(`help.title`),width:`max-w-2xl`,children:[(0,X.jsx)(_o,{title:r(`help.title`)}),(0,X.jsxs)(`div`,{className:`max-h-[70dvh] overflow-y-auto scroll-thin`,children:[(0,X.jsx)(`div`,{className:`p-4`,children:xo.map(e=>(0,X.jsxs)(`div`,{className:`flex items-center justify-between py-1.5`,children:[(0,X.jsx)(`span`,{className:`text-sm text-ink-dim`,children:r(e.desc)}),(0,X.jsx)(`kbd`,{className:`rounded border border-line bg-surface px-2 py-0.5 font-mono text-[11px] text-ink`,children:e.keys})]},e.keys))}),(0,X.jsxs)(`div`,{className:`border-t border-line px-4 pb-4 pt-3`,children:[(0,X.jsx)(`p`,{className:`mb-3 text-xs font-semibold uppercase tracking-wider text-ink-faint`,children:r(`help.commands`)}),i.map(e=>(0,X.jsxs)(`div`,{className:`mb-4`,children:[(0,X.jsx)(`p`,{className:`mb-1 text-[10px] font-semibold uppercase tracking-wider text-ink-faint`,children:e.group}),e.rows.map(e=>(0,X.jsxs)(`div`,{className:`flex items-start justify-between gap-4 py-1`,children:[(0,X.jsx)(`code`,{className:`shrink-0 font-mono text-xs text-ink`,children:e.label}),(0,X.jsx)(`span`,{className:`text-right text-xs text-ink-dim`,children:e.desc})]},e.label))]},e.group))]})]})]})}function Co({sid:e,config:t,onSaved:n}){let{locale:r}=Z(),i=r===`zh-CN`,a=t.roles.find(e=>e.role===`engineer`),o=new Map(t.operator_knobs.map(e=>[e.name,e.value])),s=o.get(`ARGUS_SKILL_MAP_MODEL`)||`auto`,c=o.get(`ARGUS_SKILL_MAP_REASONING_EFFORT`)||`auto`,[l,u]=(0,I.useState)(s===`auto`?``:s),[d,f]=(0,I.useState)(!1),[p,m]=(0,I.useState)(``);(0,I.useEffect)(()=>u(s===`auto`?``:s),[s]);let h=async(t,r)=>{if(!d){f(!0),m(``);try{await U.setConfig(e,t,r),await n()}catch(e){m(e instanceof Error?e.message:String(e))}finally{f(!1)}}},g=i?`跟随科研设置`:`Follow research settings`;return(0,X.jsxs)(`section`,{className:`map-model-settings rounded-lg border border-line glass-card p-3`,"aria-label":i?`地图模型`:`Map model`,children:[(0,X.jsx)(`div`,{className:`text-xs font-semibold text-ink`,children:i?`地图模型`:`Map model`}),(0,X.jsx)(`p`,{className:`mt-1 text-xs text-ink-dim`,children:i?`沿用科研 Engineer 的接入与账号。留空即可跟随 Engineer 模型。`:`Uses the research Engineer's runner and account. Leave the model blank to follow Engineer settings.`}),(0,X.jsxs)(`p`,{className:`mt-1 text-xs text-ink-faint`,children:[a?.backend_label,` · `,a?.model||(i?`接入默认模型`:`Runner default model`)]}),(0,X.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-end gap-2`,children:[(0,X.jsxs)(`label`,{className:`min-w-0 flex-1 text-xs text-ink-dim`,children:[i?`摘要模型`:`Summary model`,(0,X.jsx)(`input`,{value:l,onChange:e=>u(e.target.value),disabled:d,placeholder:g,className:`mt-1 h-9 w-full rounded border border-line bg-bg px-2 text-xs text-ink outline-none focus:border-blue`})]}),(0,X.jsx)(`button`,{type:`button`,disabled:d,onClick:()=>void h(`ARGUS_SKILL_MAP_MODEL`,l.trim()||`auto`),className:`h-9 rounded border border-line px-3 text-xs text-ink-dim hover:border-blue disabled:opacity-40`,children:i?`应用`:`Apply`}),s!==`auto`&&(0,X.jsx)(`button`,{type:`button`,disabled:d,onClick:()=>void h(`ARGUS_SKILL_MAP_MODEL`,`auto`),className:`h-9 rounded border border-line px-3 text-xs text-ink-dim hover:border-blue disabled:opacity-40`,children:g})]}),(0,X.jsxs)(`label`,{className:`mt-3 flex items-center gap-3 text-xs text-ink-dim`,children:[i?`思考强度`:`Reasoning effort`,(0,X.jsxs)(`select`,{value:c,disabled:d,onChange:e=>void h(`ARGUS_SKILL_MAP_REASONING_EFFORT`,e.target.value),className:`h-9 rounded border border-line bg-bg px-2 text-xs text-ink outline-none focus:border-blue`,children:[(0,X.jsx)(`option`,{value:`auto`,children:g}),[[`low`,`低`],[`medium`,`中`],[`high`,`高`],[`xhigh`,`很高`],[`max`,`最高`]].map(([e,t])=>(0,X.jsx)(`option`,{value:e,children:i?t:e},e))]})]}),p&&(0,X.jsx)(`p`,{role:`alert`,className:`mt-2 text-xs text-err`,children:p})]})}var wo=[{name:`ARGUS_SKILL_MAX_ACTIVE_DAEMONS`,group:`Limits`,label:`Active daemon limit`,description:`Maximum background sessions running on this host.`},{name:`ARGUS_SKILL_UNPRICED_COST_POLICY`,group:`Safety`,label:`Unpriced calls`,description:`Whether calls with unresolved pricing are blocked or allowed.`},{name:`ARGUS_SKILL_SAFE_MODE`,group:`Safety`,label:`Safe mode`,description:`Enable extra-conservative runtime guardrails.`},{name:`ARGUS_SKILL_ENABLE_TELEGRAM`,group:`Interface`,label:`Telegram`,description:`Enable the Telegram notification bridge.`},{name:`ARGUS_SKILL_SHOW_REASONING`,group:`Interface`,label:`Show reasoning`,description:`Stream role reasoning into the cockpit activity view.`}];function To(e){let t=new Map(e.map(e=>[e.name,e]));return wo.flatMap(e=>{let n=t.get(e.name);return n?[{...n,group:e.group,label:e.label,doc:e.description}]:[]})}function Eo(e,t){let n=new URL(e),r=n.protocol===`https:`?`wss:`:`ws:`,i=encodeURIComponent(t);return{webApi:`${n.origin}/api`,eventStream:`${r}//${n.host}/api/projects/${i}/stream`,daemon:`local process · events.jsonl · no TCP port`}}var Do=[{value:`copilot`,label:`settings.backendLabel.copilot`},{value:`codex`,label:`settings.backendLabel.codex`},{value:`claude`,label:`settings.backendLabel.claude`},{value:`cursor`,label:`settings.backendLabel.cursor`},{value:`opencode`,label:`settings.backendLabel.opencode`},{value:`pi`,label:`settings.backendLabel.pi`},{value:`grok`,label:`settings.backendLabel.grok`},{value:`qoder`,label:`settings.backendLabel.qoder`},{value:`dsh`,label:`settings.backendLabel.dsh`}],Oo={copilot:`copilot`,codex:`codex`,claude:`claude`,cursor:`cursor`,opencode:`opencode`,pi:`pi`,grok:`grok`,qoder:`qoder`,dsh:`dsh`};function ko(e){return Oo[e]??``}function Ao(e,t){let n=ko(e);return n?t(`settings.backendLabel.${n}`):e}function jo(e){return e?.operator_knobs.find(e=>e.name===`ARGUS_SKILL_RUNNER_BACKEND`)?.value??e?.roles[0]?.backend??``}var Mo=[{alias:`global_daily_cap`,env:`ARGUS_SKILL_GLOBAL_DAILY_CAP_USD`,label:`settings.budget.global`,unit:`settings.unit.usd`,step:`0.1`},{alias:`codex_daily_requests`,env:`ARGUS_SKILL_CODEX_DAILY_CALL_CAP`,label:`settings.budget.codex`,unit:`settings.unit.calls`,step:`1`},{alias:`copilot_daily_requests`,env:`ARGUS_SKILL_COPILOT_DAILY_CALL_CAP`,label:`settings.budget.copilot`,unit:`settings.unit.calls`,step:`1`},{alias:`copilot_daily_premium`,env:`ARGUS_SKILL_COPILOT_DAILY_PREMIUM_CAP`,label:`settings.budget.premium`,unit:`settings.unit.requests`,step:`1`}],No={ARGUS_SKILL_MAX_ACTIVE_DAEMONS:{label:`settings.knob.activeDaemons`,doc:`settings.knob.activeDaemonsDoc`},ARGUS_SKILL_UNPRICED_COST_POLICY:{label:`settings.knob.unpricedCalls`,doc:`settings.knob.unpricedCallsDoc`},ARGUS_SKILL_SAFE_MODE:{label:`settings.knob.safeMode`,doc:`settings.knob.safeModeDoc`},ARGUS_SKILL_ENABLE_TELEGRAM:{label:`settings.knob.telegram`,doc:`settings.knob.telegramDoc`},ARGUS_SKILL_SHOW_REASONING:{label:`settings.knob.showReasoning`,doc:`settings.knob.showReasoningDoc`}},Po={Limits:`settings.group.limits`,Safety:`settings.group.safety`,Interface:`settings.group.interface`},Fo={manager:`settings.role.managerDoc`,planner:`settings.role.plannerDoc`,engineer:`settings.role.engineerDoc`,reviewer:`settings.role.reviewerDoc`,curator:`settings.role.curatorDoc`};function Io(e,t){let n=e.trim();return n===`not applicable for this model`?t(`settings.source.notApplicable`):n.startsWith(`capability vault`)?t(`settings.source.vaultDefault`):n.startsWith(`default`)?t(`settings.source.default`):n.startsWith(`persisted:`)||n===`persisted`?t(`settings.source.saved`):n.startsWith(`ARGUS_SKILL_`)||n===`env`?t(`settings.source.environment`):n.startsWith(`global:`)?t(`settings.source.hostConfig`):t(`settings.source.other`)}function Lo(e,t){let n=e.value.trim().toLowerCase();if(e.name===`ARGUS_SKILL_UNPRICED_COST_POLICY`){if(n===`block`)return t(`settings.value.block`);if(n===`allow`)return t(`settings.value.allow`)}return[`ARGUS_SKILL_SAFE_MODE`,`ARGUS_SKILL_ENABLE_TELEGRAM`,`ARGUS_SKILL_SHOW_REASONING`].includes(e.name)?t([`1`,`true`,`on`,`yes`].includes(n)?`settings.value.enabled`:`settings.value.disabled`):e.value}function Ro(e,t){let n={low:`low`,medium:`medium`,high:`high`,xhigh:`xhigh`}[e.toLowerCase()];return n?t(`settings.effort.${n}`):e}function zo({message:e,retrying:t,onRetry:n,t:r}){return(0,X.jsxs)(`div`,{role:`alert`,className:`flex flex-col items-center gap-3 px-4 py-8 text-center`,children:[(0,X.jsx)(`p`,{className:`text-sm text-err`,children:e}),(0,X.jsx)(`button`,{type:`button`,onClick:n,disabled:t,className:`rounded-md border border-err/40 px-3 py-1.5 text-xs font-medium text-err hover:bg-err/10 disabled:opacity-40`,children:r(t?`common.loading`:`common.retry`)})]})}function Bo({sid:e,open:t,onClose:n}){let{t:r}=Z(),{data:i,isLoading:a,isError:o,isFetching:s,refetch:c}=xr(e,t),l=!!(i&&(i.recommended||i.checks.length||i.log_tail.trim()));return(0,X.jsxs)(go,{open:t,onClose:n,label:r(`doctor.title`),width:`max-w-3xl`,children:[(0,X.jsx)(_o,{title:r(`doctor.title`),sub:r(`doctor.subtitle`)}),(0,X.jsxs)(`div`,{className:`p-4`,children:[a&&(0,X.jsx)(`div`,{className:`flex justify-center py-8`,children:(0,X.jsx)(bi,{})}),!a&&o&&(0,X.jsx)(zo,{message:r(`doctor.loadError`),retrying:s,onRetry:()=>void c(),t:r}),!a&&!o&&!l&&(0,X.jsx)(xi,{children:r(`doctor.empty`)}),!a&&!o&&i?.recommended&&(0,X.jsxs)(`div`,{className:`mb-4 rounded-lg border border-gold/40 bg-gold/5 p-3`,children:[(0,X.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-wide text-gold`,children:r(`doctor.recommended`)}),(0,X.jsx)(`div`,{className:`mt-1 text-sm text-ink`,children:i.recommended.name}),(0,X.jsx)(`div`,{className:`mt-0.5 text-xs text-ink-dim`,children:i.recommended.detail}),i.recommended.fix&&(0,X.jsx)(`pre`,{className:`mt-2 whitespace-pre-wrap break-words rounded bg-bg p-2 font-mono text-xs text-blue-sky`,children:i.recommended.fix})]}),!a&&!o&&(0,X.jsx)(`div`,{className:`space-y-1.5`,children:(i?.checks??[]).map((e,t)=>(0,X.jsxs)(`div`,{className:`flex items-start gap-2 rounded-md border border-line/60 px-3 py-2`,children:[(0,X.jsx)(`span`,{className:e.ok?`text-ok`:`text-err`,children:e.ok?`✓`:`✗`}),(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsx)(`div`,{className:`text-xs font-medium text-ink`,children:e.name}),e.detail&&(0,X.jsx)(`div`,{className:`mt-0.5 text-[11px] text-ink-dim`,children:e.detail}),!e.ok&&e.fix&&(0,X.jsx)(`pre`,{className:`mt-1 whitespace-pre-wrap break-words rounded bg-bg p-1.5 font-mono text-xs text-ink-dim`,children:e.fix})]})]},t))}),!a&&!o&&i?.log_tail&&(0,X.jsxs)(`div`,{className:`mt-4`,children:[(0,X.jsx)(`div`,{className:`mb-1 text-[10px] font-semibold uppercase tracking-wide text-ink-faint`,children:r(`doctor.daemonLog`)}),(0,X.jsx)(`pre`,{className:`max-h-48 overflow-x-hidden overflow-y-auto whitespace-pre-wrap break-words rounded-lg bg-bg p-3 font-mono text-xs leading-relaxed text-ink-dim scroll-thin`,children:i.log_tail})]})]})]})}function Vo({sid:e,open:t,onClose:n}){let{t:r}=Z(),i=oe(),{data:a,isLoading:s,isError:c,isFetching:l,refetch:u}=Sr(e,t),[d,f]=(0,I.useState)(!1),[p,h]=(0,I.useState)(``),[g,_]=(0,I.useState)(!1),[v,y]=(0,I.useState)(``),[b,x]=(0,I.useState)(!1),[C,w]=(0,I.useState)(``),[E,D]=(0,I.useState)(``),[ee,O]=(0,I.useState)(!1),[te,ne]=(0,I.useState)(``),[k,re]=(0,I.useState)(!1),[A,j]=(0,I.useState)(``),[ie,ae]=(0,I.useState)({});(0,I.useEffect)(()=>{t||f(!1)},[t]),(0,I.useEffect)(()=>{if(!t||!a)return;h(a.operator_knobs.find(e=>e.name===`ARGUS_SKILL_MODEL`)?.value??``);let e=new Map(a.operator_knobs.map(e=>[e.name,e.value]));ae(Object.fromEntries(Mo.map(t=>[t.alias,e.get(t.env)??``])))},[a,t]);let M=async()=>{await u(),await i.invalidateQueries({queryKey:[`map-copy`]})},se=jo(a),N=async t=>{if(!g){_(!0),y(``),x(!1);try{await U.setConfig(e,`ARGUS_SKILL_RUNNER_BACKEND`,t),await M(),y(r(`settings.backendSwitched`,{backend:Ao(t,r)}))}catch(e){x(!0),y(e instanceof Error?e.message:String(e))}finally{_(!1)}}},ce=async()=>{if(!g){_(!0),y(``),x(!1);try{await U.setConfig(e,`ARGUS_SKILL_MODEL`,p.trim()||`auto`),await M(),y(r(`settings.applied`))}catch(e){x(!0),y(e instanceof Error?e.message:String(e))}finally{_(!1)}}},le=async()=>{if(!k){re(!0),j(``);try{let t=Object.fromEntries(Mo.map(e=>{let t=String(ie[e.alias]??``).trim();if(!t)throw Error(r(`settings.required`,{field:r(e.label)}));return[e.alias,t]}));await U.setBudgets(e,t),await M(),j(r(`settings.budgetSaved`))}catch(e){j(e instanceof Error?e.message:String(e))}finally{re(!1)}}},ue=async t=>{if(t.preventDefault(),!(!C.trim()||!E.trim()||ee)){O(!0),ne(``);try{await U.setConfig(e,C.trim(),E.trim()),await M(),ne(r(`settings.applied`))}catch(e){ne(e instanceof Error?e.message:String(e))}finally{O(!1)}}},de=To(a?.operator_knobs??[]).reduce((e,t)=>((e[t.group]??=[]).push(t),e),{}),fe=Eo(window.location.origin,e),P=!!(a&&(a.roles.length||a.operator_knobs.length));return(0,X.jsxs)(go,{open:t,onClose:n,label:r(`common.settings`),width:`max-w-4xl`,children:[(0,X.jsx)(_o,{title:r(`common.settings`),sub:r(`settings.subtitle`)}),(0,X.jsxs)(`div`,{className:`p-4`,children:[s&&(0,X.jsx)(`div`,{className:`flex justify-center py-8`,children:(0,X.jsx)(bi,{})}),!s&&c&&(0,X.jsx)(zo,{message:r(`settings.loadError`),retrying:l,onRetry:()=>void u(),t:r}),!s&&!c&&!P&&(0,X.jsx)(xi,{children:r(`settings.empty`)}),!s&&!c&&P&&a&&(0,X.jsxs)(`div`,{className:`space-y-4`,children:[(0,X.jsxs)(`section`,{className:`rounded-lg border border-line glass-card p-3`,children:[(0,X.jsx)(`div`,{className:`mb-2 text-[10px] font-semibold uppercase tracking-wide text-ink-faint`,children:r(`settings.quickConfig`)}),(0,X.jsxs)(`label`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(`span`,{className:`w-12 shrink-0 text-[10px] text-ink-faint`,children:r(`settings.backend`)}),(0,X.jsxs)(`select`,{value:ko(se),disabled:g,onChange:e=>void N(e.target.value),className:`h-8 min-w-44 rounded border border-line bg-bg px-2 text-xs text-ink outline-none focus:border-blue disabled:opacity-40`,children:[ko(se)?null:(0,X.jsx)(`option`,{value:``,disabled:!0,children:se?r(`settings.backendUnsupported`,{backend:se}):r(`settings.backendUnavailable`)}),Do.map(e=>(0,X.jsx)(`option`,{value:e.value,children:r(e.label)},e.value))]})]}),(0,X.jsxs)(`div`,{className:`mt-2 flex items-center gap-2`,children:[(0,X.jsx)(`span`,{className:`w-12 shrink-0 text-[10px] text-ink-faint`,children:r(`settings.model`)}),(0,X.jsx)(`input`,{value:p,onChange:e=>h(e.target.value),placeholder:r(`settings.modelPlaceholder`),className:`h-8 min-w-0 flex-1 rounded border border-line bg-bg px-2 font-mono text-xs text-ink outline-none focus:border-blue`}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>void ce(),disabled:g,className:`h-8 shrink-0 rounded border border-line/70 px-2.5 text-xs font-medium text-ink-dim hover:border-blue/50 disabled:opacity-40`,children:r(`settings.applyModel`)})]}),v&&(0,X.jsx)(`div`,{role:b?`alert`:`status`,className:`mt-1.5 text-[10px] ${b?`text-err`:`text-ink-dim`}`,children:v})]}),(0,X.jsx)(Co,{sid:e,config:a,onSaved:M}),(0,X.jsxs)(`section`,{className:`rounded-lg border border-gold/40 bg-gold/5 p-3`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-wide text-gold`,children:r(`settings.budgetTitle`)}),(0,X.jsx)(`p`,{className:`mt-0.5 text-[10px] text-ink-faint`,children:r(`settings.budgetHint`)})]}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>void le(),disabled:k,title:r(`settings.saveBudgets`),"aria-label":r(`settings.saveBudgets`),className:`flex h-9 w-9 items-center justify-center rounded border border-blue/35 bg-blue/8 text-xs font-semibold text-blue hover:border-blue-deep hover:bg-blue-deep hover:text-white disabled:opacity-40`,children:k?`…`:(0,X.jsx)(o,{icon:m})})]}),(0,X.jsx)(`div`,{className:`mt-3 grid gap-2 sm:grid-cols-2 lg:grid-cols-3`,children:Mo.map(e=>(0,X.jsxs)(`label`,{className:`rounded border border-line/70 bg-bg/60 p-2`,children:[(0,X.jsx)(`span`,{className:`block text-[10px] text-ink-faint`,children:r(e.label)}),(0,X.jsxs)(`div`,{className:`mt-1 flex items-center gap-2`,children:[(0,X.jsx)(`input`,{type:`number`,min:`0`,step:e.step,value:ie[e.alias]??``,onChange:t=>ae(n=>({...n,[e.alias]:t.target.value})),className:`h-8 min-w-0 flex-1 bg-transparent font-mono text-sm text-ink outline-none`}),(0,X.jsx)(`span`,{className:`text-[9px] text-ink-faint`,children:r(e.unit)})]})]},e.alias))}),A?(0,X.jsx)(`div`,{className:`mt-2 text-xs text-ink-dim`,children:A}):null]}),(0,X.jsxs)(`section`,{className:`overflow-hidden rounded-lg border border-line bg-surface/50`,children:[(0,X.jsxs)(`button`,{type:`button`,"aria-expanded":d,"aria-controls":`config-advanced-settings`,onClick:()=>f(e=>!e),className:`flex w-full items-center justify-between gap-3 px-3 py-3 text-left hover:bg-bg/30`,children:[(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`span`,{className:`block text-xs font-semibold text-ink`,children:r(`settings.advanced`)}),(0,X.jsx)(`span`,{className:`mt-0.5 block text-[10px] text-ink-faint`,children:r(`settings.advancedHint`)})]}),(0,X.jsx)(o,{icon:T,className:`text-xs text-ink-faint transition-transform ${d?`rotate-180`:``}`})]}),d&&(0,X.jsxs)(`div`,{id:`config-advanced-settings`,className:`space-y-4 border-t border-line/70 p-3`,children:[(0,X.jsxs)(`section`,{className:`rounded-lg border border-line bg-surface p-3`,children:[(0,X.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-wide text-ink-faint`,children:r(`settings.connection`)}),(0,X.jsxs)(`div`,{className:`mt-2 grid gap-2 text-[10px] sm:grid-cols-[100px_minmax(0,1fr)]`,children:[(0,X.jsx)(`span`,{className:`text-ink-faint`,children:r(`settings.webApi`)}),(0,X.jsx)(`code`,{className:`min-w-0 break-all text-ink-dim`,children:fe.webApi}),(0,X.jsx)(`span`,{className:`text-ink-faint`,children:r(`settings.eventStream`)}),(0,X.jsx)(`code`,{className:`min-w-0 break-all text-ink-dim`,children:fe.eventStream}),(0,X.jsx)(`span`,{className:`text-ink-faint`,children:r(`settings.taskDaemon`)}),(0,X.jsx)(`span`,{className:`text-ink-dim`,children:r(`settings.taskDaemonValue`)})]})]}),(0,X.jsxs)(`form`,{onSubmit:e=>void ue(e),className:`rounded-lg border border-blue/30 bg-blue/5 p-3`,children:[(0,X.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-wide text-blue`,children:r(`settings.overrideTitle`)}),(0,X.jsx)(`p`,{className:`mt-0.5 text-[10px] text-ink-faint`,children:r(`settings.overrideHint`)}),(0,X.jsxs)(`div`,{className:`mt-2 grid gap-2 sm:grid-cols-[minmax(0,1fr)_minmax(0,1fr)_auto]`,children:[(0,X.jsx)(`input`,{value:C,onChange:e=>w(e.target.value),placeholder:r(`settings.namePlaceholder`),className:`h-9 rounded border border-line bg-bg px-2 font-mono text-xs text-ink outline-none focus:border-blue`}),(0,X.jsx)(`input`,{value:E,onChange:e=>D(e.target.value),placeholder:r(`settings.valuePlaceholder`),className:`h-9 rounded border border-line bg-bg px-2 font-mono text-xs text-ink outline-none focus:border-blue`}),(0,X.jsx)(`button`,{disabled:ee||!C.trim()||!E.trim(),title:r(`settings.applyAdvanced`),"aria-label":r(`settings.applyAdvanced`),className:`flex h-9 w-9 items-center justify-center rounded border border-blue/35 bg-blue/8 text-xs font-medium text-blue hover:border-blue-deep hover:bg-blue-deep hover:text-white disabled:opacity-40`,children:ee?`…`:(0,X.jsx)(o,{icon:S})})]}),te?(0,X.jsx)(`div`,{className:`mt-2 text-xs text-ink-dim`,children:te}):null]}),a.roles.length>0&&(0,X.jsxs)(`section`,{children:[(0,X.jsx)(`div`,{className:`mb-2 text-[10px] font-semibold uppercase tracking-[0.14em] text-ink-faint`,children:r(`settings.rolesTitle`)}),(0,X.jsx)(`div`,{className:`grid gap-2 sm:grid-cols-2`,children:a.roles.map(e=>(0,X.jsxs)(`div`,{className:`rounded-lg border border-line bg-surface p-3`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,X.jsx)(`div`,{className:`text-xs font-semibold text-ink`,children:e.role===`curator`?r(`settings.role.curator`):Vi(e.role,r)}),(0,X.jsx)(`span`,{className:`text-[10px] text-ink-faint`,children:e.backend_label})]}),(0,X.jsx)(`div`,{className:`mt-2 truncate font-mono text-[11px] text-ink-dim`,title:e.model,children:e.model}),(0,X.jsxs)(`div`,{className:`mt-1 flex items-center gap-2 text-[10px] text-ink-faint`,children:[(0,X.jsx)(`span`,{className:`truncate`,children:Io(e.model_source,r)}),e.reasoning_effort&&(0,X.jsx)(`span`,{className:`ml-auto shrink-0`,style:{color:ft(e.reasoning_effort)},children:Ro(e.reasoning_effort,r)})]}),Fo[e.role]&&(0,X.jsx)(`p`,{className:`mt-2 text-[10px] leading-relaxed text-ink-faint`,children:r(Fo[e.role])})]},e.role))})]}),Object.keys(de).length>0&&(0,X.jsxs)(`section`,{children:[(0,X.jsx)(`div`,{className:`mb-2 text-[10px] font-semibold uppercase tracking-[0.14em] text-ink-faint`,children:r(`settings.rawConfig`)}),Object.entries(de).map(([e,t])=>(0,X.jsxs)(`div`,{className:`mt-3 first:mt-0`,children:[(0,X.jsx)(`div`,{className:`mb-1.5 text-[10px] font-semibold uppercase tracking-[0.14em] text-ink-faint`,children:r(Po[e])}),(0,X.jsx)(`div`,{className:`overflow-hidden rounded-lg border border-line`,children:t.map((e,t)=>{let n=No[e.name],i=Lo(e,r);return(0,X.jsxs)(`div`,{className:`grid gap-1 px-3 py-2.5 sm:grid-cols-[minmax(0,1fr)_auto] ${t?`border-t border-line/60`:``}`,children:[(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsx)(`div`,{className:`text-xs font-medium text-ink-dim`,children:r(n.label)}),(0,X.jsx)(`code`,{className:`mt-0.5 block break-all text-[9px] text-ink-faint`,children:e.name}),(0,X.jsx)(`div`,{className:`mt-1 text-[10px] leading-relaxed text-ink-faint`,children:r(n.doc)})]}),(0,X.jsxs)(`div`,{className:`text-left sm:text-right`,children:[(0,X.jsxs)(`div`,{className:`text-[11px] text-ink`,children:[i,i!==e.value&&(0,X.jsxs)(`code`,{className:`ml-1 text-[9px] text-ink-faint`,children:[`(`,e.value,`)`]})]}),(0,X.jsx)(`div`,{className:`mt-0.5 text-[9px] text-ink-faint`,children:Io(e.source,r)})]})]},e.name)})})]},e))]}),(0,X.jsxs)(`p`,{className:`text-[10px] text-ink-faint`,children:[r(`settings.footer`),` `,(0,X.jsx)(`code`,{children:`argus-skill --config-help`}),`.`]})]})]})]})]})]})}function Ho({sid:e,open:t,onClose:n}){let{t:r}=Z(),{data:i,isLoading:a,refetch:s}=Cr(e,t),[c,l]=(0,I.useState)(``),[u,d]=(0,I.useState)(!1),[f,p]=(0,I.useState)(``);(0,I.useEffect)(()=>{t&&i!=null&&l(i)},[i,t]);let h=async()=>{if(!u){d(!0),p(``);try{await U.setIdentity(e,c),await s(),p(r(`identity.saved`))}catch(e){p(e instanceof Error?e.message:String(e))}finally{d(!1)}}};return(0,X.jsxs)(go,{open:t,onClose:n,label:r(`identity.title`),width:`max-w-2xl`,children:[(0,X.jsx)(_o,{title:r(`identity.title`),sub:r(`identity.subtitle`)}),(0,X.jsxs)(`div`,{className:`max-h-[64vh] overflow-y-auto scroll-thin p-5`,children:[a&&(0,X.jsx)(`div`,{className:`flex justify-center py-8`,children:(0,X.jsx)(bi,{})}),a?null:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`textarea`,{value:c,onChange:e=>l(e.target.value),rows:12,className:`w-full resize-y rounded-lg border border-line bg-bg p-3 font-sans text-sm leading-relaxed text-ink outline-none focus:border-blue`,placeholder:r(`identity.placeholder`)}),(0,X.jsxs)(`div`,{className:`mt-3 flex items-center justify-between`,children:[(0,X.jsx)(`span`,{className:`text-xs text-ink-faint`,children:f}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>void h(),disabled:u||c===(i??``),title:r(`identity.save`),"aria-label":r(`identity.save`),className:`flex h-9 w-9 items-center justify-center rounded border border-blue/35 bg-blue/8 text-xs font-medium text-blue hover:border-blue-deep hover:bg-blue-deep hover:text-white disabled:opacity-40`,children:u?`…`:(0,X.jsx)(o,{icon:m})})]})]})]})]})}function Uo({sid:e,open:t,onClose:n}){let{t:r}=Z(),{data:i,isLoading:a}=wr(e,t),o=i??[];return(0,X.jsxs)(go,{open:t,onClose:n,label:r(`transcript.title`),width:`max-w-2xl`,children:[(0,X.jsx)(_o,{title:r(`transcript.title`),sub:r(`transcript.subtitle`)}),(0,X.jsxs)(`div`,{className:`max-h-[64vh] overflow-y-auto scroll-thin p-4`,children:[a&&(0,X.jsx)(`div`,{className:`flex justify-center py-8`,children:(0,X.jsx)(bi,{})}),!a&&o.length===0&&(0,X.jsx)(xi,{children:r(`transcript.empty`)}),o.map((e,t)=>{let n=e.role===`operator`;return(0,X.jsxs)(`div`,{className:`grid grid-cols-[72px_minmax(0,1fr)] border-b border-line/50 py-2.5 last:border-b-0`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`div`,{className:`font-mono text-[10px] font-semibold uppercase tracking-wide ${n?`text-ink-faint`:`text-blue-sky`}`,children:n?r(`transcript.operator`):`argus`}),(0,X.jsx)(`div`,{className:`mt-0.5 text-[9px] text-ink-faint`,children:li(e.ts)})]}),(0,X.jsx)(`div`,{className:`whitespace-pre-wrap text-sm leading-relaxed text-ink-dim`,children:e.text})]},t)})]})]})}function Wo({questions:e,backlog:t,onAnswer:n,onLocate:r}){let{t:i}=Z(),a=_t(e,t);if(!a.length)return null;let o=a[0];return(0,X.jsxs)(`div`,{className:`mb-2 flex min-h-11 items-center gap-3 rounded-md border border-gold/40 bg-gold/5 px-3 py-2`,children:[(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`div`,{className:`truncate text-xs font-medium text-gold`,children:o.title}),(0,X.jsx)(`div`,{className:`truncate text-xs text-ink-dim`,title:o.reason||o.question,children:o.reason||o.question})]}),a.length>1?(0,X.jsxs)(`span`,{className:`font-mono text-xs text-ink-faint`,children:[`+`,a.length-1]}):null,r?(0,X.jsx)(`button`,{onClick:r,className:`shrink-0 text-xs text-ink-dim hover:text-gold`,children:i(`pending.showOnMap`)}):null,(0,X.jsx)(`button`,{onClick:n,className:`shrink-0 text-xs font-medium text-gold hover:text-gold-soft`,children:i(`pending.reviewRespond`)})]})}function Go({reply:e,open:t,busy:n,onClose:r,onSubmit:i}){let{t:a}=Z(),o=(0,I.useMemo)(()=>e?.options[0]?.id??`custom`,[e]),[s,c]=(0,I.useState)(o),[l,u]=(0,I.useState)(``),[d,f]=(0,I.useState)(``);if((0,I.useEffect)(()=>{t&&(c(o),u(``),f(``))},[o,t,e?.id]),!e)return null;let p=e.options.length===0,m=e.options.find(e=>e.id===s),h=p?!!l.trim():!!(m&&(!m.requires_note||l.trim())),g=()=>{if(!n){if(!h){f(a(`decision.noteRequired`));return}f(``),i(p?`custom`:s,l.trim())}};return(0,X.jsxs)(go,{open:t,onClose:n?()=>void 0:r,label:a(`decision.operator`),width:`max-w-2xl`,children:[(0,X.jsx)(_o,{title:a(`decision.required`),sub:e.title}),(0,X.jsxs)(`div`,{className:`space-y-4 px-5 py-4`,children:[e.reason?(0,X.jsxs)(`section`,{className:`rounded-md border border-gold/30 bg-gold/5 p-3`,children:[(0,X.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-wider text-gold`,children:a(`decision.whyBlocked`)}),(0,X.jsx)(`p`,{className:`mt-1 whitespace-pre-wrap text-sm leading-relaxed text-ink`,children:e.reason})]}):null,e.evidence.length?(0,X.jsxs)(`section`,{children:[(0,X.jsx)(`div`,{className:`mb-2 text-[10px] font-semibold uppercase tracking-wider text-ink-faint`,children:a(`decision.evidence`)}),(0,X.jsx)(`div`,{className:`space-y-2`,children:e.evidence.map((e,t)=>(0,X.jsxs)(`div`,{className:`rounded border border-line/70 bg-bg/40 p-2.5`,children:[(0,X.jsx)(`div`,{className:`text-xs font-medium text-ink`,children:e.label}),e.summary?(0,X.jsx)(`div`,{className:`mt-1 text-xs text-ink-dim`,children:e.summary}):null,e.path?(0,X.jsx)(`div`,{className:`mt-1 break-all font-mono text-[10px] text-blue-sky`,children:e.path}):null]},`${e.path}:${t}`))})]}):null,(0,X.jsx)(`p`,{className:`whitespace-pre-wrap text-sm leading-relaxed text-ink`,children:e.question}),e.options.length?(0,X.jsx)(`div`,{className:`space-y-2`,children:e.options.map(e=>(0,X.jsxs)(`button`,{type:`button`,onClick:()=>{c(e.id),f(``)},disabled:n,className:`w-full rounded-md border p-3 text-left ${s===e.id?`border-blue bg-blue/5`:`border-line bg-bg/30`}`,children:[(0,X.jsx)(`div`,{className:`text-sm font-medium text-ink`,children:e.label}),(0,X.jsx)(`div`,{className:`mt-1 text-xs leading-relaxed text-ink-dim`,children:e.description})]},e.id))}):null,p||m?.requires_note||l?(0,X.jsx)(`textarea`,{"data-autofocus":!0,value:l,onChange:e=>{u(e.target.value),f(``)},onKeyDown:e=>{sa(e)||e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),g())},rows:3,disabled:n,placeholder:a(`decision.notePlaceholder`),className:`w-full resize-y rounded-lg border border-line bg-bg px-3 py-2 text-sm leading-relaxed text-ink outline-none focus:border-blue disabled:opacity-60`}):null,d?(0,X.jsx)(`p`,{role:`alert`,className:`text-xs text-err`,children:d}):null,(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,X.jsx)(`span`,{className:`text-xs text-ink-faint`,children:a(`decision.resumeHint`)}),(0,X.jsxs)(`div`,{className:`flex gap-2`,children:[(0,X.jsx)(`button`,{type:`button`,onClick:r,disabled:n,className:`rounded-md px-3 py-2 text-xs text-ink-dim hover:bg-bg disabled:opacity-50`,children:a(`decision.later`)}),(0,X.jsx)(`button`,{type:`button`,onClick:g,disabled:n,className:`rounded-md border border-blue/35 bg-blue/8 px-3 py-2 text-xs font-medium text-blue hover:border-blue-deep hover:bg-blue-deep hover:text-white disabled:opacity-50`,children:a(n?`decision.applying`:p||s===`custom`?`decision.sendAnswer`:s===`stop`?`decision.stopCampaign`:`decision.useOption`)})]})]})]})]})}function Ko({alert:e}){if(!e)return null;let t=e.tone===`block`,n=e.kind===`budget`;return(0,X.jsxs)(`div`,{className:`mx-3 mt-3 flex items-center gap-2.5 rounded-lg border px-3.5 py-2 text-[13px] ${t?`border-err/50 bg-err/10 text-err`:`border-warn/50 bg-warn/10 text-warn`}`,role:t?`alert`:`status`,children:[(0,X.jsx)(`span`,{className:`shrink-0 font-mono text-xs font-bold leading-none`,children:n?`$`:t?`!`:`i`}),(0,X.jsx)(`span`,{className:`shrink-0 text-[10px] font-semibold uppercase tracking-wide`,children:n?`budget alarm`:t?`action required`:`notice`}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,title:e.text,children:e.text})]})}function qo({html:e,title:t,className:n=``,sid:r,path:i}){return r&&i?(0,X.jsx)(Jo,{sid:r,path:i,html:e,title:t,className:n}):(0,X.jsx)(`iframe`,{title:t,srcDoc:e,sandbox:`allow-scripts`,referrerPolicy:`no-referrer`,className:`min-h-0 w-full flex-1 border-0 bg-white ${n}`})}function Jo({html:e,title:t,className:n,sid:r,path:i}){let{locale:a}=Z(),o=a===`zh-CN`,s=ce({queryKey:[`artifact-html`,r,i,e],queryFn:({signal:e})=>U.artifactPreview(r,i,e),enabled:!!(r&&i),staleTime:3e4,retry:1});return r&&i&&s.isPending?(0,X.jsx)(`div`,{className:`m-auto p-6 text-sm text-ink-dim`,role:`status`,children:o?`正在加载网页和配套资源…`:`Loading the website and its assets…`}):r&&i&&s.isError?(0,X.jsxs)(`div`,{className:`m-auto p-6 text-sm text-err`,role:`alert`,children:[o?`网页预览加载失败,请重试或下载文件。`:`Preview could not load. Retry or download the file.`,(0,X.jsx)(`button`,{type:`button`,className:`ml-3 underline`,onClick:()=>void s.refetch(),children:o?`重试`:`Retry`})]}):(0,X.jsxs)(`div`,{className:`flex min-h-0 w-full flex-1 flex-col ${n}`,children:[!!s.data?.warnings.length&&(0,X.jsx)(`p`,{className:`shrink-0 bg-warn/10 px-3 py-2 text-xs text-warn`,role:`status`,children:o?`部分配套资源无法加载,页面可能不完整。`:`Some linked assets are unavailable; the preview may be incomplete.`}),(0,X.jsx)(`iframe`,{title:t,srcDoc:s.data?.html??e,sandbox:`allow-scripts allow-downloads`,referrerPolicy:`no-referrer`,className:`min-h-0 w-full flex-1 border-0 bg-white`})]})}function Yo(e){let t=e.trim();if(!t)return``;try{return JSON.stringify(JSON.parse(t),null,2)}catch{try{return t.split(/\r?\n/).filter(Boolean).map(e=>JSON.parse(e)).map(e=>JSON.stringify(e,null,2)).join(` +`)}catch{return e}}}function Xo(e,t){let n=[],r=[],i=``,a=!1;for(let o=0;oe.some(e=>e.length>0))}function Zo({value:e}){return(0,X.jsx)(`pre`,{className:`min-h-0 flex-1 overflow-auto whitespace-pre-wrap break-words p-5 font-mono text-xs leading-6 text-ink-dim scroll-thin`,children:Yo(e)||`(empty data)`})}function Qo({value:e,delimiter:t}){let n=Xo(e,t).slice(0,200),r=n[0]??[];return(0,X.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto p-4 scroll-thin`,children:n.length?(0,X.jsxs)(`table`,{className:`w-full border-collapse text-left text-xs`,children:[(0,X.jsx)(`thead`,{children:(0,X.jsx)(`tr`,{children:r.slice(0,40).map((e,t)=>(0,X.jsx)(`th`,{className:`border border-line/60 bg-surface px-2 py-1.5 font-semibold text-ink`,children:e},t))})}),(0,X.jsx)(`tbody`,{children:n.slice(1).map((e,t)=>(0,X.jsx)(`tr`,{children:r.slice(0,40).map((t,n)=>(0,X.jsx)(`td`,{className:`border border-line/50 px-2 py-1.5 align-top text-ink-dim`,children:e[n]??``},n))},t))})]}):(0,X.jsx)(`div`,{className:`text-sm text-ink-faint`,children:`(empty table)`})})}var $o=`/assets/pdf.min-Bbvtrhlt.mjs`,es=`/assets/pdf.worker.min-CLrFZWeq.mjs`,ts=null,ns=0;function rs(){ts=null,ns+=1}function is(){if(ts)return ts;let e=new URL($o,import.meta.url),t=new URL(es,import.meta.url);ns&&(e.searchParams.set(`retry`,String(ns)),t.searchParams.set(`retry`,String(ns)));let n=oi(()=>import(e.href).then(e=>(e.GlobalWorkerOptions.workerSrc=t.href,e)),[]).catch(e=>{throw ts===n&&rs(),e});return ts=n,n}function as(e,t,n,r){let i=Math.max(1,n-32)/Math.max(1,e),a=Math.max(1,r-32)/Math.max(1,t);return Math.min(2.5,i,a)}function os({src:e,name:t,className:n=``,onPageOrientation:r,onRetry:i}){let{locale:a}=Z(),o=a===`zh-CN`,s=(0,I.useRef)(null),c=(0,I.useRef)(null),l=(0,I.useRef)(null),[u,d]=(0,I.useState)(null),[f,p]=(0,I.useState)(1),[m,h]=(0,I.useState)(1),[g,_]=(0,I.useState)({width:0,height:0}),[v,y]=(0,I.useState)(!0),[b,x]=(0,I.useState)(!1),[S,C]=(0,I.useState)(``),[w,T]=(0,I.useState)(0);(0,I.useEffect)(()=>{let e=c.current;if(!e)return;let t=()=>_({width:e.clientWidth,height:e.clientHeight});t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[]),(0,I.useEffect)(()=>{let t=!0,n=new AbortController,r=null;return d(null),p(1),h(1),l.current=null,c.current?.scrollTo(0,0),C(``),y(!0),Promise.all([fetch(e,{signal:n.signal}).then(e=>{if(!e.ok)throw Error(`PDF request failed (${e.status})`);return e.arrayBuffer()}),is()]).then(async([e,n])=>{if(!t)return;r=n.getDocument({data:new Uint8Array(e)});let i=await r.promise;t&&(d(i),y(!1))}).catch(e=>{t&&(y(!1),C(e instanceof Error?e.message:String(e)))}),()=>{t=!1,n.abort(),r?.destroy().catch(()=>{})}},[e,w]),(0,I.useEffect)(()=>{let e=s.current;if(!u||!e||g.width<=0||g.height<=0)return;let t=!1,n=null;return x(!0),C(``),u.getPage(f).then(e=>{if(t||!s.current)return;let i=e.getViewport({scale:1});r?.(i.width>i.height?`landscape`:`portrait`);let a=as(i.width,i.height,g.width,g.height),o=e.getViewport({scale:a*m}),u=document.createElement(`canvas`),d=u.getContext(`2d`,{alpha:!1});if(!d)throw Error(`Canvas rendering is unavailable`);let f=Math.min(window.devicePixelRatio||1,2);return u.width=Math.max(1,Math.floor(o.width*f)),u.height=Math.max(1,Math.floor(o.height*f)),n=e.render({canvas:u,canvasContext:d,viewport:o,transform:f===1?void 0:[f,0,0,f,0,0]}),n.promise.then(()=>{if(t||!s.current)return;let e=s.current,n=e.getContext(`2d`,{alpha:!1});if(!n)throw Error(`Canvas rendering is unavailable`);e.width=u.width,e.height=u.height,e.style.width=`${o.width}px`,e.style.height=`${o.height}px`,n.drawImage(u,0,0);let r=c.current,i=l.current;if(r&&i){let t=r.getBoundingClientRect(),n=e.getBoundingClientRect();r.scrollLeft+=n.left+i.x*n.width-t.left-r.clientWidth/2,r.scrollTop+=n.top+i.y*n.height-t.top-r.clientHeight/2,l.current=null}})}).then(()=>{t||x(!1)}).catch(e=>{t||e instanceof Error&&e.name===`RenderingCancelledException`||(x(!1),C(e instanceof Error?e.message:String(e)))}),()=>{t=!0,n?.cancel()}},[r,f,u,g.height,g.width,m]);let E=e=>{let t=c.current,n=s.current;if(t&&n&&n.clientWidth&&n.clientHeight){let e=t.getBoundingClientRect(),r=n.getBoundingClientRect();l.current={x:Math.max(0,Math.min(1,(e.left+t.clientWidth/2-r.left)/r.width)),y:Math.max(0,Math.min(1,(e.top+t.clientHeight/2-r.top)/r.height))}}h(t=>Math.max(.6,Math.min(2.2,Math.round((t+e)*100)/100)))},D=()=>{l.current=null,c.current?.scrollTo(0,0),h(1)},ee=u?.numPages??0;return(0,X.jsxs)(`div`,{className:`pdf-viewer flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden bg-bg ${n}`,"aria-busy":v||b,children:[(0,X.jsxs)(`div`,{className:`flex min-h-10 shrink-0 flex-wrap items-center gap-2 border-b border-line/70 bg-panel px-3 py-1.5 text-[11px] text-ink-dim`,children:[(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-ink`,title:t,children:t}),(0,X.jsxs)(`span`,{className:`shrink-0 font-mono tabular-nums`,children:[o?`第`:`Page`,` `,f,` / `,ee||`…`]}),(0,X.jsx)(`button`,{type:`button`,disabled:!u||f<=1,onClick:()=>{c.current?.scrollTo(0,0),l.current=null,p(e=>Math.max(1,e-1))},className:`rounded border border-line px-2 py-1 hover:border-blue/50 hover:text-ink disabled:opacity-35`,children:o?`上一页`:`Previous`}),(0,X.jsx)(`button`,{type:`button`,disabled:!u||f>=ee,onClick:()=>{c.current?.scrollTo(0,0),l.current=null,p(e=>Math.min(ee,e+1))},className:`rounded border border-line px-2 py-1 hover:border-blue/50 hover:text-ink disabled:opacity-35`,children:o?`下一页`:`Next`}),(0,X.jsx)(`button`,{type:`button`,"aria-label":o?`缩小`:`Zoom out`,disabled:!u||m<=.6,onClick:()=>E(-.15),className:`flex h-7 w-7 items-center justify-center rounded border border-line hover:border-blue/50 hover:text-ink`,children:`−`}),(0,X.jsxs)(`span`,{className:`w-10 text-center font-mono tabular-nums`,children:[Math.round(m*100),`%`]}),(0,X.jsx)(`button`,{type:`button`,"aria-label":o?`放大`:`Zoom in`,disabled:!u||m>=2.2,onClick:()=>E(.15),className:`flex h-7 w-7 items-center justify-center rounded border border-line hover:border-blue/50 hover:text-ink`,children:`+`}),(0,X.jsx)(`button`,{type:`button`,disabled:!u,onClick:D,className:`rounded border border-line px-2 py-1 hover:border-blue/50 hover:text-ink disabled:opacity-35`,children:o?`适合页面`:`Fit page`})]}),(0,X.jsxs)(`div`,{ref:c,className:`pdf-scroll-viewport relative min-h-0 min-w-0 flex-1 overflow-auto bg-surface/60 p-4 scroll-thin`,tabIndex:0,"aria-label":o?`PDF 页面滚动区域`:`PDF page scroll area`,children:[v?(0,X.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center`,children:(0,X.jsx)(bi,{})}):null,S?(0,X.jsxs)(`div`,{role:`alert`,className:`m-auto max-w-sm rounded border border-err/35 bg-err/5 p-4 text-center text-sm text-err`,children:[(0,X.jsx)(`p`,{children:o?`PDF 暂时无法预览`:`PDF preview is temporarily unavailable`}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>{rs(),i?i():T(e=>e+1)},className:`mt-3 rounded border border-line bg-panel px-3 py-1.5 text-ink hover:border-blue/50`,children:o?`重试预览`:`Retry preview`}),(0,X.jsxs)(`details`,{className:`mt-3 break-words text-xs text-ink-dim`,children:[(0,X.jsx)(`summary`,{children:o?`错误详情`:`Error details`}),S]})]}):null,S?null:(0,X.jsx)(`div`,{className:`pdf-page-stage flex min-h-full min-w-full w-max items-center justify-center`,children:(0,X.jsx)(`canvas`,{ref:s,role:`img`,"aria-label":`${t} · ${o?`第`:`page`} ${f}`,className:`block max-w-none shrink-0 bg-white shadow-xl`})})]})]})}function ss(e,t){return typeof e==`string`?e.trim().slice(0,t):``}function cs(e,t){return ss(e,t*2).replace(/!?(?:\[([^\]]+)\])\([^)]+\)/g,`$1`).replace(/[*_`#]/g,``).replace(/\s+/g,` `).trim().slice(0,t)}function ls(e){let t=ss(e.completionId,300);if(!t)return null;let n=ss(e.path,1e3);return{deliveryId:t,title:cs(e.title,240)||`已完成的任务`,summary:cs(e.summary,500),...n?{path:n}:{}}}function us(){return typeof window>`u`||window.parent===window?null:window.parent}function ds(e){if(!e||typeof e!=`object`||Array.isArray(e))return null;let t=e,n=ss(t.deliveryId,300);if(!n)return null;let r=ss(t.path,1e3);return{deliveryId:n,title:ss(t.title,240)||`Argus`,summary:ss(t.summary,1e3),...r?{path:r}:{}}}function fs(e){let t=ds(e),n=us();return!t||!n?Promise.resolve(!1):(n.postMessage({type:`argus:notify-completion`,payload:t},`*`),Promise.resolve(!0))}function ps(e){let t=us();t&&t.postMessage({type:`argus:large-preview`,payload:e},`*`)}function ms(e){let t=us();if(!t)return()=>void 0;let n=n=>{if(n.source!==t||n.data?.type!==`argus:open-delivery`)return;let r=ds(n.data.payload);r&&e(r)};return window.addEventListener(`message`,n),()=>window.removeEventListener(`message`,n)}function hs(e){let t=us();if(!t)return()=>void 0;let n=n=>{n.source===t&&n.data?.type===`argus:new-chat`&&e()};return window.addEventListener(`message`,n),()=>window.removeEventListener(`message`,n)}function gs(){if(typeof document>`u`)return()=>void 0;let e=us();if(!e)return()=>void 0;let t=t=>{if(t.defaultPrevented||t.button!==0&&t.button!==1)return;let n=t.target instanceof Element?t.target.closest(`a[href]`):null;if(!n)return;let r;try{r=new URL(n.href,window.location.href)}catch{return}r.origin===window.location.origin||![`http:`,`https:`].includes(r.protocol)||(t.preventDefault(),e.postMessage({type:`argus:open-external`,payload:r.toString()},`*`))},n=t=>{if(t.defaultPrevented||t.isComposing||t.altKey||t.shiftKey||!(t.ctrlKey||t.metaKey))return;let n=t.key===`,`?`argus:show-setup`:t.key.toLowerCase()===`n`?`argus:request-new-chat`:null;n&&(t.preventDefault(),e.postMessage({type:n},`*`))},r=()=>e.postMessage({type:`argus:cockpit-interaction`},`*`);return document.addEventListener(`click`,t,!0),document.addEventListener(`auxclick`,t,!0),window.addEventListener(`keydown`,n),document.addEventListener(`pointerdown`,r,{passive:!0}),()=>{document.removeEventListener(`click`,t,!0),document.removeEventListener(`auxclick`,t,!0),window.removeEventListener(`keydown`,n),document.removeEventListener(`pointerdown`,r)}}function _s(e){return e.kind===`markdown`||e.mime?.split(`;`,1)[0].trim().toLowerCase()===`text/markdown`||/\.(?:md|markdown)$/i.test(e.name||e.path||``)}function vs({sid:e,path:t,onClose:n,delivery:r,deliveries:i=[],onSelectDelivery:a,onSelectPath:o,reviewActivity:s}){let{t:c,locale:l}=Z(),u=l===`zh-CN`,d=r?Qr(r):[],f=Er(e,t),p=f.data,m=p?_s(p):!1,[h,g]=(0,I.useState)(null),[_,v]=(0,I.useState)(``),[y,b]=(0,I.useState)(0),[x,S]=(0,I.useState)(!1),[C,w]=(0,I.useState)(!1),[T,E]=(0,I.useState)(`portrait`),D=p?.kind===`pdf`||t?.toLowerCase().endsWith(`.pdf`)===!0,ee=!!(t&&/(?:^|[\\/])REVIEW\.md$/i.test(t));(0,I.useEffect)(()=>{if(!(!t||!D))return ps(!0),()=>ps(!1)},[t,D]),(0,I.useEffect)(()=>{if(E(`portrait`),g(null),v(``),!e||!t||!p||![`image`,`pdf`,`audio`,`video`].includes(p.kind))return;let n=!0,r=``,i=new AbortController;return U.artifactBlob(e,t,!1,i.signal).then(e=>{n&&(r=URL.createObjectURL(e),g(r))},e=>n&&v(e.message)),()=>{n=!1,i.abort(),r&&URL.revokeObjectURL(r)}},[e,t,p?.kind,y]);let O=async(n=!1)=>{if(!(!e||!t||!p)){S(!0),v(``);try{let r=n?await U.artifactBundle(e,t):await U.artifactBlob(e,t,!0),i=URL.createObjectURL(r),a=document.createElement(`a`);a.href=i,a.download=n?`${p.name.replace(/\.html?$/i,``)}-website.zip`:p.name,document.body.appendChild(a),a.click(),a.remove(),window.setTimeout(()=>URL.revokeObjectURL(i),0)}catch(e){v(e.message)}finally{S(!1)}}};return(0,X.jsxs)(go,{open:!!(t||r),onClose:n,label:r?u?`交付成果`:`Delivery`:c(`artifact.preview`),width:r?C?`max-w-none`:`max-w-6xl`:D?`max-w-none`:`max-w-5xl`,viewport:r?C:D,showClose:!1,style:r?{height:C?`100dvh`:`min(92dvh, 960px)`,display:`flex`,flexDirection:`column`,overflow:`hidden`}:D?{maxWidth:T===`portrait`?`min(96vw, 76dvh)`:`min(96vw, 145dvh)`}:void 0,children:[r&&!C&&(0,X.jsxs)(`header`,{className:`delivery-header`,children:[(0,X.jsxs)(`div`,{className:`delivery-heading`,children:[(0,X.jsx)(`span`,{className:`delivery-mark`,children:(0,X.jsx)(eo,{size:22})}),(0,X.jsxs)(`div`,{children:[(0,X.jsxs)(`p`,{children:[`DELIVERY · `,u?`交付成果`:`Your results`]}),(0,X.jsx)(`h2`,{children:u?`成果文件`:`Result files`})]}),(0,X.jsxs)(`button`,{type:`button`,onClick:n,className:`delivery-return`,"aria-label":u?`关闭交付弹窗`:`Close delivery`,children:[u?`返回地图`:`Back to map`,` ×`]})]}),i.length>1?(0,X.jsx)(`select`,{"aria-label":u?`选择交付任务`:`Choose delivery`,className:`delivery-task-select`,value:r.delivery_id,onChange:e=>{let t=i.find(t=>t.delivery_id===e.target.value);t&&a?.(t)},children:i.map(e=>(0,X.jsx)(`option`,{value:e.delivery_id,children:e.title},e.delivery_id))}):(0,X.jsx)(`p`,{className:`delivery-task-title`,title:r.title,children:r.title}),(0,X.jsxs)(`div`,{className:`delivery-facts`,children:[(0,X.jsxs)(`span`,{children:[(0,X.jsx)(Ua,{size:13}),[`done`,`passed`,`approved`,`accepted`].includes(r.review_status)?u?`任务已完成`:`Task completed`:u?`可查看`:`Available`]}),(0,X.jsxs)(`span`,{children:[d.length,` `,u?`个文件`:`files`]})]}),r.summary&&(0,X.jsxs)(`details`,{className:`delivery-summary`,children:[(0,X.jsx)(`summary`,{children:u?`查看成果说明`:`Result summary`}),(0,X.jsx)(`p`,{children:ei(r.summary)})]})]}),!C&&!!d.length&&(0,X.jsx)(`nav`,{className:`delivery-files`,"aria-label":u?`交付文件`:`Delivery files`,children:d.map(e=>(0,X.jsxs)(`button`,{type:`button`,"aria-pressed":t===e.path,onClick:()=>o?.(e.path),title:e.path,children:[(0,X.jsx)(`span`,{children:e.path.split(`/`).at(-1)}),r?.primary_target?.path===e.path&&(0,X.jsx)(`small`,{children:u?`主要成果`:`Main result`})]},e.path))}),(0,X.jsxs)(`div`,{className:`flex shrink-0 items-start gap-2 border-b border-line px-4 py-3 sm:px-5 ${t?``:`hidden`}`,children:[(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`h2`,{className:`truncate font-mono text-sm font-semibold text-ink`,title:p?.storage_path??p?.path??t??``,children:p?.name??t??c(`artifact.title`)}),(0,X.jsx)(`p`,{className:`mt-0.5 truncate text-[11px] text-ink-faint`,children:p?`${p.kind} · ${fi(p.size)} · ${p.mime}`:c(`artifact.approvedEvidence`)})]}),r&&(0,X.jsx)(`button`,{type:`button`,onClick:()=>w(e=>!e),"aria-label":C?u?`收起预览`:`Exit full screen`:u?`全屏预览`:`Full screen preview`,title:u?`切换全屏预览`:`Toggle full screen preview`,className:`shrink-0 rounded-md border border-line p-2 text-ink-dim`,children:C?(0,X.jsx)($a,{size:16}):(0,X.jsx)(Qa,{size:16})}),p?.kind===`html`&&(0,X.jsx)(`button`,{type:`button`,disabled:x,onClick:()=>void O(!0),className:`shrink-0 rounded-md border border-blue-deep/60 bg-blue-deep/10 px-3 py-2 text-xs text-blue-sky disabled:opacity-50`,children:u?`下载完整网页`:`Download website`}),(0,X.jsx)(`button`,{type:`button`,disabled:!p||x,onClick:()=>void O(),className:`rounded-md border border-blue-deep/60 bg-blue-deep/10 px-3 py-1.5 text-xs text-blue-sky transition-colors hover:bg-blue-deep/20 disabled:cursor-wait disabled:opacity-50`,children:c(x?`artifact.downloading`:`artifact.download`)}),(!r||C)&&(0,X.jsx)(`button`,{type:`button`,"aria-label":c(`artifact.close`),onClick:n,className:`rounded-md px-2 py-1 text-lg leading-none text-ink-faint hover:bg-surface hover:text-ink`,children:`×`})]}),(0,X.jsxs)(`div`,{className:r?`flex min-h-0 flex-1 flex-col overflow-auto bg-bg/40 p-2 sm:p-3`:D?`flex min-h-0 flex-1 flex-col overflow-hidden bg-bg/40`:`flex min-h-64 max-h-[72vh] flex-col overflow-x-hidden overflow-y-auto bg-bg/40 p-3 scroll-thin sm:p-4`,children:[!t&&r&&(0,X.jsx)(`p`,{className:`m-auto p-6 text-sm text-ink-dim`,children:ei(r.summary)}),f.isLoading?(0,X.jsx)(`div`,{className:`m-auto`,children:(0,X.jsx)(bi,{})}):null,f.isError?(0,X.jsxs)(`div`,{className:`m-auto text-sm text-err`,children:[c(`artifact.unavailable`),` · `,f.error.message]}):null,p?.why&&!D&&!r?(0,X.jsxs)(`div`,{className:`mb-3 rounded-md border border-line bg-surface px-3 py-2 text-xs text-ink-dim`,children:[(0,X.jsx)(`span`,{className:`mr-1 text-ink-faint`,children:`Reviewer:`}),p.why]}):null,p?.kind===`text`&&!m?(0,X.jsxs)(`pre`,{className:`min-h-52 overflow-x-hidden overflow-y-auto whitespace-pre-wrap break-words rounded-lg border border-line bg-bg p-4 font-mono text-xs leading-relaxed text-ink-dim scroll-thin`,children:[p.preview||c(`artifact.empty`),p.truncated?`\n\n… ${c(`artifact.truncated`)}`:``]}):null,p&&m?(0,X.jsxs)(`div`,{className:`min-h-52 overflow-auto rounded-lg border border-line bg-bg p-4 text-sm text-ink-dim scroll-thin`,children:[ee&&(0,X.jsxs)(`div`,{className:`mb-4 border-b border-line pb-3 text-xs leading-5 text-ink-faint`,role:`status`,children:[s===`revising`?u?`正在根据这份意见修改论文,修改后的版本尚待复审。`:`The paper is being revised against this opinion; the revised version awaits review.`:s===`reviewing`?u?`Reviewer 正在更新本轮审稿意见,内容会自动刷新。`:`The Reviewer is updating this round’s opinion. This file refreshes automatically.`:u?`这是最近保存的审稿意见,文件更新后会自动刷新。`:`This is the latest saved review. Changes to this file appear automatically.`,p.mtime!=null&&(0,X.jsxs)(`div`,{children:[u?`最近更新:`:`Last updated: `,new Date(p.mtime*1e3).toLocaleString(l)]})]}),(0,X.jsx)(ki,{artifacts:d.map(e=>({path:e.path})),onOpenArtifact:o,children:p.preview||c(`artifact.empty`)})]}):null,p?.kind===`json`?(0,X.jsx)(Zo,{value:p.preview||``}):null,p?.kind===`table`?(0,X.jsx)(Qo,{value:p.preview||``,delimiter:p.name.endsWith(`.tsv`)?` `:`,`}):null,p?.kind===`html`?(0,X.jsx)(`div`,{className:`flex flex-1 overflow-hidden rounded-lg border border-line ${r?`min-h-0`:`min-h-[60vh]`}`,children:(0,X.jsx)(qo,{sid:e,path:t,html:p.preview||``,title:`HTML preview: ${p.name}`})}):null,p?.kind===`image`&&h?(0,X.jsx)(`div`,{className:`flex min-h-64 flex-1 items-center justify-center rounded border border-line bg-bg/50`,children:(0,X.jsx)(`img`,{src:h,alt:p.why||p.name,className:`max-h-[62vh] max-w-full object-contain`})}):null,p?.kind===`pdf`&&h?(0,X.jsx)(os,{src:h,name:p.name,className:`min-h-0 overflow-hidden`,onPageOrientation:E,onRetry:()=>b(e=>e+1)}):null,p?.kind===`audio`&&h?(0,X.jsx)(`div`,{className:`m-auto w-full max-w-xl`,children:(0,X.jsx)(`audio`,{controls:!0,preload:`metadata`,src:h,className:`w-full`})}):null,p?.kind===`video`&&h?(0,X.jsx)(`div`,{className:`flex min-h-64 flex-1 items-center justify-center rounded border border-line bg-black`,children:(0,X.jsx)(`video`,{controls:!0,playsInline:!0,preload:`metadata`,src:h,className:`max-h-[62vh] max-w-full`})}):null,p&&[`image`,`pdf`,`audio`,`video`].includes(p.kind)&&!h&&!_?(0,X.jsx)(`div`,{className:`m-auto`,children:(0,X.jsx)(bi,{})}):null,p?.kind===`binary`?(0,X.jsxs)(`div`,{className:`m-auto max-w-md text-center`,children:[(0,X.jsx)(`div`,{className:`text-3xl text-ink-faint`,children:`◇`}),(0,X.jsx)(`p`,{className:`mt-2 text-sm text-ink-dim`,children:c(`artifact.noPreview`)}),(0,X.jsx)(`p`,{className:`mt-1 text-xs text-ink-faint`,children:c(`artifact.downloadHint`)})]}):null,_?(0,X.jsx)(`div`,{className:`mt-3 text-center text-xs text-err`,children:_}):null]})]})}var ys=`__argus_live_progress__`,bs=new Set([`framed`,`grounding`,`queued`,`running`,`in_progress`,`working`]),xs=new Set([`complete`,`completed`,`done`,`success`]);function Ss(e){return xs.has(String(e?.mission.status||``).toLowerCase())}function Cs(e){return(e??[]).filter(e=>e.source===`manager_live`)}function ws(e){return Cs(e).filter(e=>e.exists)[0]??null}function Ts(e){let t=e??[],n={markdown:0,pdf:1,html:2,text:3,table:4,json:5,image:6,video:7,audio:8,binary:9},r=t.filter(e=>e.exists&&e.source===`delivery`),i=t.filter(e=>e.exists&&e.source===`manager_live`),a=t.filter(e=>e.exists&&e.source!==`manager_live`&&e.source!==`delivery`);return a.length||r.length?[...r,...[...a].sort((e,t)=>(n[e.kind]??99)-(n[t.kind]??99)),...i]:i}function Es(e){return Ts(e).find(e=>e.exists)??null}function Ds(e){let t=Ts(e);return t.find(e=>e.source===`delivery`)??t.find(e=>e.source!==`manager_live`)??t[0]??null}function Os(e){let t=e.path.split(`/`);return t[t.length-1]||e.path}function ks(e,t){if(e){let n=String(e.mission.status||``).toLowerCase();if(bs.has(n))return ys;let r=e.delivery?.primary_target?.path;if(r)return r;if(Ss(e))return Ds(t)?.path??`__argus_live_progress__`;let i=ws(t);return i?i.path:ys}return Es(t)?.path??``}var As={manager:`Manager`,planner:`Planner`,engineer:`Engineer`,reviewer:`Reviewer`};function js(e){let t=String(e.agent_layer??e.actor??``);if(t===`main`)return`engineer`;if(t)return t;let n=String(e.type??``);return n.startsWith(`round.review`)||n.startsWith(`reviewer`)?`reviewer`:n.startsWith(`life.planner`)?`planner`:n.startsWith(`life.manager`)||n.startsWith(`manager`)?`manager`:n.startsWith(`engineer`)||n.startsWith(`round.`)?`engineer`:``}function Ms(e,t=[]){if(Ss(e))return null;let n=String(e?.active_role??``);if(!n)return null;let r=e?.roles.find(e=>e.role===n),i=``;for(let e=t.length-1;e>=0;--e){let r=t[e];if(js(r)!==n||String(r.kind??``)===`reasoning`)continue;let a=String(r.text??r.action_summary??``).trim();if(!(!a||a.startsWith(`{`))){i=a.split(` +`)[0].slice(0,240);break}}return{role:n,roleLabel:As[n]??n,label:r?.label||`Working`,detail:i}}function Ns(e){let t=e.dag.find(e=>[`running`,`in_progress`,`claimed`].includes(e.status)),n=e.dag.filter(e=>[`done`,`completed`].includes(e.status)).length,r=e.dag.length,i=`Awaiting Planner`;return e.mission.status===`idle`?i=`Ready for a new mission`:e.mission.status===`complete`&&(i=`Mission complete`),{title:Cn(t?.title||e.mission.title||i),dagProgress:r>0?`${n} / ${r} complete`:`Not planned`}}function Ps({view:e,liveStatus:t,artifacts:n=[],onOpenArtifact:r}){let{t:i}=Z(),a=Ns(e),o=[...n].filter(e=>e.exists&&e.source!==`manager_live`).sort((e,t)=>Number(t.mtime??0)-Number(e.mtime??0)).slice(0,4),s=e.timeline.slice(-6).reverse(),c=e.delivery,l=e=>e===`done`?`text-ok`:[`running`,`in_progress`,`claimed`].includes(e)?`text-blue-sky`:[`failed`,`blocked`,`rejected`].includes(e)?`text-err`:`text-ink-faint`;return(0,X.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-5 text-sm text-ink-dim scroll-thin`,children:[c?(0,X.jsxs)(`section`,{className:`mb-4 rounded-lg border border-ok/35 bg-ok/10 p-4`,children:[(0,X.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-[0.14em] text-ok`,children:c.kind===`submission_certified`?`交付已认证`:`已完成`}),(0,X.jsx)(`h3`,{className:`mt-2 text-base font-semibold leading-snug text-ink`,children:c.title}),c.summary?(0,X.jsx)(`p`,{className:`mt-2 text-xs leading-5 text-ink-dim`,children:c.summary}):null,c.primary_target?(0,X.jsxs)(`button`,{type:`button`,onClick:()=>r(c.primary_target.path),title:n.find(e=>e.path===c.primary_target.path)?.storage_path||c.primary_target.path,className:`mt-3 rounded border border-ok/40 bg-panel px-2.5 py-1.5 font-mono text-[10px] text-ok hover:border-ok`,children:[`打开成果 · `,c.primary_target.label||c.primary_target.path]}):null]}):null,(0,X.jsxs)(`section`,{className:`rounded-lg border border-blue-deep/30 bg-blue-deep/10 p-4`,children:[(0,X.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-[0.14em] text-blue-sky`,children:i(`research.currentWork`)}),(0,X.jsx)(`h3`,{className:`mt-2 text-base font-semibold leading-snug text-ink`,children:a.title}),t?.detail?(0,X.jsx)(`p`,{className:`mt-2 leading-6 text-ink-dim`,children:t.detail}):null,(0,X.jsxs)(`div`,{className:`mt-3 grid grid-cols-2 gap-3 text-xs`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`span`,{className:`text-ink-faint`,children:i(`mission.stage`)}),(0,X.jsx)(`div`,{className:`mt-1 font-medium capitalize text-blue-sky`,children:e.stage.label||e.stage.id||`—`})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`span`,{className:`text-ink-faint`,children:i(`mission.campaign`)}),(0,X.jsx)(`div`,{className:`mt-1 font-mono text-ink`,children:wn(e.mission.campaign_elapsed_seconds)})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`span`,{className:`text-ink-faint`,children:i(`mission.round`)}),(0,X.jsxs)(`div`,{className:`mt-1 font-mono text-ink`,children:[e.round.current||`—`,e.round.max?` / ${e.round.max}`:``]})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`span`,{className:`text-ink-faint`,children:i(`research.dagProgress`)}),(0,X.jsx)(`div`,{className:`mt-1 font-mono text-ink`,children:a.dagProgress})]})]})]}),(0,X.jsxs)(`section`,{className:`mt-5`,children:[(0,X.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-[0.14em] text-ink-faint`,children:i(`mission.researchDag`)}),(0,X.jsx)(`div`,{className:`mt-2 space-y-2`,children:e.dag.map(e=>(0,X.jsx)(`div`,{className:`rounded-md border border-line/60 bg-panel px-3 py-2.5`,children:(0,X.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,X.jsx)(`span`,{className:`mt-0.5 shrink-0 font-mono text-xs ${l(e.status)}`,children:e.status===`done`?`✓`:[`running`,`in_progress`,`claimed`].includes(e.status)?`●`:`○`}),(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`div`,{className:`text-xs font-medium leading-5 text-ink`,children:e.title}),(0,X.jsx)(`div`,{className:`mt-0.5 font-mono text-[10px] ${l(e.status)}`,children:e.status})]})]})},e.id))})]}),o.length?(0,X.jsxs)(`section`,{className:`mt-5`,children:[(0,X.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-[0.14em] text-ink-faint`,children:i(`research.verifiedOutputs`)}),(0,X.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:o.map(e=>(0,X.jsxs)(`button`,{type:`button`,onClick:()=>r(e.path),title:e.storage_path||e.path,className:`rounded border border-line/70 bg-panel px-2.5 py-1.5 font-mono text-[10px] text-blue-sky hover:border-blue/60`,children:[Os(e),` ↗`]},e.path))})]}):null,s.length?(0,X.jsxs)(`section`,{className:`mt-5`,children:[(0,X.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-[0.14em] text-ink-faint`,children:i(`research.recentMilestones`)}),(0,X.jsx)(`div`,{className:`mt-2 space-y-2 border-l border-line/70 pl-3`,children:s.map(e=>(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`div`,{className:`text-xs font-medium text-ink`,children:e.title}),e.detail?(0,X.jsx)(`div`,{className:`mt-0.5 line-clamp-2 text-xs leading-5 text-ink-faint`,children:e.detail}):null]},e.id))})]}):null]})}function Fs({sid:e,artifacts:t,error:n=!1,onExpand:r,onOpenFile:i,className:a=``,embedded:s=!1,onCollapse:c,missionView:l,activityEvents:u=[],requestedPath:d,requestedPathToken:f}){let{t:p,locale:m}=Z(),h=(0,I.useMemo)(()=>Ts(t),[t]),g=(0,I.useMemo)(()=>Es(t),[t]),_=Ss(l),v=(0,I.useMemo)(()=>{if(!_)return null;let e=l?.delivery?.primary_target?.path;return h.find(t=>t.path===e&&t.exists)??Ds(t)},[t,_,l?.delivery?.primary_target?.path,h]),[y,b]=(0,I.useState)(null);(0,I.useEffect)(()=>{b(_&&v?v.path:null)},[_,v?.path,l?.mission.id,e]),(0,I.useEffect)(()=>{if(!d)return;let e=h.find(e=>e.path===d&&e.exists);e&&b(e.path)},[h,d,f]);let S=e=>{b(e),e!==`__argus_live_progress__`&&i?.()},C=y??ks(l,t),w=C===ys,T=w?null:h.find(e=>e.path===C)??(_?v:g),E=Er(e,T?.exists?T.path:null,T?.mtime??null),D=E.data,ee=D?_s(D):!1,[O,te]=(0,I.useState)(null),[ne,k]=(0,I.useState)(``),[re,A]=(0,I.useState)(!1),[j,ie]=(0,I.useState)(``),ae=(0,I.useMemo)(()=>Ms(l,u),[u,l]);(0,I.useEffect)(()=>{if(te(null),k(``),!e||!T||!D||![`image`,`pdf`,`audio`,`video`].includes(D.kind))return;let t=!0,n=``,r=new AbortController;return U.artifactBlob(e,T.path,!1,r.signal).then(e=>{t&&(n=URL.createObjectURL(e),te(n))},e=>t&&k(e.message)),()=>{t=!1,r.abort(),n&&URL.revokeObjectURL(n)}},[e,T?.path,D?.kind,D?.mtime]);let M=l?.delivery??null,oe=M?.primary_target?.path??``,se=!!(_&&!w&&T&&(T.source===`delivery`||T.path===oe)),N=m===`zh-CN`?M?.kind===`submission_certified`?`交付已认证`:`已完成`:M?.kind===`submission_certified`?`Certified delivery`:`Delivered result`,ce=se?N:w?p(`research.liveProgress`):h[0]?.group_title||p(`research.artifact`),le=async()=>{if(!(!e||!T)){A(!0),ie(``);try{let t=await U.artifactBlob(e,T.path,!0),n=URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=T.name,document.body.appendChild(r),r.click(),r.remove(),window.setTimeout(()=>URL.revokeObjectURL(n),0)}catch(e){ie(e.message)}finally{A(!1)}}};return(0,X.jsxs)(`section`,{className:`glass-panel glass-panel--side flex min-h-0 flex-col overflow-hidden ${s?``:`rounded-lg border`} ${a}`,"aria-label":p(`research.canvas`),children:[(0,X.jsxs)(`header`,{className:`flex h-12 shrink-0 items-center gap-3 border-b border-line/50 bg-panel px-4`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 shrink-0 items-center gap-2`,children:[(0,X.jsx)(`span`,{className:`h-2 w-2 rounded-full ${se?`bg-ok`:`animate-pulse bg-blue`}`}),(0,X.jsx)(`h2`,{className:`max-w-24 truncate text-sm font-semibold text-ink sm:max-w-48`,children:ce})]}),l||h.length>0?(0,X.jsxs)(`label`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`span`,{className:`sr-only`,children:p(`research.previewArtifact`)}),(0,X.jsxs)(`select`,{value:w?ys:T?.path??``,onChange:e=>S(e.target.value),title:w?p(`research.liveProgress`):T?.storage_path||T?.path,className:`h-8 w-full min-w-0 max-w-64 truncate rounded-md border border-line/50 bg-bg px-2 font-mono text-xs text-ink-dim outline-none focus:border-blue/60`,children:[l?(0,X.jsx)(`option`,{value:ys,children:p(`research.liveProgress`)}):null,h.map(e=>(0,X.jsxs)(`option`,{value:e.path,disabled:!e.exists,title:e.storage_path||e.path,children:[e.source===`delivery`?`交付 · `:e.source===`manager_live`?`Checkpoint · `:``,Os(e),e.exists?``:` · pending`]},e.path))]})]}):(0,X.jsx)(`div`,{className:`flex-1`}),(0,X.jsx)(`div`,{className:`shrink-0`,children:T?(0,X.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,X.jsx)(`button`,{type:`button`,onClick:()=>void le(),disabled:re||!T.exists,title:p(`artifact.download`),"aria-label":p(`artifact.download`),className:`flex h-7 w-7 items-center justify-center rounded-md text-ink-faint hover:bg-surface hover:text-ink disabled:opacity-40`,children:(0,X.jsx)(`svg`,{viewBox:`0 0 16 16`,"aria-hidden":`true`,className:`h-4 w-4`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.25`,children:(0,X.jsx)(`path`,{d:`M8 2.25v7.5M5.25 7.5 8 10.25 10.75 7.5M3 13.25h10`})})}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>r(T.path),title:p(`research.openLarge`),"aria-label":p(`research.openLarge`),className:`flex h-7 w-7 items-center justify-center rounded-md text-ink-faint hover:bg-surface hover:text-ink`,children:(0,X.jsx)(`svg`,{viewBox:`0 0 16 16`,"aria-hidden":`true`,className:`h-4 w-4`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.25`,children:(0,X.jsx)(`path`,{d:`M6 3H3v3M10 3h3v3M6 13H3v-3M10 13h3v-3`})})})]}):null}),c?(0,X.jsx)(`button`,{type:`button`,onClick:c,"aria-label":p(`research.collapse`),title:p(`research.collapse`),className:`hidden h-8 w-8 shrink-0 items-center justify-center rounded-md border border-line/50 bg-bg/40 text-ink-faint hover:border-blue/50 hover:text-ink lg:flex`,children:(0,X.jsx)(o,{icon:x,className:`h-3.5 w-3.5`})}):null]}),ae?(0,X.jsxs)(`div`,{className:`shrink-0 border-b border-line/50 bg-blue-deep/10 px-4 py-3`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2 text-xs`,children:[(0,X.jsx)(`span`,{"data-role-dot":ae.role,className:`h-2 w-2 shrink-0 animate-pulse rounded-full motion-reduce:animate-none`,style:{background:W.role[ae.role]??W.inkFaint},"aria-hidden":`true`}),(0,X.jsx)(`span`,{className:`font-semibold text-ink`,children:ae.roleLabel}),(0,X.jsx)(`span`,{className:`text-blue-sky`,children:p(`mission.active`)}),(0,X.jsxs)(`span`,{className:`truncate text-ink-faint`,children:[`· `,ae.label]})]}),ae.detail?(0,X.jsx)(`p`,{className:`mt-1 line-clamp-2 text-xs leading-5 text-ink-dim`,children:ae.detail}):null]}):null,(0,X.jsxs)(`div`,{className:`relative flex min-h-0 flex-1 flex-col bg-bg`,children:[w&&l?(0,X.jsx)(Ps,{view:l,liveStatus:ae,artifacts:t,onOpenArtifact:S}):null,!w&&n?(0,X.jsx)(`div`,{className:`m-auto max-w-sm px-6 text-center text-sm text-warn`,children:p(`research.unavailable`)}):null,!w&&!n&&h.length===0?(0,X.jsxs)(`div`,{className:`m-auto max-w-sm px-8 text-center`,children:[(0,X.jsx)(`div`,{className:`text-3xl text-ink-faint`,children:`◇`}),(0,X.jsx)(`h3`,{className:`mt-3 text-xs text-ink-faint`,children:p(`research.noPreview`)})]}):null,!w&&!n&&h.length>0&&!T?(0,X.jsxs)(`div`,{className:`m-auto max-w-sm px-8 text-center`,children:[(0,X.jsx)(bi,{}),(0,X.jsx)(`p`,{className:`mt-3 text-xs text-ink-faint`,children:p(`research.waiting`)})]}):null,T&&!T.exists?(0,X.jsxs)(`div`,{className:`m-auto max-w-sm px-8 text-center`,children:[(0,X.jsx)(bi,{}),(0,X.jsx)(`p`,{className:`mt-3 text-xs text-ink-faint`,children:p(`research.updating`)})]}):null,T?.exists&&E.isLoading?(0,X.jsx)(`div`,{className:`m-auto`,children:(0,X.jsx)(bi,{})}):null,T?.exists&&E.isError?(0,X.jsxs)(`div`,{className:`m-auto px-6 text-center text-sm text-err`,children:[p(`artifact.unavailable`),` · `,E.error.message]}):null,D?.kind===`text`&&!ee?(0,X.jsxs)(`pre`,{className:`min-h-0 flex-1 overflow-x-hidden overflow-y-auto whitespace-pre-wrap break-words p-5 font-mono text-xs leading-6 text-ink-dim scroll-thin`,children:[D.preview||`(empty file)`,D.truncated?` + +… live preview truncated · expand to inspect the complete file`:``]}):null,D&&ee?(0,X.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto p-5 text-sm text-ink-dim scroll-thin`,children:(0,X.jsx)(ki,{artifacts:t,onOpenArtifact:S,children:D.preview||`(empty file)`})}):null,D?.kind===`json`?(0,X.jsx)(Zo,{value:D.preview||``}):null,D?.kind===`table`?(0,X.jsx)(Qo,{value:D.preview||``,delimiter:D.name.endsWith(`.tsv`)?` `:`,`}):null,D?.kind===`html`&&!D.truncated?(0,X.jsx)(qo,{sid:e,path:D.path,html:D.preview||``,title:`Live HTML preview: ${D.name}`}):null,D?.kind===`html`&&D.truncated?(0,X.jsx)(`div`,{className:`m-auto max-w-sm px-8 text-center text-sm text-warn`,children:p(`artifact.htmlTooLarge`)}):null,D?.kind===`image`&&O?(0,X.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center overflow-hidden p-4`,children:(0,X.jsx)(`img`,{src:O,alt:D.why||D.name,className:`max-h-full max-w-full object-contain`})}):null,D?.kind===`pdf`&&O?(0,X.jsx)(os,{src:O,name:D.name}):null,D?.kind===`audio`&&O?(0,X.jsx)(`div`,{className:`m-auto w-full max-w-xl px-6`,children:(0,X.jsx)(`audio`,{controls:!0,preload:`metadata`,src:O,className:`w-full`})}):null,D?.kind===`video`&&O?(0,X.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center overflow-hidden bg-black p-2`,children:(0,X.jsx)(`video`,{controls:!0,playsInline:!0,preload:`metadata`,src:O,className:`max-h-full max-w-full`})}):null,D?.kind===`binary`?(0,X.jsx)(`div`,{className:`m-auto max-w-sm px-8 text-center text-sm text-ink-dim`,children:p(`research.fileUnavailable`)}):null,D&&[`image`,`pdf`,`audio`,`video`].includes(D.kind)&&!O&&!ne?(0,X.jsx)(`div`,{className:`m-auto`,children:(0,X.jsx)(bi,{})}):null,ne?(0,X.jsx)(`div`,{className:`m-auto px-6 text-center text-sm text-err`,children:ne}):null]}),w?(0,X.jsxs)(`footer`,{className:`flex h-9 items-center gap-2 border-t border-line px-4 font-mono text-xs text-ink-faint`,children:[(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:p(`research.eventSourced`)}),(0,X.jsx)(`span`,{className:`shrink-0 text-ok`,children:se?N:p(`common.live`)})]}):D?(0,X.jsxs)(`footer`,{className:`flex h-9 items-center gap-2 border-t border-line px-4 font-mono text-xs text-ink-faint`,children:[(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,title:D.storage_path||D.path,children:D.storage_path||D.path}),j?(0,X.jsx)(`span`,{className:`ml-auto truncate text-err`,title:j,children:p(`research.downloadFailed`)}):null,(0,X.jsxs)(`span`,{className:`shrink-0`,children:[D.kind,` · `,fi(D.size)]}),(0,X.jsx)(`span`,{className:`shrink-0 text-ok`,children:se?N:p(`common.live`)})]}):null]})}function Is({notice:e,onClose:t}){if((0,I.useEffect)(()=>{if(!e)return;let n=window.setTimeout(t,e.tone===`error`?8e3:4e3);return()=>window.clearTimeout(n)},[e,t]),!e)return null;let n=e.tone===`error`?`border-err/60 bg-err/10 text-err`:e.tone===`success`?`border-ok/60 bg-ok/10 text-ok`:`border-blue-deep/60 bg-panel text-blue-sky`;return(0,X.jsxs)(`div`,{role:e.tone===`error`?`alert`:`status`,"aria-live":e.tone===`error`?`assertive`:`polite`,className:`fixed bottom-4 left-4 right-4 z-[70] flex items-start gap-2 rounded-md border px-3 py-2.5 shadow-glow sm:left-auto sm:max-w-md ${n}`,children:[(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`mt-px shrink-0`,children:e.tone===`error`?`!`:e.tone===`success`?`✓`:`i`}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 break-words text-xs leading-relaxed text-ink-dim`,children:e.message}),(0,X.jsx)(`button`,{type:`button`,"aria-label":`dismiss notification`,onClick:t,className:`shrink-0 rounded px-1 text-base leading-none opacity-70 hover:bg-white/5 hover:opacity-100`,children:`×`})]})}function Ls({open:e,busy:t,onClose:n,onCreate:r}){let{t:i}=Z(),[a,o]=(0,I.useState)(``),[s,c]=(0,I.useState)(``),[l,u]=(0,I.useState)(``),d=(0,I.useRef)(null);(0,I.useEffect)(()=>{e&&(o(``),c(``),u(``))},[e]);let f=()=>{t||n()},p=async e=>{e.preventDefault(),!t&&await r(a.trim(),s.trim(),l.trim())&&n()},m=e=>{sa(e)||e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),d.current?.requestSubmit())},h=!!s.trim();return(0,X.jsx)(go,{open:e,onClose:f,label:i(`new.createDaemon`),width:`max-w-xl`,showClose:!1,children:(0,X.jsxs)(`form`,{ref:d,onSubmit:e=>void p(e),children:[(0,X.jsxs)(`div`,{className:`flex items-start gap-3 border-b border-line px-5 py-4`,children:[(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`h2`,{className:`text-base font-semibold text-ink`,children:i(`landing.new`)}),(0,X.jsx)(`p`,{className:`mt-0.5 text-xs text-ink-faint`,children:i(`new.subtitle`)})]}),(0,X.jsx)(`button`,{type:`button`,"aria-label":i(`new.close`),onClick:f,disabled:t,className:`rounded px-2 py-1 text-lg leading-none text-ink-faint hover:bg-surface hover:text-ink disabled:opacity-40`,children:`×`})]}),(0,X.jsxs)(`div`,{className:`space-y-4 p-5`,children:[(0,X.jsxs)(`label`,{className:`block`,children:[(0,X.jsxs)(`span`,{className:`mb-1 block text-[10px] font-semibold uppercase tracking-wider text-ink-faint`,children:[i(`new.name`),` `,(0,X.jsx)(`span`,{className:`normal-case tracking-normal`,children:i(`new.optional`)})]}),(0,X.jsx)(`input`,{"data-autofocus":!0,value:a,onChange:e=>o(e.target.value),maxLength:80,disabled:t,placeholder:i(`new.namePlaceholder`),className:`h-10 w-full rounded border border-line bg-bg/50 px-3 text-sm text-ink outline-none placeholder:text-ink-faint focus:border-blue-deep disabled:opacity-50`})]}),(0,X.jsxs)(`label`,{className:`block`,children:[(0,X.jsxs)(`span`,{className:`mb-1 block text-[10px] font-semibold uppercase tracking-wider text-ink-faint`,children:[i(`new.workdir`),` `,(0,X.jsx)(`span`,{className:`normal-case tracking-normal`,children:i(`new.optional`)})]}),(0,X.jsx)(`input`,{value:l,onChange:e=>u(e.target.value),disabled:t,placeholder:i(`newDaemon.workdirPlaceholder`),className:`h-10 w-full rounded border border-line bg-bg/50 px-3 font-mono text-xs text-ink outline-none placeholder:text-ink-faint focus:border-blue-deep disabled:opacity-50`}),(0,X.jsx)(`span`,{className:`mt-1 block text-[10px] leading-relaxed text-ink-faint`,children:i(`new.workdirHint`)})]}),(0,X.jsxs)(`label`,{className:`block`,children:[(0,X.jsxs)(`span`,{className:`mb-1 block text-[10px] font-semibold uppercase tracking-wider text-ink-faint`,children:[i(`new.objective`),` `,(0,X.jsx)(`span`,{className:`normal-case tracking-normal`,children:i(`new.optional`)})]}),(0,X.jsx)(`textarea`,{value:s,onChange:e=>c(e.target.value),onKeyDown:m,maxLength:4e3,disabled:t,rows:4,placeholder:i(`new.objectivePlaceholder`),className:`w-full resize-y rounded border border-line bg-bg/50 px-3 py-2.5 text-sm leading-relaxed text-ink outline-none placeholder:text-ink-faint focus:border-blue-deep disabled:opacity-50`})]}),(0,X.jsxs)(`div`,{className:`rounded border p-3 ${h?`border-gold/40 bg-gold/5`:`border-line bg-bg/30`}`,children:[(0,X.jsx)(`div`,{className:`text-xs font-medium ${h?`text-gold`:`text-blue-sky`}`,children:i(h?`new.startsAfterCreate`:`new.idleUntilMessage`)}),(0,X.jsx)(`p`,{className:`mt-1 text-[11px] leading-relaxed text-ink-faint`,children:i(h?`new.startsHint`:`new.idleHint`)})]})]}),(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-t border-line px-5 py-3`,children:[(0,X.jsx)(`span`,{className:`text-[10px] text-ink-faint`,children:i(`new.shortcut`)}),(0,X.jsxs)(`div`,{className:`flex gap-2`,children:[(0,X.jsx)(`button`,{type:`button`,onClick:f,disabled:t,className:`rounded border border-line px-3 py-1.5 text-xs text-ink-dim hover:bg-surface disabled:opacity-40`,children:i(`common.cancel`)}),(0,X.jsx)(`button`,{type:`submit`,disabled:t,className:`rounded border border-blue/35 bg-blue/8 px-3 py-1.5 text-xs font-medium text-blue hover:border-blue-deep hover:bg-blue-deep hover:text-white disabled:cursor-wait disabled:opacity-50`,children:i(t?`new.creating`:h?`new.createAndStart`:`sidebar.create`)})]})]})]})})}function Rs({open:e,sid:t,name:n,alive:r,controlAvailable:i=!0,busy:a,onClose:o,onRename:s,onStart:c,onStop:l,onDelete:u}){let{t:d}=Z(),[f,p]=(0,I.useState)(n),[m,h]=(0,I.useState)(!1),[g,_]=(0,I.useState)(!1);(0,I.useEffect)(()=>{e&&(p(n),h(!1),_(!1))},[e,n,t]);let v=async e=>{e.preventDefault(),await s(f.trim())},y=r&&!g,b=async()=>{if(y){await l()&&_(!0);return}await c()&&_(!1)};return(0,X.jsxs)(go,{open:e,onClose:()=>!a&&o(),label:d(`manage.daemon`),width:`max-w-lg`,children:[(0,X.jsxs)(`div`,{className:`border-b border-line px-5 py-4`,children:[(0,X.jsx)(`h2`,{className:`text-base font-semibold text-ink`,children:d(`topbar.manageSession`)}),(0,X.jsx)(`p`,{className:`mt-0.5 font-mono text-[10px] text-ink-faint`,children:t})]}),(0,X.jsx)(`form`,{onSubmit:e=>void v(e),className:`border-b border-line p-5`,children:(0,X.jsxs)(`label`,{className:`block`,children:[(0,X.jsx)(`span`,{className:`mb-1 block text-[10px] font-semibold uppercase tracking-wider text-ink-faint`,children:d(`manage.displayName`)}),(0,X.jsxs)(`div`,{className:`flex gap-2`,children:[(0,X.jsx)(`input`,{value:f,onChange:e=>p(e.target.value),maxLength:80,disabled:a,className:`h-9 min-w-0 flex-1 rounded border border-line bg-bg/50 px-3 text-sm text-ink outline-none focus:border-blue-deep disabled:opacity-50`}),(0,X.jsx)(`button`,{type:`submit`,disabled:a||f.trim()===n,className:`rounded border border-line px-3 text-xs text-ink-dim hover:bg-surface disabled:opacity-40`,children:d(`common.save`)})]})]})}),(0,X.jsxs)(`div`,{className:`border-b border-line p-5`,children:[(0,X.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-wider text-ink-faint`,children:d(`manage.executor`)}),(0,X.jsxs)(`div`,{className:`mt-2 flex items-center justify-between rounded border border-line bg-bg/30 p-3`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`div`,{className:`text-sm text-ink`,children:d(y?i?`manage.running`:`manage.runningExternally`:`manage.paused`)}),(0,X.jsx)(`p`,{className:`mt-0.5 text-[11px] text-ink-faint`,children:d(y?i?`manage.stopNowHint`:`manage.externalHint`:`manage.resumeHint`)})]}),(0,X.jsx)(`button`,{type:`button`,disabled:a||!i,onClick:()=>void b(),className:`rounded border px-3 py-1.5 text-xs disabled:cursor-wait disabled:opacity-50 ${y?`border-warn/50 text-warn hover:bg-warn/10`:`border-blue-deep bg-blue-deep text-white hover:bg-blue-deep/80`}`,children:d(a?`manage.working`:i?y?`manage.stopNow`:`manage.resume`:`common.external`)})]})]}),(0,X.jsxs)(`div`,{className:`p-5`,children:[(0,X.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-wider text-err`,children:d(`manage.deleteSession`)}),(0,X.jsx)(`p`,{className:`mt-1 text-[11px] leading-relaxed text-ink-faint`,children:d(`manage.deleteHint`)}),m?(0,X.jsxs)(`div`,{className:`mt-3 flex items-center justify-between gap-3 rounded border border-err/40 bg-err/5 p-3`,children:[(0,X.jsx)(`span`,{className:`text-xs text-ink-dim`,children:d(`manage.confirmQuestion`)}),(0,X.jsxs)(`div`,{className:`flex gap-2`,children:[(0,X.jsx)(`button`,{type:`button`,onClick:()=>h(!1),className:`rounded px-2 py-1 text-xs text-ink-faint hover:bg-surface`,children:d(`common.cancel`)}),(0,X.jsx)(`button`,{type:`button`,disabled:a,onClick:()=>void u(),className:`rounded bg-err px-3 py-1 text-xs font-medium text-bg disabled:opacity-50`,children:d(`manage.confirmDelete`)})]})]}):(0,X.jsx)(`button`,{type:`button`,disabled:a||y,onClick:()=>h(!0),className:`mt-3 rounded border border-err/40 px-3 py-1.5 text-xs text-err hover:bg-err/10 disabled:cursor-not-allowed disabled:opacity-40`,children:d(`manage.delete`)})]})]})}var zs={科学环境已就绪:`Scientific environment ready`,"科学环境 · ⟦0⟧ 项待配置":`Scientific environment · ⟦0⟧ item(s) to configure`,科学环境:`Scientific environment`,检查环境:`Check environment`,"免费科学组件自动配置;SHELX 需要你在官网取得学术授权后输入下载凭据。":`Free scientific components are configured automatically; SHELX requires academic authorization from the official website before entering download credentials.`,修复依赖:`Repair dependencies`,"配置 SHELX":`Configure SHELX`,"SHELX 授权安装":`SHELX authorized installation`,学术授权:`Academic authorization`,前往官网申请:`Apply on official website`,"填写授权邮件中的 username 和 password,即可自动下载安装。凭据仅用于本次官方下载,不保存,也不发送给模型。":`Enter the username and password from the authorization email to download and install automatically. Credentials are used only for this official download, are not saved, and are not sent to the model.`,用户名:`Username`,"SHELX 用户名":`SHELX username`,密码:`Password`,"SHELX 密码":`SHELX password`,"查看许可 ↗":`View license ↗`,"下载并安装 SHELX":`Download and install SHELX`,取消:`Cancel`,科学软件健康检查:`Scientific software health check`,"点击“检查环境”可验证科学内核与外部程序。":`Click “Check environment” to verify the scientific kernel and external programs.`,可用:`Available`,待授权安装:`Authorization required`,待修复:`Needs repair`,查看检查详情:`View check details`,查看原因与安装方式:`View cause and installation method`,"官方安装说明 ↗":`Official installation instructions ↗`,使用已有安装:`Use existing installation`,"DIALS 环境目录":`DIALS environment directory`,"Systre JAR 路径(需要已有 Java)":`Systre JAR path (existing Java required)`,"⟦0⟧ 可执行文件路径":`⟦0⟧ executable path`,"填写运行 Argus 的电脑上的路径,验证成功后生效。":`Enter the path on the computer running Argus. It takes effect after successful verification.`,验证并使用:`Verify and use`,最近检查:`Last checked`,"· 检查不调用模型":`· Check does not call the model`,无法读取插件列表:`Unable to read plugin list`,插件操作未完成:`Plugin operation incomplete`,插件:`Plugins`,关闭插件列表:`Close plugin list`,"按需安装研究工具,沿用 Argus 的模型与执行后端。":`Install research tools as needed, using Argus's model and execution backend.`,"正在读取插件…":`Reading plugins…`,暂无可用插件:`No plugins available`,已启用:`Enabled`,已停用:`Disabled`,未安装:`Not installed`,"· 当前后端":`· Current backend`,安装:`Install`,打开工作台:`Open workbench`,启用:`Enable`,更新至:`Update to`,停用:`Disable`,卸载:`Uninstall`,"原生会话输入 ⟦0⟧ 可启用后台工具。卸载保留会话、研究数据和科学软件。":`Native session input ⟦0⟧ can enable background tools. Uninstalling preserves sessions, research data, and scientific software.`,"首次安装自动配置独立 Python、DIALS、Systre / Java 和 PLATON 学术免费组件。SHELX 稍后输入授权信息即可安装。":`First installation automatically configures standalone Python, DIALS, Systre / Java, and free academic PLATON components. SHELX can be installed later by entering authorization details.`,"暂不支持,敬请期待。当前插件支持 Codex、Copilot 和 Pi。":`Not supported yet. Stay tuned. Current plugins support Codex, Copilot, and Pi.`,"安装科学环境需要 Python 3.11–3.13。请安装 Python 后重试,或设置 ARGUS_PLUGIN_PYTHON。":`Installing the scientific environment requires Python 3.11–3.13. Install Python and try again, or set ARGUS_PLUGIN_PYTHON.`,准备安装:`Prepare installation`,获取并校验插件包:`Download and verify plugin package`,"安装独立运行环境(首次可能需要几分钟)":`Install standalone environment (may take several minutes the first time)`,"插件仍有任务运行,请等任务结束或先暂停,再进行此操作。":`This plugin still has running tasks. Wait for them to finish or pause them before continuing.`,"此插件版本尚未提供可校验的发行包。":`No verifiable release package is available for this plugin version.`,"插件包校验失败,未安装。":`Plugin package verification failed. Not installed.`,正在准备:`Preparing`,"当前系统或 Argus 插件接口版本暂不支持此插件。":`This plugin is not currently supported by the system or Argus plugin API version.`,"插件发行包尚未发布。":`The plugin release package has not been published.`,安装完成:`Installation complete`,环境检查完成:`Environment check complete`,"此插件已有安装或更新操作正在进行。":`An installation or update operation for this plugin is already in progress.`,插件尚未安装:`Plugin not installed`,"安装进程已中断;已有可用版本保持不变,可重试。":`Installation was interrupted. The existing available version is unchanged; you can retry.`,"安装未完成,已有版本保持不变":`Installation incomplete; existing version unchanged`,"此版本已安装,可启用插件。":`This version is installed. You can enable the plugin.`,请先安装插件:`Install the plugin first`,请先更新插件以使用环境管理功能:`Update the plugin first to use environment management`,"插件包超过允许大小。":`The plugin package exceeds the allowed size.`,科学计算内核:`Scientific computing kernel`,"cctbx · Gemmi · RDKit · 科学服务":`cctbx · Gemmi · RDKit · scientific services`,衍射帧处理与探测器格式支持:`Diffraction frame processing and detector format support`,周期网络与拓扑识别:`Periodic networks and topology identification`,"本地 checkCIF 结构校验 · 学术免费":`Local checkCIF structure validation · free for academic use`,"结构精修 · 需要学术授权":`Structure refinement · academic authorization required`,"结构求解 · 需要学术授权":`Structure solution · academic authorization required`,全部组件可用:`All components available`,部分组件需要配置或修复:`Some components require configuration or repair`,"PLATON 官网中间证书已更换,请更新插件安装器":`The PLATON official-site intermediate certificate has changed. Update the plugin installer.`,"PLATON Mac 发行包架构不符":`PLATON Mac release package architecture mismatch`,"请输入授权邮件中的用户名和密码。":`Enter the username and password from the authorization email.`,请选择有效的科学软件路径:`Select a valid scientific software path`,检查科学软件与运行环境:`Check scientific software and runtime environment`,"正在修复科学 Python 依赖":`Repairing scientific Python dependencies`,"(首次下载可能需要几分钟)":`(The initial download may take several minutes)`,"from cctbx.array_family import flex; import gemmi,rdkit; from argus_crystalpilot import worker; from argus_crystalpilot.resources import bundle_root; assert (bundle_root()/'ui/dist/index.html').is_file(); import crystalpilot; from pathlib import Path; assert (Path(crystalpilot.__file__).parent/'io/dxtbx_plugin/pyproject.toml').is_file(); assert flex.double([1,2]).size()==2; print('科学内核及工作台资源可用')":`from cctbx.array_family import flex; import gemmi,rdkit; from argus_crystalpilot import worker; from argus_crystalpilot.resources import bundle_root; assert (bundle_root()/'ui/dist/index.html').is_file(); import crystalpilot; from pathlib import Path; assert (Path(crystalpilot.__file__).parent/'io/dxtbx_plugin/pyproject.toml').is_file(); assert flex.double([1,2]).size()==2; print('Scientific kernel and workbench resources available')`,"; from importlib.metadata import entry_points; assert {'FormatCBFMiniRigaku:FormatCBF','FormatBrukerSfrmGeom:FormatBruker','FormatRODLegacy:FormatROD'} <= {e.name for e in entry_points(group='dxtbx.format')}; from dials.util.version import dials_version; assert flex.reflection_table() is not None; print(dials_version()+' · 探测器格式插件可用')":`; from importlib.metadata import entry_points; assert {'FormatCBFMiniRigaku:FormatCBF','FormatBrukerSfrmGeom:FormatBruker','FormatRODLegacy:FormatROD'} <= {e.name for e in entry_points(group='dxtbx.format')}; from dials.util.version import dials_version; assert flex.reflection_table() is not None; print(dials_version()+' · detector format plugins available')`,"Systre 19.6.0 · pcu 拓扑计算通过":`Systre 19.6.0 · pcu topology calculation passed`,"正在安装 Apple Rosetta 2 兼容组件":`Installing Apple Rosetta 2 compatibility components`,"从 SHELX 官方站点下载":`Downloading from the official SHELX site`,"SHELX 下载内容不是支持的可执行程序":`SHELX download is not a supported executable`,"已可用,保留当前安装":`Already available; keeping current installation`,正在安装:`Installing`,"尚未安装 DIALS":`DIALS is not installed`,"PLATON 编译需要 Apple 命令行工具;请运行 xcode-select --install,然后点击修复依赖。":`PLATON compilation requires Apple Command Line Tools; run xcode-select --install, then click Repair dependencies.`,"SHELX 官方 Mac 版需要 Rosetta 2,请先同意安装兼容组件。":`The official Mac version of SHELX requires Rosetta 2. Agree to install the compatibility components first.`,"暂未完成;可在健康检查中重试":`Not completed; retry from the health check`,"SHELX 下载或启动失败;请核对授权、网络及系统平台后重试。":`SHELX download or launch failed; check authorization, network, and system platform, then retry.`,"尚未安装 Systre":`Systre is not installed`,"尚未安装 Java":`Java is not installed`,"Systre 未能识别内置 pcu 网络":`Systre could not identify the built-in pcu network`,"尚未安装 PLATON":`PLATON is not installed`,"PLATON 安装配方已更新,点击修复依赖即可使用当前版本。":`The PLATON installation recipe has been updated. Click Repair dependencies to use the current version.`,"PLATON 未生成校验规则;请检查运行库":`PLATON did not generate verification rules; check the runtime`,"请输入 SHELX 授权信息以安装":`Enter SHELX authorization details to install`,"无法启动,请核对平台与运行库":`Unable to start; check the platform and runtime`},Bs=e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),Vs=/⟦\d+⟧/g,Hs=Object.entries(zs).filter(([e])=>e.includes(`⟦`)).sort((e,t)=>t[0].length-e[0].length).map(([e,t])=>({regex:RegExp(`^`+e.split(Vs).map(Bs).join(`([\\s\\S]*?)`)+`$`),slots:e.match(Vs)??[],target:t})),Us=new RegExp(Object.keys(zs).filter(e=>e.length>1&&!e.includes(`⟦`)).sort((e,t)=>t.length-e.length).map(Bs).join(`|`),`g`);function Ws(e,t){if(t===`zh-CN`||!/[\u3400-\u9fff]/.test(e))return e;if(zs[e.trim()])return e.replace(e.trim(),zs[e.trim()]);for(let t of Hs){let n=t.regex.exec(e.trim());if(n){let e=new Map(t.slots.map((e,t)=>[e,n[t+1]]));return t.target.replace(Vs,t=>e.get(t)??t)}}return e.replace(Us,e=>zs[e])}function Gs(){let{locale:e}=Z();return t=>typeof t==`string`?Ws(t,e):t}var Ks=Se(),qs=`inline-flex items-center justify-center gap-1.5 rounded-lg border border-line px-3 py-1.5 text-sm transition-colors hover:bg-bg disabled:cursor-not-allowed disabled:opacity-45`;function Js({health:e,setup:t,running:n,act:r,platform:i,machine:a}){let o=Gs(),[s,c]=(0,I.useState)(!1),[l,u]=(0,I.useState)(!1),[d,f]=(0,I.useState)(``),[p,m]=(0,I.useState)(``),[h,g]=(0,I.useState)(null),[_,v]=(0,I.useState)(``),[y,b]=(0,I.useState)(!1),x=t.license?.platform_consent,S=x?.platform===i&&x?.machines.includes(a||``),C=e?.components||[],w=C.filter(e=>e.status!==`ready`),T=w.some(e=>e.license_required),E=w.some(e=>e.automatic);async function D(e){e.preventDefault();let n=await r(t.license.action,{username:d,password:p,accept_platform_license:y});m(``),n&&(u(!1),f(``),c(!0))}return(0,X.jsxs)(`div`,{className:`mt-5 border-t border-line/60 pt-4`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,X.jsxs)(`button`,{type:`button`,"aria-expanded":s,onClick:()=>c(!s),className:`inline-flex items-center gap-2 text-sm text-ink-dim hover:text-ink`,children:[(0,X.jsx)(ro,{size:16,strokeWidth:1.5}),(0,X.jsx)(`span`,{children:o(e?.checked?e.ready?o(`科学环境已就绪`):o(`科学环境 · ${w.length} 项待配置`):o(`科学环境`))}),(0,X.jsx)(Ha,{size:13,className:`transition-transform duration-200 ${s?`rotate-180`:``}`})]}),(0,X.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 text-xs text-ink-faint hover:text-ink disabled:opacity-45`,disabled:n,onClick:()=>{c(!0),r(`health`)},children:[(0,X.jsx)(no,{size:12}),o(`检查环境`)]})]}),o((T||E||!e?.checked)&&(0,X.jsx)(`p`,{className:`mt-2 text-xs leading-relaxed text-ink-faint`,children:o(` 免费科学组件自动配置;SHELX 需要你在官网取得学术授权后输入下载凭据。 `)})),(0,X.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[o((E||!e?.checked)&&(0,X.jsxs)(`button`,{className:qs,disabled:n,onClick:()=>{c(!0),r(`repair`)},children:[(0,X.jsx)(qa,{size:14}),o(`修复依赖`)]})),o(t.license&&(0,X.jsxs)(`button`,{className:qs,disabled:n,onClick:()=>{u(!l),m(``),f(``)},children:[(0,X.jsx)(Xa,{size:14}),o(o(T?`配置 SHELX`:`SHELX 授权安装`))]}))]}),o(l&&t.license&&(0,X.jsxs)(`form`,{onSubmit:D,className:`mt-4 rounded-lg bg-bg/70 p-3`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-2 text-sm`,children:[(0,X.jsxs)(`span`,{className:`font-medium`,children:[o(t.license.name),o(` 学术授权`)]}),(0,X.jsxs)(`a`,{href:t.license.url,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-xs text-blue`,children:[o(`前往官网申请`),(0,X.jsx)(Ja,{size:11})]})]}),(0,X.jsx)(`p`,{className:`mb-3 mt-1.5 text-xs leading-relaxed text-ink-faint`,children:o(`填写授权邮件中的 username 和 password,即可自动下载安装。凭据仅用于本次官方下载,不保存,也不发送给模型。`)}),(0,X.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,X.jsxs)(`label`,{className:`text-xs text-ink-dim`,children:[o(`用户名`),(0,X.jsx)(`input`,{"aria-label":o(`SHELX 用户名`),value:d,onChange:e=>f(e.target.value),required:!0,maxLength:200,autoComplete:`off`,autoCapitalize:`none`,spellCheck:!1,className:`mt-1.5 w-full rounded-md border border-line bg-panel px-2.5 py-2 text-sm text-ink outline-none focus:border-blue/60`})]}),(0,X.jsxs)(`label`,{className:`text-xs text-ink-dim`,children:[o(`密码`),(0,X.jsx)(`input`,{"aria-label":o(`SHELX 密码`),type:`password`,value:p,onChange:e=>m(e.target.value),required:!0,maxLength:500,autoComplete:`new-password`,className:`mt-1.5 w-full rounded-md border border-line bg-panel px-2.5 py-2 text-sm text-ink outline-none focus:border-blue/60`})]})]}),o(S&&x&&(0,X.jsxs)(`label`,{className:`mt-3 flex items-start gap-2 text-xs leading-relaxed text-ink-faint`,children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:y,onChange:e=>b(e.target.checked),className:`mt-0.5`}),(0,X.jsxs)(`span`,{children:[o(x.text),` `,(0,X.jsx)(`a`,{href:x.url,target:`_blank`,rel:`noreferrer`,className:`text-blue`,children:o(`查看许可 ↗`)})]})]})),(0,X.jsxs)(`div`,{className:`mt-3 flex gap-2`,children:[(0,X.jsxs)(`button`,{type:`submit`,className:qs,disabled:n||!d.trim()||!p.trim(),children:[(0,X.jsx)(qa,{size:14}),o(`下载并安装 SHELX`)]}),(0,X.jsx)(`button`,{type:`button`,className:`px-2 text-xs text-ink-faint`,onClick:()=>{u(!1),f(``),m(``)},children:o(`取消`)})]})]})),s&&(0,X.jsxs)(`div`,{className:`mt-3`,"aria-label":o(`科学软件健康检查`),children:[o(!C.length&&(0,X.jsx)(`p`,{className:`py-2 text-xs text-ink-faint`,children:o(`点击“检查环境”可验证科学内核与外部程序。`)})),C.map(e=>(0,X.jsx)(`div`,{className:`border-b border-line/40 py-2.5 last:border-0`,children:(0,X.jsxs)(`div`,{className:`flex items-start gap-2.5`,children:[o(e.status===`ready`?(0,X.jsx)(Va,{size:15,strokeWidth:1.7,className:`mt-0.5 shrink-0 text-blue/75`}):(0,X.jsx)(Wa,{size:15,strokeWidth:1.5,className:`mt-0.5 shrink-0 text-ink-faint`})),(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-3 text-sm`,children:[(0,X.jsx)(`span`,{children:o(e.name)}),(0,X.jsx)(`span`,{className:`shrink-0 text-xs text-ink-faint`,children:o(e.status===`ready`?o(`可用`):e.license_required?o(`待授权安装`):o(`待修复`))})]}),(0,X.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-ink-faint`,children:o(e.description)}),(0,X.jsxs)(`details`,{className:`mt-1.5 text-xs text-ink-faint`,children:[(0,X.jsx)(`summary`,{className:`cursor-pointer hover:text-ink-dim`,children:o(e.status===`ready`?o(`查看检查详情`):o(`查看原因与安装方式`))}),(0,X.jsx)(`p`,{className:`mt-2 whitespace-pre-wrap break-words leading-relaxed`,children:o(e.detail)}),e.path&&(0,X.jsx)(`p`,{className:`mt-1 break-all leading-relaxed`,children:e.path}),(0,X.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-3`,children:[(0,X.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,className:`text-blue`,children:o(`官方安装说明 ↗`)}),o(e.id!==`python`&&t.actions.includes(`configure`)&&(0,X.jsx)(`button`,{type:`button`,disabled:n,onClick:()=>{g(e.id),v(``)},className:`text-blue`,children:o(`使用已有安装`)}))]})]})]})]})},e.id)),o(h&&(0,X.jsxs)(`form`,{onSubmit:async e=>{e.preventDefault(),await r(`configure`,{paths:{[h]:_}})&&(g(null),v(``))},className:`mt-3 rounded-lg bg-bg/70 p-3`,children:[(0,X.jsxs)(`label`,{className:`text-xs text-ink-dim`,children:[o(o(h===`dials`?`DIALS 环境目录`:h===`systre`?`Systre JAR 路径(需要已有 Java)`:`${h.toUpperCase()} 可执行文件路径`)),(0,X.jsx)(`input`,{required:!0,value:_,onChange:e=>v(e.target.value),className:`mt-2 w-full rounded-md border border-line bg-panel px-2 py-2 text-sm text-ink`})]}),(0,X.jsx)(`p`,{className:`mt-1.5 text-xs text-ink-faint`,children:o(`填写运行 Argus 的电脑上的路径,验证成功后生效。`)}),(0,X.jsxs)(`div`,{className:`mt-3 flex gap-3`,children:[(0,X.jsx)(`button`,{className:qs,disabled:n,children:o(`验证并使用`)}),(0,X.jsx)(`button`,{type:`button`,className:`text-xs text-ink-faint`,onClick:()=>g(null),children:o(`取消`)})]})]})),o(e?.checked&&(0,X.jsxs)(`p`,{className:`mt-2 text-[11px] text-ink-faint`,children:[o(`最近检查 `),o(new Date(e.checked*1e3).toLocaleString()),o(` · 检查不调用模型`)]}))]})]})}function Ys({compact:e=!1}){let t=Gs(),{locale:n}=Z(),[r,i]=(0,I.useState)(!1),[a,o]=(0,I.useState)([]),[s,c]=(0,I.useState)(``),[l,u]=(0,I.useState)(!1),[d,f]=(0,I.useState)(null),p=(0,I.useRef)(null);async function m(e){let n=await fetch(`/api/plugins`,{headers:Ke(),signal:e});if(!n.ok)throw Error(t(`无法读取插件列表`));o((await n.json()).plugins)}(0,I.useEffect)(()=>{if(!r)return;let e=new AbortController;p.current?.focus(),c(``),u(!0),m(e.signal).catch(t=>{e.signal.aborted||c(t.message)}).finally(()=>u(!1));let t=window.setInterval(()=>void m(e.signal).catch(()=>{}),1500),n=e=>{e.key===`Escape`&&i(!1)};return window.addEventListener(`keydown`,n),()=>{e.abort(),window.clearInterval(t),window.removeEventListener(`keydown`,n)}},[r]);async function h(e,n,r){f(e.id),c(``);try{let i=await fetch(`/api/plugins/${e.id}/${n===`launch`?`launch`:`manage/${n}`}`,{method:`POST`,headers:{...Ke(),"Content-Type":`application/json`},body:r?JSON.stringify(r):void 0}),a=await i.json();if(!i.ok)throw Error(a.detail||t(`插件操作未完成`));return n===`launch`?window.location.assign(a.url):await m(),!0}catch(e){return c(e instanceof Error?e.message:String(e)),!1}finally{f(null)}}return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`button`,{type:`button`,onClick:()=>i(!0),title:t(`插件`),"aria-label":t(`插件`),className:`mx-2 my-1 flex h-9 shrink-0 items-center rounded-md text-sm text-ink-dim transition-colors hover:bg-bg hover:text-ink ${e?`justify-center`:`gap-2 px-3`}`,children:[(0,X.jsx)(Ba,{size:17,strokeWidth:1.5}),t(!e&&(0,X.jsx)(`span`,{children:t(`插件`)}))]}),r&&(0,Ks.createPortal)((0,X.jsx)(`div`,{className:`fixed inset-0 z-[100] flex items-center justify-center bg-black/20 p-5 backdrop-blur-sm`,onClick:()=>i(!1),children:(0,X.jsxs)(`section`,{role:`dialog`,"aria-modal":`true`,"aria-labelledby":`plugin-title`,onClick:e=>e.stopPropagation(),className:`max-h-[85vh] w-full max-w-xl overflow-y-auto rounded-2xl border border-line bg-panel p-6 text-ink shadow-xl`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,X.jsx)(`h2`,{id:`plugin-title`,className:`text-lg font-semibold`,children:t(`插件`)}),(0,X.jsx)(`button`,{ref:p,type:`button`,"aria-label":t(`关闭插件列表`),className:`icon-control p-1.5`,onClick:()=>i(!1),children:(0,X.jsx)(oo,{size:18})})]}),(0,X.jsx)(`p`,{className:`mb-6 mt-2 text-sm text-ink-faint`,children:t(`按需安装研究工具,沿用 Argus 的模型与执行后端。`)}),t(s&&(0,X.jsx)(`p`,{role:`alert`,className:`mb-4 text-sm text-ink-dim`,children:t(s)})),t(l&&(0,X.jsx)(`p`,{className:`text-sm text-ink-faint`,children:t(`正在读取插件…`)})),t(!l&&!a.length&&(0,X.jsx)(`p`,{className:`text-sm text-ink-faint`,children:t(`暂无可用插件`)})),t(a.map(e=>{let r=e.operation?.status===`running`||d===e.id,i=r||!e.supported,a=`inline-flex items-center justify-center gap-1.5 rounded-lg border border-line px-3 py-1.5 text-sm transition-colors hover:bg-bg disabled:cursor-not-allowed disabled:opacity-45`;return(0,X.jsxs)(`article`,{className:`rounded-xl border border-line/70 p-4`,"data-testid":`plugin-${e.id}`,children:[(0,X.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,X.jsx)(Ka,{size:24,strokeWidth:1.25,className:`mt-0.5 shrink-0 text-blue`}),(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,X.jsx)(`h3`,{className:`font-medium`,children:t(e.name)}),(0,X.jsx)(`span`,{className:`text-xs text-ink-faint`,children:t(e.installed_version||e.version)})]}),(0,X.jsx)(`p`,{className:`mt-1 text-sm leading-relaxed text-ink-faint`,children:t(e.description)})]})]}),(0,X.jsxs)(`div`,{className:`mt-4 text-xs text-ink-faint`,children:[t(e.installed?e.enabled?t(`已启用`):t(`已停用`):t(`未安装`)),t(` · 当前后端 `),t(Array.from(new Set(Object.values(e.backends))).join(` / `))]}),t(!e.supported&&(0,X.jsx)(`p`,{className:`mt-3 text-sm text-ink-dim`,children:t(e.reason)})),t(e.operation?.status===`running`&&(0,X.jsxs)(`p`,{role:`status`,className:`mt-3 flex items-center gap-2 text-sm text-ink-dim`,children:[(0,X.jsx)(Za,{size:14,className:`animate-spin`}),t(e.operation.progress)]})),t(e.operation?.status===`failed`&&(0,X.jsx)(`p`,{role:`status`,className:`mt-3 break-words text-sm text-ink-dim`,children:t(e.operation.error)})),(0,X.jsxs)(`div`,{className:`mt-4 flex flex-wrap items-center gap-2`,children:[t(!e.installed&&(0,X.jsxs)(`button`,{className:a,disabled:i,onClick:()=>void h(e,`install`),children:[(0,X.jsx)(qa,{size:14}),t(`安装`)]})),t(e.installed&&e.enabled&&(0,X.jsxs)(`button`,{className:a,disabled:i,onClick:()=>void h(e,`launch`),children:[t(`打开工作台`),(0,X.jsx)(Ra,{size:14})]})),t(e.installed&&!e.enabled&&(0,X.jsx)(`button`,{className:a,disabled:i,onClick:()=>void h(e,`enable`),children:t(`启用`)})),t(e.update_available&&(0,X.jsxs)(`button`,{className:a,disabled:i,onClick:()=>void h(e,`update`),children:[(0,X.jsx)(no,{size:14}),t(`更新至 `),t(e.version)]})),t(e.installed&&e.enabled&&(0,X.jsx)(`button`,{className:a,disabled:r,onClick:()=>void h(e,`disable`),children:t(`停用`)})),t(e.installed&&(0,X.jsx)(`button`,{className:a,disabled:r,onClick:()=>void h(e,`uninstall`),children:t(`卸载`)}))]}),(0,X.jsx)(`p`,{className:`mt-4 text-xs leading-relaxed text-ink-faint`,children:t(e.installed?t(`原生会话输入 ${e.command||``} 可启用后台工具。卸载保留会话、研究数据和科学软件。`):t(`首次安装自动配置独立 Python、DIALS、Systre / Java 和 PLATON 学术免费组件。SHELX 稍后输入授权信息即可安装。`))}),t(e.rights_notice&&(0,X.jsx)(`p`,{className:`mt-3 text-[10px] leading-relaxed text-ink-faint`,"data-testid":`plugin-rights-notice`,children:t(n===`zh-CN`&&e.rights_notice_zh||e.rights_notice)})),t(e.installed&&e.setup&&(0,X.jsx)(Js,{health:e.health,setup:e.setup,running:r,platform:e.platform,machine:e.machine,act:(t,n)=>h(e,t,n)}))]},e.id)}))]})}),document.body)]})}function Xs(e){return e.replace(/[\\/]+$/,``).split(/[\\/]/).at(-1)||e}function Zs(e,t,n){if(e.length===0)return`local`;let r=n.trim(),i=r?e.filter(e=>e.launch_cwd?.trim()===r):[];return i.length===0||t&&!i.some(e=>e.id===t)?`all`:`local`}function Qs({projects:e,activeId:t,localCwd:n,onSelect:i,onPrefetch:a,onManage:s,onResume:l,resumingId:u,onOpenPanel:d,onNew:f,loading:p,creating:m=!1,error:h,onRetry:_,mobileOpen:v=!1,collapsed:y=!1,onToggleCollapse:S,themeMode:w,onCycleTheme:ee}){let{locale:O,setLocale:te,t:k}=Z(),[re,A]=(0,I.useState)(`local`),j=(0,I.useRef)(!1),[ie,ae]=(0,I.useState)(``),[M,oe]=(0,I.useState)(()=>new Set),se=y&&!v,N=n.trim(),ce=(0,I.useMemo)(()=>N?e.filter(e=>e.launch_cwd?.trim()===N):[],[N,e]);(0,I.useEffect)(()=>{j.current||p||e.length===0||(j.current=!0,A(Zs(e,t,N)))},[t,p,N,e]);let le=re===`local`?ce:e,ue=ie.trim()?Mn(le,ie):le,de=(0,I.useMemo)(()=>{if(re===`local`)return ue.length>0?[[N||`Local`,ue]]:[];let e=new Map;return ue.forEach(t=>{let n=t.launch_cwd?.trim()||k(`common.unassigned`),r=e.get(n)??[];r.push(t),e.set(n,r)}),[...e.entries()]},[N,re,ue]),fe=w===`light`?c:ne,P=w===`light`?`dark`:`light`,F=e=>M.has(e)&&!ie.trim();return(0,X.jsxs)(`aside`,{"data-state":se?`collapsed`:`expanded`,"data-resizable-panel":`left`,className:`glass-panel glass-panel--side fixed inset-y-0 left-0 z-50 flex h-full shrink-0 flex-col border-r transition-[width,transform,visibility] duration-panel ease-panel lg:visible lg:static lg:z-auto lg:translate-x-0 ${se?`w-14`:`w-64 lg:w-[var(--sidebar-width)]`} ${v?`visible translate-x-0`:`invisible -translate-x-full`}`,children:[(0,X.jsx)(`div`,{className:`chrome-seam-surface flex h-12 shrink-0 items-center border-b border-line/50 ${se?`justify-center`:`justify-between px-4`}`,children:se?(0,X.jsx)(Mi,{size:22,compact:!0}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Mi,{size:24}),(0,X.jsx)(`button`,{type:`button`,onClick:S,"aria-label":k(`sidebar.collapse`),title:`${k(`sidebar.collapse`)} · Ctrl/⌘ B`,className:`icon-control flex h-8 w-8 shrink-0 items-center justify-center`,children:(0,X.jsx)(o,{icon:E,className:`h-3.5 w-3.5`})})]})}),se?(0,X.jsx)(`div`,{className:`flex h-12 shrink-0 items-center justify-center`,children:(0,X.jsx)(`button`,{type:`button`,onClick:S,"aria-label":k(`sidebar.expand`),title:`${k(`sidebar.expand`)} · Ctrl/⌘ B`,className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-md border border-line/50 bg-bg/40 text-ink-faint hover:border-blue/50 hover:text-ink`,children:(0,X.jsx)(o,{icon:x,className:`h-3.5 w-3.5`})})}):null,(0,X.jsx)(Ys,{compact:se}),se?null:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`flex h-12 shrink-0 items-center gap-1 border-b border-line/50 px-3`,children:[[`local`,`all`].map(t=>(0,X.jsxs)(`button`,{type:`button`,onClick:()=>A(t),className:`h-8 rounded-md px-3 text-xs font-medium capitalize transition-colors ${re===t?`bg-bg text-ink`:`text-ink-faint hover:text-ink-dim`}`,children:[k(`common.${t}`),(0,X.jsx)(`span`,{className:`ml-1.5 font-mono text-ink-faint`,children:t===`local`?ce.length:e.length})]},t)),(0,X.jsx)(`button`,{type:`button`,onClick:f,disabled:m,"aria-label":k(`sidebar.create`),title:k(`sidebar.create`),className:`ml-auto flex h-8 w-8 items-center justify-center rounded-md text-lg text-blue hover:bg-bg disabled:opacity-40`,children:m?`…`:`+`})]}),(0,X.jsxs)(`div`,{className:`px-3 py-2`,children:[(0,X.jsx)(`label`,{className:`sr-only`,htmlFor:`daemon-search`,children:k(`sidebar.find`)}),(0,X.jsxs)(`div`,{className:`flex items-center rounded-md border border-line/60 bg-bg/60 px-2 focus-within:border-blue/60`,children:[(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`mr-1.5 text-xs text-ink-faint`,children:`/`}),(0,X.jsx)(`input`,{id:`daemon-search`,value:ie,onChange:e=>ae(e.target.value),placeholder:k(`sidebar.find`),className:`h-8 min-w-0 flex-1 bg-transparent text-xs text-ink outline-none placeholder:text-ink-faint`}),ie?(0,X.jsx)(`button`,{type:`button`,"aria-label":k(`sidebar.clearSearch`),onClick:()=>ae(``),className:`px-1 text-sm text-ink-faint hover:text-ink`,children:`×`}):null]})]}),(0,X.jsxs)(`div`,{className:`mobile-scroll-region min-h-0 flex-1 overflow-x-hidden overflow-y-auto px-3 pb-3 scroll-thin`,children:[p&&e.length===0?(0,X.jsx)(`div`,{className:`px-1 py-3 text-xs text-ink-faint`,children:k(`common.loading`)}):null,h?(0,X.jsx)(`button`,{type:`button`,onClick:_,className:`mb-2 w-full rounded-md bg-err/5 px-3 py-2 text-left text-xs text-err`,children:k(`sidebar.refreshFailed`)}):null,!p&&!h&&ue.length===0?(0,X.jsxs)(`div`,{className:`px-1 py-4 text-xs text-ink-faint`,children:[(0,X.jsx)(`div`,{children:ie.trim()?k(`sidebar.noMatches`,{query:ie.trim()}):k(`sidebar.noSessions`)}),ie.trim()?(0,X.jsx)(`button`,{type:`button`,onClick:()=>ae(``),className:`mt-2 text-xs text-ink-dim underline underline-offset-2 hover:text-ink`,children:k(`sidebar.clearSearch`)}):null]}):null,de.map(([e,n])=>(0,X.jsxs)(`section`,{className:`mb-4 last:mb-0`,children:[(0,X.jsxs)(`button`,{type:`button`,"aria-expanded":!F(e),title:e,onClick:()=>oe(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),className:`mb-1 flex h-7 w-full items-center gap-2 rounded-md px-1.5 text-left text-[11px] font-medium text-ink-faint hover:bg-bg/70 hover:text-ink-dim`,children:[(0,X.jsx)(o,{icon:T,className:`h-2.5 w-2.5 transition-transform ${F(e)?`-rotate-90`:``}`}),(0,X.jsx)(o,{icon:C,className:`h-3 w-3`}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:Xs(e)}),(0,X.jsx)(`span`,{className:`font-mono text-[10px]`,children:n.length})]}),F(e)?null:n.map(e=>{let n=e.id===t,c=En(e),d=c?(e.label||e.display_name||``).trim():e.objective.trim()||e.id||k(`sidebar.unnamedSession`),f=e.daemon_alive&&e.daemon_protocol_compatible===!1,p=f&&e.daemon_protocol_error===`daemon release is incompatible with WebAPI release`,m=f&&!p,h=!e.daemon_alive&&e.last_active>0&&!!e.workdir?.trim();return(0,X.jsxs)(`div`,{"data-active":n?`true`:`false`,onPointerEnter:()=>{n||a?.(e.id)},className:`session-card group relative mb-0.5 h-14 w-full rounded-md transition-colors duration-150 ease-panel ${n?`text-ink`:`text-ink-dim hover:text-ink`}`,children:[(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`absolute left-0 transition-colors ${n?`inset-y-1 w-px bg-blue`:`inset-y-2 w-px bg-transparent group-hover:bg-ink-faint/30`}`}),(0,X.jsxs)(`button`,{type:`button`,onClick:()=>i(e.id),onFocus:()=>{n||a?.(e.id)},"aria-current":n?`page`:void 0,title:`${d}${!c&&d!==e.id?` · ${e.id}`:``}${e.objective&&e.objective!==d?` — ${e.objective}`:``}`,className:`flex h-14 w-full min-w-0 flex-col justify-center px-2.5 text-left ${h?`pr-[4.75rem]`:`pr-10`}`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,X.jsx)(gi,{ok:e.daemon_alive&&!m,title:m?k(`sidebar.updateRequired`):e.daemon_alive?k(`sidebar.daemonAlive`):k(`sidebar.stopped`)}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm font-medium`,children:d})]}),(0,X.jsxs)(`div`,{className:`mt-1 flex min-w-0 items-center gap-1.5 pl-3.5 text-[11px] text-ink-faint`,children:[(0,X.jsx)(`span`,{className:`min-w-0 truncate ${m?`text-warn`:``}`,children:m?k(`sidebar.updateRequired`):e.daemon_alive?k(`sidebar.runningFor`,{uptime:ui(e.uptime_seconds)}):li(e.last_active)}),p&&(0,X.jsx)(`span`,{title:k(`sidebar.updateAvailableHint`),className:`shrink-0 rounded border border-line px-1 text-[10px] leading-4`,children:k(`sidebar.updateAvailable`)})]})]}),h&&l?(0,X.jsx)(`button`,{type:`button`,disabled:u!=null,onClick:t=>{t.stopPropagation(),l(e.id)},"aria-label":k(`sidebar.resume`),title:k(`sidebar.resumeHint`,{workdir:e.workdir??``}),className:`absolute right-9 top-3 flex h-8 w-8 items-center justify-center rounded-md text-blue opacity-100 hover:bg-blue/10 disabled:opacity-40 sm:opacity-0 sm:group-hover:opacity-100 sm:group-focus-within:opacity-100`,children:u===e.id?`…`:(0,X.jsx)(o,{icon:r,className:`h-3 w-3`})}):null,(0,X.jsx)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),s(e.id)},"aria-label":k(`sidebar.manage`,{name:d}),title:k(`sidebar.manageHint`),className:`absolute right-1 top-3 flex h-8 w-8 items-center justify-center rounded-md text-ink-faint opacity-100 transition-opacity hover:bg-panel-raised hover:text-ink sm:opacity-0 sm:group-hover:opacity-100 sm:group-focus-within:opacity-100`,children:(0,X.jsx)(o,{icon:D,className:`h-4 w-4`})})]},e.id)})]},e))]}),(0,X.jsxs)(`div`,{className:`flex min-h-14 items-center justify-between border-t border-line/50 px-4 py-2`,children:[(0,X.jsx)(`button`,{type:`button`,onClick:()=>d(`config`),className:`icon-control flex h-8 w-8 items-center justify-center`,"aria-label":k(`sidebar.openSettings`),title:k(`common.settings`),children:(0,X.jsx)(o,{icon:b,className:`h-3.5 w-3.5`})}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>te(O===`zh-CN`?`en`:`zh-CN`),title:k(`language.switchTo`,{language:k(O===`zh-CN`?`language.english`:`language.chinese`)}),"aria-label":k(`language.switchTo`,{language:k(O===`zh-CN`?`language.english`:`language.chinese`)}),className:`icon-control flex h-8 w-8 items-center justify-center`,children:(0,X.jsx)(o,{icon:g,className:`h-3.5 w-3.5`})}),(0,X.jsx)(`button`,{type:`button`,onClick:ee,title:k(`sidebar.theme`,{current:w,next:P}),"aria-label":k(`sidebar.theme`,{current:w,next:P}),className:`icon-control flex h-8 w-8 items-center justify-center`,children:(0,X.jsx)(o,{icon:fe,className:`h-3.5 w-3.5`})})]})]})]})}var $s={in_progress:`rgb(var(--blue))`,running:`rgb(var(--blue))`,pending:`rgb(var(--ink-faint))`,queued:`rgb(var(--ink-faint))`,done:`rgb(var(--blue))`,completed:`rgb(var(--blue))`,blocked:`rgb(var(--err))`,failed:`rgb(var(--err))`};function ec({items:e,onDispose:t,onStop:n,onInspect:r,busy:i,readOnly:a=!1}){let{t:o}=Z(),[s,c]=(0,I.useState)(!1),l=Vn(e,!1),u=Vn(e,!0),d=s?u:l;return(0,X.jsxs)(`section`,{className:`card flex flex-col ${d.length>0?`min-h-0 flex-1`:`shrink-0`}`,children:[(0,X.jsx)(yi,{title:o(`panel.backlog`),right:(0,X.jsx)(`button`,{className:`text-[10px] text-ink-faint transition-colors hover:text-ink`,onClick:()=>c(e=>!e),children:o(s?`backlog.active`:`backlog.history`,{count:s?l.length:u.length})})}),(0,X.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto scroll-thin`,children:[d.length===0&&(0,X.jsx)(xi,{children:o(s?`backlog.noHistory`:`backlog.empty`)}),d.map(e=>{let s=$s[e.status]??`rgb(var(--ink-faint))`,c=e.iterate;return(0,X.jsx)(`div`,{className:`group border-b border-line/60 px-3 py-2 last:border-0`,children:(0,X.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsx)(`button`,{type:`button`,onClick:()=>r?.(e.id),disabled:!r,className:`block max-w-full truncate text-left text-xs font-medium text-ink enabled:hover:text-blue-sky enabled:focus-visible:outline-none enabled:focus-visible:underline`,title:r?o(`backlog.viewDetails`):void 0,children:e.title||e.objective}),(0,X.jsxs)(`div`,{className:`mt-0.5 flex items-center gap-1.5`,children:[(0,X.jsx)(_i,{color:s,children:Bi(e.status,o)}),typeof e.priority==`number`&&(0,X.jsx)(`span`,{className:`text-[10px] text-ink-faint`,children:Hi(e.priority,o)}),c&&(0,X.jsxs)(`span`,{className:`text-[10px] text-blue-sky`,children:[`↻ `,o(`backlog.iterating`)]})]})]}),(0,X.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1 opacity-0 transition-opacity group-focus-within:opacity-100 group-hover:opacity-100`,children:[!a&&c&&(0,X.jsx)(vi,{variant:`ghost`,onClick:()=>n(e.id),disabled:i,title:o(`backlog.stopIterating`),children:o(`backlog.stop`)}),!a&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(vi,{variant:`ghost`,onClick:()=>t(e.id,`done`),disabled:i,title:o(`backlog.markDone`),children:`✓`}),(0,X.jsx)(vi,{variant:`ghost`,onClick:()=>t(e.id,`rm`),disabled:i,title:o(`backlog.remove`),children:`✕`})]})]})]})},e.id)})]})]})}var tc={win:`rgb(var(--blue))`,milestone:`rgb(var(--blue))`,insight:`rgb(var(--ink-dim))`,decision:`rgb(var(--ink-dim))`,failure:`rgb(var(--err))`,note:`rgb(var(--ink-faint))`};function nc({entries:e}){let{t}=Z(),n=[...e].reverse();return(0,X.jsxs)(`section`,{className:`card flex min-h-0 flex-1 flex-col`,children:[(0,X.jsx)(yi,{title:t(`panel.journal`),right:(0,X.jsx)(`span`,{className:`text-[10px] text-ink-faint`,children:e.length})}),(0,X.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto scroll-thin`,children:[e.length===0&&(0,X.jsx)(xi,{children:`no journal entries yet`}),n.map(e=>{let t=tc[e.kind]??`rgb(var(--ink-faint))`,n=String(e.extra?.pricing_status??``),r=e.extra&&Object.prototype.hasOwnProperty.call(e.extra,`cost_usd`)?e.extra.cost_usd:e.cost_usd,i=typeof r==`number`&&r>0?`${di(r)}${n===`partial`||n===`unpriced`?`+`:``}`:n===`partial`||n===`unpriced`?n:``;return(0,X.jsxs)(`div`,{className:`border-b border-line/60 px-3 py-2 last:border-0`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,X.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full`,style:{background:t}}),(0,X.jsx)(`span`,{className:`text-[10px] uppercase tracking-wide`,style:{color:t},children:e.kind}),(0,X.jsx)(`span`,{className:`ml-auto text-[10px] text-ink-faint`,children:li(e.ts)})]}),(0,X.jsx)(`div`,{className:`mt-1 text-xs font-medium text-ink`,children:e.title}),e.summary&&(0,X.jsx)(`div`,{className:`mt-0.5 text-[11px] leading-snug text-ink-dim`,children:e.summary}),(0,X.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-1`,children:[(e.tags??[]).slice(0,4).map(e=>(0,X.jsx)(`span`,{className:`rounded bg-line/60 px-1 text-[9px] text-ink-faint`,children:e},e)),i?(0,X.jsx)(`span`,{className:`ml-auto text-[10px] text-ink-faint`,children:i}):null]})]},e.id)})]})]})}var rc=[`manager`,`planner`,`engineer`,`reviewer`];function ic(e){return e==null?``:e<3?`now`:e<60?`${Math.floor(e)}s`:e<3600?`${Math.floor(e/60)}m`:`${Math.floor(e/3600)}h`}function ac({roles:e}){let{t}=Z(),n=new Map(e.map(e=>[e.role,e])),r=rc.map(e=>n.get(e)).filter(Boolean),i=e.filter(e=>!rc.includes(e.role)),a=[...r,...i];return(0,X.jsxs)(`section`,{className:`card`,children:[(0,X.jsx)(yi,{title:t(`panel.roles`)}),(0,X.jsx)(`div`,{children:a.map(e=>{let t=W.role[e.role]??W.info;return(0,X.jsxs)(`div`,{className:`grid grid-cols-[84px_minmax(0,1fr)_auto] items-center gap-2 border-b border-line/60 px-3 py-2 last:border-b-0`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,X.jsx)(`span`,{"data-role-dot":e.role,"aria-hidden":`true`,className:`inline-block h-1.5 w-1.5 shrink-0 rounded-full`,style:{background:t}}),(0,X.jsx)(`span`,{className:`text-[11px] font-medium capitalize`,style:{color:e.active?t:W.inkDim},children:e.role})]}),(0,X.jsx)(`div`,{className:`min-w-0 truncate font-mono text-[10px] text-ink-faint`,title:e.model,children:e.model||`—`}),(0,X.jsxs)(`div`,{className:`flex items-center gap-1 text-right`,children:[(0,X.jsx)(`span`,{className:`text-[10px]`,style:{color:e.active?W.ink:W.inkFaint},children:e.active?e.status||`active`:`idle`}),e.active&&ic(e.age_s)&&(0,X.jsxs)(`span`,{className:`text-[10px] tabular-nums text-ink-faint`,children:[`· `,ic(e.age_s)]}),e.effort&&(0,X.jsxs)(`span`,{className:`text-[10px]`,style:{color:ft(e.effort)},children:[`· `,e.effort]})]})]},e.role)})})]})}function oc({open:e,snap:t,journal:n,busy:r,onClose:i,onDispose:a,onStop:o,onInspect:s}){let{t:c}=Z();return(0,X.jsxs)(go,{open:e,onClose:i,label:`Project inspector`,width:`max-w-6xl`,children:[(0,X.jsx)(_o,{title:c(`panel.project`),sub:t.session.display_name||t.session.id}),(0,X.jsxs)(`div`,{className:`h-[68vh] min-h-0 space-y-3 overflow-y-auto bg-bg p-3 scroll-thin lg:grid lg:grid-cols-[minmax(0,1.4fr)_minmax(300px,0.8fr)] lg:gap-3 lg:space-y-0 lg:overflow-hidden`,children:[(0,X.jsx)(ec,{items:t.backlog,onDispose:a,onStop:o,onInspect:s,busy:r}),(0,X.jsxs)(`div`,{className:`flex min-h-0 flex-col gap-3`,children:[(0,X.jsx)(ac,{roles:t.roles}),(0,X.jsx)(nc,{entries:n})]})]})]})}var sc=e=>e?new Date(e*1e3).toLocaleString():`—`;function cc({label:e,value:t}){return(0,X.jsxs)(`div`,{className:`rounded-md border border-line/70 bg-bg/40 px-3 py-2`,children:[(0,X.jsx)(`div`,{className:`text-[9px] font-semibold uppercase tracking-wider text-ink-faint`,children:e}),(0,X.jsx)(`div`,{className:`mt-0.5 text-xs text-ink-dim`,children:t})]})}function lc({sid:e,itemId:t,onClose:n,onDone:r,onSkip:i,onStop:a,busy:o,readOnly:s=!1}){let{t:c}=Z(),l=Or(e,t),u=l.data,d=u?Bn(u):!1,f=Ui(u?.outcome,c);return(0,X.jsxs)(go,{open:!!t,onClose:n,label:c(`task.details`),width:`max-w-3xl`,showClose:!1,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-start gap-3 border-b border-line px-4 py-3 sm:flex-nowrap sm:px-5`,children:[(0,X.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(`h2`,{className:`truncate text-sm font-semibold text-ink`,children:u?.title||c(`task.details`)}),u?(0,X.jsx)(_i,{children:Bi(u.status,c)}):null]})}),!s&&u&&!d?(0,X.jsxs)(`div`,{className:`order-3 flex w-full shrink-0 items-center justify-end gap-1 sm:order-none sm:w-auto`,children:[u.iterate?(0,X.jsx)(vi,{onClick:()=>a(u.id),disabled:o,children:c(`task.stopLoop`)}):null,(0,X.jsx)(vi,{onClick:()=>r(u.id),disabled:o,children:c(`task.done`)}),(0,X.jsx)(vi,{variant:`danger`,onClick:()=>i(u.id),disabled:o,children:c(`task.skip`)})]}):null,(0,X.jsx)(`button`,{type:`button`,"aria-label":c(`task.close`),onClick:n,className:`order-2 rounded-md px-2 py-1 text-lg leading-none text-ink-faint hover:bg-surface hover:text-ink sm:order-none`,children:`×`})]}),(0,X.jsxs)(`div`,{className:`max-h-[70vh] overflow-y-auto p-4 scroll-thin sm:p-5`,children:[l.isLoading?(0,X.jsx)(`div`,{className:`flex justify-center py-12`,children:(0,X.jsx)(bi,{})}):null,l.isError?(0,X.jsx)(`div`,{className:`rounded-md border border-err/40 bg-err/5 p-3 text-xs text-err`,children:l.error.message}):null,u?(0,X.jsxs)(`div`,{className:`space-y-4`,children:[u.pending_question?(0,X.jsxs)(`div`,{className:`rounded-lg border border-warn/40 bg-warn/5 p-3`,children:[(0,X.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-wider text-warn`,children:c(`task.waitingOnYou`)}),(0,X.jsx)(`p`,{className:`mt-1 whitespace-pre-wrap text-sm leading-relaxed text-ink`,children:u.pending_question})]}):null,(0,X.jsxs)(`section`,{children:[(0,X.jsx)(`div`,{className:`mb-1 text-[10px] font-semibold uppercase tracking-wider text-ink-faint`,children:c(`task.objective`)}),(0,X.jsx)(`div`,{className:`whitespace-pre-wrap rounded-lg border border-line bg-bg/50 p-3 text-sm leading-relaxed text-ink-dim`,children:u.objective||u.original_objective||c(`task.noObjective`)})]}),(0,X.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 sm:grid-cols-4`,children:[(0,X.jsx)(cc,{label:c(`task.priority`),value:Hi(u.priority,c)}),(0,X.jsx)(cc,{label:c(`task.started`),value:sc(u.started_ts)}),(0,X.jsx)(cc,{label:c(`task.finished`),value:sc(u.finished_ts)})]}),f.length?(0,X.jsxs)(`section`,{children:[(0,X.jsx)(`div`,{className:`mb-1 text-[10px] font-semibold uppercase tracking-wider text-ink-faint`,children:c(`task.outcome`)}),(0,X.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:f.map(e=>(0,X.jsx)(_i,{children:e},e))})]}):null,u.iterate||u.iteration_cycles_done||u.iteration_cost_usd?(0,X.jsxs)(`section`,{children:[(0,X.jsx)(`div`,{className:`mb-1 text-[10px] font-semibold uppercase tracking-wider text-ink-faint`,children:c(`task.iteration`)}),(0,X.jsxs)(`div`,{className:`grid grid-cols-3 gap-2`,children:[(0,X.jsx)(cc,{label:c(`task.mode`),value:u.iterate?c(`task.autoIterate`):c(`task.singlePass`)}),(0,X.jsx)(cc,{label:c(`task.cycles`),value:`${u.iteration_cycles_done??0}/${u.iteration_max_cycles??`—`}`}),(0,X.jsx)(cc,{label:c(`task.cost`),value:`$${(u.iteration_cost_usd??0).toFixed(2)}`})]})]}):null,u.last_error?(0,X.jsxs)(`section`,{className:`rounded-lg border border-err/30 bg-err/5 p-3`,children:[(0,X.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-wider text-err`,children:c(`task.lastError`)}),(0,X.jsx)(`p`,{className:`mt-1 whitespace-pre-wrap font-mono text-xs leading-relaxed text-ink-dim`,children:u.last_error})]}):null,u.notes?(0,X.jsxs)(`section`,{children:[(0,X.jsx)(`div`,{className:`mb-1 text-[10px] font-semibold uppercase tracking-wider text-ink-faint`,children:c(`task.notes`)}),(0,X.jsx)(`p`,{className:`whitespace-pre-wrap text-xs leading-relaxed text-ink-dim`,children:u.notes})]}):null,u.tags?.length||u.deps?.length?(0,X.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[(u.tags??[]).map(e=>(0,X.jsxs)(_i,{children:[`#`,e]},`tag-${e}`)),u.deps?.length?(0,X.jsx)(_i,{children:c(`task.dependsOnCount`,{count:u.deps.length})}):null]}):null]}):null]})]})}function uc({onPointerDown:e,onReset:t,onNudge:n,value:r,min:i=240,max:a=600,label:o=`Resize panel`}){return(0,X.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":o,"aria-valuenow":r,"aria-valuemin":i,"aria-valuemax":a,tabIndex:0,onPointerDown:e,onDoubleClick:t,onKeyDown:e=>{e.key===`ArrowLeft`?(e.preventDefault(),n(-16)):e.key===`ArrowRight`?(e.preventDefault(),n(16)):e.key===`Home`&&(e.preventDefault(),t())},className:`group relative hidden w-2 shrink-0 cursor-col-resize items-center justify-center outline-none lg:flex`,children:(0,X.jsx)(`span`,{className:`h-full w-px bg-line/30 transition-colors duration-150 group-hover:bg-blue/70 group-focus:bg-blue/70`})})}var dc=[`manager`,`planner`,`engineer`,`reviewer`],Q=new Set([`grounding`,`task`,`decision`,`agent_message`,`assistant_message`,`command_execution`,`tool_use`,`handoff`,`review`,`verdict`,`completion`,`plan`,`file_change`,`result`]),fc=/^(using a tool|running project command|inspecting project state|working|reporting progress|暂无详细记录)$/i;function pc(e){let t=Et(e).replace(/^\s*(?:RESULT|SUMMARY)\s*=\s*/gim,``).trim();return fc.test(t)||t.startsWith(`{`)?``:t}function mc(e,t,n=``){if(n){if(/^(?:rg|grep|glob|search)$/.test(n))return t?`检索项目文件`:`Searching project files`;if(/^(?:view|read|read_file)$/.test(n))return t?`读取文件`:`Reading a file`;if(/apply_patch|edit|write/.test(n))return t?`编辑文件`:`Editing a file`;if(/bash|shell|exec|terminal/.test(n))return t?`运行终端命令`:`Running a command`;if(/playwright|browser/.test(n))return t?`检查浏览器交互`:`Checking browser interactions`}return({grounding:[`理解任务与检查项目`,`Understanding the task`],task:[`安排任务`,`Task assignment`],decision:[`确定执行方案`,`Execution decision`],plan:[`制定执行计划`,`Planning the work`],agent_message:[`更新执行进度`,`Progress update`],assistant_message:[`更新执行进度`,`Progress update`],command_execution:[`运行项目命令`,`Running a project command`],tool_use:[`使用工具`,`Using a tool`],file_change:[`更新项目文件`,`Updating project files`],handoff:[`提交结果与交接`,`Results and handoff`],review:[`复核实现与结果`,`Reviewing implementation and results`],verdict:[`给出审查结论`,`Review verdict`],completion:[`完成任务`,`Task completed`],result:[`产出结果`,`Result`]}[e]??[e,e])[+!t]}function hc(e,t,n){let r=new Map;for(let i of e?.role_work??[]){if(i.role!==t||!Q.has(i.kind))continue;let e=i.item_id||i.mission_id;n&&e!==n||r.set(i.id,{...i,detail:pc(i.detail)})}return[...r.values()].sort((e,t)=>t.ts-e.ts)}function gc(e,t,n){return[...e].reverse().find(e=>e.type===`engineer.progress`&&[`tool_use`,`command_execution`,`file_change`].includes(String(e.kind))&&String(e.agent_layer||e.actor||e.role)===t&&(!n||String(e.item_id||e.mission_id)===n))}function _c(e,t,n,r,i){return r||[`done`,`completed`,`failed`,`aborted`,`stopped`].includes(e?.mission.status??``)||i&&e?.mission.id!==i?!1:t.length?t.some(e=>e.role===n&&e.active):e?.active_role===n&&[`working`,`grounding`,`framed`,`running`].includes(e?.mission.status??``)}var vc={manager:[`统筹`,`Manager`],planner:[`规划`,`Planner`],engineer:[`执行`,`Engineer`],reviewer:[`审查`,`Reviewer`]};function yc({view:e,roles:t=[],events:n=[],taskId:r,paused:i=!1,selectedRole:a,onSelectRole:o,onClose:s,showTabs:c=!0}){let{locale:l}=Z(),u=l===`zh-CN`,[d,f]=(0,I.useState)(null),[p,m]=(0,I.useState)(Date.now),h=a||d||t.find(e=>e.active)?.role||e?.active_role||`manager`,g=_c(e,t,h,i,r),_=hc(e,h,r),v=_[0],y=_.find(e=>e.detail&&[`agent_message`,`assistant_message`,`decision`,`verdict`,`handoff`,`review`,`completion`].includes(e.kind)),b=gc(n,h,r),x=b&&Number(b.ts||0)>=(v?.ts??0),S=!x&&v&&[`agent_message`,`assistant_message`].includes(v.kind)&&v.detail?v.detail.split(/[。\n]/)[0].slice(0,70):mc(x?String(b.kind):v?.kind||`task`,u,x?String(b.tool_name||``):``),C=t.find(e=>e.role===h)?.model||e?.roles.find(e=>e.role===h)?.model,w=v?Math.max(0,Math.floor(p/1e3-v.ts)):0;(0,I.useEffect)(()=>{if(!g)return;let e=setInterval(()=>m(Date.now()),1e3);return()=>clearInterval(e)},[g]);let T=e=>vc[e]?.[+!u]||e;return(0,X.jsxs)(`section`,{className:`agent-activity`,"aria-label":u?`Agent 工作详情`:`Agent work details`,children:[(0,X.jsxs)(`header`,{className:`agent-activity-heading`,children:[(0,X.jsxs)(`span`,{children:[(0,X.jsx)(La,{size:15}),u?`Agent 动态`:`Agent activity`]}),s&&(0,X.jsx)(`button`,{type:`button`,onClick:s,"aria-label":u?`关闭 Agent 详情`:`Close Agent details`,children:(0,X.jsx)(oo,{size:17})})]}),c&&(0,X.jsx)(`div`,{className:`agent-activity-tabs`,role:`group`,"aria-label":u?`筛选 Agent`:`Filter agents`,children:dc.map(n=>(0,X.jsxs)(`button`,{type:`button`,"data-role":n,"aria-pressed":h===n,onClick:()=>{f(n),o?.(n)},children:[(0,X.jsx)(`i`,{"data-active":_c(e,t,n,i,r)}),T(n)]},n))}),(0,X.jsxs)(`div`,{className:`agent-current`,"data-active":g,children:[(0,X.jsxs)(`div`,{className:`agent-current-kicker`,children:[(0,X.jsx)(`span`,{children:g?T(h)+(u?` Agent 正在工作`:` is working`):i?u?`会话已暂停`:`Session paused`:u?`最近进度`:`Latest progress`}),g?(0,X.jsxs)(`span`,{className:`agent-live-indicator`,children:[(0,X.jsx)(`i`,{}),`LIVE`]}):(0,X.jsx)(to,{size:12})]}),(0,X.jsx)(`h3`,{children:v||x?S:u?`等待任务分配`:`Waiting for an assignment`}),y?.detail&&(0,X.jsx)(`div`,{className:`agent-current-summary`,children:(0,X.jsx)(ki,{children:y.detail})}),!y&&v?.detail&&(0,X.jsx)(`p`,{className:`agent-current-summary`,children:v.detail}),v&&(0,X.jsxs)(`div`,{className:`agent-current-meta`,children:[(0,X.jsx)(Ga,{size:12}),(0,X.jsx)(`span`,{children:u?`${w<60?w+` 秒`:Math.floor(w/60)+` 分钟`}前更新`:`Updated ${w<60?w+`s`:Math.floor(w/60)+`m`} ago`}),C&&(0,X.jsx)(`span`,{children:C})]})]}),(0,X.jsxs)(`div`,{className:`agent-records-heading`,children:[(0,X.jsx)(`span`,{children:u?`工作记录`:`Work log`}),(0,X.jsxs)(`span`,{children:[_.length,` `,u?`条`:`records`]})]}),(0,X.jsxs)(`div`,{className:`agent-records`,role:`log`,"aria-live":`off`,children:[_.slice(0,24).map((e,t)=>{let n=g&&t===0,r=[`done`,`completed`].includes(e.status),i=[`failed`,`error`,`rejected`].includes(e.status),a=r?Va:[`tool_use`,`command_execution`].includes(e.kind)?ao:Ya;return(0,X.jsxs)(`article`,{className:`agent-record`,"data-active":n,"data-failed":i,children:[(0,X.jsx)(`span`,{className:`agent-record-icon`,children:(0,X.jsx)(a,{size:13})}),(0,X.jsxs)(`div`,{children:[(0,X.jsxs)(`div`,{className:`agent-record-title`,children:[(0,X.jsx)(`strong`,{children:mc(e.kind,u)}),(0,X.jsx)(`time`,{children:new Date(e.ts*1e3).toLocaleTimeString(u?`zh-CN`:`en-US`,{hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hour12:!1})})]}),(0,X.jsxs)(`small`,{children:[n?u?`进行中`:`In progress`:i?u?`需要处理`:`Needs attention`:r?u?`已完成`:`Completed`:u?`已记录`:`Recorded`,e.round_index==null?``:u?` · 第 ${e.round_index} 轮`:` · Round ${e.round_index}`]}),e.detail&&(0,X.jsxs)(`details`,{open:t===0||e===y,children:[(0,X.jsxs)(`summary`,{children:[(0,X.jsx)(`span`,{children:u?`查看详情`:`Read details`}),(0,X.jsx)(Ha,{size:12})]}),(0,X.jsx)(`div`,{className:`agent-record-detail`,children:(0,X.jsx)(ki,{children:e.detail})})]})]})]},e.id)}),!_.length&&(0,X.jsx)(`p`,{className:`agent-records-empty`,children:u?`${T(h)}尚未留下这个任务的工作记录。`:`No work has been recorded for this task by ${T(h)}.`})]})]})}var bc=[`manager`,`planner`,`engineer`,`reviewer`],xc=[`active`,`running`,`in_progress`,`claimed`],Sc=[`complete`,`completed`,`done`,`success`,`incomplete`,`stalled`,`blocked`,`ended`],Cc=864e5,wc=300;function Tc(e,t){return bc.includes(e)?t(`role.${e}`):Vi(e,t)}function Ec(e){let t=e.type.toLowerCase().split(/[._-]/).at(-1);return[`failed`,`failure`,`error`].includes(t??``)||e.tone===`error`&&/\bfailed\b/i.test(e.title)}function Dc(e,t,n=new Date){let r=new Date(e*1e3),i=r.toLocaleTimeString(t,{hour:`2-digit`,minute:`2-digit`,hourCycle:`h23`}),a=Date.UTC(n.getFullYear(),n.getMonth(),n.getDate()),o=Date.UTC(r.getFullYear(),r.getMonth(),r.getDate());if(o===a)return i;let s=+(t===`zh-CN`);return o>=a-(n.getDay()-s+7)%7*Cc&&ot;(0,I.useEffect)(()=>{if(t!=null||a)return;let e=i.current;if(!e)return;let n=()=>c(e.scrollHeight>e.clientHeight);n();let r=new ResizeObserver(n);return r.observe(e),()=>r.disconnect()},[e,a,t]);let u=!a&&t!=null&&l?`${e.slice(0,t)}…`:e;return(0,X.jsxs)(`div`,{className:`mt-2`,children:[(0,X.jsx)(`p`,{ref:i,className:`${t==null&&!a?`line-clamp-3`:``} whitespace-pre-wrap break-words ${n}`,children:u}),l?(0,X.jsx)(`button`,{type:`button`,onClick:()=>o(e=>!e),"aria-expanded":a,className:`mt-1 text-[11px] text-blue-sky hover:text-ink`,children:r(a?`mission.showLess`:`mission.showMore`)}):null]})}function kc(e){let t=[...e.dag],n=[],r=new Set;for(;t.length;){let i=t.findIndex(t=>t.deps.every(t=>r.has(t)||!e.dag.some(e=>e.id===t))),[a]=t.splice(i>=0?i:0,1);n.push(a),r.add(a.id)}return n}function Ac(e,t=16){let n=kc(e);if(n.length<=t)return{nodes:n,hidden:[]};let r=new Set(n.slice(-t).map(e=>e.id)),i=n.find(e=>[`running`,`in_progress`,`claimed`].includes(e.status)),a=new Map(n.map(e=>[e.id,e])),o=i?[i]:[];for(;o.length;){let e=o.pop();r.has(e.id)||(r.add(e.id),e.deps.forEach(e=>{let t=a.get(e);t&&o.push(t)}))}return{nodes:n.filter(e=>r.has(e.id)),hidden:n.filter(e=>!r.has(e.id))}}function jc({view:e}){let{t}=Z(),n=e.achievement;return n?(0,X.jsxs)(`section`,{className:`border-b border-ok/35 bg-ok/5 px-5 py-4 animate-appear`,children:[(0,X.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-[0.16em] text-ok`,children:t(`mission.achievement`)}),(0,X.jsx)(`div`,{className:`mt-2 text-sm font-semibold text-ink`,children:n.title}),n.summary?(0,X.jsx)(`div`,{className:`mt-1 text-xs text-ink-dim`,children:n.summary}):null,(0,X.jsxs)(`div`,{className:`mt-2 text-xs`,children:[(0,X.jsxs)(`span`,{className:`text-ink-faint`,children:[t(`mission.elapsed`),` `]}),(0,X.jsx)(`span`,{className:`font-mono text-ink`,children:wn(n.elapsed_seconds??0)})]}),(0,X.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-x-5 gap-y-1 text-[11px] text-ink-dim`,children:[(0,X.jsx)(`span`,{children:t(`mission.rejectedAttempts`,{count:n.rejected_attempts??0})}),(0,X.jsx)(`span`,{children:t(`mission.skillsLearned`,{count:n.skills_learned??0})}),(0,X.jsx)(`span`,{children:t(`mission.artifacts`,{count:n.artifacts??0})})]})]}):null}function Mc({view:e,sid:t=``,snapshot:n,artifacts:r=[],onOpenArtifact:i,onOpenDelivery:a,gitDiff:o,onNotify:s}){let{locale:c,t:l}=Z(),u=new Map(e.roles.map(e=>[e.role,e])),d=e.dag.find(e=>[`running`,`in_progress`,`claimed`].includes(e.status)),f=Ac(e),p=f.nodes,m=Cn(e.mission.objective||e.mission.title||l(`mission.waiting`)),h=e.mission.final_output?.trim()||``,g=!!(h&&h!==e.mission.summary.trim()),[_,v]=(0,I.useState)(Math.max(0,e.timeline.length-1)),[y,b]=(0,I.useState)(e.active_role||`planner`),[x,S]=(0,I.useState)(d?.id||``),[C,w]=(0,I.useState)(!1),T=e.delivery,E=new Map(r.map(e=>[e.path,e])),D=e.learned_skills.filter(e=>e.status===`active`),ee=e.learned_wiki_pages.filter(e=>e.status!==`retired`),O=!!(e.storage.project_skill_dir||e.storage.global_skill_dir||e.storage.wiki_paths.length||e.storage.skill_history_compressed||e.storage.wiki_retired_compressed),te=!!(D.length||ee.length||O),ne=e.mission.status.toLowerCase(),k=[`working`,`grounding`,`framed`].includes(ne),re=[`degraded`,`red`,`critical`].includes(e.health?.toLowerCase()??``),A=[`failed`,`error`].includes(e.mission.status.toLowerCase()),j=e.dag.some(t=>t.status.toLowerCase()===`failed`&&(t.id===e.mission.id||!k&&!d)),ie=[`hold`,`paused`].includes(e.stage.id.toLowerCase()),ae=e.outcome.execution_status?.toLowerCase()===`failed`&&e.stage.id.toLowerCase()===`delivery`,M=re||ae||A||j||ie,oe=re?`mission.attentionHealth`:ae?`mission.deliveryFailed`:A?`mission.attentionFailed`:j?`mission.attentionStepFailed`:`mission.attentionPaused`,se=e.role_work.filter(e=>xc.includes(e.status.toLowerCase())).sort((e,t)=>t.ts-e.ts),N=se.find(t=>t.role===e.active_role)??se[0],ce=Sc.includes(ne),le=Ui(e.outcome,l)[0]??Bi(e.mission.status,l),ue=M?l(oe):ce?l(`mission.statusDone`,{outcome:le,elapsed:wn(e.mission.elapsed_seconds)}):k&&N?l(`mission.statusActive`,{role:Vi(e.active_role||N.role,l),work:N.title}):l(`mission.statusWaiting`),de=re||ae||A||j?`error`:ie?`waiting`:ce?`done`:k&&N?`active`:`waiting`;(0,I.useEffect)(()=>v(Math.max(0,e.timeline.length-1)),[e.timeline.length]),(0,I.useEffect)(()=>{d?.id&&S(d.id)},[d?.id]);let fe=async()=>{if(!C){w(!0);try{await U.setContinuous(t,!0,n?.continuous?.objective??``),s?.(`success`,l(`sidebar.resumeSuccess`))}catch(e){s?.(`error`,l(`sidebar.resumeFailed`,{error:mi(e)}))}finally{w(!1)}}},P=e.timeline.slice(0,_+1).slice(-12).reverse(),F=e.dag.find(e=>e.id===x);return(0,X.jsxs)(`section`,{className:`min-h-0 flex-1 overflow-x-hidden overflow-y-auto bg-panel scroll-thin`,"aria-label":l(`mission.control`),children:[(0,X.jsxs)(`header`,{className:`border-b border-line/60 px-5 py-5`,children:[(0,X.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-[0.16em] text-ink-faint`,children:l(`mobile.mission`)}),(0,X.jsx)(`div`,{role:`heading`,"aria-level":1,className:`mt-1 line-clamp-4 max-w-4xl text-lg font-semibold leading-snug text-ink`,title:m,children:(0,X.jsx)(ki,{artifacts:r,onOpenArtifact:i,children:m})}),m.length>600?(0,X.jsxs)(`details`,{className:`mt-2 text-xs text-ink-faint`,children:[(0,X.jsx)(`summary`,{className:`cursor-pointer hover:text-ink`,children:l(`mission.showObjective`)}),(0,X.jsx)(`div`,{className:`mt-2 text-ink-dim`,children:(0,X.jsx)(ki,{artifacts:r,onOpenArtifact:i,children:m})})]}):null,(0,X.jsxs)(`div`,{className:`mission-status-line`,"data-tone":de,role:M?`alert`:`status`,children:[(0,X.jsxs)(`div`,{className:`mission-status-line__signal`,children:[(0,X.jsx)(`span`,{className:`mission-status-line__marker`,"aria-hidden":`true`}),(0,X.jsx)(`span`,{children:ue})]}),e.frontier.change?(0,X.jsx)(`div`,{className:`mission-status-line__subtitle`,children:e.frontier.change}):null]}),e.mission.summary||g?(0,X.jsxs)(`div`,{className:`mt-3 rounded border border-ok/25 bg-ok/5 px-3 py-2`,children:[(0,X.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-[0.12em] text-ok`,children:l(`mission.summary`)}),(0,X.jsx)(`div`,{className:`mt-1 whitespace-pre-wrap text-xs leading-relaxed text-ink-dim`,children:(0,X.jsx)(ki,{artifacts:r,onOpenArtifact:i,children:e.mission.summary})}),g?(0,X.jsxs)(`details`,{className:`mt-2 border-t border-ok/20 pt-2 text-xs text-ink-dim`,children:[(0,X.jsx)(`summary`,{className:`cursor-pointer font-medium text-ok hover:text-ink`,children:l(`mission.showFullOutput`)}),(0,X.jsx)(`div`,{className:`mt-3 break-words text-sm leading-relaxed text-ink`,children:(0,X.jsx)(ki,{artifacts:r,onOpenArtifact:i,children:h})})]}):null]}):null,T?(0,X.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-3 rounded border border-ok/30 bg-ok/5 px-3 py-2`,children:[(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-[0.12em] text-ok`,children:l(T.kind===`submission_certified`?`mission.deliveryCertified`:`mission.taskCompleted`)}),(0,X.jsx)(`div`,{className:`mt-1 truncate text-xs text-ink-dim`,title:T.summary||T.title,children:T.summary||T.title})]}),a?(0,X.jsx)(`button`,{type:`button`,onClick:()=>a(T),title:T.primary_target?E.get(T.primary_target.path)?.storage_path||T.primary_target.path:T.title,className:`shrink-0 rounded border border-ok/40 px-2 py-1 font-mono text-[10px] text-ok hover:border-ok`,children:l(T.primary_target?`mission.openResult`:`mission.viewTask`)}):null]}):null]}),n?.continuous?.done_at&&(0,X.jsxs)(`div`,{className:`mb-3 flex items-center gap-3 rounded-lg border-l-2 border-blue bg-blue/5 px-3 py-2`,children:[(0,X.jsx)(`span`,{className:`text-base`,children:`↩`}),(0,X.jsxs)(`span`,{className:`min-w-0 flex-1 truncate text-sm text-ink-dim`,children:[l(`mission.continuousDone`),n.continuous.objective?` · ${n.continuous.objective}`:``]}),(0,X.jsx)(`button`,{type:`button`,disabled:C,onClick:()=>void fe(),className:`compact-control shrink-0 px-3`,children:C?`…`:l(`mission.resumeContinuous`)})]}),(0,X.jsx)(jc,{view:e}),(0,X.jsxs)(`section`,{className:`border-b border-line/60 px-5 py-4`,"aria-label":l(`mission.team`),children:[(0,X.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-[0.16em] text-ink-faint`,children:l(`mission.team`)}),(0,X.jsx)(`div`,{className:`mt-3 grid gap-2 sm:grid-cols-2 xl:grid-cols-4`,children:bc.map(e=>{let t=u.get(e),n=t?.status===`active`,r=t?.status===`rejected`||t?.status===`error`,i=W.role[e]??W.inkFaint;return(0,X.jsxs)(`button`,{type:`button`,onClick:()=>b(e),"aria-pressed":y===e,className:`min-w-0 rounded-r-md border-l-2 py-2 pl-3 text-left transition-colors hover:bg-bg/60 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue`,style:{borderColor:y===e||n||t?.status===`done`?i:`rgb(var(--line))`,backgroundColor:y===e?`color-mix(in srgb, ${i} 8%, transparent)`:void 0},children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(`span`,{"data-role-dot":e,"aria-hidden":`true`,className:`h-2 w-2 shrink-0 rounded-full ${n?`animate-pulse motion-reduce:animate-none`:``}`,style:{background:i}}),(0,X.jsx)(`span`,{className:`text-xs font-semibold`,style:{color:i},children:Vi(e,l)})]}),(0,X.jsx)(`div`,{className:`mt-1 truncate text-xs ${r?`text-err`:`text-ink-dim`}`,children:t?.label||l(`mission.waitingShort`)})]},e)})})]}),(0,X.jsxs)(`section`,{className:`border-b border-line/60 px-5 py-4`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,X.jsxs)(`div`,{className:`text-[10px] font-semibold uppercase tracking-[0.16em] text-ink-faint`,children:[l(`mission.roleWork`),` · `,(0,X.jsx)(`span`,{style:{color:W.role[y]??W.inkDim},children:Vi(y,l)})]}),F?(0,X.jsx)(`button`,{type:`button`,onClick:()=>S(``),className:`text-[10px] text-ink-faint hover:text-ink`,children:l(`mission.filteredBy`,{task:F.title||F.objective||l(`task.untitled`)})}):(0,X.jsx)(`span`,{className:`text-[10px] text-ink-faint`,children:l(`mission.allVisible`)})]}),(0,X.jsx)(`div`,{className:`mt-3`,children:(0,X.jsx)(yc,{view:e,roles:n?.roles,events:n?.recent_events,taskId:x||void 0,selectedRole:y,showTabs:!1,paused:n?!n.daemon.alive:!1})})]}),(0,X.jsxs)(`div`,{className:`grid min-h-[320px] border-b border-line/60 lg:grid-cols-[minmax(0,1.15fr)_minmax(260px,0.85fr)]`,children:[(0,X.jsxs)(`section`,{className:`min-w-0 border-b border-line/60 px-5 py-4 lg:border-b-0 lg:border-r`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,X.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-[0.16em] text-ink-faint`,children:l(`mission.researchDag`)}),d?(0,X.jsxs)(`span`,{className:`max-w-48 truncate text-[10px] text-blue-sky`,children:[l(`mission.active`),` · `,d.title]}):null]}),(0,X.jsxs)(`div`,{className:`mt-3 space-y-0`,children:[f.hidden.length?(0,X.jsx)(`div`,{className:`mb-3 rounded border border-line/60 bg-bg/50 px-3 py-2 text-[10px] text-ink-faint`,children:l(`mission.hiddenTasks`,{count:f.hidden.length,failed:f.hidden.filter(e=>[`failed`,`blocked`].includes(e.status)).length,skipped:f.hidden.filter(e=>e.status===`skipped`).length})}):null,p.length?p.map((e,t)=>{let n=e.id===d?.id,r=[`done`,`completed`].includes(e.status),i=[`failed`,`blocked`].includes(e.status);return(0,X.jsxs)(`button`,{type:`button`,onClick:()=>S(e.id),className:`relative flex w-full min-w-0 gap-3 pb-3 text-left last:pb-0 ${x===e.id?`bg-white/[0.03]`:``}`,children:[t(0,X.jsx)(`li`,{children:e},e))})]}):null]}):null]}),(0,X.jsxs)(`section`,{className:`min-w-0 px-5 py-4`,children:[(0,X.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-[0.16em] text-ink-faint`,children:l(`mission.capabilities`)}),D.length?(0,X.jsxs)(`div`,{className:`mt-3`,children:[(0,X.jsx)(`div`,{className:`text-[10px] uppercase tracking-[0.12em] text-ok`,children:l(`mission.capabilitiesUnlocked`)}),(0,X.jsx)(`div`,{className:`mt-2 space-y-2`,children:D.slice(-8).map(e=>(0,X.jsxs)(`details`,{className:`rounded border border-ok/35 bg-ok/5 px-2 py-1.5`,children:[(0,X.jsx)(`summary`,{className:`cursor-pointer text-[10px] text-ok`,children:String(e.name||l(`mission.learnedCapability`))}),e.mission_title?(0,X.jsx)(`div`,{className:`mt-2 text-[9px] text-ink-faint`,children:l(`mission.learnedDuring`,{mission:e.mission_title})}):null,e.content?(0,X.jsxs)(`pre`,{className:`mt-2 max-h-64 overflow-auto whitespace-pre-wrap border-t border-ok/20 pt-2 font-mono text-[10px] leading-5 text-ink-dim scroll-thin`,children:[e.content,e.content_truncated?`\n… ${l(`mission.contentTruncated`)}`:``]}):(0,X.jsx)(`div`,{className:`mt-2 text-[10px] text-ink-faint`,children:l(`mission.skillUnavailable`)})]},String(e.id)))})]}):null,ee.length?(0,X.jsxs)(`div`,{className:`mt-4 border-t border-line/50 pt-3`,children:[(0,X.jsx)(`div`,{className:`text-[10px] uppercase tracking-[0.12em] text-blue-sky`,children:l(`mission.knowledgeRetained`)}),(0,X.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:ee.slice(-6).map(e=>(0,X.jsx)(`span`,{className:`rounded border border-blue/35 bg-blue/5 px-2 py-1 text-[10px] text-blue-sky`,children:String(e.title||e.id)},String(e.id)))})]}):null,O?(0,X.jsxs)(`div`,{className:`mt-4 border-t border-line/50 pt-3`,children:[(0,X.jsx)(`div`,{className:`text-[10px] uppercase tracking-[0.12em] text-ink-faint`,children:l(`mission.selfEvolution`)}),(0,X.jsx)(`div`,{className:`mt-2 text-[10px] text-ink-dim`,children:l(`mission.knowledgeSaved`)})]}):null,te?null:(0,X.jsx)(`div`,{className:`py-10 text-center text-xs text-ink-faint`,children:l(`mission.noCapabilities`)})]})]}),(0,X.jsxs)(`section`,{className:`px-5 py-4`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,X.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-[0.16em] text-ink-faint`,children:l(`mission.replay`)}),e.timeline.length>1?(0,X.jsx)(`input`,{type:`range`,min:0,max:e.timeline.length-1,value:_,onChange:e=>v(Number(e.target.value)),"aria-label":l(`mission.replayTimeline`),className:`h-1 min-w-32 flex-1 accent-blue`}):null,P.length?(0,X.jsx)(`span`,{className:`text-[10px] text-ink-faint`,children:l(P.length===1?`mission.showingLatestEvent`:`mission.showingLastEvents`,{count:P.length})}):null]}),(0,X.jsxs)(`div`,{className:`mt-3 space-y-3`,children:[P.map(e=>{let t=new Date(e.ts*1e3),n=W.role[e.role]??W.inkFaint,r=Ec(e)?l(`mission.roleFailed`,{role:Tc(e.role,l)}):e.title;return(0,X.jsxs)(`article`,{className:`rounded border border-line/60 bg-bg/35 px-3 py-2.5 text-xs`,children:[(0,X.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`mt-1.5 h-2 w-2 shrink-0 rounded-full ${e.tone===`error`?`bg-err`:e.tone===`success`||e.tone===`metric`||e.tone===`skill`?`bg-ok`:`bg-blue`}`}),(0,X.jsx)(`span`,{className:`shrink-0 rounded-full border px-2 py-0.5 text-[10px] font-medium`,style:{borderColor:n,color:n},children:Tc(e.role,l)}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 break-words font-medium leading-5 text-ink`,children:r}),(0,X.jsx)(`time`,{dateTime:t.toISOString(),title:t.toLocaleString(c,{dateStyle:`medium`,timeStyle:`short`}),className:`shrink-0 font-mono text-[10px] text-ink-faint`,children:Dc(e.ts,c)})]}),e.detail?(0,X.jsx)(Oc,{detail:e.detail,previewLength:wc,textClassName:`leading-5 text-ink-dim`}):null]},e.id)}),e.timeline.length?null:(0,X.jsx)(`div`,{className:`py-10 text-center text-xs text-ink-faint`,children:l(`mission.waitingEvents`)})]}),e.artifacts.length?(0,X.jsx)(`div`,{className:`mt-5 flex flex-wrap gap-2 border-t border-line/50 pt-4`,children:e.artifacts.slice(-8).map(e=>{let t=String(e.path||``),n=E.get(t);return(0,X.jsx)(`button`,{type:`button`,disabled:!t||!i||n?.exists===!1,onClick:()=>t&&i?.(t),title:n?.storage_path||t,className:`rounded border border-line px-2 py-1 font-mono text-[10px] text-blue-sky hover:border-blue-sky/50 disabled:text-ink-faint`,children:String(e.title||l(`research.artifact`))},String(e.id||t))})}):null,o?.available&&(o.status||o.diff)?(0,X.jsxs)(`div`,{className:`mt-5 border-t border-line/50 pt-4 text-[10px] text-ink-faint`,children:[(0,X.jsx)(`span`,{className:`font-semibold uppercase tracking-[0.14em]`,children:l(`mission.projectFilesChanged`)}),(0,X.jsxs)(`span`,{children:[` · `,l(`mission.reviewInIde`)]})]}):null]})]})}var Nc={available:`bg-ok/10 text-ok`,absent:`bg-bg text-ink-faint`,inaccessible:`bg-warn/10 text-warn`,degraded:`bg-warn/10 text-warn`};function Pc({status:e,error:t}){let{t:n}=Z();return(0,X.jsxs)(`section`,{className:`rounded-lg border border-line bg-panel p-4 lg:col-span-2`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,X.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wide text-ink-dim`,children:n(`resource.title`)}),e?(0,X.jsx)(`span`,{className:`rounded px-2 py-1 text-[10px] font-semibold uppercase ${e.enforcement===`strict`?`bg-ok/10 text-ok`:`bg-warn/10 text-warn`}`,children:Gi(e.enforcement,n)}):null]}),t?(0,X.jsx)(`p`,{className:`mt-3 text-xs text-err`,children:t}):null,!e&&!t?(0,X.jsx)(`p`,{className:`mt-3 text-xs text-ink-faint`,children:n(`resource.loading`)}):null,e?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`mt-3 grid gap-2 sm:grid-cols-2`,children:e.accelerators.map(e=>(0,X.jsxs)(`div`,{className:`rounded border border-line bg-bg p-3`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,X.jsx)(`span`,{className:`text-xs font-semibold text-ink`,children:Wi(e.kind,n)}),(0,X.jsxs)(`span`,{className:`rounded px-2 py-0.5 text-[10px] font-medium ${Nc[e.status]}`,children:[Bi(e.status,n),` · `,n(`resource.devices`,{count:e.device_count})]})]}),e.detail?(0,X.jsx)(`p`,{className:`mt-2 text-xs text-ink-faint`,children:e.detail}):null]},e.kind))}),(0,X.jsxs)(`div`,{className:`mt-4 grid gap-4 md:grid-cols-2`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`h4`,{className:`text-[10px] font-semibold uppercase tracking-wide text-ink-faint`,children:n(`resource.inUse`,{count:e.holders.length})}),(0,X.jsx)(`div`,{className:`mt-2 space-y-2`,children:e.holders.length===0?(0,X.jsx)(`p`,{className:`text-xs text-ink-faint`,children:n(`resource.none`)}):e.holders.map((e,t)=>(0,X.jsxs)(`div`,{className:`rounded border border-line bg-bg p-3 text-xs`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,X.jsx)(`span`,{className:`font-medium text-ink`,children:n(`resource.devices`,{count:e.device_count})}),(0,X.jsx)(`span`,{className:`shrink-0 font-mono text-ink-faint`,children:n(`resource.timeLeft`,{ttl:Tn(e.ttl_seconds)})})]}),(0,X.jsx)(`p`,{className:`mt-1 text-ink-dim`,children:e.intent||n(`resource.noIntent`)}),e.yield_requests.map((e,t)=>(0,X.jsxs)(`div`,{className:`mt-2 border-l-2 border-warn/50 pl-2 text-ink-faint`,children:[(0,X.jsx)(`div`,{children:n(`resource.yieldRequest`,{reason:e.reason})}),e.response?(0,X.jsxs)(`div`,{children:[Ki(e.response.decision,n),` · `,e.response.reason]}):null]},t))]},`${e.project}:${e.task_id}:${t}`))})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`h4`,{className:`text-[10px] font-semibold uppercase tracking-wide text-ink-faint`,children:n(`resource.queue`,{count:e.queue.length})}),(0,X.jsx)(`div`,{className:`mt-2 space-y-2`,children:e.queue.length===0?(0,X.jsx)(`p`,{className:`text-xs text-ink-faint`,children:n(`resource.none`)}):e.queue.map(e=>(0,X.jsxs)(`div`,{className:`rounded border border-line bg-bg p-3 text-xs`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,X.jsx)(`span`,{className:`font-medium text-ink`,children:n(`resource.queuePosition`,{position:e.position})}),(0,X.jsx)(`span`,{className:`shrink-0 font-mono text-ink-faint`,children:n(`resource.timeLeft`,{ttl:Tn(e.ttl_seconds)})})]}),(0,X.jsx)(`p`,{className:`mt-1 text-ink-dim`,children:e.intent||n(`resource.noIntent`)})]},e.position))})]})]})]}):null]})}var Fc=e=>e instanceof Error?e.message:String(e||`Unknown error`);async function Ic(e){let t=await e,n=t&&typeof t==`object`?t:{},r=String(n.command_status??``);if(Number(n.rc??0)!==0||r===`failed`||r===`rejected`)throw Error(String(n.error||`daemon command ${r||`failed`}`));return t}function Lc({open:e,sid:t,snap:n,onClose:i,onChanged:s,onRestored:c}){let{t:l}=Z(),[p,m]=(0,I.useState)(`task`),[g,_]=(0,I.useState)(``),[v,x]=(0,I.useState)(n.session.workdir??n.session.cwd??``),[C,T]=(0,I.useState)(`ls`),[E,D]=(0,I.useState)(``),[ne,k]=(0,I.useState)(``),[re,A]=(0,I.useState)(null),[j,ie]=(0,I.useState)(null),[ae,M]=(0,I.useState)(null),[oe,se]=(0,I.useState)(``),[N,ce]=(0,I.useState)([]),[le,ue]=(0,I.useState)(0),[de,fe]=(0,I.useState)(``),[P,F]=(0,I.useState)(``),[pe,me]=(0,I.useState)(`work`);(0,I.useEffect)(()=>{e&&(x(n.session.workdir??n.session.cwd??``),Promise.all([U.metrics(),U.trash()]).then(([e,t])=>{A(e),ce(t.entries),ue(t.total)},e=>D(Fc(e))))},[e,n.session.cwd,n.session.workdir]),(0,I.useEffect)(()=>{if(!e)return;let t=!1,n=async()=>{try{let e=await U.sourceUpdateStatus();t||ie(e)}catch(e){t||D(Fc(e))}};U.sourceUpdateStatus().then(async e=>{if(!t&&(ie(e),!e.running)){let e=await U.checkSourceUpdate();t||ie(e)}}).catch(e=>{t||D(Fc(e))});let r=window.setInterval(()=>void n(),1500);return()=>{t=!0,window.clearInterval(r)}},[e]),(0,I.useEffect)(()=>{!e||pe!==`system`||(M(null),se(``),U.resources().then(M,e=>se(Fc(e))))},[e,pe]);let he=async(e,t,n)=>{if(!P){F(e),D(``);try{let e=await t();n!==null&&D(n||JSON.stringify(e,null,2)),s()}catch(e){D(Fc(e))}finally{F(``)}}},ge=async()=>{let e=g.trim();if(e){if(p===`plan`){await he(`quick`,async()=>{let n=await U.previewPlan(t,e);return D([...n.steps.map((e,t)=>`${t+1}. ${e.title}${e.detail?` — ${e.detail}`:``}`),...n.notes.map(e=>`Note: ${e}`),...n.error?[`Error: ${n.error}`]:[]].join(` +`)),n},null);return}await he(`quick`,p===`task`?()=>U.addTask(t,e):p===`nudge`?()=>U.nudge(t,e):()=>U.note(t,e),`${p} submitted.`),_(``)}},_e=async e=>{await he(`restore:${e.trash_id}`,async()=>{let t=await U.restoreTrash(e.trash_id);return ce(t=>t.filter(t=>t.trash_id!==e.trash_id)),ue(e=>Math.max(0,e-1)),await c(t.sid),t},`Restored ${e.label}.`)},ve=n.daemon.alive&&n.daemon.protocol_compatible===!1,ye=n.daemon.alive&&n.daemon.control_available===!1,be=n.daemon_admission?.running_daemons??[],xe=p===`task`?h:p===`nudge`?te:p===`note`?d:y,Se=l(`operations.action.${p}`),Ce=async()=>{await he(`trash-search`,async()=>{let e=await U.trash(de);return ce(e.entries),ue(e.total),e},null)};return(0,X.jsxs)(go,{open:e,onClose:()=>!P&&i(),label:l(`operations.title`),width:`max-w-5xl`,children:[(0,X.jsx)(_o,{title:l(`operations.title`),sub:n.session.display_name||t}),(0,X.jsx)(`div`,{className:`flex gap-1 overflow-x-auto border-b border-line bg-panel px-4 py-2 scroll-thin`,children:[[`work`,l(`operations.work`),h],[`runtime`,l(`operations.runtime`),b],[`system`,l(`operations.system`),u],[`recovery`,l(`operations.recovery`),a]].map(([e,t,n])=>(0,X.jsxs)(`button`,{type:`button`,onClick:()=>{me(e),D(``)},"aria-current":pe===e?`page`:void 0,className:`flex h-8 shrink-0 items-center justify-center gap-2 rounded-md px-3 text-xs font-medium ${pe===e?`bg-blue/10 text-blue`:`text-ink-faint hover:bg-bg hover:text-ink`}`,children:[(0,X.jsx)(o,{icon:n}),(0,X.jsx)(`span`,{children:t})]},e))}),(0,X.jsxs)(`div`,{className:`grid max-h-[76vh] gap-3 overflow-y-auto bg-bg p-3 scroll-thin lg:grid-cols-2`,children:[pe===`work`?(0,X.jsxs)(`section`,{className:`rounded-lg border border-line bg-panel p-4 lg:col-span-2`,children:[(0,X.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wide text-ink-dim`,children:l(`operations.workInput`)}),(0,X.jsx)(`p`,{className:`mt-1 text-xs text-ink-faint`,children:l(`operations.workHint`)}),(0,X.jsx)(`div`,{className:`mt-3 grid grid-cols-2 gap-1 sm:grid-cols-4`,children:[[`task`,h],[`nudge`,te],[`note`,d],[`plan`,y]].map(([e,t])=>(0,X.jsxs)(`button`,{type:`button`,onClick:()=>m(e),"aria-pressed":p===e,className:`flex h-9 items-center justify-center gap-2 rounded px-2 text-xs font-medium ${p===e?`bg-blue/10 text-blue`:`bg-bg text-ink-dim hover:text-ink`}`,children:[(0,X.jsx)(o,{icon:t}),(0,X.jsx)(`span`,{children:l(`operations.action.${e}`)})]},e))}),(0,X.jsx)(`textarea`,{value:g,onChange:e=>_(e.target.value),rows:5,placeholder:p===`plan`?l(`operations.planPlaceholder`):l(`operations.actionPlaceholder`,{action:p}),className:`mt-3 w-full resize-y rounded border border-line bg-bg p-3 text-sm text-ink outline-none focus:border-blue`}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>void ge(),disabled:!!P||!g.trim(),className:`mt-2 flex h-9 items-center justify-center gap-2 rounded border border-blue/35 bg-blue/8 px-3 text-xs font-medium text-blue hover:border-blue-deep hover:bg-blue-deep hover:text-white disabled:opacity-40`,children:P===`quick`?`…`:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(o,{icon:xe}),(0,X.jsx)(`span`,{children:p===`plan`?l(`operations.previewPlan`):l(`operations.submitAction`,{action:Se})})]})})]}):null,pe===`runtime`?(0,X.jsxs)(`section`,{className:`rounded-lg border border-line bg-panel p-4 lg:col-span-2`,children:[(0,X.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wide text-ink-dim`,children:l(`operations.runtime`)}),(0,X.jsx)(`p`,{className:`mt-1 text-xs text-ink-faint`,children:l(`operations.runtimeHint`)}),(0,X.jsx)(`label`,{className:`mt-3 block text-[10px] uppercase tracking-wide text-ink-faint`,children:l(`operations.workdir`)}),(0,X.jsxs)(`div`,{className:`mt-1 flex gap-2`,children:[(0,X.jsx)(`input`,{value:v,onChange:e=>x(e.target.value),className:`h-9 min-w-0 flex-1 rounded border border-line bg-bg px-2 font-mono text-xs text-ink outline-none focus:border-blue`}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>void he(`cwd`,()=>U.setWorkdir(t,v),l(`operations.workdirUpdated`)),disabled:!!P||!v.trim(),title:l(`operations.applyWorkdir`),"aria-label":l(`operations.applyWorkdir`),className:`flex h-9 w-9 items-center justify-center rounded border border-blue/50 text-xs text-blue disabled:opacity-40`,children:(0,X.jsx)(o,{icon:S})})]}),(0,X.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-2`,children:[(0,X.jsx)(`button`,{type:`button`,onClick:()=>void he(`reset`,()=>U.resetManager(t),`Manager context reset.`),disabled:!!P,title:l(`operations.resetManager`),"aria-label":l(`operations.resetManager`),className:`flex h-9 w-9 items-center justify-center rounded border border-line text-xs text-ink-dim disabled:opacity-40`,children:(0,X.jsx)(o,{icon:O})}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>void he(`upgrade`,()=>Ic(U.upgradeDaemon(t,n.daemon_commands?.revision)),`Current-release daemon started after safely draining active work.`),disabled:!!P||ye,title:ye?`Externally supervised daemon cannot be restarted from this Web host`:ve?`Upgrade incompatible daemon`:`Restart on current release`,"aria-label":ye?`Externally supervised daemon`:ve?`Upgrade incompatible daemon`:`Restart on current release`,className:`flex h-9 w-9 items-center justify-center rounded border text-xs disabled:opacity-40 ${ve?`border-err/60 bg-err/10 text-err`:`border-line text-ink-dim`}`,children:(0,X.jsx)(o,{icon:w})})]}),(0,X.jsxs)(`div`,{className:`mt-4 rounded-lg border border-line bg-bg p-3`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-start gap-3`,children:[(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(`span`,{className:`text-xs font-semibold text-ink`,children:l(`operations.sourceUpdate`)}),(0,X.jsx)(`span`,{className:`rounded px-1.5 py-0.5 text-[10px] font-semibold ${j?.state===`failed`?`bg-err/10 text-err`:j?.update_available?`bg-warn/10 text-warn`:j?.update_available===!1?`bg-ok/10 text-ok`:`bg-line text-ink-dim`}`,children:j?.running?l(`operations.updateRunning`):j?.update_available?l(`operations.updateAvailable`):j?.update_available===!1?l(`operations.updateCurrent`):l(`operations.updateChecking`)})]}),(0,X.jsx)(`p`,{className:`mt-1 text-xs text-ink-faint`,children:j?.error||j?.message||l(`operations.updateChecking`)}),(0,X.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-x-4 gap-y-1 font-mono text-[10px] text-ink-dim`,children:[(0,X.jsxs)(`span`,{children:[l(`operations.currentRevision`),`: `,j?.current_revision?.slice(0,12)||`—`]}),(0,X.jsxs)(`span`,{children:[l(`operations.latestRevision`),`: `,j?.upstream_revision?.slice(0,12)||`—`]}),j?.phase&&j.phase!==`complete`&&j.phase!==`idle`?(0,X.jsxs)(`span`,{children:[l(`operations.updatePhase`),`: `,j.phase]}):null]}),j?.running?(0,X.jsx)(`div`,{className:`mt-2 h-1 overflow-hidden rounded bg-line`,children:(0,X.jsx)(`div`,{className:`h-full w-1/2 animate-pulse rounded bg-blue`})}):null]}),(0,X.jsxs)(`button`,{type:`button`,onClick:()=>void he(`source-update`,async()=>{let e=await U.applySourceUpdate();return ie(e),e},null),disabled:!!P||!!j?.running||j?.can_update===!1,title:j?.can_update===!1?j.error||l(`operations.updateUnavailable`):l(`operations.pullLatest`),"aria-label":l(`operations.pullLatest`),className:`flex h-9 items-center gap-2 rounded border border-blue/50 px-3 text-xs font-medium text-blue disabled:opacity-40`,children:[(0,X.jsx)(o,{icon:f}),(0,X.jsx)(`span`,{children:j?.running?l(`operations.updateRunning`):l(`operations.pullLatest`)})]})]}),j?.restart_required?(0,X.jsx)(`p`,{className:`mt-2 text-xs text-warn`,children:l(`operations.updateRestart`)}):null]}),n.daemon.protocol_error?(0,X.jsx)(`p`,{className:`mt-2 text-xs text-err`,children:n.daemon.protocol_error}):null,be.length?(0,X.jsxs)(`div`,{className:`mt-4`,children:[(0,X.jsx)(`div`,{className:`text-[10px] uppercase tracking-wide text-ink-faint`,children:l(`operations.replaceSlot`)}),(0,X.jsx)(`div`,{className:`mt-2 space-y-1`,children:be.map(e=>(0,X.jsxs)(`button`,{type:`button`,disabled:!!P,onClick:()=>void he(`replace:${e.id}`,()=>Ic(U.replaceDaemon(t,e.id,!!n.continuous?.enabled,n.daemon_commands?.revision)),`Parked ${e.label||e.id} and started this session.`),title:`Replace ${e.label||e.id}`,"aria-label":`Replace ${e.label||e.id}`,className:`flex w-full items-center justify-between rounded border border-line bg-bg px-2 py-1.5 text-left text-xs text-ink-dim disabled:opacity-40`,children:[(0,X.jsx)(`span`,{className:`truncate`,children:e.label||e.id}),(0,X.jsx)(o,{icon:w,className:`ml-2 text-warn`})]},e.id))})]}):null]}):null,pe===`system`?(0,X.jsxs)(`section`,{className:`rounded-lg border border-line bg-panel p-4`,children:[(0,X.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wide text-ink-dim`,children:l(`operations.skills`)}),(0,X.jsxs)(`div`,{className:`mt-3 flex gap-2`,children:[(0,X.jsx)(`input`,{value:C,onChange:e=>T(e.target.value),className:`h-9 min-w-0 flex-1 rounded border border-line bg-bg px-2 font-mono text-xs text-ink outline-none focus:border-blue`,placeholder:`ls, stats, show NAME…`}),(0,X.jsx)(`button`,{type:`button`,disabled:!!P,onClick:()=>void he(`skills`,async()=>{let e=await U.skills(t,C);return k(e),e},null),title:l(`operations.runSkill`),"aria-label":l(`operations.runSkill`),className:`flex h-9 w-9 items-center justify-center rounded border border-blue/50 text-xs text-blue disabled:opacity-40`,children:(0,X.jsx)(o,{icon:r})})]}),ne?(0,X.jsx)(`pre`,{className:`mt-3 max-h-48 overflow-auto whitespace-pre-wrap rounded bg-bg p-3 font-mono text-xs text-ink-dim scroll-thin`,children:ne}):null]}):null,pe===`system`?(0,X.jsxs)(`section`,{className:`rounded-lg border border-line bg-panel p-4`,children:[(0,X.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wide text-ink-dim`,children:l(`operations.metrics`)}),(0,X.jsxs)(`div`,{className:`mt-3 flex items-center gap-3`,children:[(0,X.jsx)(`span`,{className:`rounded px-2 py-1 text-xs font-semibold ${re?.slo?.status===`healthy`?`bg-ok/10 text-ok`:`bg-warn/10 text-warn`}`,children:re?.slo?.status??`loading`}),(0,X.jsxs)(`span`,{className:`text-xs text-ink-faint`,children:[`event validation failures: `,re?.event_validation_failures??`—`]})]}),re?(0,X.jsx)(`pre`,{className:`mt-3 max-h-48 overflow-auto whitespace-pre-wrap rounded bg-bg p-3 font-mono text-[10px] text-ink-dim scroll-thin`,children:JSON.stringify({web:re.web,provider:re.provider,cost_control:re.cost_control},null,2)}):null]}):null,pe===`system`?(0,X.jsx)(Pc,{status:ae,error:oe}):null,pe===`recovery`?(0,X.jsxs)(`section`,{className:`rounded-lg border border-line bg-panel p-4 lg:col-span-2`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsxs)(`h3`,{className:`mr-auto text-xs font-semibold uppercase tracking-wide text-ink-dim`,children:[l(`operations.trash`),` · `,le]}),(0,X.jsx)(`input`,{value:de,onChange:e=>fe(e.target.value),onKeyDown:e=>{!sa(e)&&e.key===`Enter`&&Ce()},placeholder:l(`operations.searchTrash`),className:`h-8 min-w-52 rounded border border-line bg-bg px-2 text-xs text-ink outline-none focus:border-blue`}),(0,X.jsx)(`button`,{type:`button`,disabled:!!P,onClick:()=>void Ce(),title:l(`operations.searchTrash`),"aria-label":l(`operations.searchTrash`),className:`flex h-8 w-8 items-center justify-center rounded border border-blue/50 text-xs text-blue disabled:opacity-40`,children:(0,X.jsx)(o,{icon:ee})})]}),N.length?(0,X.jsx)(`div`,{className:`mt-3 grid gap-2 sm:grid-cols-2`,children:N.map(e=>(0,X.jsxs)(`div`,{className:`flex items-center gap-3 rounded border border-line bg-bg p-2`,children:[(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`div`,{className:`truncate text-xs text-ink`,children:e.label}),(0,X.jsx)(`div`,{className:`truncate font-mono text-[10px] text-ink-faint`,children:e.trash_path})]}),(0,X.jsx)(`button`,{type:`button`,disabled:!!P,onClick:()=>void _e(e),title:`Restore ${e.label}`,"aria-label":`Restore ${e.label}`,className:`flex h-8 w-8 items-center justify-center rounded border border-blue/50 text-xs text-blue disabled:opacity-40`,children:(0,X.jsx)(o,{icon:a})})]},e.trash_id))}):(0,X.jsx)(`p`,{className:`mt-3 text-xs text-ink-faint`,children:l(`operations.trashEmpty`)}),le>N.length?(0,X.jsxs)(`p`,{className:`mt-2 text-[10px] text-ink-faint`,children:[`Showing the newest `,N.length,` matches. Narrow the search to find older sessions.`]}):null]}):null,E?(0,X.jsx)(`pre`,{className:`rounded-lg border border-line bg-panel p-3 font-mono text-xs whitespace-pre-wrap text-ink-dim lg:col-span-2`,children:E}):null]})]})}var Rc=[`handshake.service`,`handshake.project`,`handshake.ready`];function zc(){let{t:e}=Z(),t=(0,I.useRef)(null);return ci(t,(e,t)=>{if(t){e.set(`[data-handshake-line], [data-handshake-node]`,{opacity:1,scale:1,clearProps:`transform`});return}e.to(`[data-handshake-mark]`,{scale:1.055,duration:.75,ease:`sine.inOut`,repeat:-1,yoyo:!0,transformOrigin:`50% 50%`}),e.timeline({repeat:-1,repeatDelay:.25}).fromTo(`[data-handshake-line]`,{scaleX:0,opacity:.25,transformOrigin:`0% 50%`},{scaleX:1,opacity:.8,duration:.9,ease:`power2.inOut`}).fromTo(`[data-handshake-node]`,{autoAlpha:.25,scale:.72},{autoAlpha:1,scale:1,duration:.28,stagger:.16,ease:`back.out(1.8)`},.12).to(`[data-handshake-node]`,{autoAlpha:.35,duration:.3,stagger:.08},`+=0.35`)}),(0,X.jsxs)(`div`,{ref:t,role:`status`,"aria-label":e(`handshake.connecting`),className:`w-full max-w-xl px-6 text-center`,children:[(0,X.jsx)(`div`,{"data-handshake-mark":!0,className:`handshake-mark glass-card mx-auto flex h-16 w-16 items-center justify-center rounded-3xl text-blue shadow-glow sm:h-20 sm:w-20`,children:(0,X.jsx)(Ai,{size:48,className:`text-ink`})}),(0,X.jsxs)(`div`,{className:`relative mx-auto mt-8 h-10 max-w-sm sm:max-w-md`,children:[(0,X.jsx)(`div`,{className:`absolute left-[10%] right-[10%] top-3 h-px bg-line/80`}),(0,X.jsx)(`div`,{"data-handshake-line":!0,className:`handshake-line absolute left-[10%] right-[10%] top-3 h-px`}),(0,X.jsx)(`div`,{className:`relative flex justify-between`,children:Rc.map(t=>(0,X.jsxs)(`div`,{className:`flex w-20 flex-col items-center gap-2.5`,children:[(0,X.jsx)(`span`,{"data-handshake-node":!0,className:`handshake-node h-6 w-6 rounded-full border ring-4 ring-bg`,children:(0,X.jsx)(`span`,{className:`m-auto mt-[7px] block h-2 w-2 rounded-full bg-blue`})}),(0,X.jsx)(`span`,{className:`text-xs font-medium text-ink-faint`,children:e(t)})]},t))})]}),(0,X.jsx)(`p`,{className:`mt-9 text-base font-medium text-ink-dim`,children:e(`handshake.title`)}),(0,X.jsx)(`p`,{className:`mt-1.5 text-sm text-ink-faint`,children:e(`handshake.detail`)})]})}function Bc({loading:e,hasProjects:t,error:n,onRetry:r,onNew:i,onChoose:a,canCreate:o}){let{t:s}=Z();return(0,X.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-4 text-center`,children:[e?(0,X.jsx)(zc,{}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Mi,{size:32,tag:ca}),(0,X.jsx)(`p`,{className:`max-w-md text-sm leading-relaxed ${n?`text-err`:`text-ink-faint`}`,children:n||s(t?`landing.selectOrCreate`:`landing.noSessions`)})]}),!e&&(0,X.jsxs)(`div`,{className:`flex flex-wrap justify-center gap-2`,children:[n?(0,X.jsx)(vi,{onClick:r,variant:`danger`,children:s(`common.retry`)}):null,t?(0,X.jsx)(vi,{onClick:a,children:s(`landing.select`)}):o?(0,X.jsx)(vi,{onClick:i,variant:`primary`,children:s(`landing.new`)}):null]})]})}function $({active:e,onSelect:t,onOpenSessions:n,sidebarOpen:r=!1}){let{t:a}=Z(),s=[{id:`mission`,label:a(`mobile.mission`),icon:y},{id:`activity`,label:a(`mobile.activity`),icon:l},{id:`workbench`,label:a(`mobile.workbench`),icon:p},{id:`map`,label:a(`mobile.map`),icon:y},{id:`preview`,label:a(`mobile.preview`),icon:i}];return(0,X.jsxs)(`nav`,{"aria-label":a(`mobile.views`),className:`mobile-tabbar glass-panel glass-panel--raised fixed inset-x-0 bottom-0 z-40 items-stretch border-t border-line/60 lg:hidden ${r?`hidden`:`flex`}`,children:[n?(0,X.jsxs)(`button`,{type:`button`,onClick:n,"aria-label":a(`topbar.openSessions`),className:`flex min-h-[3.25rem] flex-1 flex-col items-center justify-center gap-0.5 text-ink-faint active:bg-panel-raised`,children:[(0,X.jsx)(o,{icon:_,className:`h-4 w-4`}),(0,X.jsx)(`span`,{className:`text-[10px] leading-none`,children:a(`mobile.sessions`)})]}):null,s.map(n=>{let r=n.id===e;return(0,X.jsxs)(`button`,{type:`button`,onClick:()=>t(n.id),"aria-current":r?`page`:void 0,className:`flex min-h-[3.25rem] flex-1 flex-col items-center justify-center gap-0.5 active:bg-panel-raised ${r?`text-blue`:`text-ink-faint`}`,children:[(0,X.jsx)(o,{icon:n.icon,className:`h-4 w-4`}),(0,X.jsx)(`span`,{className:`text-[10px] leading-none`,children:n.label})]},n.id)})]})}function Vc(){(0,I.useEffect)(()=>{let e=window.visualViewport,t=document.documentElement;if(!e)return;let n=null,r=()=>{n!=null&&window.cancelAnimationFrame(n),n=window.requestAnimationFrame(()=>{let n=window.innerHeight-e.height-e.offsetTop,r=n>24?Math.round(n):0;t.style.setProperty(`--keyboard-inset`,`${r}px`)})};return r(),e.addEventListener(`resize`,r),e.addEventListener(`scroll`,r),()=>{n!=null&&window.cancelAnimationFrame(n),e.removeEventListener(`resize`,r),e.removeEventListener(`scroll`,r),t.style.removeProperty(`--keyboard-inset`)}},[])}async function Hc(e,t){let n=Ht(e.trim());if(!n)return{kind:`not-command`};if(!n.cmd){let e=Ut(n.name);return{kind:`error`,message:e?`Unknown command ${n.name}. Did you mean ${e}?`:`Unknown command ${n.name}. Use /help for the full list.`}}if(n.cmd.id===`ask`||n.cmd.id===`crystalpilot`)return{kind:`not-command`};if(Ft(n.cmd)&&!n.rest)return{kind:`error`,message:`Usage: ${n.cmd.name}${n.cmd.arg?` ${n.cmd.arg}`:``}`};try{await t[n.cmd.id](n.rest)}catch(e){return{kind:`error`,message:e instanceof Error?e.message:String(e??`Command failed`)}}return{kind:`handled`}}function Uc({activeSid:e,activityEventsRef:t,notify:n,onClearEvents:r,onDispose:i,onOpenConfig:a,onOpenDoctor:o,onOpenHelp:s,onOpenIdentity:c,onOpenInspector:l,onOpenNewDaemon:u,onOpenOperations:d,onOpenSidebar:f,onReconnectEvents:p,onRenameProject:m,onRewriteDraft:h,onSelectProject:g,onSetArtifactPath:_,onSetEventFilter:v,onSetEventQuery:y,onSetTaskItemId:b,onSetWorkspaceView:x,onShowArtifacts:S,onStopIteration:C,onStopWaiting:w,refetchSnapshot:T}){return{status:async()=>l(),roles:async()=>d(),journal:async()=>l(),backlog:async()=>x(`mission`),item:async e=>{e&&b(e)},artifacts:async()=>S(),artifact:async e=>{e&&_(e)},events:async e=>{x(`activity`);let{filter:t,query:n}=Vt(e);v(t),y(n)},find:async e=>{x(`activity`),v(`all`),y(e)},run:async()=>x(`activity`),clear:async()=>{x(`activity`),v(`all`),y(``),r(t.current.length)},cancel:async()=>w(),task:async t=>{e&&(await U.addTask(e,t),T(),n(`success`,`Task queued.`))},rewrite:async e=>{let t=e.trim();if(!t){n(`info`,`Type your prompt in the composer and press Rewrite, or use /rewrite .`);return}h(t)},plan:async t=>{if(!e)return;let r=await U.previewPlan(e,t);r.error?n(`error`,r.error):n(`info`,r.steps.map(e=>e.title).join(` +`)||`Plan preview ready.`)},nudge:async t=>{e&&(await U.nudge(e,t),n(`success`,`Guidance injected.`))},abort:async t=>{e&&(await U.abortMission(e,t||`operator abort`),n(`info`,`Abort requested.`))},note:async t=>{e&&(await U.note(e,t),n(`success`,`Note appended to timeline.`))},done:async e=>{e&&i(e,`done`)},skip:async e=>{e&&i(e,`rm`)},stop:async e=>{e&&C(e)},new:async()=>u(),daemons:async()=>f(),resume:async e=>{e&&e!==`list`?g(e):f()},attach:async e=>{e&&g(e)},rename:async t=>{!e||!t||await m(t)},doctor:async()=>o(),backend:async t=>{if(!e||!t){a();return}await U.setConfig(e,`runner_backend`,t),n(`success`,`Backend set to ${t}.`)},config:async t=>{if(!e||!t){a();return}let r=t.indexOf(`=`);r>0?(await U.setConfig(e,t.slice(0,r).trim(),t.slice(r+1).trim()),n(`success`,`Config updated.`)):a()},identity:async()=>c(),reset:async()=>{e&&(await U.resetManager(e),n(`success`,`Manager context reset.`))},skills:async t=>{e&&n(`info`,(await U.skills(e,t||`ls`)).slice(0,400))},reconnect:async()=>p(),help:async()=>s(),quit:async()=>n(`info`,`Background work continues; close this browser tab when ready.`)}}function Wc(e){return e.kind===`error`?(typeof e.reply==`string`?e.reply.trim():``)||`Manager could not handle this message.`:null}function Gc(e,t){e.kind===`task`&&t.dispatchTask(e);let n=Wc(e);n&&t.notifyError(n),t.refetchTranscript()}var Kc={skipFirst:0,reconnectKey:0};function qc(e,t){return t.kind===`clear`?{...e,skipFirst:Math.max(0,t.offset)}:t.kind===`reconnect`?{skipFirst:0,reconnectKey:e.reconnectKey+1}:{...e,skipFirst:0}}var Jc=`local_request_id`;function Yc(e,t,n,r=Date.now()){return{type:`ui.operator`,agent_layer:`operator`,text:n,ts:r/1e3,event_id:`local-${e}-${t}-operator`,message_id:`local-${t}-operator`,[Jc]:t}}function Xc(e,t,n,r,i,a=Date.now(),o=`auto`){let s=r.trim();if(!s)return e;let c=e.findIndex(e=>e.type===`ui.argus`&&Number(e[Jc])===n),l=i.endsWith(`-argus`)?`${i.slice(0,-6)}-operator`:``,u=l?e.map(e=>e.type===`ui.operator`&&Number(e[Jc])===n?{...e,message_id:l}:e):e,d=u.find(e=>e.type===`ui.operator`&&Number(e[Jc])===n),f=d?Math.max(0,a-Number(d.ts??a/1e3)*1e3):0;if(c<0)return[...u,{type:`ui.argus`,agent_layer:`manager`,text:s,ts:a/1e3,event_id:`local-${t}-${n}-argus`,message_id:i||`local-${n}-argus`,fragment_mode:o,response_latency_ms:f,[Jc]:n}];let p=u[c],m=[...u];return m[c]={...p,text:kt(String(p.text??``),s,o),message_id:i||p.message_id,fragment_mode:o},m}function Zc(e,t,n){let r=new Map;e.forEach(e=>{let t=String(e.type??``);if(t!==`ui.operator`&&t!==`ui.argus`)return;let n=`${t}\u0000${String(e.text??``)}`;r.set(n,(r.get(n)??0)+1)});let i=t.map(e=>({type:e.role===`operator`?`ui.operator`:`ui.argus`,agent_layer:e.role===`operator`?`operator`:`manager`,text:e.text,ts:e.ts,message_id:e.message_id||`transcript-${e.ts}-${e.role}`,...e.mission_result===!0?{mission_result:!0}:{},...typeof e.item_id==`string`?{item_id:e.item_id}:{},...typeof e.success==`boolean`?{success:e.success}:{},...typeof e.summary==`string`?{summary:e.summary}:{},...typeof e.delivery_id==`string`?{delivery_id:e.delivery_id}:{},...e.delivery&&typeof e.delivery==`object`?{delivery:e.delivery}:{}})),a=Array(i.length).fill(!0);for(let e=i.length-1;e>=0;--e){let t=i[e],n=`${String(t.type)}\u0000${String(t.text??``)}`,o=r.get(n)??0;o>0&&(a[e]=!1,r.set(n,o-1))}let o=[...i.filter((e,t)=>a[t]),...e],s=Array(o.length).fill(!0),c=new Set,l=n.map(e=>{let t=String(e.message_id??``),n=t?o.findIndex((e,n)=>!c.has(n)&&String(e.message_id??``)===t):-1,r=Number(e.ts??0);if(n<0&&(n=o.findIndex((t,n)=>{if(c.has(n)||t.type!==e.type||t.text!==e.text)return!1;let i=Number(t.ts??0);return Math.abs(i-r)<=5})),n>=0){c.add(n),s[n]=!1;let t=o[n];return{...e,...t.mission_result===!0?{mission_result:!0}:{},...typeof t.item_id==`string`?{item_id:t.item_id}:{},...typeof t.success==`boolean`?{success:t.success}:{},...typeof t.summary==`string`?{summary:t.summary}:{},...typeof t.delivery_id==`string`?{delivery_id:t.delivery_id}:{},...t.delivery&&typeof t.delivery==`object`?{delivery:t.delivery}:{}}}return e});return[...o.filter((e,t)=>s[t]),...l].sort((e,t)=>Number(e.ts??0)-Number(t.ts??0))}function Qc(e,t){if(!t.length)return e;let n=new Map(t.map(e=>[e.id,e]));return e.map(e=>{let t=n.get(e.id);return t?{...e,spend_usd:t.spend_usd,known_cost_usd:t.known_cost_usd,spend_status:t.spend_status,usage_calls:t.usage_calls,premium_requests:t.premium_requests,cost_updated_at:t.updated_at}:e})}async function $c(e,t,n,r=``){let i=await e.createDaemon(``,t,r),a=n.trim();return{created:i,startCampaign:a?()=>e.setContinuous(i.sid,!0,a):null}}var el=e=>e instanceof Error?e.message:String(e||`Unknown error`);function tl({localCwd:e,notify:t,onFocusComposer:n,queryClient:r,refetchProjects:i,selectProject:a}){let[o,s]=(0,I.useState)(!1),c=(0,I.useRef)(!1);return{createDaemon:async(o,l,u)=>{if(c.current)return!1;c.current=!0,s(!0);try{let{created:s,startCampaign:c}=await $c(U,o,l,u),d=String(s.workdir||u||``);return r.setQueryData([`projects`],t=>({local_cwd:t?.local_cwd??e,projects:[{id:s.sid,label:o||s.sid,display_name:o,objective:``,launch_cwd:d,workdir:d,last_active:Date.now()/1e3,daemon_alive:!1,daemon_pid:null,uptime_seconds:null},...(t?.projects??[]).filter(e=>e.id!==s.sid)]})),a(s.sid),i(),window.setTimeout(n,0),t(c?`info`:`success`,c?`Session created and selected. Campaign is starting in the background.`:`Session created and selected.`),c&&c().then(()=>{r.invalidateQueries({queryKey:[`snapshot`,s.sid]}),i(),t(`success`,`Campaign started.`)}).catch(e=>{t(`error`,`Session was created, but the campaign could not start: ${el(e)}`)}),!0}catch(e){return t(`error`,`Could not create session: ${el(e)}`),!1}finally{c.current=!1,s(!1)}},creatingDaemon:o}}var nl=e=>e instanceof Error?e.message:String(e||`Unknown error`);function rl({actions:e,manageActions:t,manageTargetSid:n,setManageTargetSid:r,activeSid:i,clearProjectSelection:a,continuous:o,notify:s,refetchProjects:c,selectProject:l,setDaemonManageOpen:u}){let d=e.startDaemon.isPending||e.stopDaemon.isPending||e.forceStopDaemon.isPending||t.startDaemon.isPending||t.forceStopDaemon.isPending||t.updateProject.isPending||t.deleteProject.isPending,f=(0,I.useCallback)(e=>({onSuccess:()=>s(`success`,e),onError:e=>s(`error`,nl(e))}),[s]),p=(0,I.useCallback)(()=>e.startDaemon.mutate(void 0,f(`Daemon start requested.`)),[f,e.startDaemon]),m=(0,I.useCallback)(()=>e.forceStopDaemon.mutate(void 0,f(`Stop requested; the verified daemon process is being interrupted.`)),[f,e.forceStopDaemon]),h=(0,I.useCallback)(async()=>{try{return await t.startDaemon.mutateAsync(),s(`success`,`Daemon resumed.`),!0}catch(e){return s(`error`,nl(e)),!1}},[t.startDaemon,s]),g=(0,I.useCallback)(async()=>{try{return await t.forceStopDaemon.mutateAsync(),await c(),s(`success`,`Daemon stopped. This session can now be deleted.`),!0}catch(e){return s(`error`,nl(e)),!1}},[t.forceStopDaemon,s,c]),_=(0,I.useCallback)(async e=>{if(!n)return!1;try{return await t.updateProject.mutateAsync({sid:n,name:e}),s(`success`,`Session name updated.`),!0}catch(e){return s(`error`,nl(e)),!1}},[t.updateProject,n,s]),v=(0,I.useCallback)(async()=>{if(!n)return!1;try{let e=n,o=await t.deleteProject.mutateAsync();u(!1),r(null);let d=await c();if(e===i){a(`replace`);let e=Dn(d.data?.projects??[])[0];e&&l(e.id,`replace`)}return s(`success`,o.workdir_preserved?`Session moved to recoverable trash. Files remain in ${o.workdir}.`:`Session moved to recoverable trash.`),!0}catch(e){return s(`error`,nl(e)),!1}},[i,a,t.deleteProject,n,s,c,l,u,r]),y=(0,I.useCallback)(e=>{r(e),u(!0)},[u,r]);return{daemonBusy:d,manageDeleteProject:v,manageStopDaemon:g,manageRenameProject:_,manageStartDaemon:h,requestDispose:(0,I.useCallback)((t,n)=>e.disposeBacklog.mutate({id:t,op:n},{onSuccess:()=>s(`success`,n===`done`?`Work marked done.`:`Work removed.`),onError:e=>s(`error`,nl(e))}),[e.disposeBacklog,s]),requestManageSession:y,requestStartDaemon:p,requestStopDaemon:m,requestStopIteration:(0,I.useCallback)(t=>e.stopBacklog.mutate(t,{onSuccess:()=>s(`success`,`Iteration stopped.`),onError:e=>s(`error`,nl(e))}),[e.stopBacklog,s]),toggleContinuous:(0,I.useCallback)(()=>{if(!o)return;let t=!o.enabled;e.setContinuous.mutate({enabled:t,objective:o.objective},f(t?`Continuous campaign enabled.`:`Continuous campaign stopped.`))},[f,e.setContinuous,o])}}function il({focusComposer:e,openHelp:t,toggleKiosk:n,togglePalette:r,toggleReasoning:i,toggleSidebarCollapse:a}){(0,I.useEffect)(()=>{let o=o=>{let s=o.target,c=s?.tagName===`INPUT`||s?.tagName===`TEXTAREA`,l=o.metaKey||o.ctrlKey;l&&o.key.toLowerCase()===`k`?(o.preventDefault(),r()):l&&o.key.toLowerCase()===`t`?(o.preventDefault(),i()):l&&o.key===`.`?(o.preventDefault(),n()):l&&o.key.toLowerCase()===`b`?(o.preventDefault(),a()):l&&o.key.toLowerCase()===`j`?(o.preventDefault(),e()):!c&&o.key===`?`?(o.preventDefault(),t()):!c&&o.key===`/`&&(o.preventDefault(),e())};return window.addEventListener(`keydown`,o),()=>window.removeEventListener(`keydown`,o)},[e,t,n,r,i,a])}var al=e=>e instanceof Error?e.message:String(e||`Unknown error`),ol=`argus.decision.prompted.v1`,sl=()=>{try{return window.sessionStorage.getItem(ol)??``}catch{return``}},cl=e=>{try{window.sessionStorage.setItem(ol,e)}catch{}};function ll({activeSid:e,autoOpen:t=!0,backlog:n,notify:r,pendingQuestions:i,refetchSnapshot:a}){let[o,s]=(0,I.useState)(!1),[c,l]=(0,I.useState)(!1),u=(0,I.useRef)(``),d=(0,I.useMemo)(()=>{let e=(n??[]).map(e=>({...e,operator_decision:e.operator_decision}));return _t(i??[],e)[0]??null},[n,i]);return(0,I.useEffect)(()=>{if(!d||!e){s(!1);return}if(!t)return;let n=`${e}:${d.id}`;u.current!==n&&sl()!==n&&(u.current=n,cl(n),s(!0))},[e,t,d]),{answerPendingReply:async(t,n)=>{if(!(!e||!d||c)){l(!0);try{let i=d.legacy?await U.answerPending(e,d.item_id,n):await U.resolveDecision(e,d.id,t,n);if(i.resolved===!1){r(`info`,String(i.reply||`Manager needs a more specific answer.`));return}s(!1),await a(),i.daemon&&Number(i.daemon.rc??0)!==0?r(`error`,`Answer queued, but the daemon did not start: ${i.daemon.error||`operator action required`}`):r(`success`,String(i.reply||`Manager delivered your answer to the team.`))}catch(e){await a(),r(`error`,`Could not send answer: ${al(e)}`)}finally{l(!1)}}},pendingReply:d,pendingReplyBusy:c,pendingReplyOpen:o,setPendingReplyOpen:s}}var ul=`argus.browser.project.v1`;function dl(){try{return window.sessionStorage.getItem(ul)}catch{return null}}function fl(e){try{e?window.sessionStorage.setItem(ul,e):window.sessionStorage.removeItem(ul)}catch{}}function pl(e,t){let n=new URL(window.location.href);e?n.searchParams.set(`project`,e):n.searchParams.delete(`project`);let r=t===`push`?`pushState`:`replaceState`;window.history[r](window.history.state,``,n.toString())}function ml({cancelActiveMessage:e,notify:t,projects:n,projectsError:r,projectsReady:i,queryClient:a,setArtifactPath:o,setSidebarOpen:s,setTaskItemId:c}){let l=new URLSearchParams(window.location.search),[u,d]=(0,I.useState)(l.get(`project`)||dl()),f=(0,I.useRef)(u),p=(0,I.useRef)(!1);f.current=u;let m=(0,I.useCallback)(t=>{t!==f.current&&(e(),o(null),c(null)),f.current=t,d(t),fl(t)},[e,o,c]),h=(0,I.useCallback)((e,t=`push`)=>{let n=new URLSearchParams(window.location.search).get(`project`);m(e),n!==e&&pl(e,t)},[m]),g=(0,I.useCallback)((e=`replace`)=>{let t=new URLSearchParams(window.location.search).get(`project`);m(null),t!=null&&pl(null,e)},[m]),_=(0,I.useCallback)(e=>{a.prefetchQuery({queryKey:[`snapshot`,e],queryFn:({signal:t})=>U.prefetchSnapshot(e,t),staleTime:3e3})},[a]);return(0,I.useEffect)(()=>{if(!i)return;let e=p.current,r=An(n,f.current,e);if(!e&&(p.current=!0,r.id===f.current?fl(r.id):m(r.id),new URLSearchParams(window.location.search).get(`project`)!==r.id&&pl(r.id,`replace`),r.recovered)){let e=n.find(e=>e.id===r.id);t(`info`,e?`Project “${r.requested}” was not found. Switched to ${e.label||e.id}.`:`Project “${r.requested}” was not found. Create a daemon to continue.`)}},[m,t,n,i]),(0,I.useEffect)(()=>{let e=()=>{let e=new URLSearchParams(window.location.search).get(`project`);if(s(!1),!e){m(null);return}if(!i){m(e);return}let r=kn(n,e);if(m(r.id),r.recovered){pl(r.id,`replace`);let e=n.find(e=>e.id===r.id);t(`info`,e?`Project “${r.requested}” was not found. Switched to ${e.label||e.id}.`:`Project “${r.requested}” was not found. Create a daemon to continue.`)}};return window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)},[m,t,n,i,s]),{activateProject:m,activeSid:i?u&&n.some(e=>e.id===u)?u:null:r?u:null,clearProjectSelection:g,prefetchProject:_,selectProject:h,sid:u,sidRef:f}}function hl(e){try{return globalThis.localStorage?.getItem(e)??null}catch{return null}}function gl(e,t){try{return globalThis.localStorage?.setItem(e,t),!!globalThis.localStorage}catch{return!1}}function _l(e,t,n){let r=n?t+8:56,i=Math.max(320,e-r-360-8);return Math.max(320,Math.min(840,i,Math.round(e*.45)))}var vl=`argus.themeStyle`;function yl(){return`standard`}function bl(){gl(vl,`standard`)}function xl(e,t){let n=hl(e);return n==null?t:n===`true`}function Sl(e){document.documentElement.dataset.theme=e,window.parent!==window&&window.parent.postMessage({type:`argus:theme-changed`,payload:e},`*`)}function Cl(){let e=new URLSearchParams(window.location.search),[t,n]=(0,I.useState)(e.get(`kiosk`)===`1`),[r,i]=(0,I.useState)(()=>xl(`argus.reasoning.visible.v1`,!1)),[a,o]=(0,I.useState)(()=>{let t=e.get(`view`);if(t===`mission`||t===`activity`||t===`workbench`||t===`map`)return t;let n=hl(`argus.workspace.view`);return n===`mission`||n===`activity`||n===`workbench`||n===`map`?n:`map`}),[s,c]=(0,I.useState)(`activity`),[l,u]=(0,I.useState)(()=>xl(`argus.preview.expanded.v5`,!0)),[d,f]=(0,I.useState)(()=>{let e=Number(hl(`argus.sidebar.width.v2`)||256);return Number.isFinite(e)?Math.max(220,Math.min(400,e)):256}),[p,m]=(0,I.useState)(()=>{let e=Number(hl(`argus.preview.width.v2`)||440);return Number.isFinite(e)?Math.max(320,Math.min(840,e)):440}),[h,g]=(0,I.useState)(!1),[_,v]=(0,I.useState)(()=>xl(`argus.sidebar.expanded.v4`,!0)),[y,b]=(0,I.useState)(()=>{let t=e.get(`desktopTheme`);if(t===`light`||t===`dark`)return t;let n=hl(`argus.theme`);return n===`light`||n===`dark`?n:null}),x=yl(),[S,C]=(0,I.useState)(()=>window.matchMedia(`(prefers-color-scheme: dark)`).matches),w=y??(S?`dark`:`light`),T=(0,I.useRef)(w),E=(0,I.useRef)(null),D=(0,I.useRef)(null);(0,I.useEffect)(()=>{gl(`argus.sidebar.expanded.v4`,String(_)),gl(`argus.preview.expanded.v5`,String(l)),gl(`argus.sidebar.width.v2`,String(d)),gl(`argus.preview.width.v2`,String(p))},[_,d,l,p]),(0,I.useEffect)(()=>{gl(`argus.workspace.view`,a)},[a]),(0,I.useEffect)(()=>{gl(`argus.reasoning.visible.v1`,String(r))},[r]),(0,I.useEffect)(()=>{let e=window.matchMedia(`(prefers-color-scheme: dark)`),t=()=>C(e.matches);return t(),e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]),(0,I.useEffect)(()=>{T.current=w,Sl(w)},[w]),(0,I.useEffect)(()=>{document.documentElement.dataset.themeStyle=x,bl()},[x]),(0,I.useEffect)(()=>{window.parent!==window&&window.parent.postMessage({type:`argus:theme-preference`,payload:y||`system`},`*`)},[y]);let ee=(0,I.useCallback)(()=>{let e=T.current===`light`?`dark`:`light`;T.current=e,Sl(e),gl(`argus.theme`,e);let t=new URL(window.location.href);t.searchParams.has(`desktopTheme`)&&(t.searchParams.set(`desktopTheme`,e),window.history.replaceState(window.history.state,``,t.toString())),(0,I.startTransition)(()=>b(e))},[]),O=(0,I.useCallback)(()=>{u(!0),c(`preview`);let e=E.current?.clientWidth??window.innerWidth;if(e>=1024){let t=_l(e,d,_);m(e=>Math.max(e,t))}},[_,d]),te=(0,I.useCallback)((e,t)=>{let n=E.current;if(!n)return;t.preventDefault();let r=n.getBoundingClientRect(),i=e===`left`?d:p;n.dataset.resizing=e,document.body.style.cursor=`col-resize`,document.body.style.userSelect=`none`;let a=t=>{if(e===`left`){let e=l?p+8:56,n=Math.max(220,Math.min(400,r.width-e-360-8));i=Math.max(220,Math.min(n,t.clientX-r.left))}else{let e=_?d+8:56,n=Math.max(320,Math.min(840,r.width-e-360-8));i=Math.max(320,Math.min(n,r.right-t.clientX))}D.current??=window.requestAnimationFrame(()=>{n.style.setProperty(e===`left`?`--sidebar-width`:`--preview-width`,`${i}px`),D.current=null})},o=()=>{D.current!=null&&window.cancelAnimationFrame(D.current),D.current=null,n.style.setProperty(e===`left`?`--sidebar-width`:`--preview-width`,`${i}px`),e===`left`?f(i):m(i),delete n.dataset.resizing,document.body.style.cursor=``,document.body.style.userSelect=``,window.removeEventListener(`pointermove`,a),window.removeEventListener(`pointerup`,o),window.removeEventListener(`pointercancel`,o)};window.addEventListener(`pointermove`,a),window.addEventListener(`pointerup`,o,{once:!0}),window.addEventListener(`pointercancel`,o,{once:!0})},[_,d,l,p]);return(0,I.useEffect)(()=>{let e=()=>{if(window.innerWidth<1024||!E.current)return;let e=E.current.clientWidth,t=_?d:56,n=l?p:56,r=(_?8:0)+(l?8:0),i=Math.max(540,e-360-r);if(t+n<=i)return;let a=l?Math.max(320,Math.min(p,i-t)):n,o=_?Math.max(220,Math.min(d,i-a)):t;o+a>i&&l&&(a=Math.max(320,i-o)),_&&f(o),l&&m(a)};return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[_,d,l,p]),{cycleTheme:ee,kiosk:t,leftPanelOpen:_,leftWidth:d,mobileView:s,openPreview:O,resizeSidebar:te,rightPanelOpen:l,rightWidth:p,setKiosk:n,setLeftPanelOpen:v,setLeftWidth:f,setMobileView:c,setRightPanelOpen:u,setRightWidth:m,setShowReasoning:i,setSidebarOpen:g,setWorkspaceView:o,shellRef:E,showReasoning:r,sidebarOpen:h,themeMode:w,themeStyle:x,workspaceView:a}}function wl(e){let t=e.trim();if(!t||/\s/.test(t))return``;if(!t.includes(`?`)&&!t.includes(`://`))return t;try{return new URL(t,window.location.href).searchParams.get(`token`)?.trim()??``}catch{return``}}function Tl({error:e,onRetry:t}){let{t:n}=Z(),r=L(e),i=e instanceof Ze,[a,o]=(0,I.useState)(!1),[s,c]=(0,I.useState)(``),[l,u]=(0,I.useState)(``);return!r&&!i?null:(0,X.jsxs)(`div`,{role:`alert`,className:`fixed left-1/2 top-3 z-[100] flex w-[min(92vw,42rem)] -translate-x-1/2 flex-wrap items-start gap-3 rounded-xl border border-err/50 bg-panel/95 px-4 py-3 text-left text-sm text-ink shadow-xl backdrop-blur`,children:[(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`mt-0.5 font-mono font-bold text-err`,children:`!`}),(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`strong`,{className:`block text-err`,children:n(r?`connection.pairingTitle`:`connection.unreachableTitle`)}),(0,X.jsx)(`span`,{className:`mt-0.5 block text-xs leading-relaxed text-ink-dim`,children:n(r?`connection.pairingDetail`:`connection.unreachableDetail`)})]}),r&&!a?(0,X.jsx)(`button`,{type:`button`,onClick:()=>o(!0),className:`shrink-0 rounded-md border border-blue/45 bg-blue/10 px-2.5 py-1 text-xs font-medium text-blue hover:bg-blue/15`,children:n(`connection.pairAgain`)}):r?null:(0,X.jsx)(`button`,{type:`button`,onClick:t,className:`shrink-0 rounded-md border border-err/40 px-2.5 py-1 text-xs text-err hover:bg-err/10`,children:n(`common.retry`)}),r&&a?(0,X.jsxs)(`form`,{onSubmit:e=>{e.preventDefault();let t=wl(s);if(!t){u(n(`connection.pairingInvalid`));return}let r=new URL(window.location.href);r.searchParams.set(`token`,t),window.location.replace(r.toString())},className:`flex w-full basis-full flex-wrap gap-2 pl-7`,children:[(0,X.jsx)(`label`,{className:`sr-only`,htmlFor:`pairing-link`,children:n(`connection.pairingInput`)}),(0,X.jsx)(`input`,{id:`pairing-link`,"data-autofocus":!0,type:`password`,autoComplete:`off`,value:s,onChange:e=>{c(e.target.value),u(``)},placeholder:n(`connection.pairingPlaceholder`),className:`h-9 min-w-0 flex-1 rounded-md border border-line bg-bg px-3 text-xs text-ink outline-none focus:border-blue`}),(0,X.jsx)(`button`,{type:`submit`,className:`h-9 rounded-md border border-blue/35 bg-blue/8 px-3 text-xs font-medium text-blue hover:border-blue-deep hover:bg-blue-deep hover:text-white`,children:n(`connection.connect`)}),l?(0,X.jsx)(`span`,{role:`alert`,className:`w-full text-xs text-err`,children:l}):null]}):null]})}function El(e){try{let t=JSON.parse(hl(e)||`[]`);return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}catch{return[]}}function Dl(e,t,n,r=!0){let i=(0,I.useRef)(),[a,o]=(0,I.useState)(null),s=(0,I.useCallback)(t=>{if(!e)return;let n=`argus.delivery.seen.v1:${e}`;gl(n,JSON.stringify([...new Set([...El(n),t])].slice(-80)))},[e]),c=(0,I.useCallback)((t,n)=>{if(!e)return;s(t.delivery_id);let r=Qr(t),i=r.find(e=>e.path===n)?.path||r[0]?.path||null;o({sid:e,receipt:t,path:i})},[e,s]);return(0,I.useEffect)(()=>{if(!e||!t)return;let a=n?.delivery_id;if(i.current?.sid!==e){i.current={sid:e,ids:new Set(a?[a]:[])},o(null);return}!a||i.current.ids.has(a)||!r||(i.current.ids.add(a),n&&Qr(n).length&&!El(`argus.delivery.seen.v1:${e}`).includes(a)&&c(n))},[e,t,n,c,r]),{selection:a?.sid===e?a:null,open:c,close:(0,I.useCallback)(()=>o(null),[]),selectPath:(0,I.useCallback)(e=>o(t=>t&&{...t,path:e}),[])}}var Ol=0,kl=(0,I.lazy)(async()=>({default:(await oi(()=>import(`./ResearchWorkbenchPanel-B7craOIV.js`),__vite__mapDeps([2,1,3,4,5,6]))).ResearchWorkbenchPanel})),Al=(0,I.lazy)(async()=>({default:(await oi(()=>import(`./MapPanel-BHfjXA2X.js`),__vite__mapDeps([7,1,3,4,8,9,5,10]))).MapPanel}));function jl(e,t){let[n,r]=(0,I.useState)(e),i=(0,I.useRef)(e),a=(0,I.useRef)(null),o=(0,I.useRef)(0);return i.current=e,(0,I.useEffect)(()=>{if(e===n)return;let s=o.current+t-Date.now();if(s<=0){o.current=Date.now(),r(e);return}a.current||=setTimeout(()=>{a.current=null,o.current=Date.now(),r(i.current)},s)},[e,n,t]),(0,I.useEffect)(()=>()=>{a.current&&clearTimeout(a.current)},[]),n}function Ml(){let{locale:e,t}=Z(),n=oe(),r=_r(),i=vr(),a=(0,I.useMemo)(()=>Dn(Qc(r.data?.projects??[],i.data?.projects??[])),[i.data?.projects,r.data?.projects]),s=r.data?.local_cwd??``,c=[r.error,i.error].find(e=>Qe(e)),[l,u]=(0,I.useState)(`none`),{cycleTheme:d,kiosk:f,leftPanelOpen:p,leftWidth:m,mobileView:h,openPreview:g,resizeSidebar:_,rightPanelOpen:v,rightWidth:y,setKiosk:b,setLeftPanelOpen:x,setLeftWidth:S,setMobileView:C,setRightPanelOpen:w,setRightWidth:T,setShowReasoning:D,setSidebarOpen:ee,setWorkspaceView:O,shellRef:te,showReasoning:ne,sidebarOpen:k,themeMode:re,workspaceView:A}=Cl(),[j,ie]=(0,I.useState)(()=>A===`mission`?`mission`:`activity`),[ae,M]=(0,I.useState)(A===`workbench`);(0,I.useEffect)(()=>{if(A===`workbench`){M(!0);return}A!==`map`&&ie(A)},[A]),Vc();let[se,N]=(0,I.useState)(0),[ce,le]=(0,I.useState)(``),[ue,de]=(0,I.useState)([]),fe=(0,I.useRef)(ce);fe.current=ce;let[P,F]=(0,I.useState)(!1),[pe,me]=(0,I.useState)(0),[he,ge]=(0,I.useState)(Rr),[_e,ve]=(0,I.useState)(!1),[ye,be]=(0,I.useState)([]),[xe,Se]=(0,I.useState)([]),[Ce,we]=(0,I.useState)(null),[Te,Ee]=(0,I.useState)({path:``,token:0}),[De,Oe]=(0,I.useState)(null),[ke,Ae]=(0,I.useState)(!1),[je,Me]=(0,I.useState)(!1),[Ne,Pe]=(0,I.useState)(null),[Fe,Ie]=(0,I.useState)(null),Le=(0,I.useRef)(!1),Re=(0,I.useRef)(null),ze=(0,I.useRef)(0),Be=(0,I.useRef)(),Ve=(0,I.useRef)({sid:``,completionId:``,view:null,artifacts:[]}),He=(0,I.useRef)(null),[Ue,We]=(0,I.useState)(null),[Ge,Ke]=(0,I.useReducer)(qc,Kc),[qe,Je]=(0,I.useState)(`all`),[Ye,Xe]=(0,I.useState)(``),Ze=(0,I.useCallback)(()=>We(null),[]);(0,I.useEffect)(()=>{try{localStorage.setItem(Lr,he)}catch{}},[he]);let L=(0,I.useCallback)((e,t)=>{We({id:++Ol,tone:e,message:t})},[]),$e=(0,I.useCallback)(()=>{let e=!!Re.current;return ze.current+=1,Re.current?.controller.abort(),Re.current=null,ve(!1),Se([]),e},[]),et=(0,I.useCallback)(()=>{$e()&&L(`info`,`Stopped waiting for this reply. Server-side work may still finish in the project timeline.`)},[$e,L]),{activeSid:R,clearProjectSelection:z,prefetchProject:tt,selectProject:nt,sidRef:rt}=ml({cancelActiveMessage:$e,notify:L,projects:a,projectsError:r.isError,projectsReady:r.isSuccess,queryClient:n,setArtifactPath:we,setSidebarOpen:ee,setTaskItemId:Oe});(0,I.useEffect)(()=>()=>{ze.current+=1,Re.current?.controller.abort(),Re.current=null},[]),(0,I.useEffect)(()=>gs(),[]);let it=(0,I.useCallback)(e=>{let t=(e||``).trim(),n=rt.current;!t||!n||P||(F(!0),U.rewritePrompt(n,t).then(e=>{if(F(!1),e.error||!e.rewritten.trim()){L(`error`,`Rewrite failed: ${e.error||`empty rewrite`} — your prompt is unchanged`);return}le(e.rewritten),N(e=>e+1);let t=e.questions.length?` Manager asks: ${e.questions.join(` · `)}`:``;L(`success`,`Prompt rewritten — review it, then send.${t}`)},e=>{F(!1),L(`error`,`Rewrite failed: ${mi(e)} — your prompt is unchanged`)}))},[L,P,rt]),{createDaemon:B,creatingDaemon:at}=tl({localCwd:s,notify:L,onFocusComposer:()=>N(e=>e+1),queryClient:n,refetchProjects:r.refetch,selectProject:nt});(0,I.useEffect)(()=>hs(()=>Ae(!0)),[]);let ot=yr(R),st=yr(Ne),V=ot.data,H=V?.session.id===R?R:null,ct=V?.continuous,lt=Tr(H,!0),ut=Dr(H,j===`mission`),{events:dt,connected:W}=Ir(H,Ge.reconnectKey),ft=(0,I.useMemo)(()=>Nr(dt),[dt]),pt=(0,I.useMemo)(()=>Fr(dt),[dt]);(0,I.useEffect)(()=>{if(!H||!ft)return;let e=window.setTimeout(()=>{n.invalidateQueries({queryKey:[`artifacts`,H],exact:!0})},180);return()=>window.clearTimeout(e)},[ft,H,n]),(0,I.useEffect)(()=>{if(!H||!pt)return;let e=window.setTimeout(()=>{n.invalidateQueries({queryKey:[`snapshot`,H],exact:!0})},80);return()=>window.clearTimeout(e)},[H,n,pt]);let mt=(0,I.useMemo)(()=>Rn(dt),[dt]),ht=wr(H,j===`activity`,120),gt=br(R,20,l===`inspector`),{answerPendingReply:_t,pendingReply:G,pendingReplyBusy:vt,pendingReplyOpen:yt,setPendingReplyOpen:bt}=ll({activeSid:R,autoOpen:A!==`map`,backlog:V?.backlog,notify:L,pendingQuestions:V?.pending_questions,refetchSnapshot:ot.refetch}),xt=(0,I.useMemo)(()=>Zc(dt,ht.data??[],ye),[dt,ye,ht.data]),St=jl(dt,250),Ct=jl(xt,250),wt=(0,I.useMemo)(()=>V?xn(V,xt,lt.data??[]):null,[xt,lt.data,V]),Tt=V?.daemon.alive&&wt?.routing.vertical===`research`?wt.active_role.startsWith(`reviewer`)?`reviewing`:wt.active_role.startsWith(`engineer`)?`revising`:void 0:void 0,Et=ti((0,I.useMemo)(()=>ra(xt),[xt]),wt?.delivery??null,xt),Dt=V?.backlog.some(e=>[`pending`,`running`,`in_progress`,`claimed`].includes(e.status))??!1,Ot=Ss(wt)&&!Dt&&!V?.continuous?.enabled,kt=H&&Ot&&wt?.mission.id?`completion:${H}:${wt.mission.id}`:``;He.current=Et,Ve.current={sid:H||``,completionId:kt,view:wt,artifacts:lt.data??[]};let At=(0,I.useCallback)(()=>{g()},[g]),jt=(0,I.useCallback)((e,t=!0)=>{let n=e.trim();if(!n){t&&O(`mission`);return}if(A===`map`){we(n);return}w(!0),C(`preview`),Ee(e=>({path:n,token:e.token+1}))},[C,w,O,A]),Mt=Dl(H,!!V&&!ht.isPending,Et,!Ce&&!ni(V?.backlog??[],Et?.item_id)),Pt=Mt.open,Ft=(0,I.useMemo)(()=>{let e=new Map;for(let t of xt){let n=t.delivery;n?.delivery_id&&Array.isArray(n.targets)&&e.set(n.delivery_id,n)}for(let t of[wt?.delivery,Et])t&&e.set(t.delivery_id,t);return[...e.values()].filter(e=>Qr(e).length).sort((e,t)=>t.delivered_at-e.delivered_at)},[xt,wt?.delivery,Et]);(0,I.useEffect)(()=>{H&&Et?.delivery_id&&n.invalidateQueries({queryKey:[`artifacts`,H],exact:!0})},[H,Et?.delivery_id,n]),(0,I.useEffect)(()=>{if(!H)return;let e=Be.current;if(!e||e.sid!==H){Be.current={sid:H,id:kt||null};return}if(!kt){Be.current={sid:H,id:null};return}if(e.id===kt)return;let n=window.setTimeout(()=>{let e=Ve.current;if(e.sid!==H||e.completionId!==kt||!e.view)return;let n=e.view.delivery,r=Ds(e.artifacts),i=ls({completionId:kt,title:n?.title||e.view.mission.title||t(`mission.taskCompleted`),summary:n?.summary||e.view.mission.summary,path:n?.primary_target?.path||r?.path});i&&fs(i),Be.current={sid:H,id:kt}},500);return()=>window.clearTimeout(n)},[kt,H,t]),(0,I.useEffect)(()=>ms(e=>{let t=He.current;t&&t.delivery_id===e.deliveryId?Pt(t):e.path?jt(e.path):(C(`activity`),O(`mission`))}),[jt,Pt,C,O]);let K=(0,I.useRef)(xt);K.current=xt,(0,I.useEffect)(()=>{Je(`all`),Xe(``),be([]),Ke({kind:`reset`})},[H]);let It=kr(R,V?.daemon_commands?.revision),Lt=kr(Ne,st.data?.daemon_commands?.revision),Rt=(0,I.useCallback)(async e=>{Ie(e);try{await U.startDaemon(e),await r.refetch(),L(`success`,t(`sidebar.resumeSuccess`))}catch(e){L(`error`,t(`sidebar.resumeFailed`,{error:mi(e)}))}finally{Ie(null)}},[L,r,t]),{daemonBusy:zt,manageDeleteProject:Bt,manageStopDaemon:Vt,manageRenameProject:Ht,manageStartDaemon:Ut,requestDispose:Wt,requestManageSession:Gt,requestStartDaemon:Kt,requestStopDaemon:qt,requestStopIteration:Jt,toggleContinuous:Yt}=rl({actions:It,manageActions:Lt,manageTargetSid:Ne,setManageTargetSid:Pe,activeSid:R,clearProjectSelection:z,continuous:ct,notify:L,refetchProjects:r.refetch,selectProject:nt,setDaemonManageOpen:Me}),Xt=(0,I.useCallback)(async e=>{if(!R)return;let t=await It.updateProject.mutateAsync({sid:R,name:e});L(`success`,`Renamed to "${t.name}".`)},[It.updateProject,R,L]),Zt=(0,I.useMemo)(()=>Uc({activeSid:R,activityEventsRef:K,notify:L,onClearEvents:e=>Ke({kind:`clear`,offset:e}),onDispose:Wt,onOpenConfig:()=>u(`config`),onOpenDoctor:()=>u(`doctor`),onOpenHelp:()=>u(`help`),onOpenIdentity:()=>u(`identity`),onOpenInspector:()=>u(`inspector`),onOpenNewDaemon:()=>Ae(!0),onOpenOperations:()=>u(`operations`),onOpenSidebar:()=>ee(!0),onReconnectEvents:()=>Ke({kind:`reconnect`}),onRenameProject:Xt,onRewriteDraft:it,onSelectProject:nt,onSetArtifactPath:we,onSetEventFilter:Je,onSetEventQuery:Xe,onSetTaskItemId:Oe,onSetWorkspaceView:O,onShowArtifacts:At,onStopIteration:Jt,onStopWaiting:et,refetchSnapshot:ot.refetch}),[R,L,At,Xt,Wt,Jt,nt,ot.refetch,et,O]);il({focusComposer:()=>N(e=>e+1),openHelp:()=>u(`help`),toggleKiosk:()=>b(e=>!e),togglePalette:()=>u(e=>e===`palette`?`none`:`palette`),toggleReasoning:()=>D(e=>!e),toggleSidebarCollapse:()=>x(e=>!e)});let Qt=async(e,n=[],r)=>{let i=R;if(!i||Le.current||Re.current)return!1;Le.current=!0;let a,o;try{if(!n.length){let t=await Hc(e,Zt);if(t.kind===`handled`)return r?.({type:`settled`,outcome:`message`}),!0;if(t.kind===`error`)return L(`error`,t.message),!1}a=++ze.current,o=new AbortController,Re.current={id:a,sid:i,controller:o}}finally{Le.current=!1}let s=()=>{let e=Re.current;return!!(e&&e.id===a&&e.sid===i&&rt.current===i&&!o.signal.aborted)},c=()=>{Re.current?.id===a&&(Re.current=null,ve(!1),Se([]))};ve(!0),Se([]);let l=[];if(n.length)try{let e=await U.uploadAttachments(i,n,o.signal);if(!s())return!1;l=e.attachments.map(e=>({attachment_id:e.attachment_id}))}catch(e){return s()&&(L(`error`,t(`chat.attachmentUploadFailed`,{error:mi(e)})),c()),!1}be(t=>[...t,Yc(i,a,e)]);let u=(e,t=``,n=`auto`)=>{!s()||typeof e!=`string`||!e.trim()||be(r=>Xc(r,i,a,e,t,Date.now(),n))},d=e=>{if(!s())return;let t=e.item;typeof t?.id==`string`&&r?.({type:`task`,taskId:t.id});let n=e.daemon&&typeof e.daemon==`object`?e.daemon:null,i=typeof e.reply==`string`?e.reply:null;n?.admission_required?L(`error`,i||`Task queued, but all daemon slots are busy: ${String(n.error||`operator action required`)}`):n&&Number(n.rc??0)!==0?L(`error`,i||`Task queued, but executor did not start: ${String(n.error||`unknown error`)}`):i&&!r&&L(`success`,i),ot.refetch?.()},f=e=>{s()&&Gc(e,{dispatchTask:d,notifyError:e=>L(`error`,e),refetchTranscript:()=>{ht.refetch()}})};return(async()=>{let t=!1,n=null,a=[];try{try{await U.messageStream(i,e,{onPhase:(e,t,n)=>{!s()||n.heartbeat||(a=Kn(a,{label:e,role:t,kind:n.kind,detail:n.detail,heartbeat:n.heartbeat,quietS:n.quietS}),Se(a))},onDelta:(e,n,r)=>{s()&&(t=!0,a=qn(a),Se(a),u(e,n,r===`append`||r===`snapshot`?r:`auto`))},onDone:e=>{if(!s())return;u(e.reply,``,`snapshot`),f(e);let t=e.item;(e.kind!==`task`||typeof t?.id!=`string`)&&r?.({type:`settled`,outcome:e.kind===`error`?`error`:`message`})},onError:e=>{s()&&(n=e)}},{signal:o.signal,attachments:l,routeOverride:he})}catch(e){s()&&(n=e)}if(!s())return;n&&(L(`error`,hi(n,t)),r?.({type:`settled`,outcome:`error`}))}finally{o.signal.aborted&&r?.({type:`settled`,outcome:`cancelled`}),c()}})(),!0},$t=(0,I.useRef)(Qt);$t.current=Qt;let en=async(e,t=[])=>{let n=fe.current,r=rt.current,i=await Qt(e,t);return i&&rt.current===r&&(le(e=>e===n?``:e),de(e=>e.filter(e=>!t.includes(e)))),i},tn=(0,I.useMemo)(()=>{let n=vo(Nt,e=>{$t.current(e)},e=>{le(e),N(e=>e+1)},e),r=[...f?[]:[{id:`new`,label:t(`palette.newDaemon`),hint:`+`,group:t(`palette.view`),run:()=>Ae(!0)}],{id:`transcript`,label:t(`palette.openTranscript`),hint:`/transcript`,group:t(`palette.view`),run:()=>u(`transcript`)},{id:`inspector`,label:t(`palette.openProject`),hint:t(`palette.projectHint`),group:t(`palette.view`),run:()=>u(`inspector`)},{id:`operations`,label:t(`palette.openOperations`),hint:t(`palette.operationsHint`),group:t(`palette.view`),run:()=>u(`operations`)},{id:`help`,label:t(`help.title`),hint:`?`,group:t(`palette.view`),run:()=>u(`help`)},{id:`reasoning`,label:t(ne?`palette.hideReasoning`:`palette.showReasoning`),hint:`⌘T`,group:t(`palette.view`),run:()=>D(e=>!e)},{id:`kiosk`,label:t(f?`palette.exitKiosk`:`palette.enterKiosk`),hint:`⌘.`,group:t(`palette.view`),run:()=>b(e=>!e)}],i=f?[]:[{id:`message`,label:t(`palette.messageArgus`),hint:`/`,group:t(`palette.action`),run:()=>N(e=>e+1)},..._e?[{id:`cancel-message`,label:t(`palette.stopWaiting`),hint:`Esc`,group:t(`palette.action`),run:et}]:[],...ct?[{id:`continuous`,label:ct.enabled?t(`palette.stopContinuous`):t(`palette.startContinuous`),group:t(`palette.action`),run:Yt}]:[],...V?.daemon.control_available===!1?[]:[V?.daemon.alive?{id:`stop`,label:t(`palette.stopDaemon`),group:t(`palette.action`),run:qt}:{id:`start`,label:t(`palette.startDaemon`),group:t(`palette.action`),run:Kt}]],o=a.map(e=>({id:`p-${e.id}`,label:e.label||e.id,hint:e.daemon_alive?`● ${t(`common.live`)}`:`○`,keywords:`${e.id} ${e.display_name??``} ${e.objective} ${e.daemon_alive?`live running`:`stopped idle`}`,group:t(`palette.project`),run:()=>nt(e.id)}));return[...r,...i,...n,...o]},[a,V?.daemon.alive,f,ne,ct?.enabled,_e,et,e,t]);return(0,X.jsxs)(`div`,{ref:te,style:{"--sidebar-width":`${m}px`,"--preview-width":`${y}px`},className:`workbench-shell ambient-canvas flex w-screen max-w-full overflow-hidden text-ink`,children:[(0,X.jsx)(Tl,{error:c,onRetry:()=>{r.refetch(),i.refetch()}}),Mt.selection&&(0,X.jsx)(vs,{sid:Mt.selection.sid,path:Mt.selection.path,delivery:Mt.selection.receipt,deliveries:Ft,reviewActivity:Mt.selection.sid===H?Tt:void 0,onSelectDelivery:Pt,onSelectPath:Mt.selectPath,onClose:Mt.close},`${Mt.selection.sid}:${Mt.selection.receipt.delivery_id}`),!f&&k?(0,X.jsx)(`button`,{type:`button`,"aria-label":t(`common.closeSessions`),onClick:()=>ee(!1),className:`fixed inset-0 z-30 bg-black/40 lg:hidden`}):null,f?null:(0,X.jsx)(Qs,{projects:a,activeId:R,localCwd:s,onSelect:e=>{nt(e),ee(!1)},onPrefetch:tt,onManage:Gt,onResume:e=>void Rt(e),resumingId:Fe,onOpenPanel:e=>u(e),onNew:()=>Ae(!0),loading:r.isLoading,creating:at,error:r.isError?mi(r.error):void 0,onRetry:()=>void r.refetch(),mobileOpen:k,collapsed:!p,onToggleCollapse:()=>x(e=>!e),themeMode:re,onCycleTheme:d}),!f&&p?(0,X.jsx)(uc,{label:t(`common.resizeSessions`),value:m,min:220,max:400,onPointerDown:e=>_(`left`,e),onReset:()=>S(256),onNudge:e=>S(t=>Math.max(220,Math.min(400,t+e)))}):null,(0,X.jsx)(`main`,{className:`flex min-w-0 flex-1 overflow-x-hidden`,children:V?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`section`,{className:`${h===`activity`?`flex`:`hidden`} glass-panel glass-panel--main h-full min-w-0 flex-1 flex-col lg:flex`,children:[A!==`map`&&(0,X.jsx)(Zr,{snap:V,streamOk:W,onStart:Kt,onStop:qt,onManage:()=>R&&Gt(R),busy:zt,snapshotStale:ot.isError,readOnly:f,missionView:wt}),(0,X.jsxs)(`div`,{className:`hidden h-10 shrink-0 items-center gap-1 border-b border-line/60 px-3 lg:flex`,children:[(0,X.jsxs)(`div`,{className:`workspace-tabs`,"data-active":A,children:[(0,X.jsx)(`span`,{className:`workspace-tab-indicator`,"aria-hidden":`true`}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>O(`mission`),className:`workspace-tab`,"data-selected":A===`mission`,children:t(`mobile.mission`)}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>O(`activity`),className:`workspace-tab`,"data-selected":A===`activity`,children:t(`mobile.activity`)}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>O(`workbench`),className:`workspace-tab`,"data-selected":A===`workbench`,children:t(`mobile.workbench`)}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>O(`map`),className:`workspace-tab`,"data-selected":A===`map`,children:t(`mobile.map`)})]}),A===`mission`?(0,X.jsx)(`span`,{className:`ml-auto hidden max-w-72 truncate text-[10px] text-ink-faint sm:block`,children:wt?.active_role?t(`mission.roleActive`,{role:wt.active_role}):t(`mission.overview`)}):(0,X.jsx)(`span`,{className:`ml-auto`}),!f&&A!==`map`?(0,X.jsx)(`button`,{type:`button`,onClick:()=>u(`operations`),className:`rounded border border-line/60 px-2 py-1 text-[10px] text-ink-faint hover:border-blue/50 hover:text-blue`,children:t(`mission.operations`)}):null]}),A===`map`&&(0,X.jsx)(I.Suspense,{fallback:(0,X.jsx)(`div`,{className:`m-auto text-sm text-ink-faint`,children:t(`common.loading`)}),children:(0,X.jsx)(Al,{snapshot:V,events:St,managerSteps:xe,draft:ce,onDraftChange:le,onSend:Qt,pending:_e,onCancel:et,focusSignal:se,readOnly:f,onOpenSettings:()=>u(`config`),routeOverride:he,onRouteOverrideChange:ge,conversationEvents:Ct,connected:W,artifacts:lt.data??[],deliveryCount:Ft.length,onOpenDelivery:()=>{let e=$r(Ft,wt?.routing.vertical||``);e&&Pt(e.receipt,e.path)},onOpenReceipt:Pt,onOpenArtifact:we,onAnswer:()=>bt(!0)},V.session.id)}),(0,X.jsxs)(`div`,{className:`${A===`workbench`||A===`map`?`hidden`:`flex`} min-h-0 flex-1 flex-col`,children:[(0,X.jsx)(Ko,{alert:mt}),j===`mission`&&wt?(0,X.jsx)(Mc,{view:wt,sid:V.session.id,snapshot:V,gitDiff:ut.data,artifacts:lt.data,onOpenArtifact:jt,onOpenDelivery:Pt,onNotify:L}):(0,X.jsx)(oa,{events:xt,connected:W,showReasoning:ne,onToggleReasoning:()=>D(e=>!e),embedded:!0,filter:qe,query:Ye,skipFirst:Ge.skipFirst,artifacts:lt.data,onOpenArtifact:jt,onOpenDelivery:Pt}),f?null:(0,X.jsx)(`div`,{className:`composer-dock shrink-0 px-4 pt-3`,children:(0,X.jsxs)(`div`,{className:`mx-auto w-full max-w-full lg:max-w-[61.8vw]`,children:[(0,X.jsx)(Wo,{questions:V.pending_questions??[],backlog:V.backlog,onAnswer:()=>bt(!0)}),(0,X.jsx)(ho,{value:ce,attachments:ue,onAttachmentsChange:de,onChange:le,onSend:en,onCancel:et,disabled:!R,pending:_e,focusSignal:se,embedded:!0,steps:xe,onRewrite:it,rewriting:P,slashSelection:pe,onSlashSelectionChange:me,routeOverride:he,onRouteOverrideChange:ge},R||`no-session`)]})})]}),ae&&R?(0,X.jsx)(`div`,{className:`${A===`workbench`?`flex`:`hidden`} min-h-0 flex-1`,children:(0,X.jsx)(I.Suspense,{fallback:(0,X.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center text-xs text-ink-faint`,children:t(`common.loading`)}),children:(0,X.jsx)(kl,{sid:R,active:A===`workbench`})})}):null]}),v&&A!==`map`?(0,X.jsx)(uc,{label:t(`common.resizePreview`),value:y,min:320,max:840,onPointerDown:e=>_(`right`,e),onReset:()=>T(440),onNudge:e=>T(t=>Math.max(320,Math.min(840,t-e)))}):null,(A!==`map`||h===`preview`)&&(0,X.jsxs)(`aside`,{"data-resizable-panel":`right`,className:`${h===`preview`?`flex`:`hidden`} relative min-w-0 flex-1 flex-col overflow-hidden border-l border-line/60 bg-panel transition-[width] duration-[250ms] ease-panel lg:flex lg:flex-none ${v?`lg:w-[var(--preview-width)]`:`lg:w-14`}`,children:[(0,X.jsx)(`div`,{className:`lg:hidden`,children:(0,X.jsx)(Zr,{snap:V,streamOk:W,onStart:Kt,onStop:qt,onManage:()=>R&&Gt(R),busy:zt,snapshotStale:ot.isError,readOnly:f,missionView:wt})}),(0,X.jsx)(Fs,{sid:H,artifacts:lt.data,error:lt.isError,onExpand:we,onOpenFile:At,className:`min-h-0 flex-1 mobile-scroll-region ${v?`lg:flex`:`lg:hidden`}`,embedded:!0,onCollapse:()=>w(!1),missionView:wt,activityEvents:xt,requestedPath:Te.path,requestedPathToken:Te.token}),v?null:(0,X.jsx)(`div`,{className:`hidden h-12 items-center justify-center border-b border-line/50 text-ink-faint lg:flex`,children:(0,X.jsx)(`button`,{type:`button`,onClick:At,"aria-label":t(`common.expandPreview`),title:t(`common.expandPreview`),className:`flex h-8 w-8 items-center justify-center rounded-md border border-line/50 bg-bg/40 hover:border-blue/50 hover:text-ink`,children:(0,X.jsx)(o,{icon:E,className:`h-3.5 w-3.5`})})})]})]}):(0,X.jsx)(Bc,{loading:r.isLoading||!!(R&&ot.isLoading),hasProjects:a.length>0,error:r.isError&&a.length===0?mi(r.error):ot.isError&&!V?mi(ot.error):void 0,onRetry:()=>{r.refetch(),R&&ot.refetch()},onNew:()=>Ae(!0),onChoose:()=>ee(!0),canCreate:!f})}),(0,X.jsx)(bo,{open:l===`palette`,onClose:()=>u(`none`),items:tn}),(0,X.jsx)(So,{open:l===`help`,onClose:()=>u(`none`)}),R&&(0,X.jsx)(Bo,{sid:R,open:l===`doctor`,onClose:()=>u(`none`)}),R&&(0,X.jsx)(Vo,{sid:R,open:l===`config`,onClose:()=>u(`none`)}),R&&(0,X.jsx)(Ho,{sid:R,open:l===`identity`,onClose:()=>u(`none`)}),R&&(0,X.jsx)(Uo,{sid:R,open:l===`transcript`,onClose:()=>u(`none`)}),R&&V?(0,X.jsx)(oc,{open:l===`inspector`,snap:V,journal:gt.data??[],busy:It.disposeBacklog.isPending||It.stopBacklog.isPending,onClose:()=>u(`none`),onDispose:Wt,onStop:Jt,onInspect:Oe}):null,R&&V?(0,X.jsx)(Lc,{open:l===`operations`,sid:R,snap:V,onClose:()=>u(`none`),onChanged:()=>{ot.refetch(),r.refetch()},onRestored:async e=>{await r.refetch(),nt(e)}}):null,(0,X.jsx)(vs,{sid:R,path:Ce,reviewActivity:R===H?Tt:void 0,onClose:()=>we(null)}),(0,X.jsx)(lc,{sid:R,itemId:De,onClose:()=>Oe(null),onDone:e=>Wt(e,`done`),onSkip:e=>Wt(e,`rm`),onStop:Jt,busy:It.disposeBacklog.isPending||It.stopBacklog.isPending,readOnly:f}),(0,X.jsx)(Ls,{open:ke,busy:at,onClose:()=>Ae(!1),onCreate:B}),(0,X.jsx)(Go,{reply:G,open:yt,busy:vt,onClose:()=>bt(!1),onSubmit:_t}),Ne?(0,X.jsx)(Rs,{open:je,sid:Ne,name:st.data?.session.display_name||a.find(e=>e.id===Ne)?.display_name||a.find(e=>e.id===Ne)?.label||``,alive:st.data?.daemon.alive??!!a.find(e=>e.id===Ne)?.daemon_alive,controlAvailable:st.data?.daemon.control_available!==!1,busy:zt,onClose:()=>{Me(!1),Pe(null)},onRename:Ht,onStart:Ut,onStop:Vt,onDelete:Bt}):null,(0,X.jsx)(Is,{notice:Ue,onClose:Ze}),V&&!f?(0,X.jsx)($,{active:h===`preview`?`preview`:A,sidebarOpen:k,onSelect:e=>{if(e===`preview`){C(`preview`);return}C(`activity`),O(e)},onOpenSessions:()=>ee(!0)}):null]})}function Nl({onDone:e}){let{t}=Z(),n=(0,I.useRef)(!1),r=(0,I.useCallback)(()=>{n.current||(n.current=!0,e())},[e]);return(0,I.useEffect)(()=>{let e=window.setTimeout(r,970),t=()=>r();return window.addEventListener(`keydown`,t,{once:!0}),()=>{window.clearTimeout(e),window.removeEventListener(`keydown`,t)}},[r]),(0,X.jsx)(`div`,{role:`status`,"aria-label":t(`splash.starting`),onClick:r,onAnimationEnd:e=>{e.currentTarget===e.target&&r()},className:`argus-web-splash`,children:(0,X.jsx)(`div`,{className:`argus-web-splash-logo`,"aria-hidden":`true`,children:(0,X.jsx)(Ai,{size:168})})})}var Pl=class extends I.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}render(){if(!this.state.failed)return this.props.children;let e=this.props.locale===`zh-CN`;return(0,X.jsx)(`main`,{className:`flex min-h-dvh items-center justify-center bg-bg p-8 text-ink`,role:`alert`,children:(0,X.jsxs)(`section`,{className:`max-w-lg rounded-xl border border-line bg-panel p-8 shadow-lg`,children:[(0,X.jsx)(`p`,{className:`mb-3 text-xs font-semibold uppercase tracking-widest text-blue`,children:`Argus`}),(0,X.jsx)(`h1`,{className:`text-lg font-semibold`,children:e?`工作台暂时无法显示`:`The workspace could not be displayed`}),(0,X.jsx)(`p`,{className:`mt-3 text-sm leading-relaxed text-ink-dim`,children:e?`页面资源未能正确加载。后端任务不会因此被停止;你仍可使用桌面菜单查看日志或设置。重新加载会丢弃页面中尚未发送的输入。`:`A page resource failed to load. Backend work has not been stopped. Desktop menus remain available for logs and settings. Reloading discards unsent input on this page.`}),(0,X.jsxs)(`div`,{className:`mt-6 flex flex-wrap gap-3`,children:[(0,X.jsx)(`button`,{type:`button`,className:`rounded-md bg-blue px-4 py-2 text-sm text-white`,onClick:()=>window.location.reload(),children:e?`重新加载工作台`:`Reload workspace`}),(0,X.jsx)(`button`,{type:`button`,className:`rounded-md border border-line px-4 py-2 text-sm`,onClick:()=>{let e=new URL(window.location.href);e.searchParams.set(`view`,`activity`),window.location.assign(e.toString())},children:e?`返回对话页面`:`Return to conversation`})]})]})})}};function Fl(e,t,n){let r=!1;e.addEventListener(`vite:preloadError`,e=>{let i=e.payload,a=i instanceof Error?i.message:String(i??``);if(!/\/(?:pdf[.-]|pdfjs)[^/\s]*\.(?:m?js)(?:[?#\s]|$)/i.test(a)&&/failed to fetch dynamically imported module|importing a module script failed|loading chunk .+ failed/i.test(a)){if(r){e.preventDefault();return}try{let e=n.storage(),t=`argus.stale-chunk-reloaded`;if(e.getItem(t)===n.releaseId)return;e.setItem(t,n.releaseId)}catch{return}e.preventDefault(),r=!0,t()}})}Fl(window,()=>window.location.reload(),{releaseId:Ne,storage:()=>window.sessionStorage}),We();var Il=window.parent!==window;document.documentElement.dataset.argusEmbedded=String(Il);var Ll=new De({defaultOptions:{queries:{staleTime:3e3,retry:pr,refetchOnWindowFocus:!1}}});function Rl(){let{locale:e}=Z(),[t,n]=(0,I.useState)(!Il);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Pl,{locale:e,children:(0,X.jsx)(Ml,{})}),t?(0,X.jsx)(Nl,{onDone:()=>n(!1)}):null]})}Oe.createRoot(document.getElementById(`root`)).render((0,X.jsx)(I.StrictMode,{children:(0,X.jsx)(de,{client:Ll,children:(0,X.jsx)(Jr,{children:(0,X.jsx)(Rl,{})})})}));export{ba as A,U as B,Ua as C,La as D,za as E,Ai as F,Se as G,qe as H,ki as I,fi as L,Aa as M,sa as N,Ia as O,oa as P,ei as R,Wa as S,Va as T,H as U,Ke as V,et as W,eo as _,Wo as a,Ya as b,co as c,uo as d,oo as f,to as g,no as h,os as i,Da as j,ja as k,lo as l,ro as m,gl as n,go as o,io as p,yc as r,so as s,hl as t,fo as u,Qa as v,Ha as w,Ga as x,Za as y,Z as z}; \ No newline at end of file diff --git a/frontend/web/dist/assets/play-4uDgOsGD.js b/frontend/web/dist/assets/play-4uDgOsGD.js new file mode 100644 index 000000000..9360eacb7 --- /dev/null +++ b/frontend/web/dist/assets/play-4uDgOsGD.js @@ -0,0 +1 @@ +import{O as e}from"./index-CpMiioIG.js";var t=e(`ChevronRight`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]),n=e(`GitBranch`,[[`line`,{x1:`6`,x2:`6`,y1:`3`,y2:`15`,key:`17qcm7`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}],[`circle`,{cx:`6`,cy:`18`,r:`3`,key:`fqmcym`}],[`path`,{d:`M18 9a9 9 0 0 1-9 9`,key:`n2h4wq`}]]),r=e(`Play`,[[`polygon`,{points:`6 3 20 12 6 21 6 3`,key:`1oa8hb`}]]);export{n,t as r,r as t}; \ No newline at end of file diff --git a/frontend/web/dist/index.html b/frontend/web/dist/index.html index dda5c05e0..01b95f4b1 100644 --- a/frontend/web/dist/index.html +++ b/frontend/web/dist/index.html @@ -38,13 +38,13 @@ document.documentElement.dataset.themeStyle = style; })(); - + - +
diff --git a/frontend/web/src/components/PluginEnvironment.tsx b/frontend/web/src/components/PluginEnvironment.tsx new file mode 100644 index 000000000..8ed5df7bb --- /dev/null +++ b/frontend/web/src/components/PluginEnvironment.tsx @@ -0,0 +1,90 @@ +import { usePluginText } from '../lib/pluginText'; +import { useState } from 'react'; +import { Check, CircleHelp, Download, KeyRound, RefreshCw, ShieldCheck, ChevronDown, ExternalLink } from 'lucide-react'; + +export type PluginHealth = { + checked?: number; ready?: boolean; summary?: string; + components?: { id: string; name: string; description: string; status: string; detail: string; path?: string; url: string; automatic: boolean; license_required: boolean }[]; +}; +export type PluginSetup = { actions: string[]; license?: { action: string; name: string; url: string; platform_consent?: { platform: string; machines: string[]; text: string; url: string } } }; +const control = 'inline-flex items-center justify-center gap-1.5 rounded-lg border border-line px-3 py-1.5 text-sm transition-colors hover:bg-bg disabled:cursor-not-allowed disabled:opacity-45'; + +export function PluginEnvironment({ health, setup, running, act, platform, machine }: { + health?: PluginHealth; setup: PluginSetup; running: boolean; + platform?: string; machine?: string; + act: (action: string, payload?: Record) => Promise; +}) { + const tr = usePluginText(); + const [expanded, setExpanded] = useState(false); + const [credentials, setCredentials] = useState(false); + const [username, setUsername] = useState(''); + const [password, setPassword] = useState(''); + const [manual, setManual] = useState(null); + const [path, setPath] = useState(''); + const [acceptPlatform, setAcceptPlatform] = useState(false); + const terms = setup.license?.platform_consent; + const platformConsent = terms?.platform === platform && terms?.machines.includes(machine || ''); + const components = health?.components || []; + const missing = components.filter(c => c.status !== 'ready'); + const needLicense = missing.some(c => c.license_required); + const needRepair = missing.some(c => c.automatic); + async function license(event: React.FormEvent) { + event.preventDefault(); + const submitted = await act(setup.license!.action, { username, password, accept_platform_license: acceptPlatform }); + // Secrets stay in this form only until submitted/closed. No browser storage. + setPassword(''); + if (submitted) { setCredentials(false); setUsername(''); setExpanded(true); } + } + return
+
+ + +
+ {tr((needLicense || needRepair || !health?.checked) &&

{tr(" 免费科学组件自动配置;SHELX 需要你在官网取得学术授权后输入下载凭据。 ")}

)} +
+ {tr((needRepair || !health?.checked) && )} + {tr(setup.license && )} +
+ {tr(credentials && setup.license &&
+
{tr(setup.license.name)}{tr(" 学术授权")} + {tr("前往官网申请")}
+

{tr("填写授权邮件中的 username 和 password,即可自动下载安装。凭据仅用于本次官方下载,不保存,也不发送给模型。")}

+
+ + +
+ {tr(platformConsent && terms && )} +
+
+
)} + {expanded &&
+ {tr(!components.length &&

{tr("点击“检查环境”可验证科学内核与外部程序。")}

)} + {components.map(component =>
+
+ {tr(component.status === 'ready' ? : )} +
{tr(component.name)}{tr(component.status === 'ready' ? tr("可用") : component.license_required ? tr("待授权安装") : tr("待修复"))}
+

{tr(component.description)}

+
{tr(component.status === 'ready' ? tr("查看检查详情") : tr("查看原因与安装方式"))} +

{tr(component.detail)}

+ {component.path &&

{component.path}

} +
{tr("官方安装说明 ↗")} + {tr(component.id !== 'python' && setup.actions.includes('configure') && )}
+
+
+
+
)} + {tr(manual &&
{ e.preventDefault(); if (await act('configure', { paths: { [manual]: path } })) { setManual(null); setPath(''); } }} className="mt-3 rounded-lg bg-bg/70 p-3"> + +

{tr("填写运行 Argus 的电脑上的路径,验证成功后生效。")}

+
+
)} + {tr(health?.checked &&

{tr("最近检查 ")}{tr(new Date(health.checked * 1000).toLocaleString())}{tr(" · 检查不调用模型")}

)} +
} +
; +} diff --git a/frontend/web/src/components/PluginLauncher.tsx b/frontend/web/src/components/PluginLauncher.tsx new file mode 100644 index 000000000..83db93b3b --- /dev/null +++ b/frontend/web/src/components/PluginLauncher.tsx @@ -0,0 +1,98 @@ +import { usePluginText } from '../lib/pluginText'; +import { useI18n } from '../i18n'; +import { useEffect, useRef, useState } from 'react'; +import { createPortal } from 'react-dom'; +import { Boxes, Diamond, ArrowUpRight, X, Download, Loader2, RefreshCw } from 'lucide-react'; +import { authHeaders } from '../api'; +import { PluginEnvironment, type PluginHealth, type PluginSetup } from './PluginEnvironment'; + +type Plugin = { + id: string; name: string; description: string; version: string; url: string; command?: string; + installed: boolean; enabled: boolean; supported: boolean; reason: string; installed_version?: string; + rights_notice?: string; rights_notice_zh?: string; + update_available: boolean; backends: Record; + operation?: { status?: string; progress?: string; error?: string }; + health?: PluginHealth; setup?: PluginSetup; + platform?: string; machine?: string; +}; + +export function PluginLauncher({ compact = false }: { compact?: boolean }) { + const tr = usePluginText(); + const { locale } = useI18n(); + const [open, setOpen] = useState(false); + const [plugins, setPlugins] = useState([]); + const [error, setError] = useState(''); + const [loading, setLoading] = useState(false); + const [pending, setPending] = useState(null); + const close = useRef(null); + async function refresh(signal?: AbortSignal) { + const response = await fetch('/api/plugins', { headers: authHeaders(), signal }); + if (!response.ok) throw new Error(tr("无法读取插件列表")); + setPlugins((await response.json()).plugins); + } + useEffect(() => { + if (!open) return; + const controller = new AbortController(); + close.current?.focus(); setError(''); setLoading(true); + refresh(controller.signal).catch(e => { if (!controller.signal.aborted) setError(e.message); }).finally(() => setLoading(false)); + const timer = window.setInterval(() => void refresh(controller.signal).catch(() => {}), 1500); + const key = (event: KeyboardEvent) => { if (event.key === 'Escape') setOpen(false); }; + window.addEventListener('keydown', key); + return () => { controller.abort(); window.clearInterval(timer); window.removeEventListener('keydown', key); }; + }, [open]); + async function act(plugin: Plugin, action: string, payload?: Record): Promise { + setPending(plugin.id); setError(''); + try { + const response = await fetch(`/api/plugins/${plugin.id}/${action === 'launch' ? 'launch' : `manage/${action}`}`, { method: 'POST', headers: { ...authHeaders(), 'Content-Type': 'application/json' }, body: payload ? JSON.stringify(payload) : undefined }); + const result = await response.json(); + if (!response.ok) throw new Error(result.detail || tr("插件操作未完成")); + if (action === 'launch') window.location.assign(result.url); + else await refresh(); + return true; + } catch (e) { setError(e instanceof Error ? e.message : String(e)); return false; } + finally { setPending(null); } + } + return <> + + {open && createPortal(
setOpen(false)}> +
e.stopPropagation()} + className="max-h-[85vh] w-full max-w-xl overflow-y-auto rounded-2xl border border-line bg-panel p-6 text-ink shadow-xl"> +

{tr("插件")}

+
+

{tr("按需安装研究工具,沿用 Argus 的模型与执行后端。")}

+ {tr(error &&

{tr(error)}

)} + {tr(loading &&

{tr("正在读取插件…")}

)} + {tr(!loading && !plugins.length &&

{tr("暂无可用插件")}

)} + {tr(plugins.map(plugin => { + const running = plugin.operation?.status === 'running' || pending === plugin.id; + const disabled = running || !plugin.supported; + const control = 'inline-flex items-center justify-center gap-1.5 rounded-lg border border-line px-3 py-1.5 text-sm transition-colors hover:bg-bg disabled:cursor-not-allowed disabled:opacity-45'; + return
+
+

{tr(plugin.name)}

{tr(plugin.installed_version || plugin.version)}
+

{tr(plugin.description)}

+
+
{tr(plugin.installed ? plugin.enabled ? tr("已启用") : tr("已停用") : tr("未安装"))}{tr(" · 当前后端 ")}{tr(Array.from(new Set(Object.values(plugin.backends))).join(' / '))}
+ {tr(!plugin.supported &&

{tr(plugin.reason)}

)} + {tr(plugin.operation?.status === 'running' &&

{tr(plugin.operation.progress)}

)} + {tr(plugin.operation?.status === 'failed' &&

{tr(plugin.operation.error)}

)} +
+ {tr(!plugin.installed && )} + {tr(plugin.installed && plugin.enabled && )} + {tr(plugin.installed && !plugin.enabled && )} + {tr(plugin.update_available && )} + {tr(plugin.installed && plugin.enabled && )} + {tr(plugin.installed && )} +
+

{tr(plugin.installed ? tr(`原生会话输入 ${plugin.command || ''} 可启用后台工具。卸载保留会话、研究数据和科学软件。`) : tr("首次安装自动配置独立 Python、DIALS、Systre / Java 和 PLATON 学术免费组件。SHELX 稍后输入授权信息即可安装。"))}

+ {tr(plugin.rights_notice &&

{tr(locale === 'zh-CN' ? plugin.rights_notice_zh || plugin.rights_notice : plugin.rights_notice)}

)} + {tr(plugin.installed && plugin.setup && act(plugin, action, payload)}/>)} +
; + }))} +
+
, document.body)} + ; +} diff --git a/frontend/web/src/components/Sidebar.tsx b/frontend/web/src/components/Sidebar.tsx index e21025fdc..e7e7a0316 100644 --- a/frontend/web/src/components/Sidebar.tsx +++ b/frontend/web/src/components/Sidebar.tsx @@ -1,5 +1,6 @@ import { useEffect, useMemo, useRef, useState } from 'react'; import type { ProjectRow } from '../api'; +import { PluginLauncher } from './PluginLauncher'; import { Wordmark } from './Wordmark'; import { StatusDot } from './primitives'; import { ago, uptime } from '../lib/format'; @@ -147,6 +148,7 @@ export function Sidebar({ ) : null} + {!slim ? ( <>
diff --git a/frontend/web/src/lib/commandI18n.ts b/frontend/web/src/lib/commandI18n.ts index 8cd428a62..c35e2fb7a 100644 --- a/frontend/web/src/lib/commandI18n.ts +++ b/frontend/web/src/lib/commandI18n.ts @@ -10,6 +10,7 @@ const GROUPS: Record = { }; const DESCRIPTIONS: Record = { + crystalpilot: '在当前 Argus 会话启用晶体学工具,保持原生界面', status: '查看角色、队列、日志和健康状态', roles: '查看各角色的后端、模型、推理强度和实时活动', journal: '查看近期日志(默认 10 条)', diff --git a/frontend/web/src/lib/pluginEnglish.json b/frontend/web/src/lib/pluginEnglish.json new file mode 100644 index 000000000..e2abbddcf --- /dev/null +++ b/frontend/web/src/lib/pluginEnglish.json @@ -0,0 +1,113 @@ +{ + "科学环境已就绪": "Scientific environment ready", + "科学环境 · ⟦0⟧ 项待配置": "Scientific environment · ⟦0⟧ item(s) to configure", + "科学环境": "Scientific environment", + "检查环境": "Check environment", + "免费科学组件自动配置;SHELX 需要你在官网取得学术授权后输入下载凭据。": "Free scientific components are configured automatically; SHELX requires academic authorization from the official website before entering download credentials.", + "修复依赖": "Repair dependencies", + "配置 SHELX": "Configure SHELX", + "SHELX 授权安装": "SHELX authorized installation", + "学术授权": "Academic authorization", + "前往官网申请": "Apply on official website", + "填写授权邮件中的 username 和 password,即可自动下载安装。凭据仅用于本次官方下载,不保存,也不发送给模型。": "Enter the username and password from the authorization email to download and install automatically. Credentials are used only for this official download, are not saved, and are not sent to the model.", + "用户名": "Username", + "SHELX 用户名": "SHELX username", + "密码": "Password", + "SHELX 密码": "SHELX password", + "查看许可 ↗": "View license ↗", + "下载并安装 SHELX": "Download and install SHELX", + "取消": "Cancel", + "科学软件健康检查": "Scientific software health check", + "点击“检查环境”可验证科学内核与外部程序。": "Click “Check environment” to verify the scientific kernel and external programs.", + "可用": "Available", + "待授权安装": "Authorization required", + "待修复": "Needs repair", + "查看检查详情": "View check details", + "查看原因与安装方式": "View cause and installation method", + "官方安装说明 ↗": "Official installation instructions ↗", + "使用已有安装": "Use existing installation", + "DIALS 环境目录": "DIALS environment directory", + "Systre JAR 路径(需要已有 Java)": "Systre JAR path (existing Java required)", + "⟦0⟧ 可执行文件路径": "⟦0⟧ executable path", + "填写运行 Argus 的电脑上的路径,验证成功后生效。": "Enter the path on the computer running Argus. It takes effect after successful verification.", + "验证并使用": "Verify and use", + "最近检查": "Last checked", + "· 检查不调用模型": "· Check does not call the model", + "无法读取插件列表": "Unable to read plugin list", + "插件操作未完成": "Plugin operation incomplete", + "插件": "Plugins", + "关闭插件列表": "Close plugin list", + "按需安装研究工具,沿用 Argus 的模型与执行后端。": "Install research tools as needed, using Argus's model and execution backend.", + "正在读取插件…": "Reading plugins…", + "暂无可用插件": "No plugins available", + "已启用": "Enabled", + "已停用": "Disabled", + "未安装": "Not installed", + "· 当前后端": "· Current backend", + "安装": "Install", + "打开工作台": "Open workbench", + "启用": "Enable", + "更新至": "Update to", + "停用": "Disable", + "卸载": "Uninstall", + "原生会话输入 ⟦0⟧ 可启用后台工具。卸载保留会话、研究数据和科学软件。": "Native session input ⟦0⟧ can enable background tools. Uninstalling preserves sessions, research data, and scientific software.", + "首次安装自动配置独立 Python、DIALS、Systre / Java 和 PLATON 学术免费组件。SHELX 稍后输入授权信息即可安装。": "First installation automatically configures standalone Python, DIALS, Systre / Java, and free academic PLATON components. SHELX can be installed later by entering authorization details.", + "暂不支持,敬请期待。当前插件支持 Codex、Copilot 和 Pi。": "Not supported yet. Stay tuned. Current plugins support Codex, Copilot, and Pi.", + "安装科学环境需要 Python 3.11–3.13。请安装 Python 后重试,或设置 ARGUS_PLUGIN_PYTHON。": "Installing the scientific environment requires Python 3.11–3.13. Install Python and try again, or set ARGUS_PLUGIN_PYTHON.", + "准备安装": "Prepare installation", + "获取并校验插件包": "Download and verify plugin package", + "安装独立运行环境(首次可能需要几分钟)": "Install standalone environment (may take several minutes the first time)", + "插件仍有任务运行,请等任务结束或先暂停,再进行此操作。": "This plugin still has running tasks. Wait for them to finish or pause them before continuing.", + "此插件版本尚未提供可校验的发行包。": "No verifiable release package is available for this plugin version.", + "插件包校验失败,未安装。": "Plugin package verification failed. Not installed.", + "正在准备": "Preparing", + "当前系统或 Argus 插件接口版本暂不支持此插件。": "This plugin is not currently supported by the system or Argus plugin API version.", + "插件发行包尚未发布。": "The plugin release package has not been published.", + "安装完成": "Installation complete", + "环境检查完成": "Environment check complete", + "此插件已有安装或更新操作正在进行。": "An installation or update operation for this plugin is already in progress.", + "插件尚未安装": "Plugin not installed", + "安装进程已中断;已有可用版本保持不变,可重试。": "Installation was interrupted. The existing available version is unchanged; you can retry.", + "安装未完成,已有版本保持不变": "Installation incomplete; existing version unchanged", + "此版本已安装,可启用插件。": "This version is installed. You can enable the plugin.", + "请先安装插件": "Install the plugin first", + "请先更新插件以使用环境管理功能": "Update the plugin first to use environment management", + "插件包超过允许大小。": "The plugin package exceeds the allowed size.", + "科学计算内核": "Scientific computing kernel", + "cctbx · Gemmi · RDKit · 科学服务": "cctbx · Gemmi · RDKit · scientific services", + "衍射帧处理与探测器格式支持": "Diffraction frame processing and detector format support", + "周期网络与拓扑识别": "Periodic networks and topology identification", + "本地 checkCIF 结构校验 · 学术免费": "Local checkCIF structure validation · free for academic use", + "结构精修 · 需要学术授权": "Structure refinement · academic authorization required", + "结构求解 · 需要学术授权": "Structure solution · academic authorization required", + "全部组件可用": "All components available", + "部分组件需要配置或修复": "Some components require configuration or repair", + "PLATON 官网中间证书已更换,请更新插件安装器": "The PLATON official-site intermediate certificate has changed. Update the plugin installer.", + "PLATON Mac 发行包架构不符": "PLATON Mac release package architecture mismatch", + "请输入授权邮件中的用户名和密码。": "Enter the username and password from the authorization email.", + "请选择有效的科学软件路径": "Select a valid scientific software path", + "检查科学软件与运行环境": "Check scientific software and runtime environment", + "正在修复科学 Python 依赖": "Repairing scientific Python dependencies", + "(首次下载可能需要几分钟)": "(The initial download may take several minutes)", + "from cctbx.array_family import flex; import gemmi,rdkit; from argus_crystalpilot import worker; from argus_crystalpilot.resources import bundle_root; assert (bundle_root()/'ui/dist/index.html').is_file(); import crystalpilot; from pathlib import Path; assert (Path(crystalpilot.__file__).parent/'io/dxtbx_plugin/pyproject.toml').is_file(); assert flex.double([1,2]).size()==2; print('科学内核及工作台资源可用')": "from cctbx.array_family import flex; import gemmi,rdkit; from argus_crystalpilot import worker; from argus_crystalpilot.resources import bundle_root; assert (bundle_root()/'ui/dist/index.html').is_file(); import crystalpilot; from pathlib import Path; assert (Path(crystalpilot.__file__).parent/'io/dxtbx_plugin/pyproject.toml').is_file(); assert flex.double([1,2]).size()==2; print('Scientific kernel and workbench resources available')", + "; from importlib.metadata import entry_points; assert {'FormatCBFMiniRigaku:FormatCBF','FormatBrukerSfrmGeom:FormatBruker','FormatRODLegacy:FormatROD'} <= {e.name for e in entry_points(group='dxtbx.format')}; from dials.util.version import dials_version; assert flex.reflection_table() is not None; print(dials_version()+' · 探测器格式插件可用')": "; from importlib.metadata import entry_points; assert {'FormatCBFMiniRigaku:FormatCBF','FormatBrukerSfrmGeom:FormatBruker','FormatRODLegacy:FormatROD'} <= {e.name for e in entry_points(group='dxtbx.format')}; from dials.util.version import dials_version; assert flex.reflection_table() is not None; print(dials_version()+' · detector format plugins available')", + "Systre 19.6.0 · pcu 拓扑计算通过": "Systre 19.6.0 · pcu topology calculation passed", + "正在安装 Apple Rosetta 2 兼容组件": "Installing Apple Rosetta 2 compatibility components", + "从 SHELX 官方站点下载": "Downloading from the official SHELX site", + "SHELX 下载内容不是支持的可执行程序": "SHELX download is not a supported executable", + "已可用,保留当前安装": "Already available; keeping current installation", + "正在安装": "Installing", + "尚未安装 DIALS": "DIALS is not installed", + "PLATON 编译需要 Apple 命令行工具;请运行 xcode-select --install,然后点击修复依赖。": "PLATON compilation requires Apple Command Line Tools; run xcode-select --install, then click Repair dependencies.", + "SHELX 官方 Mac 版需要 Rosetta 2,请先同意安装兼容组件。": "The official Mac version of SHELX requires Rosetta 2. Agree to install the compatibility components first.", + "暂未完成;可在健康检查中重试": "Not completed; retry from the health check", + "SHELX 下载或启动失败;请核对授权、网络及系统平台后重试。": "SHELX download or launch failed; check authorization, network, and system platform, then retry.", + "尚未安装 Systre": "Systre is not installed", + "尚未安装 Java": "Java is not installed", + "Systre 未能识别内置 pcu 网络": "Systre could not identify the built-in pcu network", + "尚未安装 PLATON": "PLATON is not installed", + "PLATON 安装配方已更新,点击修复依赖即可使用当前版本。": "The PLATON installation recipe has been updated. Click Repair dependencies to use the current version.", + "PLATON 未生成校验规则;请检查运行库": "PLATON did not generate verification rules; check the runtime", + "请输入 SHELX 授权信息以安装": "Enter SHELX authorization details to install", + "无法启动,请核对平台与运行库": "Unable to start; check the platform and runtime" +} diff --git a/frontend/web/src/lib/pluginText.ts b/frontend/web/src/lib/pluginText.ts new file mode 100644 index 000000000..d3e4a9018 --- /dev/null +++ b/frontend/web/src/lib/pluginText.ts @@ -0,0 +1,25 @@ +import { useI18n } from '../i18n'; +import english from './pluginEnglish.json'; +const words: Record = english; +const escape = (value: string) => value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); +const token = /⟦\d+⟧/g; +const patterns = Object.entries(words).filter(([source]) => source.includes('⟦')).sort((a, b) => b[0].length - a[0].length).map(([source, target]) => ({ + regex: new RegExp('^' + source.split(token).map(escape).join('([\\s\\S]*?)') + '$'), slots: source.match(token) ?? [], target, +})); +const fragments = new RegExp(Object.keys(words).filter(key => key.length > 1 && !key.includes('⟦')).sort((a, b) => b.length - a.length).map(escape).join('|'), 'g'); +export function pluginText(value: string, locale: string): string { + if (locale === 'zh-CN' || !/[\u3400-\u9fff]/.test(value)) return value; + if (words[value.trim()]) return value.replace(value.trim(), words[value.trim()]); + for (const pattern of patterns) { + const match = pattern.regex.exec(value.trim()); + if (match) { + const substitutions = new Map(pattern.slots.map((slot, i) => [slot, match[i + 1]])); + return pattern.target.replace(token, slot => substitutions.get(slot) ?? slot); + } + } + return value.replace(fragments, key => words[key]); +} +export function usePluginText() { + const { locale } = useI18n(); + return (value: T): T => typeof value === 'string' ? pluginText(value, locale) as T : value; +} diff --git a/frontend/web/src/lib/webCommands.ts b/frontend/web/src/lib/webCommands.ts index dae78ead8..0a04b2efe 100644 --- a/frontend/web/src/lib/webCommands.ts +++ b/frontend/web/src/lib/webCommands.ts @@ -9,7 +9,7 @@ export type WebCommandHandler = (rest: string) => void | Promise; /** `/ask` is deliberately absent: it is answered by the Manager, so the web * layer passes the line through untouched rather than handling it locally. */ export type WebCommandHandlers = Record< - Exclude, + Exclude, WebCommandHandler >; export type WebCommandResult = @@ -32,7 +32,7 @@ export async function dispatchWebCommand( : `Unknown command ${parsed.name}. Use /help for the full list.`, }; } - if (parsed.cmd.id === 'ask') { + if (parsed.cmd.id === 'ask' || parsed.cmd.id === 'crystalpilot') { // Send it as an ordinary message: the Manager front door recognises the // prefix and answers inline without queuing anything. Handling it here // would need a second path to the same reply. diff --git a/frontend/web/src/test/pluginText.test.ts b/frontend/web/src/test/pluginText.test.ts new file mode 100644 index 000000000..8cd6c10cf --- /dev/null +++ b/frontend/web/src/test/pluginText.test.ts @@ -0,0 +1,16 @@ +import { describe, expect, it } from 'vitest'; +import { pluginText } from '../lib/pluginText'; + +describe('plugin center language', () => { + it('uses the host locale without changing protocol values or paths', () => { + expect(pluginText('安装', 'en')).toBe('Install'); + expect(pluginText('安装', 'zh-CN')).toBe('安装'); + expect(pluginText('codex', 'en')).toBe('codex'); + expect(pluginText('0.4.0', 'en')).toBe('0.4.0'); + }); + it('keeps component counts in translated health summaries', () => { + const text = pluginText('科学环境 · 2 项待配置', 'en'); + expect(text).toContain('2'); + expect(text).not.toMatch(/[\u3400-\u9fff]/); + }); +}); diff --git a/frontend/web/src/test/webCommands.test.ts b/frontend/web/src/test/webCommands.test.ts index 0044d6419..6e282f3fd 100644 --- a/frontend/web/src/test/webCommands.test.ts +++ b/frontend/web/src/test/webCommands.test.ts @@ -12,7 +12,7 @@ describe('web slash dispatch', () => { it('routes every canonical command to its stable handler id', async () => { // `/ask` is answered by the Manager, not by a local handler; it has its // own test below. - for (const command of COMMANDS.filter((c) => c.id !== 'ask')) { + for (const command of COMMANDS.filter((c) => c.id !== 'ask' && c.id !== 'crystalpilot')) { const table = handlers(); const argument = command.argument === 'required' ? 'value' : ''; const result = await dispatchWebCommand( @@ -20,7 +20,7 @@ describe('web slash dispatch', () => { table, ); expect(result.kind).toBe('handled'); - expect(table[command.id as Exclude]).toHaveBeenCalledWith( + expect(table[command.id as Exclude]).toHaveBeenCalledWith( argument, ); } @@ -30,7 +30,7 @@ describe('web slash dispatch', () => { // The Manager front door recognises the prefix and answers inline without // queuing anything; handling it here would need a second path to the same // reply. - for (const line of ['/ask why is it slow', '/chat hello']) { + for (const line of ['/ask why is it slow', '/chat hello', '/crystalpilot', '/crystalpilot status']) { expect((await dispatchWebCommand(line, handlers())).kind).toBe('not-command'); } }); diff --git a/pyproject.toml b/pyproject.toml index f8eb93f97..86b3dfd1b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -32,6 +32,7 @@ dependencies = [ "rich>=13.7", "PyYAML>=6", "portalocker>=3", + "psutil>=5.9", "jsonschema>=4", "pypdf>=5,<7", "fastapi>=0.110", @@ -134,6 +135,7 @@ Repository = "https://github.com/lbx154/Argus" [tool.hatch.build.targets.wheel] packages = ["argus_skill"] +exclude = ["argus_skill/verticals/crystalpilot/**"] # Package Markdown and JSON files are runtime Skill data. [tool.hatch.build.targets.wheel.force-include] diff --git a/tests/apps/test_runtime_packaged_skills.py b/tests/apps/test_runtime_packaged_skills.py new file mode 100644 index 000000000..e5b37a081 --- /dev/null +++ b/tests/apps/test_runtime_packaged_skills.py @@ -0,0 +1,127 @@ +"""Wheel-cache hardlinks must not block real missions or weaken source guards.""" +import os +from types import SimpleNamespace + +import pytest + +from argus_skill.apps._runtime_execute import SkillLoopExecuteMixin +from argus_skill.apps._runtime_helpers import _ExecuteState + + +@pytest.fixture +def packaged(tmp_path): + cache = tmp_path / "wheel-cache" + package = tmp_path / "site-packages" + cache.mkdir() + canonical = [] + for role, name in [("engineer/workflows", "chemistry-playground.md"), + ("reviewer", "chemistry-playground-review.md")]: + origin = cache / name + origin.write_text("trusted " + name) + target = package / role / name + target.parent.mkdir(parents=True, exist_ok=True) + try: + os.link(origin, target) + except OSError as exc: + pytest.skip(f"hardlinks unavailable: {exc}") + canonical.append(target) + + class Harness(SkillLoopExecuteMixin): + @staticmethod + def _canonical_playground_skill_paths(): + return tuple(canonical) + + def _set_usage_context(self, value): + self.usage = value + + def _run_bounded_planning(self, *_args, **_kwargs): + pass + + return Harness(), canonical, cache + + +def test_cache_hardlinks_are_detached_before_source_guard(packaged): + harness, paths, cache = packaged + original = {p.name: (cache / p.name).read_bytes() for p in paths} + sibling = paths[0].parent / "another-workflow.md" + os.link(cache / paths[0].name, sibling) + (paths[0].parent / ".argus-skill-concurrent-startup").write_bytes(b"unfinished temporary copy") + snapshots, error = harness._snapshot_playground_skill_files() + assert not error and len(snapshots) == 3 + assert all(path.stat().st_nlink == 1 for path, _ in snapshots) + assert all((cache / name).read_bytes() == value for name, value in original.items()) + assert harness._restore_playground_skill_files(snapshots, error) == (False, "", True) + paths[0].write_text("changed by an agent") + changed, _, ok = harness._restore_playground_skill_files(snapshots, error) + assert changed and ok and paths[0].read_bytes() == original[paths[0].name] + assert (cache / paths[0].name).read_bytes() == original[paths[0].name] + + +def test_hardlink_replacement_during_execution_is_still_rejected(packaged, tmp_path): + harness, paths, _ = packaged + snapshots, error = harness._snapshot_playground_skill_files() + outside = tmp_path / "outside.md" + outside.write_text("outside must remain untouched") + paths[0].unlink() + os.link(outside, paths[0]) + changed, reason, ok = harness._restore_playground_skill_files(snapshots, error) + assert changed and ok and "modified protected Skill" in reason + assert paths[0].read_bytes() == snapshots[0][1] + assert outside.read_text() == "outside must remain untouched" + + +def test_symlink_preflight_is_not_misreported_as_pipeline_mutation(packaged, tmp_path): + harness, paths, cache = packaged + paths[0].unlink() + try: + paths[0].symlink_to(cache / paths[0].name) + except OSError as exc: + pytest.skip(f"symlinks unavailable: {exc}") + state = _ExecuteState() + state.workdir = tmp_path / "work" + state.workdir.mkdir() + state.loop = SimpleNamespace(run=lambda *a, **kw: pytest.fail("must refuse before execution")) + with pytest.raises(RuntimeError, match="refused before execution: protected Playground Skill") as caught: + harness._invoke_execute_loop(state, sink=SimpleNamespace(), objective="refine crystal", original_objective="", + preplanned=True, mission_id="test", usage_mission_id=None) + assert "created formal pipeline" not in str(caught.value) + assert list(state.workdir.iterdir()) == [] + assert harness.usage is None and harness._current_sink is None + + +def test_empty_pipeline_restore_is_a_noop(tmp_path): + work = tmp_path / "work" + work.mkdir() + snapshot = SkillLoopExecuteMixin._snapshot_pipeline_state(work) + assert snapshot[1:] == (False, None, "") + assert SkillLoopExecuteMixin._restore_pipeline_state(snapshot) == (False, "", True) + assert list(work.iterdir()) == [] + + +def test_actual_pipeline_creation_is_detected_and_removed(tmp_path): + snapshot = SkillLoopExecuteMixin._snapshot_pipeline_state(tmp_path) + path = snapshot[0] + path.parent.mkdir(parents=True, exist_ok=True) + path.write_text('{"current_stage":"complete"}') + changed, reason, ok = SkillLoopExecuteMixin._restore_pipeline_state(snapshot) + assert changed and ok and "created formal pipeline" in reason and not path.exists() + + +def test_formal_mission_reaches_loop_with_uv_installed_skills(packaged, tmp_path): + harness, paths, cache = packaged + state = _ExecuteState() + state.workdir = tmp_path / "work" + state.workdir.mkdir() + seen = [] + + def run(*args, **kwargs): + seen.append(kwargs["workdir"]) + assert all(path.stat().st_nlink == 1 for path in paths) + return SimpleNamespace(extras={}, status="done") + + state.loop = SimpleNamespace(run=run) + harness._invoke_execute_loop(state, sink=SimpleNamespace(), objective="solve crystal", original_objective="", + preplanned=True, mission_id="test", usage_mission_id=None) + assert seen == [state.workdir] and state.outcome.status == "done" + assert not state.playground_workflow_guarded + assert all((cache / path.name).read_text().startswith("trusted") for path in paths) diff --git a/tests/core/test_codex_startup_billing.py b/tests/core/test_codex_startup_billing.py new file mode 100644 index 000000000..15317ee5b --- /dev/null +++ b/tests/core/test_codex_startup_billing.py @@ -0,0 +1,62 @@ +from argus_skill.core.token_usage import TokenUsage +from argus_skill.core.usage import UsageRecord, build_usage_record + +ERROR = "Process exited with code 1 before turn completion.\nNot inside a trusted directory and --skip-git-repo-check was not specified." + + +def receipt(): + return { + "type": "agent.io.complete", + "backend": "codex", + "call_id": "test-call", + "run_label": "main", + "exit_code": 1, + "turn_failed": True, + "turn_completed": False, + "thread_id": None, + "fatal_error": "Process exited with code 1 before turn completion.", + "tool_activity_observed": False, + "agent_message_count": 0, + "stdout_line_count": 0, + "json_event_count": 0, + "command": ["codex", "exec", "--json", "-"], + } + + +def record(tmp_path, **kw): + return build_usage_record( + call_id="test-call", + project_root=tmp_path, + mission_id=None, + provider="codex", + model="gpt-5.6-luna", + run_label="main", + started_at=1, + completed_at=2, + status="error", + error=ERROR, + **kw, + ) + + +def test_proven_local_refusal_releases_only_unobserved_cost(tmp_path): + r = record(tmp_path, startup_receipt=receipt()) + assert r.pricing_status == "not_billed" and r.cost_usd == 0 + old = r.to_jsonable() + old.update(pricing_status="partial", cost_usd=None) + assert UsageRecord.from_jsonable(old, startup_receipt=receipt()).pricing_status == "not_billed" + + +def test_error_text_alone_does_not_claim_zero_usage(tmp_path): + assert record(tmp_path).pricing_status != "not_billed" + r = receipt() + r["stdout_line_count"] = 1 + assert record(tmp_path, startup_receipt=r).pricing_status != "not_billed" + + +def test_observed_usage_is_never_erased(tmp_path): + usage = TokenUsage( + input_tokens=100, output_tokens=10, input_tokens_present=True, output_tokens_present=True + ) + r = record(tmp_path, startup_receipt=receipt(), token_usage=usage) + assert r.pricing_status != "not_billed" and r.cost_usd > 0 diff --git a/tests/core/test_external_plugin_release.py b/tests/core/test_external_plugin_release.py new file mode 100644 index 000000000..c270dfbf7 --- /dev/null +++ b/tests/core/test_external_plugin_release.py @@ -0,0 +1,48 @@ +"""A public host build must retain separately published plugin artifacts.""" + +import json + +import pytest + +from argus_skill.release_tools import build_plugins + + +def test_build_preserves_external_catalog_without_private_source(tmp_path, monkeypatch): + monkeypatch.setattr(build_plugins, "ROOT", tmp_path) + directory = tmp_path / "argus_skill" + directory.mkdir() + entry = { + "id": "external", + "version": "1.2.3", + "artifact": { + "filename": "external-1.2.3-py3-none-any.whl", + "sha256": "a" * 64, + "url": "https://downloads.example.org/external.whl", + "local": "/maintainer/only.whl", + }, + } + path = directory / "plugin_catalog.json" + path.write_text(json.dumps({"plugins": [entry]})) + monkeypatch.setattr( + build_plugins.subprocess, + "run", + lambda *a, **k: pytest.fail("External plugin must not be built or installed"), + ) + build_plugins.main() + published = json.loads(path.read_text()) + assert published["plugins"][0]["artifact"]["sha256"] == "a" * 64 + assert "local" not in published["plugins"][0]["artifact"] + assert json.loads((tmp_path / "dist-plugins/catalog.json").read_text()) == published + build_plugins.main() + assert json.loads(path.read_text()) == published + + +def test_invalid_external_catalog_is_not_published(tmp_path, monkeypatch): + monkeypatch.setattr(build_plugins, "ROOT", tmp_path) + directory = tmp_path / "argus_skill" + directory.mkdir() + (directory / "plugin_catalog.json").write_text( + json.dumps({"plugins": [{"id": "bad", "artifact": {"url": "http://unsafe.example"}}]}) + ) + with pytest.raises(ValueError, match="HTTPS release URL and SHA-256"): + build_plugins.main() diff --git a/tests/core/test_plugin_manager.py b/tests/core/test_plugin_manager.py new file mode 100644 index 000000000..b6d1e7f7a --- /dev/null +++ b/tests/core/test_plugin_manager.py @@ -0,0 +1,135 @@ +import zipfile + +import pytest + +from argus_skill.core import plugin_manager as pm + + +@pytest.fixture +def empty_host(tmp_path, monkeypatch): + monkeypatch.setenv("ARGUS_SKILL_HOME", str(tmp_path / "host")) + monkeypatch.setenv("ARGUS_WORKBENCH_HOST_ROOT", str(tmp_path / "host")) + for role in ("MANAGER", "PLANNER", "ENGINEER", "REVIEWER"): + monkeypatch.setenv("ARGUS_SKILL_" + role + "_BACKEND", "pi") + return tmp_path / "host" + + +def test_default_does_not_load_optional_vertical(empty_host): + from argus_skill.skills.vertical_select import available_verticals + + assert pm.installed(empty_host) == {} + assert "crystalpilot" not in available_verticals() + row = pm.plugin_rows(empty_host)[0] + assert not row["installed"] and not row["available"] + + +@pytest.mark.parametrize("backend", ["codex", "copilot", "pi"]) +@pytest.mark.parametrize("system", ["linux", "windows", "darwin"]) +def test_supported_matrix(backend, system, monkeypatch): + from types import SimpleNamespace + + from argus_skill.core import role_config + + # Simulate the target architecture instead of inheriting arm64 on macOS CI. + monkeypatch.setattr(pm.platform, "machine", lambda: "x86_64") + + monkeypatch.setattr( + role_config, + "resolve_all_roles", + lambda **kw: [SimpleNamespace(role="engineer", backend=backend)], + ) + assert pm.compatibility(pm.catalog()["crystalpilot"], system=system)["supported"] + + +def test_unsupported_mixed_roles_are_reported(monkeypatch): + from types import SimpleNamespace + + from argus_skill.core import role_config + + monkeypatch.setattr( + role_config, + "resolve_all_roles", + lambda **kw: [ + SimpleNamespace(role="engineer", backend="pi"), + SimpleNamespace(role="reviewer", backend="claude"), + ], + ) + result = pm.compatibility(pm.catalog()["crystalpilot"]) + assert not result["supported"] and result["unsupported_roles"] == {"reviewer": "claude"} + assert "敬请期待" in result["reason"] + + +def test_hash_mismatch_is_rejected(tmp_path): + source = tmp_path / "release.whl" + source.write_bytes(b"bad payload") + spec = {"_catalog_dir": str(tmp_path), "artifact": {"sha256": "0" * 64, "local": "release.whl"}} + with pytest.raises(pm.PluginError, match="校验失败"): + pm._fetch(spec, tmp_path / "copy.whl") + + +def test_archive_traversal_is_rejected(tmp_path): + wheel = tmp_path / "bad.whl" + with zipfile.ZipFile(wheel, "w") as z: + z.writestr("../outside.py", "bad") + with pytest.raises(pm.PluginError, match="Unsafe path"): + pm._extract(wheel, tmp_path / "package") + assert not (tmp_path / "outside.py").exists() + + +def test_manage_requires_auth_and_does_not_launch_missing_plugin(empty_host): + from fastapi.testclient import TestClient + + from argus_skill.webapi.server import create_app + + client = TestClient(create_app(global_root=empty_host, auth_token="test")) + assert client.post("/api/plugins/crystalpilot/manage/install").status_code == 401 + assert client.get("/plugins/crystalpilot/").status_code == 404 + assert ( + client.post( + "/api/plugins/crystalpilot/launch", headers={"Authorization": "Bearer test"} + ).status_code + == 404 + ) + + +def test_unsupported_primary_is_blocked_even_with_supported_roles(monkeypatch): + from types import SimpleNamespace + + from argus_skill.core import role_config + + monkeypatch.setattr( + role_config, + "resolve_all_roles", + lambda **kw: [SimpleNamespace(role="engineer", backend="pi")], + ) + result = pm.compatibility( + pm.catalog()["crystalpilot"], env={"ARGUS_SKILL_RUNNER_BACKEND": "claude"} + ) + assert not result["supported"] and result["unsupported_roles"] == {"default": "claude"} + + +def test_auxiliary_backend_can_follow_role_instead_of_global(monkeypatch, empty_host): + from argus_skill.adapters.agent_cli_backend import build_agent_cli_backend_from_env + + monkeypatch.setenv("ARGUS_SKILL_RUNNER_BACKEND", "pi") + monkeypatch.setenv("ARGUS_SKILL_ENGINEER_BACKEND", "codex") + assert build_agent_cli_backend_from_env(role="engineer").backend == "codex" + assert build_agent_cli_backend_from_env().backend == "pi" + + +def test_python_falls_back_when_host_interpreter_is_incompatible(monkeypatch): + import subprocess + from types import SimpleNamespace + + monkeypatch.delenv("ARGUS_PLUGIN_PYTHON", raising=False) + monkeypatch.setattr( + pm.shutil, "which", lambda name: "/bin/" + name if name == "python3.11" else None + ) + + def probe(command, **kwargs): + if command[0] == "python3.11": + return SimpleNamespace(stdout="/compatible/python3.11\n") + raise subprocess.CalledProcessError(1, command) + + monkeypatch.setattr(pm.subprocess, "run", probe) + assert pm._python() == "/compatible/python3.11" diff --git a/tests/core/test_plugin_runtime.py b/tests/core/test_plugin_runtime.py new file mode 100644 index 000000000..bbf2e1e17 --- /dev/null +++ b/tests/core/test_plugin_runtime.py @@ -0,0 +1,129 @@ +import hashlib + +import httpx +import pytest + +from argus_skill.core import plugin_runtime as runtime + + +def client(monkeypatch, handler): + original = httpx.Client + monkeypatch.setattr( + runtime.httpx, "Client", lambda **kw: original(transport=httpx.MockTransport(handler), **kw) + ) + + +def test_verified_download_keeps_existing_file_on_mismatch(tmp_path, monkeypatch): + target = tmp_path / "program" + target.write_bytes(b"previous") + client(monkeypatch, lambda request: httpx.Response(200, content=b"corrupt")) + with pytest.raises(ValueError, match="SHA-256"): + runtime.download( + "https://example.org/program", target, checksum=hashlib.sha256(b"valid").hexdigest() + ) + assert target.read_bytes() == b"previous" + assert not list(tmp_path.glob("*.part")) + + +def test_license_redirect_never_forwards_credentials(tmp_path, monkeypatch): + requests = [] + + def handler(request): + requests.append(request) + return httpx.Response(302, headers={"location": "https://other.example/program"}) + + client(monkeypatch, handler) + with pytest.raises(ValueError, match="授权凭据"): + runtime.download( + "https://licensed.example/file", tmp_path / "out", auth=("academic", "secret") + ) + assert len(requests) == 1 + assert requests[0].url.host == "licensed.example" + + +def test_download_limits_and_tls_downgrade(tmp_path, monkeypatch): + client(monkeypatch, lambda request: httpx.Response(200, content=b"a" * 32)) + with pytest.raises(ValueError, match="大小限制"): + runtime.download("https://example.org/file", tmp_path / "out", limit=16) + assert not (tmp_path / "out").exists() + with pytest.raises(ValueError, match="HTTPS"): + runtime.download("http://example.org/file", tmp_path / "out") + + +@pytest.mark.parametrize( + "system,machine,key", + [ + ("Windows", "AMD64", "win-64"), + ("Linux", "x86_64", "linux-64"), + ("Darwin", "x86_64", "osx-64"), + ("Darwin", "arm64", "osx-arm64"), + ], +) +def test_platform_artifacts(system, machine, key): + assert runtime.platform_key(system, machine) == key + + +def test_unavailable_architecture_is_not_misidentified(): + with pytest.raises(ValueError, match="发行包"): + runtime.platform_key("Linux", "aarch64") + with pytest.raises(ValueError): + runtime.platform_key("Linux", "riscv64") + + +def test_installer_does_not_inherit_model_secrets(monkeypatch): + monkeypatch.setenv("OPENAI_API_KEY", "secret") + monkeypatch.setenv("COPILOT_PROVIDER_API_KEY", "secret") + monkeypatch.setenv("CODEX_HOME", "/external/config") + monkeypatch.setenv("PYTHONPATH", "/unrelated/module") + monkeypatch.setenv("CONDA_PREFIX", "/external/conda") + env = runtime.clean_env() + assert not { + "OPENAI_API_KEY", + "COPILOT_PROVIDER_API_KEY", + "CODEX_HOME", + "PYTHONPATH", + "CONDA_PREFIX", + } & set(env) + + +def test_missing_host_python_is_provisioned_locally(monkeypatch, tmp_path): + import subprocess + + from argus_skill.core import plugin_manager + + monkeypatch.delenv("ARGUS_PLUGIN_PYTHON", raising=False) + monkeypatch.setattr(plugin_manager.shutil, "which", lambda name: None) + + def reject(*args, **kwargs): + raise subprocess.CalledProcessError(1, args[0]) + + monkeypatch.setattr(plugin_manager.subprocess, "run", reject) + roots = [] + monkeypatch.setattr( + runtime, "portable_python", lambda root: roots.append(root) or "/local/python" + ) + assert plugin_manager._python(tmp_path) == "/local/python" + assert roots == [tmp_path / "extensions/runtime"] + + +def test_timed_out_installer_reaps_its_child(tmp_path): + import json + import subprocess + import sys + + import psutil + + marker = tmp_path / "child.json" + source = ( + "import subprocess,sys,time,json; from pathlib import Path; " + "p=subprocess.Popen([sys.executable,'-c','import time; time.sleep(30)']); " + f"Path({str(marker)!r}).write_text(json.dumps(p.pid)); time.sleep(30)" + ) + with pytest.raises(subprocess.TimeoutExpired): + runtime.run([sys.executable, "-c", source], timeout=1) + assert marker.exists() + child = json.loads(marker.read_text()) + try: + assert psutil.Process(child).status() == psutil.STATUS_ZOMBIE + except psutil.NoSuchProcess: + pass # The OS can reap the killed child between two status queries. diff --git a/tests/core/test_release.py b/tests/core/test_release.py index a02501e78..e5d2f77ac 100644 --- a/tests/core/test_release.py +++ b/tests/core/test_release.py @@ -93,6 +93,21 @@ def test_release_manifest_matches_current_shipped_source() -> None: assert identity["runtime_source_digest"] == manifest["source_digest"] +def test_bundled_workbench_identity_tracks_source_not_dependencies(tmp_path): + vertical = tmp_path / "argus_skill" / "verticals" / "sample" + vertical.mkdir(parents=True) + source = vertical / "tools.mjs" + source.write_text("export const version = 1;") + first = compute_source_digest(tmp_path) + for directory in ("node_modules/pkg", "dist", "__pycache__"): + generated = vertical / directory / "metadata.json" + generated.parent.mkdir(parents=True, exist_ok=True) + generated.write_text('{"local": true}') + assert compute_source_digest(tmp_path) == first + source.write_text("export const version = 2;") + assert compute_source_digest(tmp_path) != first + + def test_checked_in_frontend_contract_matches_current_release() -> None: root = Path(__file__).parents[2] manifest = release_manifest() diff --git a/uv.lock b/uv.lock index 572ed9874..13319ff10 100644 --- a/uv.lock +++ b/uv.lock @@ -194,6 +194,7 @@ dependencies = [ { name = "jsonschema" }, { name = "mcp" }, { name = "portalocker" }, + { name = "psutil" }, { name = "pydantic-settings" }, { name = "pypdf" }, { name = "python-multipart" }, @@ -303,6 +304,7 @@ requires-dist = [ { name = "pandas", marker = "extra == 'quant'", specifier = ">=2" }, { name = "playwright", marker = "extra == 'visual-web'", specifier = ">=1.50,<2" }, { name = "portalocker", specifier = ">=3" }, + { name = "psutil", specifier = ">=5.9" }, { name = "pydantic-settings", specifier = ">=2.5.2,<2.15" }, { name = "pymupdf", marker = "extra == 'paper'", specifier = ">=1.26,<2" }, { name = "pypdf", specifier = ">=5,<7" }, @@ -2933,6 +2935,34 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/3a/ed/1cdcab6ba3d6ab7feca11fc14f0eeea80755bb53ef4e892079f31b10a25f/propcache-0.5.2-py3-none-any.whl", hash = "sha256:be1ddfcbb376e3de5d2e2db1d58d6d67463e6b4f9f040c000de8e300295465fe", size = 14036, upload-time = "2026-05-08T21:02:10.673Z" }, ] +[[package]] +name = "psutil" +version = "7.2.2" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/aa/c6/d1ddf4abb55e93cebc4f2ed8b5d6dbad109ecb8d63748dd2b20ab5e57ebe/psutil-7.2.2.tar.gz", hash = "sha256:0746f5f8d406af344fd547f1c8daa5f5c33dbc293bb8d6a16d80b4bb88f59372", size = 493740, upload-time = "2026-01-28T18:14:54.428Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/51/08/510cbdb69c25a96f4ae523f733cdc963ae654904e8db864c07585ef99875/psutil-7.2.2-cp313-cp313t-macosx_10_13_x86_64.whl", hash = "sha256:2edccc433cbfa046b980b0df0171cd25bcaeb3a68fe9022db0979e7aa74a826b", size = 130595, upload-time = "2026-01-28T18:14:57.293Z" }, + { url = "https://files.pythonhosted.org/packages/d6/f5/97baea3fe7a5a9af7436301f85490905379b1c6f2dd51fe3ecf24b4c5fbf/psutil-7.2.2-cp313-cp313t-macosx_11_0_arm64.whl", hash = "sha256:e78c8603dcd9a04c7364f1a3e670cea95d51ee865e4efb3556a3a63adef958ea", size = 131082, upload-time = "2026-01-28T18:14:59.732Z" }, + { url = "https://files.pythonhosted.org/packages/37/d6/246513fbf9fa174af531f28412297dd05241d97a75911ac8febefa1a53c6/psutil-7.2.2-cp313-cp313t-manylinux2010_x86_64.manylinux_2_12_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:1a571f2330c966c62aeda00dd24620425d4b0cc86881c89861fbc04549e5dc63", size = 181476, upload-time = "2026-01-28T18:15:01.884Z" }, + { url = "https://files.pythonhosted.org/packages/b8/b5/9182c9af3836cca61696dabe4fd1304e17bc56cb62f17439e1154f225dd3/psutil-7.2.2-cp313-cp313t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:917e891983ca3c1887b4ef36447b1e0873e70c933afc831c6b6da078ba474312", size = 184062, upload-time = "2026-01-28T18:15:04.436Z" }, + { url = "https://files.pythonhosted.org/packages/16/ba/0756dca669f5a9300d0cbcbfae9a4c30e446dfc7440ffe43ded5724bfd93/psutil-7.2.2-cp313-cp313t-win_amd64.whl", hash = "sha256:ab486563df44c17f5173621c7b198955bd6b613fb87c71c161f827d3fb149a9b", size = 139893, upload-time = "2026-01-28T18:15:06.378Z" }, + { url = "https://files.pythonhosted.org/packages/1c/61/8fa0e26f33623b49949346de05ec1ddaad02ed8ba64af45f40a147dbfa97/psutil-7.2.2-cp313-cp313t-win_arm64.whl", hash = "sha256:ae0aefdd8796a7737eccea863f80f81e468a1e4cf14d926bd9b6f5f2d5f90ca9", size = 135589, upload-time = "2026-01-28T18:15:08.03Z" }, + { url = "https://files.pythonhosted.org/packages/81/69/ef179ab5ca24f32acc1dac0c247fd6a13b501fd5534dbae0e05a1c48b66d/psutil-7.2.2-cp314-cp314t-macosx_10_15_x86_64.whl", hash = "sha256:eed63d3b4d62449571547b60578c5b2c4bcccc5387148db46e0c2313dad0ee00", size = 130664, upload-time = "2026-01-28T18:15:09.469Z" }, + { url = "https://files.pythonhosted.org/packages/7b/64/665248b557a236d3fa9efc378d60d95ef56dd0a490c2cd37dafc7660d4a9/psutil-7.2.2-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:7b6d09433a10592ce39b13d7be5a54fbac1d1228ed29abc880fb23df7cb694c9", size = 131087, upload-time = "2026-01-28T18:15:11.724Z" }, + { url = "https://files.pythonhosted.org/packages/d5/2e/e6782744700d6759ebce3043dcfa661fb61e2fb752b91cdeae9af12c2178/psutil-7.2.2-cp314-cp314t-manylinux2010_x86_64.manylinux_2_12_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:1fa4ecf83bcdf6e6c8f4449aff98eefb5d0604bf88cb883d7da3d8d2d909546a", size = 182383, upload-time = "2026-01-28T18:15:13.445Z" }, + { url = "https://files.pythonhosted.org/packages/57/49/0a41cefd10cb7505cdc04dab3eacf24c0c2cb158a998b8c7b1d27ee2c1f5/psutil-7.2.2-cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:e452c464a02e7dc7822a05d25db4cde564444a67e58539a00f929c51eddda0cf", size = 185210, upload-time = "2026-01-28T18:15:16.002Z" }, + { url = "https://files.pythonhosted.org/packages/dd/2c/ff9bfb544f283ba5f83ba725a3c5fec6d6b10b8f27ac1dc641c473dc390d/psutil-7.2.2-cp314-cp314t-win_amd64.whl", hash = "sha256:c7663d4e37f13e884d13994247449e9f8f574bc4655d509c3b95e9ec9e2b9dc1", size = 141228, upload-time = "2026-01-28T18:15:18.385Z" }, + { url = "https://files.pythonhosted.org/packages/f2/fc/f8d9c31db14fcec13748d373e668bc3bed94d9077dbc17fb0eebc073233c/psutil-7.2.2-cp314-cp314t-win_arm64.whl", hash = "sha256:11fe5a4f613759764e79c65cf11ebdf26e33d6dd34336f8a337aa2996d71c841", size = 136284, upload-time = "2026-01-28T18:15:19.912Z" }, + { url = "https://files.pythonhosted.org/packages/e7/36/5ee6e05c9bd427237b11b3937ad82bb8ad2752d72c6969314590dd0c2f6e/psutil-7.2.2-cp36-abi3-macosx_10_9_x86_64.whl", hash = "sha256:ed0cace939114f62738d808fdcecd4c869222507e266e574799e9c0faa17d486", size = 129090, upload-time = "2026-01-28T18:15:22.168Z" }, + { url = "https://files.pythonhosted.org/packages/80/c4/f5af4c1ca8c1eeb2e92ccca14ce8effdeec651d5ab6053c589b074eda6e1/psutil-7.2.2-cp36-abi3-macosx_11_0_arm64.whl", hash = "sha256:1a7b04c10f32cc88ab39cbf606e117fd74721c831c98a27dc04578deb0c16979", size = 129859, upload-time = "2026-01-28T18:15:23.795Z" }, + { url = "https://files.pythonhosted.org/packages/b5/70/5d8df3b09e25bce090399cf48e452d25c935ab72dad19406c77f4e828045/psutil-7.2.2-cp36-abi3-manylinux2010_x86_64.manylinux_2_12_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:076a2d2f923fd4821644f5ba89f059523da90dc9014e85f8e45a5774ca5bc6f9", size = 155560, upload-time = "2026-01-28T18:15:25.976Z" }, + { url = "https://files.pythonhosted.org/packages/63/65/37648c0c158dc222aba51c089eb3bdfa238e621674dc42d48706e639204f/psutil-7.2.2-cp36-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:b0726cecd84f9474419d67252add4ac0cd9811b04d61123054b9fb6f57df6e9e", size = 156997, upload-time = "2026-01-28T18:15:27.794Z" }, + { url = "https://files.pythonhosted.org/packages/8e/13/125093eadae863ce03c6ffdbae9929430d116a246ef69866dad94da3bfbc/psutil-7.2.2-cp36-abi3-musllinux_1_2_aarch64.whl", hash = "sha256:fd04ef36b4a6d599bbdb225dd1d3f51e00105f6d48a28f006da7f9822f2606d8", size = 148972, upload-time = "2026-01-28T18:15:29.342Z" }, + { url = "https://files.pythonhosted.org/packages/04/78/0acd37ca84ce3ddffaa92ef0f571e073faa6d8ff1f0559ab1272188ea2be/psutil-7.2.2-cp36-abi3-musllinux_1_2_x86_64.whl", hash = "sha256:b58fabe35e80b264a4e3bb23e6b96f9e45a3df7fb7eed419ac0e5947c61e47cc", size = 148266, upload-time = "2026-01-28T18:15:31.597Z" }, + { url = "https://files.pythonhosted.org/packages/b4/90/e2159492b5426be0c1fef7acba807a03511f97c5f86b3caeda6ad92351a7/psutil-7.2.2-cp37-abi3-win_amd64.whl", hash = "sha256:eb7e81434c8d223ec4a219b5fc1c47d0417b12be7ea866e24fb5ad6e84b3d988", size = 137737, upload-time = "2026-01-28T18:15:33.849Z" }, + { url = "https://files.pythonhosted.org/packages/8c/c7/7bb2e321574b10df20cbde462a94e2b71d05f9bbda251ef27d104668306a/psutil-7.2.2-cp37-abi3-win_arm64.whl", hash = "sha256:8c233660f575a5a89e6d4cb65d9f938126312bca76d8fe087b947b3a1aaac9ee", size = 134617, upload-time = "2026-01-28T18:15:36.514Z" }, +] + [[package]] name = "pycparser" version = "3.0" From 0f96fd874abef0c251526974bc57d965d244c72b Mon Sep 17 00:00:00 2001 From: aHappend <228031504+aHappend@users.noreply.github.com> Date: Thu, 10 Sep 2026 10:32:11 +0000 Subject: [PATCH 2/3] Translate the plugin catalog description in the English plugin center --- argus_skill/release_manifest.json | 4 +-- frontend/core/src/release.generated.ts | 4 +-- frontend/tui/bundle/argus.mjs | 2 +- frontend/web/dist/assets/MapPanel-BZxjl6ME.js | 12 +++++++ .../assets/ResearchWorkbenchPanel-BOxuXoMY.js | 10 ++++++ frontend/web/dist/assets/index-BZHe8e4S.js | 32 +++++++++++++++++++ frontend/web/dist/assets/play-DQD97EkU.js | 1 + frontend/web/dist/index.html | 2 +- frontend/web/src/lib/pluginEnglish.json | 3 +- 9 files changed, 63 insertions(+), 7 deletions(-) create mode 100644 frontend/web/dist/assets/MapPanel-BZxjl6ME.js create mode 100644 frontend/web/dist/assets/ResearchWorkbenchPanel-BOxuXoMY.js create mode 100644 frontend/web/dist/assets/index-BZHe8e4S.js create mode 100644 frontend/web/dist/assets/play-DQD97EkU.js diff --git a/argus_skill/release_manifest.json b/argus_skill/release_manifest.json index cbf8587dc..6d7eba544 100644 --- a/argus_skill/release_manifest.json +++ b/argus_skill/release_manifest.json @@ -1,6 +1,6 @@ { "package_version": "0.1.3", - "release_id": "0.1.3+c491c972877eb8f2", + "release_id": "0.1.3+c89d57853bab4ae4", "schema_version": 1, - "source_digest": "c491c972877eb8f24680e94912e55c00a1be0608b3ad5c0ddf1ae99ee7ee0742" + "source_digest": "c89d57853bab4ae42794dc6cc0e348d9338c0440f715efacd88926e0f1ff6445" } diff --git a/frontend/core/src/release.generated.ts b/frontend/core/src/release.generated.ts index bd7d209b6..5446af4b2 100644 --- a/frontend/core/src/release.generated.ts +++ b/frontend/core/src/release.generated.ts @@ -1,3 +1,3 @@ // Generated by argus_skill.release_tools.generate_manifest. Do not edit. -export const RELEASE_ID = "0.1.3+c491c972877eb8f2"; -export const RELEASE_SOURCE_DIGEST = "c491c972877eb8f24680e94912e55c00a1be0608b3ad5c0ddf1ae99ee7ee0742"; +export const RELEASE_ID = "0.1.3+c89d57853bab4ae4"; +export const RELEASE_SOURCE_DIGEST = "c89d57853bab4ae42794dc6cc0e348d9338c0440f715efacd88926e0f1ff6445"; diff --git a/frontend/tui/bundle/argus.mjs b/frontend/tui/bundle/argus.mjs index 018445d45..1db45f5c4 100644 --- a/frontend/tui/bundle/argus.mjs +++ b/frontend/tui/bundle/argus.mjs @@ -121,7 +121,7 @@ Read about how to prevent this error on https://github.com/vadimdemedes/ink/#isr Read about how to prevent this error on https://github.com/vadimdemedes/ink/#israwmodesupported`);if(r.setEncoding("utf8"),t){this.rawModeEnabledCount===0&&(r.ref(),r.setRawMode(!0),r.addListener("readable",this.handleReadable)),this.rawModeEnabledCount++;return}--this.rawModeEnabledCount===0&&(r.setRawMode(!1),r.removeListener("readable",this.handleReadable),r.unref())};handleReadable=()=>{let t;for(;(t=this.props.stdin.read())!==null;)this.handleInput(t),this.internal_eventEmitter.emit("input",t)};handleInput=t=>{t===""&&this.props.exitOnCtrlC&&this.handleExit(),t===ab&&this.state.activeFocusId&&this.setState({activeFocusId:void 0}),this.state.isFocusEnabled&&this.state.focusables.length>0&&(t===ib&&this.focusNext(),t===sb&&this.focusPrevious())};handleExit=t=>{this.isRawModeSupported()&&this.handleSetRawMode(!1),this.props.onExit(t)};enableFocus=()=>{this.setState({isFocusEnabled:!0})};disableFocus=()=>{this.setState({isFocusEnabled:!1})};focus=t=>{this.setState(r=>r.focusables.some(s=>s?.id===t)?{activeFocusId:t}:r)};focusNext=()=>{this.setState(t=>{let r=t.focusables.find(s=>s.isActive)?.id;return{activeFocusId:this.findNextFocusable(t)??r}})};focusPrevious=()=>{this.setState(t=>{let r=t.focusables.findLast(s=>s.isActive)?.id;return{activeFocusId:this.findPreviousFocusable(t)??r}})};addFocusable=(t,{autoFocus:r})=>{this.setState(i=>{let s=i.activeFocusId;return!s&&r&&(s=t),{activeFocusId:s,focusables:[...i.focusables,{id:t,isActive:!0}]}})};removeFocusable=t=>{this.setState(r=>({activeFocusId:r.activeFocusId===t?void 0:r.activeFocusId,focusables:r.focusables.filter(i=>i.id!==t)}))};activateFocusable=t=>{this.setState(r=>({focusables:r.focusables.map(i=>i.id!==t?i:{id:t,isActive:!0})}))};deactivateFocusable=t=>{this.setState(r=>({activeFocusId:r.activeFocusId===t?void 0:r.activeFocusId,focusables:r.focusables.map(i=>i.id!==t?i:{id:t,isActive:!1})}))};findNextFocusable=t=>{let r=t.focusables.findIndex(i=>i.id===t.activeFocusId);for(let i=r+1;i{let r=t.focusables.findIndex(i=>i.id===t.activeFocusId);for(let i=r-1;i>=0;i--){let s=t.focusables[i];if(s?.isActive)return s.id}}};var hy=()=>{},xf=class{options;log;throttledLog;isUnmounted;lastOutput;container;rootNode;fullStaticOutput;exitPromise;restoreConsole;unsubscribeResize;constructor(t){FE(this),this.options=t,this.rootNode=Id("ink-root"),this.rootNode.onComputeLayout=this.calculateLayout,this.rootNode.onRender=t.debug?this.onRender:Zg(this.onRender,32,{leading:!0,trailing:!0}),this.rootNode.onImmediateRender=this.onRender,this.log=zD.create(t.stdout),this.throttledLog=t.debug?this.log:Zg(this.log,void 0,{leading:!0,trailing:!0}),this.isUnmounted=!1,this.lastOutput="",this.fullStaticOutput="",this.container=ZA.createContainer(this.rootNode,0,null,!1,null,"id",()=>{},null),this.unsubscribeExit=(0,By.default)(this.unmount,{alwaysLast:!1}),Ab.env.DEV==="true"&&ZA.injectIntoDevTools({bundleType:0,version:"16.13.1",rendererPackageName:"ink"}),t.patchConsole&&this.patchConsole(),HA||(t.stdout.on("resize",this.resized),this.unsubscribeResize=()=>{t.stdout.off("resize",this.resized)})}resized=()=>{this.calculateLayout(),this.onRender()};resolveExitPromise=()=>{};rejectExitPromise=()=>{};unsubscribeExit=()=>{};calculateLayout=()=>{let t=this.options.stdout.columns||80;this.rootNode.yogaNode.setWidth(t),this.rootNode.yogaNode.calculateLayout(void 0,void 0,it.DIRECTION_LTR)};onRender=()=>{if(this.isUnmounted)return;let{output:t,outputHeight:r,staticOutput:i}=GD(this.rootNode),s=i&&i!==` `;if(this.options.debug){s&&(this.fullStaticOutput+=i),this.options.stdout.write(this.fullStaticOutput+t);return}if(HA){s&&this.options.stdout.write(i),this.lastOutput=t;return}if(s&&(this.fullStaticOutput+=i),r>=this.options.stdout.rows){this.options.stdout.write(Mo.clearTerminal+this.fullStaticOutput+t),this.lastOutput=t;return}s&&(this.log.clear(),this.options.stdout.write(i),this.log(t)),!s&&t!==this.lastOutput&&this.throttledLog(t),this.lastOutput=t};render(t){let r=Cy.default.createElement(kf,{stdin:this.options.stdin,stdout:this.options.stdout,stderr:this.options.stderr,writeToStdout:this.writeToStdout,writeToStderr:this.writeToStderr,exitOnCtrlC:this.options.exitOnCtrlC,onExit:this.unmount},t);ZA.updateContainer(r,this.container,null,hy)}writeToStdout(t){if(!this.isUnmounted){if(this.options.debug){this.options.stdout.write(t+this.fullStaticOutput+this.lastOutput);return}if(HA){this.options.stdout.write(t);return}this.log.clear(),this.options.stdout.write(t),this.log(this.lastOutput)}}writeToStderr(t){if(!this.isUnmounted){if(this.options.debug){this.options.stderr.write(t),this.options.stdout.write(this.fullStaticOutput+this.lastOutput);return}if(HA){this.options.stderr.write(t);return}this.log.clear(),this.options.stderr.write(t),this.log(this.lastOutput)}}unmount(t){this.isUnmounted||(this.calculateLayout(),this.onRender(),this.unsubscribeExit(),typeof this.restoreConsole=="function"&&this.restoreConsole(),typeof this.unsubscribeResize=="function"&&this.unsubscribeResize(),HA?this.options.stdout.write(this.lastOutput+` `):this.options.debug||this.log.done(),this.isUnmounted=!0,ZA.updateContainer(null,this.container,null,hy),Tu.delete(this.options.stdout),t instanceof Error?this.rejectExitPromise(t):this.resolveExitPromise())}async waitUntilExit(){return this.exitPromise||=new Promise((t,r)=>{this.resolveExitPromise=t,this.rejectExitPromise=r}),this.exitPromise}clear(){!HA&&!this.options.debug&&this.log.clear()}patchConsole(){this.options.debug||(this.restoreConsole=aC((t,r)=>{t==="stdout"&&this.writeToStdout(r),t==="stderr"&&(r.startsWith("The above error occurred")||this.writeToStderr(r))}))}};var ub=(e,t)=>{let r={stdout:Zd.stdout,stdin:Zd.stdin,stderr:Zd.stderr,debug:!1,exitOnCtrlC:!0,patchConsole:!0,...cb(t)},i=fb(r.stdout,()=>new xf(r));return i.render(e),{rerender:i.render,unmount(){i.unmount()},waitUntilExit:i.waitUntilExit,cleanup:()=>Tu.delete(r.stdout),clear:i.clear}},Zm=ub,cb=(e={})=>e instanceof lb?{stdout:e,stdin:Zd.stdin}:e,fb=(e,t)=>{let r=Tu.get(e);return r||(r=t(),Tu.set(e,r)),r};var fa=Le($t(),1);function Nf(e){let{items:t,children:r,style:i}=e,[s,a]=(0,fa.useState)(0),u=(0,fa.useMemo)(()=>t.slice(s),[t,s]);(0,fa.useLayoutEffect)(()=>{a(t.length)},[t.length]);let E=u.map((h,y)=>r(h,s+y)),m=(0,fa.useMemo)(()=>({position:"absolute",flexDirection:"column",...i}),[i]);return fa.default.createElement("ink-box",{internal_static:!0,style:m},E)}var gb=Le($t(),1);var db=Le($t(),1);var pb=Le($t(),1);var eI=Le($t(),1);import{Buffer as Eb}from"node:buffer";var mb=/^(?:\x1b)([a-zA-Z0-9])$/,Ib=/^(?:\x1b+)(O|N|\[|\[\[)(?:(\d+)(?:;(\d+))?([~^$])|(?:1;)?(\d+)?([a-zA-Z]))/,Dy={OP:"f1",OQ:"f2",OR:"f3",OS:"f4","[11~":"f1","[12~":"f2","[13~":"f3","[14~":"f4","[[A":"f1","[[B":"f2","[[C":"f3","[[D":"f4","[[E":"f5","[15~":"f5","[17~":"f6","[18~":"f7","[19~":"f8","[20~":"f9","[21~":"f10","[23~":"f11","[24~":"f12","[A":"up","[B":"down","[C":"right","[D":"left","[E":"clear","[F":"end","[H":"home",OA:"up",OB:"down",OC:"right",OD:"left",OE:"clear",OF:"end",OH:"home","[1~":"home","[2~":"insert","[3~":"delete","[4~":"end","[5~":"pageup","[6~":"pagedown","[[5~":"pageup","[[6~":"pagedown","[7~":"home","[8~":"end","[a":"up","[b":"down","[c":"right","[d":"left","[e":"clear","[2$":"insert","[3$":"delete","[5$":"pageup","[6$":"pagedown","[7$":"home","[8$":"end",Oa:"up",Ob:"down",Oc:"right",Od:"left",Oe:"clear","[2^":"insert","[3^":"delete","[5^":"pageup","[6^":"pagedown","[7^":"home","[8^":"end","[Z":"tab"},yy=[...Object.values(Dy),"backspace"],hb=e=>["[a","[b","[c","[d","[e","[2$","[3$","[5$","[6$","[7$","[8$","[Z"].includes(e),Cb=e=>["Oa","Ob","Oc","Od","Oe","[2^","[3^","[5^","[6^","[7^","[8^"].includes(e),Bb=(e="")=>{let t;Eb.isBuffer(e)?e[0]>127&&e[1]===void 0?(e[0]-=128,e="\x1B"+String(e)):e=String(e):e!==void 0&&typeof e!="string"?e=String(e):e||(e="");let r={name:"",ctrl:!1,meta:!1,shift:!1,option:!1,sequence:e,raw:e};if(r.sequence=r.sequence||e||r.name,e==="\r")r.raw=void 0,r.name="return";else if(e===` -`)r.name="enter";else if(e===" ")r.name="tab";else if(e==="\b"||e==="\x1B\b")r.name="backspace",r.meta=e.charAt(0)==="\x1B";else if(e==="\x7F"||e==="\x1B\x7F")r.name="delete",r.meta=e.charAt(0)==="\x1B";else if(e==="\x1B"||e==="\x1B\x1B")r.name="escape",r.meta=e.length===2;else if(e===" "||e==="\x1B ")r.name="space",r.meta=e.length===2;else if(e.length===1&&e<="")r.name=String.fromCharCode(e.charCodeAt(0)+97-1),r.ctrl=!0;else if(e.length===1&&e>="0"&&e<="9")r.name="number";else if(e.length===1&&e>="a"&&e<="z")r.name=e;else if(e.length===1&&e>="A"&&e<="Z")r.name=e.toLowerCase(),r.shift=!0;else if(t=mb.exec(e))r.meta=!0,r.shift=/^[A-Z]$/.test(t[1]);else if(t=Ib.exec(e)){let i=[...e];i[0]==="\x1B"&&i[1]==="\x1B"&&(r.option=!0);let s=[t[1],t[2],t[4],t[6]].filter(Boolean).join(""),a=(t[3]||t[5]||1)-1;r.ctrl=!!(a&4),r.meta=!!(a&10),r.shift=!!(a&1),r.code=s,r.name=Dy[s],r.shift=hb(s)||r.shift,r.ctrl=Cb(s)||r.ctrl}return r},Qy=Bb;var wy=Le($t(),1);var Db=()=>(0,wy.useContext)(Vd),ep=Db;var yb=(e,t={})=>{let{stdin:r,setRawMode:i,internal_exitOnCtrlC:s,internal_eventEmitter:a}=ep();(0,eI.useEffect)(()=>{if(t.isActive!==!1)return i(!0),()=>{i(!1)}},[t.isActive,i]),(0,eI.useEffect)(()=>{if(t.isActive===!1)return;let u=E=>{let m=Qy(E),h={upArrow:m.name==="up",downArrow:m.name==="down",leftArrow:m.name==="left",rightArrow:m.name==="right",pageDown:m.name==="pagedown",pageUp:m.name==="pageup",return:m.name==="return",escape:m.name==="escape",ctrl:m.ctrl,shift:m.shift,tab:m.name==="tab",backspace:m.name==="backspace",delete:m.name==="delete",meta:m.meta||m.name==="escape"||m.option},y=m.ctrl?m.name:m.sequence;yy.includes(m.name)&&(y=""),y.startsWith("\x1B")&&(y=y.slice(1)),y.length===1&&typeof y[0]=="string"&&/[A-Z]/.test(y[0])&&(h.shift=!0),(!(y==="c"&&h.ctrl)||!s)&&ZA.batchedUpdates(()=>{e(y,h)})};return a?.on("input",u),()=>{a?.removeListener("input",u)}},[t.isActive,r,s,e])},ls=yb;var vy=Le($t(),1);var Qb=()=>(0,vy.useContext)(Yd),ga=Qb;var Sy=Le($t(),1);var wb=()=>(0,Sy.useContext)(qd),da=wb;var vb=Le($t(),1);var tI=Le($t(),1);var Sb=Le($t(),1);bm();import{randomUUID as np}from"node:crypto";import{homedir as Lb}from"node:os";import{posix as Mb,win32 as aI}from"node:path";var rI=class extends Error{status;method;path;constructor(t,r,i,s){super(t),this.name="ApiError",this.status=r,this.method=i,this.path=s}};function _b(e){let t=e.replace(/\s+/g," ").trim();if(!t)return"";try{let r=JSON.parse(e);for(let i of["detail","error","message"]){let s=r[i];if(typeof s=="string"&&s.trim())return s.trim();if(Array.isArray(s)){let a=s.map(u=>u&&typeof u=="object"?String(u.msg??""):"").filter(Boolean);if(a.length)return a.join("; ")}}}catch{}return t.startsWith("typeof D=="string"):[],u=nI(i?.major),E=nI(i?.minor);if(!r||!i||!s)return{compatible:!1,reason:"malformed /api/meta response"};if(typeof s.source_root!="string"||nI(s.pid)===null||typeof s.package_version!="string"||typeof s.release_id!="string")return{compatible:!1,reason:"malformed /api/meta runtime identity"};if(r.service!==bb)return{compatible:!1,reason:`unexpected service ${String(r.service||"unknown")}`};let m=e;if(i.name!==Ou.name||u!==Ou.major)return{compatible:!1,reason:`protocol ${String(i.name||"unknown")}/${String(u)} is incompatible with client ${Ou.name}/${Ou.major}`,meta:m};if(E===null||E!a.includes(D));if(h.length>0)return{compatible:!1,reason:`missing capabilities: ${h.join(", ")}`,meta:m};if(s.source_root_matches_config===!1)return{compatible:!1,reason:"backend is running from a different installation than configured",meta:m};if(s.release_id!==t.releaseId)return{compatible:!1,reason:"backend and client installations are out of sync; restart or reinstall Argus",meta:m};if(t.sourceDigest){if(typeof s.runtime_source_digest!="string"||!s.runtime_source_digest)return{compatible:!1,reason:"backend cannot verify this local installation; restart it from the current checkout",meta:m};if(s.runtime_source_digest!==t.sourceDigest)return{compatible:!1,reason:"backend is running code from a different local installation; restart it",meta:m}}return{compatible:!0,reason:"",warning:s.release_matches_source===!1?oI:void 0,meta:m}}function Ry(e,t){let r=iI(e);if(!r.compatible||!r.meta)throw new Error(`incompatible Argus API: ${r.reason}`);return r.warning&&t?.(r.warning),r.meta}function by(e){let t=Tf(e),r=Tf(t?.daemon);if(!t||t.schema_version!==rp)throw new Error(`incompatible snapshot schema: expected ${rp}, got ${String(t?.schema_version??"missing")}`);if(!r)throw new Error("invalid snapshot: daemon section is missing");let s=["global_daily_cap_usd","read_status","read_error","protocol_compatible","protocol_error"].filter(E=>!Object.hasOwn(r,E));if(s.length>0)throw new Error(`invalid snapshot: daemon fields missing: ${s.join(", ")}`);let u=["spend_usd","spend_status","usage_summary","request_usage","cost_control","daemon_commands","observability","mission_view","partial","diagnostics"].filter(E=>!Object.hasOwn(t,E));if(u.length>0)throw new Error(`invalid snapshot: fields missing: ${u.join(", ")}`);if(!Array.isArray(t.diagnostics))throw new Error("invalid snapshot: diagnostics must be an array");return e}function sI(e){let t=typeof e=="string"||e instanceof URL?String(e):e.url;try{let r=new URL(t);return r.username="",r.password="",r.searchParams.has("token")&&r.searchParams.set("token","[redacted]"),r.toString()}catch{return t}}function el(e,t){return typeof e=="object"&&e!==null?e[t]:void 0}function kb(e){let t=el(e,"cause"),r=new Set;for(;el(t,"cause")&&!r.has(t);)r.add(t),t=el(t,"cause");return t??e}function xb(e,t,r="GET"){let i=kb(e),s=String(el(i,"code")??"").trim(),a=String(el(i,"address")??"").trim(),u=String(el(i,"port")??"").trim(),E=a&&u?`${a}:${u}`:a,m=i instanceof Error?i.message.trim():String(i??"").trim(),h=e instanceof Error?e.message.trim():String(e??"").trim(),y;return s==="ECONNREFUSED"?y=`connection refused${E?` by ${E}`:""}`:s==="ECONNRESET"?y="connection reset by the local service":s==="ETIMEDOUT"?y="connection timed out":s==="ENOTFOUND"?y="host name could not be resolved":m&&m!==h?y=m:y=h||"network request failed",`${r.toUpperCase()} ${sI(t)} failed: ${y}${s?` (${s})`:""}`}function Fy(e){return e%1e3===0?`${e/1e3}s`:`${e}ms`}async function Nb(e,t,r,i,s){let a=Number.isFinite(r)&&r>0?Math.max(1,Math.trunc(r)):1,u=new AbortController,E=t.signal,m=!1,h=!1,y=()=>u.abort(E?.reason);E?.aborted?y():E?.addEventListener("abort",y,{once:!0});let D=(async()=>{let G=await fetch(e,{...t,signal:u.signal});return h=!0,await s(G)})(),_,O=new Promise((G,re)=>{_=setTimeout(()=>{m=!0;let ne=new Error(`request timed out after ${Fy(a)}`);u.abort(ne),re(ne)},a)});try{return await Promise.race([D,O])}catch(G){throw m?new Error(`${i.toUpperCase()} ${sI(e)} timed out after ${Fy(a)}; the local Argus service did not respond`,{cause:G}):E?.aborted?E.reason instanceof Error?E.reason:new Error(`${i.toUpperCase()} ${sI(e)} was aborted`,{cause:G}):h&&el(G,"cause")===void 0?G:new Error(xb(G,e,i),{cause:G})}finally{_&&clearTimeout(_),E?.removeEventListener("abort",y)}}function pa(e,t,r,i,s=t.method??"GET"){return Nb(e,t,r,s,i)}function Pb(e,t=Lb()){let r=E=>E.includes("\\")||/^[A-Za-z]:[\\/]/.test(E),i=r(e)?aI:Mb,s=i.resolve(e),a=E=>i===aI?E.toLowerCase():E,u=r(t)===(i===aI)?a(i.resolve(t)):"";if(!(a(s)===u||a(s)===a(i.parse(s).root)))return s}function Ub(e,t=""){let r=t.trim();return e===4401?{code:e,reason:r||"event stream authentication was rejected",retryable:!1}:e===4404?{code:e,reason:r||"the selected project no longer exists",retryable:!1}:{code:e,reason:r,retryable:!0}}function AI(e){let t=e.item?.title||"new mission";return e.daemon?.admission_required?`\u2192 queued: choose one running session to park before starting ${t}`:e.daemon&&e.daemon.rc!==0?`\u2192 queued but not running: ${e.daemon.error||"background executor failed to start"}`:`\u2192 dispatched to the team: ${t}`}function ky(e){let t=[],r;for(;(r=e.indexOf(` +`)r.name="enter";else if(e===" ")r.name="tab";else if(e==="\b"||e==="\x1B\b")r.name="backspace",r.meta=e.charAt(0)==="\x1B";else if(e==="\x7F"||e==="\x1B\x7F")r.name="delete",r.meta=e.charAt(0)==="\x1B";else if(e==="\x1B"||e==="\x1B\x1B")r.name="escape",r.meta=e.length===2;else if(e===" "||e==="\x1B ")r.name="space",r.meta=e.length===2;else if(e.length===1&&e<="")r.name=String.fromCharCode(e.charCodeAt(0)+97-1),r.ctrl=!0;else if(e.length===1&&e>="0"&&e<="9")r.name="number";else if(e.length===1&&e>="a"&&e<="z")r.name=e;else if(e.length===1&&e>="A"&&e<="Z")r.name=e.toLowerCase(),r.shift=!0;else if(t=mb.exec(e))r.meta=!0,r.shift=/^[A-Z]$/.test(t[1]);else if(t=Ib.exec(e)){let i=[...e];i[0]==="\x1B"&&i[1]==="\x1B"&&(r.option=!0);let s=[t[1],t[2],t[4],t[6]].filter(Boolean).join(""),a=(t[3]||t[5]||1)-1;r.ctrl=!!(a&4),r.meta=!!(a&10),r.shift=!!(a&1),r.code=s,r.name=Dy[s],r.shift=hb(s)||r.shift,r.ctrl=Cb(s)||r.ctrl}return r},Qy=Bb;var wy=Le($t(),1);var Db=()=>(0,wy.useContext)(Vd),ep=Db;var yb=(e,t={})=>{let{stdin:r,setRawMode:i,internal_exitOnCtrlC:s,internal_eventEmitter:a}=ep();(0,eI.useEffect)(()=>{if(t.isActive!==!1)return i(!0),()=>{i(!1)}},[t.isActive,i]),(0,eI.useEffect)(()=>{if(t.isActive===!1)return;let u=E=>{let m=Qy(E),h={upArrow:m.name==="up",downArrow:m.name==="down",leftArrow:m.name==="left",rightArrow:m.name==="right",pageDown:m.name==="pagedown",pageUp:m.name==="pageup",return:m.name==="return",escape:m.name==="escape",ctrl:m.ctrl,shift:m.shift,tab:m.name==="tab",backspace:m.name==="backspace",delete:m.name==="delete",meta:m.meta||m.name==="escape"||m.option},y=m.ctrl?m.name:m.sequence;yy.includes(m.name)&&(y=""),y.startsWith("\x1B")&&(y=y.slice(1)),y.length===1&&typeof y[0]=="string"&&/[A-Z]/.test(y[0])&&(h.shift=!0),(!(y==="c"&&h.ctrl)||!s)&&ZA.batchedUpdates(()=>{e(y,h)})};return a?.on("input",u),()=>{a?.removeListener("input",u)}},[t.isActive,r,s,e])},ls=yb;var vy=Le($t(),1);var Qb=()=>(0,vy.useContext)(Yd),ga=Qb;var Sy=Le($t(),1);var wb=()=>(0,Sy.useContext)(qd),da=wb;var vb=Le($t(),1);var tI=Le($t(),1);var Sb=Le($t(),1);bm();import{randomUUID as np}from"node:crypto";import{homedir as Lb}from"node:os";import{posix as Mb,win32 as aI}from"node:path";var rI=class extends Error{status;method;path;constructor(t,r,i,s){super(t),this.name="ApiError",this.status=r,this.method=i,this.path=s}};function _b(e){let t=e.replace(/\s+/g," ").trim();if(!t)return"";try{let r=JSON.parse(e);for(let i of["detail","error","message"]){let s=r[i];if(typeof s=="string"&&s.trim())return s.trim();if(Array.isArray(s)){let a=s.map(u=>u&&typeof u=="object"?String(u.msg??""):"").filter(Boolean);if(a.length)return a.join("; ")}}}catch{}return t.startsWith("typeof D=="string"):[],u=nI(i?.major),E=nI(i?.minor);if(!r||!i||!s)return{compatible:!1,reason:"malformed /api/meta response"};if(typeof s.source_root!="string"||nI(s.pid)===null||typeof s.package_version!="string"||typeof s.release_id!="string")return{compatible:!1,reason:"malformed /api/meta runtime identity"};if(r.service!==bb)return{compatible:!1,reason:`unexpected service ${String(r.service||"unknown")}`};let m=e;if(i.name!==Ou.name||u!==Ou.major)return{compatible:!1,reason:`protocol ${String(i.name||"unknown")}/${String(u)} is incompatible with client ${Ou.name}/${Ou.major}`,meta:m};if(E===null||E!a.includes(D));if(h.length>0)return{compatible:!1,reason:`missing capabilities: ${h.join(", ")}`,meta:m};if(s.source_root_matches_config===!1)return{compatible:!1,reason:"backend is running from a different installation than configured",meta:m};if(s.release_id!==t.releaseId)return{compatible:!1,reason:"backend and client installations are out of sync; restart or reinstall Argus",meta:m};if(t.sourceDigest){if(typeof s.runtime_source_digest!="string"||!s.runtime_source_digest)return{compatible:!1,reason:"backend cannot verify this local installation; restart it from the current checkout",meta:m};if(s.runtime_source_digest!==t.sourceDigest)return{compatible:!1,reason:"backend is running code from a different local installation; restart it",meta:m}}return{compatible:!0,reason:"",warning:s.release_matches_source===!1?oI:void 0,meta:m}}function Ry(e,t){let r=iI(e);if(!r.compatible||!r.meta)throw new Error(`incompatible Argus API: ${r.reason}`);return r.warning&&t?.(r.warning),r.meta}function by(e){let t=Tf(e),r=Tf(t?.daemon);if(!t||t.schema_version!==rp)throw new Error(`incompatible snapshot schema: expected ${rp}, got ${String(t?.schema_version??"missing")}`);if(!r)throw new Error("invalid snapshot: daemon section is missing");let s=["global_daily_cap_usd","read_status","read_error","protocol_compatible","protocol_error"].filter(E=>!Object.hasOwn(r,E));if(s.length>0)throw new Error(`invalid snapshot: daemon fields missing: ${s.join(", ")}`);let u=["spend_usd","spend_status","usage_summary","request_usage","cost_control","daemon_commands","observability","mission_view","partial","diagnostics"].filter(E=>!Object.hasOwn(t,E));if(u.length>0)throw new Error(`invalid snapshot: fields missing: ${u.join(", ")}`);if(!Array.isArray(t.diagnostics))throw new Error("invalid snapshot: diagnostics must be an array");return e}function sI(e){let t=typeof e=="string"||e instanceof URL?String(e):e.url;try{let r=new URL(t);return r.username="",r.password="",r.searchParams.has("token")&&r.searchParams.set("token","[redacted]"),r.toString()}catch{return t}}function el(e,t){return typeof e=="object"&&e!==null?e[t]:void 0}function kb(e){let t=el(e,"cause"),r=new Set;for(;el(t,"cause")&&!r.has(t);)r.add(t),t=el(t,"cause");return t??e}function xb(e,t,r="GET"){let i=kb(e),s=String(el(i,"code")??"").trim(),a=String(el(i,"address")??"").trim(),u=String(el(i,"port")??"").trim(),E=a&&u?`${a}:${u}`:a,m=i instanceof Error?i.message.trim():String(i??"").trim(),h=e instanceof Error?e.message.trim():String(e??"").trim(),y;return s==="ECONNREFUSED"?y=`connection refused${E?` by ${E}`:""}`:s==="ECONNRESET"?y="connection reset by the local service":s==="ETIMEDOUT"?y="connection timed out":s==="ENOTFOUND"?y="host name could not be resolved":m&&m!==h?y=m:y=h||"network request failed",`${r.toUpperCase()} ${sI(t)} failed: ${y}${s?` (${s})`:""}`}function Fy(e){return e%1e3===0?`${e/1e3}s`:`${e}ms`}async function Nb(e,t,r,i,s){let a=Number.isFinite(r)&&r>0?Math.max(1,Math.trunc(r)):1,u=new AbortController,E=t.signal,m=!1,h=!1,y=()=>u.abort(E?.reason);E?.aborted?y():E?.addEventListener("abort",y,{once:!0});let D=(async()=>{let G=await fetch(e,{...t,signal:u.signal});return h=!0,await s(G)})(),_,O=new Promise((G,re)=>{_=setTimeout(()=>{m=!0;let ne=new Error(`request timed out after ${Fy(a)}`);u.abort(ne),re(ne)},a)});try{return await Promise.race([D,O])}catch(G){throw m?new Error(`${i.toUpperCase()} ${sI(e)} timed out after ${Fy(a)}; the local Argus service did not respond`,{cause:G}):E?.aborted?E.reason instanceof Error?E.reason:new Error(`${i.toUpperCase()} ${sI(e)} was aborted`,{cause:G}):h&&el(G,"cause")===void 0?G:new Error(xb(G,e,i),{cause:G})}finally{_&&clearTimeout(_),E?.removeEventListener("abort",y)}}function pa(e,t,r,i,s=t.method??"GET"){return Nb(e,t,r,s,i)}function Pb(e,t=Lb()){let r=E=>E.includes("\\")||/^[A-Za-z]:[\\/]/.test(E),i=r(e)?aI:Mb,s=i.resolve(e),a=E=>i===aI?E.toLowerCase():E,u=r(t)===(i===aI)?a(i.resolve(t)):"";if(!(a(s)===u||a(s)===a(i.parse(s).root)))return s}function Ub(e,t=""){let r=t.trim();return e===4401?{code:e,reason:r||"event stream authentication was rejected",retryable:!1}:e===4404?{code:e,reason:r||"the selected project no longer exists",retryable:!1}:{code:e,reason:r,retryable:!0}}function AI(e){let t=e.item?.title||"new mission";return e.daemon?.admission_required?`\u2192 queued: choose one running session to park before starting ${t}`:e.daemon&&e.daemon.rc!==0?`\u2192 queued but not running: ${e.daemon.error||"background executor failed to start"}`:`\u2192 dispatched to the team: ${t}`}function ky(e){let t=[],r;for(;(r=e.indexOf(` `))>=0;){let i=e.slice(0,r);e=e.slice(r+2);for(let s of i.split(` `)){let a=s.trim();if(a.startsWith("data:"))try{t.push(JSON.parse(a.slice(5).trim()))}catch{}}}return{frames:t,rest:e}}var us=class{httpBase;wsBase;project;token;onCompatibilityWarning;metaTimeoutMs;readTimeoutMs;metaPromise;constructor(t){this.httpBase=`http://${t.host}:${t.port}`,this.wsBase=`ws://${t.host}:${t.port}`,this.project=t.project,this.token=t.token,this.onCompatibilityWarning=t.onCompatibilityWarning,this.metaTimeoutMs=t.metaTimeoutMs??8e3,this.readTimeoutMs=t.readTimeoutMs??12e3}authHeaders(){return this.token?{Authorization:`Bearer ${this.token}`}:{}}p(t){return`${this.httpBase}/api/projects/${encodeURIComponent(this.project)}${t}`}meta(){if(!this.metaPromise){let t="/api/meta",r=pa(`${this.httpBase}${t}`,{headers:this.authHeaders()},this.metaTimeoutMs,async i=>{if(i.status===404)throw new Error("incompatible Argus API: service does not expose /api/meta");return await io(i,"GET",t),Ry(await i.json(),this.onCompatibilityWarning)});this.metaPromise=r,r.catch(()=>{this.metaPromise===r&&(this.metaPromise=void 0)})}return this.metaPromise}async listProjects(){return await this.meta(),pa(`${this.httpBase}/api/projects`,{headers:this.authHeaders()},this.readTimeoutMs,async t=>(await io(t,"GET","/api/projects"),(await t.json()).projects))}async createDaemon(t="",r="",i=process.cwd(),s,a=np()){let u="/api/daemons",E=Pb(i),m={objective:t,name:r,launch_cwd:i,command_id:a,expected_revision:s};E&&(m.workdir=E);let h=JSON.stringify(m),y=()=>fetch(`${this.httpBase}${u}`,{method:"POST",headers:{"Content-Type":"application/json",Connection:"close",...this.authHeaders()},body:h}),D=await y();return D.status===400&&/Invalid HTTP request received/i.test(await D.clone().text())&&(D=await y()),await io(D,"POST",u),await D.json()}async replaceDaemon(t,r=!1,i,s=np()){return await this.post("/daemon/replace",{victim_sid:t,resume_continuous:r,command_id:s,expected_revision:i})}async scheduleDaemonUpgrade(t,r,i=np()){let s=`/api/projects/${encodeURIComponent(t)}/daemon/upgrade-schedule`,a=await fetch(`${this.httpBase}${s}`,{method:"POST",headers:{"Content-Type":"application/json",...this.authHeaders()},body:JSON.stringify({command_id:i,expected_revision:r})});return await io(a,"POST",s),await a.json()}stopDaemon(t=np()){let r="/daemon/stop";return pa(this.p(r),{method:"POST",headers:{"Content-Type":"application/json",...this.authHeaders()},body:JSON.stringify({force:!1,drain:!1,command_id:t})},this.readTimeoutMs,async i=>{await io(i,"POST",r);let s=await i.json(),a=Number(s.rc??0);if(!Number.isFinite(a)||![0,1].includes(a)){let u=String(s.error??s.message??`rc=${String(s.rc??"unknown")}`);throw new Error(`executor did not stop cleanly: ${u}`)}return s})}async setProjectLaunchCwd(t,r){let i=`/api/projects/${encodeURIComponent(t)}/launch-cwd`,s=await fetch(`${this.httpBase}${i}`,{method:"POST",headers:{"Content-Type":"application/json",...this.authHeaders()},body:JSON.stringify({launch_cwd:r})});await io(s,"POST",i)}async setProjectWorkdir(t,r){let i=`/api/projects/${encodeURIComponent(t)}/workdir`,s=await fetch(`${this.httpBase}${i}`,{method:"POST",headers:{"Content-Type":"application/json",...this.authHeaders()},body:JSON.stringify({workdir:r})});await io(s,"POST",i)}async renameProject(t){let r=this.p(""),i=await fetch(r,{method:"PATCH",headers:{"Content-Type":"application/json",...this.authHeaders()},body:JSON.stringify({name:t})});return await io(i,"PATCH",r),await i.json()}async snapshot(t=1,r,i=!1){return await this.meta(),pa(this.p(`/snapshot?compact=true&events_limit=${t}`+(i?"&prewarm=true":"")),{headers:this.authHeaders(),signal:r},this.readTimeoutMs,async s=>(await io(s,"GET","/snapshot"),by(await s.json())))}async postTask(t){let r=await fetch(this.p("/tasks"),{method:"POST",headers:{"Content-Type":"application/json",...this.authHeaders()},body:JSON.stringify({text:t})});return await io(r,"POST","/tasks"),(await r.json()).item}async postNudge(t){let r=await fetch(this.p("/nudge"),{method:"POST",headers:{"Content-Type":"application/json",...this.authHeaders()},body:JSON.stringify({text:t})});await io(r,"POST","/nudge")}async message(t,r){let i=await fetch(this.p("/message"),{method:"POST",headers:{"Content-Type":"application/json",...this.authHeaders()},body:JSON.stringify({text:t}),signal:r});return await io(i,"POST","/message"),await i.json()}async messageStream(t,r,i){let s=await fetch(this.p("/message/stream"),{method:"POST",headers:{"Content-Type":"application/json",...this.authHeaders()},body:JSON.stringify({text:t}),signal:i});if(await io(s,"POST","/message/stream"),!s.body)throw new Error("Manager stream returned no response body");let a=h=>{if(!i?.aborted)if(h.type==="phase"){let y=Number(h.quiet_s??0);r.onPhase?.(String(h.label??""),String(h.role??"manager"),{heartbeat:h.heartbeat===!0,quietS:Number.isFinite(y)?y:0,kind:String(h.kind??""),detail:String(h.detail??"")})}else h.type==="delta"?r.onDelta?.(String(h.text??""),String(h.message_id??""),String(h.fragment_mode??"auto")):h.type==="done"?r.onDone?.(h.result??{}):h.type==="error"&&r.onError?.(new Error(String(h.error??"stream error")))},u=s.body.getReader(),E=new TextDecoder,m="";for(;;){let{done:h,value:y}=await u.read();if(h)break;m+=E.decode(y,{stream:!0});let D=ky(m);m=D.rest,D.frames.forEach(a)}i?.aborted||ky(m+` diff --git a/frontend/web/dist/assets/MapPanel-BZxjl6ME.js b/frontend/web/dist/assets/MapPanel-BZxjl6ME.js new file mode 100644 index 000000000..8c7505baf --- /dev/null +++ b/frontend/web/dist/assets/MapPanel-BZxjl6ME.js @@ -0,0 +1,12 @@ +import{r as e,t}from"./rolldown-runtime-hePW80VL.js";import{A as n,k as r}from"./icons-2gFhc0pq.js";import{g as i,i as a,n as o}from"./query-CGMsBv4s.js";import{i as s,r as c}from"./markdown-BtnlLdzu.js";import{n as l,r as u,t as d}from"./play-DQD97EkU.js";import{A as f,B as p,E as m,F as h,G as g,I as _,L as v,M as y,N as b,O as x,P as S,R as C,S as w,T,_ as E,a as D,b as O,c as k,d as A,f as j,g as M,j as N,k as P,l as F,m as I,n as L,o as R,p as z,r as B,s as V,t as ee,u as te,v as H,w as U,x as W,z as G}from"./index-BZHe8e4S.js";var K=x(`ArrowLeft`,[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]),ne=x(`ChevronLeft`,[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]),re=x(`Compass`,[[`path`,{d:`m16.24 7.76-1.804 5.411a2 2 0 0 1-1.265 1.265L7.76 16.24l1.804-5.411a2 2 0 0 1 1.265-1.265z`,key:`9ktpf1`}],[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),ie=x(`CornerDownLeft`,[[`polyline`,{points:`9 10 4 15 9 20`,key:`r3jprv`}],[`path`,{d:`M20 4v7a4 4 0 0 1-4 4H4`,key:`6o5b7l`}]]),ae=x(`Ellipsis`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`19`,cy:`12`,r:`1`,key:`1wjl8i`}],[`circle`,{cx:`5`,cy:`12`,r:`1`,key:`1pcz8c`}]]),oe=x(`ListChecks`,[[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`path`,{d:`m3 7 2 2 4-4`,key:`1obspn`}],[`path`,{d:`M13 6h8`,key:`15sg57`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 18h8`,key:`oe0vm4`}]]),se=x(`LocateFixed`,[[`line`,{x1:`2`,x2:`5`,y1:`12`,y2:`12`,key:`bvdh0s`}],[`line`,{x1:`19`,x2:`22`,y1:`12`,y2:`12`,key:`1tbv5k`}],[`line`,{x1:`12`,x2:`12`,y1:`2`,y2:`5`,key:`11lu5j`}],[`line`,{x1:`12`,x2:`12`,y1:`19`,y2:`22`,key:`x3vr5v`}],[`circle`,{cx:`12`,cy:`12`,r:`7`,key:`fim9np`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),ce=x(`MessageCircle`,[[`path`,{d:`M7.9 20A9 9 0 1 0 4 16.1L2 22Z`,key:`vv11sd`}]]),le=x(`RotateCcw`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}]]),q=x(`Route`,[[`circle`,{cx:`6`,cy:`19`,r:`3`,key:`1kj8tv`}],[`path`,{d:`M9 19h8.5a3.5 3.5 0 0 0 0-7h-11a3.5 3.5 0 0 1 0-7H15`,key:`1d8sl`}],[`circle`,{cx:`18`,cy:`5`,r:`3`,key:`gq8acd`}]]),ue=x(`Search`,[[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}],[`path`,{d:`m21 21-4.3-4.3`,key:`1qie3q`}]]),de=x(`Settings2`,[[`path`,{d:`M20 7h-9`,key:`3s1dr2`}],[`path`,{d:`M14 17H5`,key:`gfn3mx`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}],[`circle`,{cx:`7`,cy:`7`,r:`3`,key:`dfmy0x`}]]),J=r();function fe({events:e,connected:t,pending:n,artifacts:r,zh:i,onClose:a,onOpenArtifact:o,onOpenDelivery:s}){let c=e.filter(e=>e.type===`ui.operator`||e.type===`ui.argus`);return(0,J.jsxs)(`aside`,{className:`map-conversation nowheel nodrag nopan`,"aria-label":i?`地图对话`:`Map conversation`,children:[(0,J.jsxs)(`header`,{children:[(0,J.jsx)(ce,{size:16}),(0,J.jsx)(`strong`,{children:i?`与 Argus 对话`:`Talk to Argus`}),(0,J.jsx)(`button`,{type:`button`,onClick:a,"aria-label":i?`关闭对话`:`Close conversation`,children:(0,J.jsx)(j,{size:18})})]}),c.length?(0,J.jsx)(S,{events:c,connected:t,showReasoning:!1,onToggleReasoning:()=>{},embedded:!0,showHeader:!1,artifacts:r,onOpenArtifact:o,onOpenDelivery:s}):(0,J.jsx)(`p`,{className:`map-conversation-empty`,children:i?`在下方发送目标或问题,回复会保留在这里。`:`Send a goal or question below. Your conversation stays here.`}),n&&(0,J.jsx)(`p`,{className:`map-conversation-pending`,role:`status`,children:i?`Argus 正在回复…`:`Argus is replying…`})]})}var Y=e(n(),1),pe=g(),me=(e,t,n)=>e+(t-e)*n,X=e=>e*e*(3-2*e),he=(e,t,n)=>Math.max(t,Math.min(n,e));function ge(e,t,n){let r=Math.hypot(t.x-e.x,t.y-e.y),i=Math.min(140,Math.max(54,r*.22))*(t.x>=e.x?-1:1),a=Math.min(120,r*.3),o={x:he(e.x+i,28,n-28),y:e.y-a},s={x:he(t.x+i*.6,28,n-28),y:t.y+a};return n=>{let r=1-n;return{x:r**3*e.x+3*r**2*n*o.x+3*r*n**2*s.x+n**3*t.x,y:r**3*e.y+3*r**2*n*o.y+3*r*n**2*s.y+n**3*t.y}}}function _e({flight:e,canvas:t,zh:n,historical:r=!1,onReveal:i,onLand:a,onFinish:o}){let s=(0,Y.useRef)(null),c=(0,Y.useRef)(null),l=(0,Y.useRef)(null),u=(0,Y.useRef)(null),d=`dispatch-wake-${(0,Y.useId)().replace(/:/g,``)}`,f=(0,Y.useRef)({onReveal:i,onLand:a,onFinish:o});f.current={onReveal:i,onLand:a,onFinish:o};let p=e.result?.type===`task`&&!r;return(0,Y.useEffect)(()=>{if(!e.result)return;let n=0,i,a,o=()=>f.current.onFinish(e.id);if(e.result.type!==`task`||r)return i=setTimeout(o,2200),()=>clearTimeout(i);let d=s.current;if(!d)return;let p=e.result.taskId,m=window.matchMedia(`(prefers-reduced-motion: reduce)`).matches,h=t.current,g=()=>{cancelAnimationFrame(n),clearTimeout(i),f.current.onLand(e.id),o()};h?.addEventListener(`pointerdown`,g,{once:!0}),h?.addEventListener(`wheel`,g,{once:!0,passive:!0});let _=performance.now(),v=0,y=!1,b=0,x,S=r=>{if(r-_>6e3){o();return}let s=t.current?.querySelector(`.map-macro[data-task-id="${CSS.escape(p)}"]`);if(!s||s.getBoundingClientRect().width<8){r-v>600&&(f.current.onReveal(p),v=r),n=requestAnimationFrame(S);return}if(m){f.current.onLand(e.id),i=setTimeout(o,1200);return}y||(f.current.onReveal(p),y=!0,v=r);let h=s.getBoundingClientRect();if((!x||Math.abs(x.x-h.x)+Math.abs(x.y-h.y)+Math.abs(x.width-h.width)>.7)&&(b=r),x=h,r-v<360||r-b<100){n=requestAnimationFrame(S);return}let g=t.current?.querySelector(`.map-composer`)?.getBoundingClientRect(),C=g?{x:g.left,y:g.top,width:g.width,height:g.height}:e.origin,w={x:C.x+C.width/2,y:C.y+C.height/2},T={x:w.x,y:w.y-26},E={x:h.left+h.width/2,y:h.top+h.height/2},D=ge(T,E,innerWidth),O=Math.min(320,C.width),k=Math.min(68,C.height),A=performance.now(),j=!1,M=t=>{if(!s.isConnected){o();return}let r=Math.min(1,(t-A)/1050),p=X(Math.min(1,r/.22)),m=X(he((r-.22)/.6,0,1)),h=X(he((r-.82)/.18,0,1)),g=r<.22?{x:w.x,y:me(w.y,T.y,p)}:D(m),_=me(52,22,h),v=me(O,_,p),y=me(k,_,p);if(d.style.width=`${v}px`,d.style.height=`${y}px`,d.style.transform=`translate3d(${g.x-v/2}px,${g.y-y/2}px,0)`,d.style.opacity=String(Math.min(1,r/.045)*(1-h)),d.style.setProperty(`--dispatch-copy`,String(1-X(Math.min(1,r/.12)))),d.style.setProperty(`--dispatch-mark`,String(me(1,.7,h))),d.dataset.phase=r<.22?`compress`:r<.82?`travel`:`arrive`,c.current&&l.current&&r>.22){let e=Math.max(0,m-.16),t=Array.from({length:13},(t,n)=>D(me(e,m,n/12)));c.current.setAttribute(`d`,t.map((e,t)=>`${t?`L`:`M`} ${e.x} ${e.y}`).join(` `)),c.current.style.opacity=String(.7*(1-h)),l.current.setAttribute(`x1`,String(t[0].x)),l.current.setAttribute(`y1`,String(t[0].y)),l.current.setAttribute(`x2`,String(g.x)),l.current.setAttribute(`y2`,String(g.y))}r>=.82&&!j&&(j=!0,f.current.onLand(e.id),u.current&&(u.current.style.left=`${E.x}px`,u.current.style.top=`${E.y}px`,a=u.current.animate([{transform:`translate(-50%,-50%) scale(.65)`,opacity:.65},{transform:`translate(-50%,-50%) scale(2.8)`,opacity:0}],{duration:650,easing:`cubic-bezier(.16,1,.3,1)`,fill:`both`}))),r<1?n=requestAnimationFrame(M):i=setTimeout(o,550)};n=requestAnimationFrame(M)};return n=requestAnimationFrame(S),()=>{cancelAnimationFrame(n),clearTimeout(i),a?.cancel(),h?.removeEventListener(`pointerdown`,g),h?.removeEventListener(`wheel`,g)}},[e.id,e.result,t,r]),p?(0,pe.createPortal)((0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`svg`,{className:`map-dispatch-trail`,"aria-hidden":`true`,children:[(0,J.jsx)(`defs`,{children:(0,J.jsxs)(`linearGradient`,{ref:l,id:d,gradientUnits:`userSpaceOnUse`,children:[(0,J.jsx)(`stop`,{stopColor:`#6fbcce`,stopOpacity:`0`}),(0,J.jsx)(`stop`,{offset:`1`,stopColor:`#87d9cf`})]})}),(0,J.jsx)(`path`,{ref:c,fill:`none`,stroke:`url(#${d})`,strokeWidth:`2.5`,strokeLinecap:`round`})]}),(0,J.jsxs)(`div`,{ref:s,className:`map-dispatch-flight`,"data-testid":`map-dispatch-flight`,"data-state":`task`,"data-task-id":e.result?.type===`task`?e.result.taskId:void 0,"aria-hidden":`true`,children:[(0,J.jsx)(`div`,{className:`map-dispatch-symbol`,children:(0,J.jsx)(h,{size:25})}),(0,J.jsxs)(`div`,{className:`map-dispatch-copy`,children:[(0,J.jsx)(`strong`,{children:e.text}),(0,J.jsx)(`span`,{children:n?`进入任务地图`:`Into your task map`})]})]}),(0,J.jsx)(`div`,{ref:u,className:`map-dispatch-halo`,"aria-hidden":`true`})]}),document.body):null}var ve=()=>({revision:0,cards:{},steps:{},links:{}}),ye=(e,t)=>`${e}\u0000${t}`,be=class{initialized=!1;seen=new Set;revision=0;loadingHistory=!1;observe(e,t=!1){let n=ve(),r=0;for(let t of e.cards){this.seen.has(`card:${t.id}`)||(n.cards[t.id]=Math.min(r++*100,400)),this.seen.add(`card:${t.id}`);let i=e.layouts[t.id],a=0;for(let e of i.steps){let r=ye(t.id,e.id);this.seen.has(`step:${r}`)||(n.steps[r]=160+Math.min(a++*120,720)),this.seen.add(`step:${r}`)}for(let e of i.links){let r=ye(t.id,e.id);this.seen.has(`link:${r}`)||(n.links[r]=Math.max(0,(n.steps[ye(t.id,e.target)]??160)-160)),this.seen.add(`link:${r}`)}}for(let t of e.links)this.seen.has(`outer:${t.id}`)||(n.links[t.id]=0),this.seen.add(`outer:${t.id}`);let i=!this.initialized||t||this.loadingHistory;return this.loadingHistory=t,this.initialized=!0,i||![n.cards,n.steps,n.links].some(e=>Object.keys(e).length)?null:{...n,revision:++this.revision}}};function xe(e,t=!1){let n=(0,Y.useRef)(new be),r=(0,Y.useRef)(new Set),[i,a]=(0,Y.useState)(ve);return(0,Y.useEffect)(()=>{let i=n.current.observe(e,t);if(t)r.current.forEach(clearTimeout),r.current.clear(),a(ve());else if(i){a(e=>({revision:i.revision,cards:{...e.cards,...i.cards},steps:{...e.steps,...i.steps},links:{...e.links,...i.links}}));let e=setTimeout(()=>{r.current.delete(e),a(e=>({revision:e.revision,cards:Object.fromEntries(Object.entries(e.cards).filter(([e])=>!(e in i.cards))),steps:Object.fromEntries(Object.entries(e.steps).filter(([e])=>!(e in i.steps))),links:Object.fromEntries(Object.entries(e.links).filter(([e])=>!(e in i.links)))}))},2e3);r.current.add(e)}},[e,t]),(0,Y.useEffect)(()=>()=>{r.current.forEach(clearTimeout),r.current.clear()},[]),i}function Se(e){if(typeof e==`string`||typeof e==`number`)return``+e;let t=``;if(Array.isArray(e))for(let n=0,r;n{}};function we(){for(var e=0,t=arguments.length,n={},r;e=0&&(n=e.slice(r+1),e=e.slice(0,r)),e&&!t.hasOwnProperty(e))throw Error(`unknown type: `+e);return{type:e,name:n}})}Te.prototype=we.prototype={constructor:Te,on:function(e,t){var n=this._,r=Ee(e+``,n),i,a=-1,o=r.length;if(arguments.length<2){for(;++a0)for(var n=Array(i),r=0,i,a;r=0&&(t=e.slice(0,n))!==`xmlns`&&(e=e.slice(n+1)),ke.hasOwnProperty(t)?{space:ke[t],local:e}:e}function je(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===`http://www.w3.org/1999/xhtml`&&t.documentElement.namespaceURI===`http://www.w3.org/1999/xhtml`?t.createElement(e):t.createElementNS(n,e)}}function Me(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Ne(e){var t=Ae(e);return(t.local?Me:je)(t)}function Pe(){}function Fe(e){return e==null?Pe:function(){return this.querySelector(e)}}function Ie(e){typeof e!=`function`&&(e=Fe(e));for(var t=this._groups,n=t.length,r=Array(n),i=0;i=v&&(v=_+1);!(b=g[v])&&++v=0;)(o=r[i])&&(a&&o.compareDocumentPosition(a)^4&&a.parentNode.insertBefore(o,a),a=o);return this}function ft(e){e||=pt;function t(t,n){return t&&n?e(t.__data__,n.__data__):!t-!n}for(var n=this._groups,r=n.length,i=Array(r),a=0;at?1:e>=t?0:NaN}function mt(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function ht(){return Array.from(this)}function gt(){for(var e=this._groups,t=0,n=e.length;t1?this.each((t==null?Ot:typeof t==`function`?At:kt)(e,t,n??``)):Mt(this.node(),e)}function Mt(e,t){return e.style.getPropertyValue(t)||Dt(e).getComputedStyle(e,null).getPropertyValue(t)}function Nt(e){return function(){delete this[e]}}function Pt(e,t){return function(){this[e]=t}}function Ft(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function It(e,t){return arguments.length>1?this.each((t==null?Nt:typeof t==`function`?Ft:Pt)(e,t)):this.node()[e]}function Lt(e){return e.trim().split(/^|\s+/)}function Rt(e){return e.classList||new zt(e)}function zt(e){this._node=e,this._names=Lt(e.getAttribute(`class`)||``)}zt.prototype={add:function(e){this._names.indexOf(e)<0&&(this._names.push(e),this._node.setAttribute(`class`,this._names.join(` `)))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute(`class`,this._names.join(` `)))},contains:function(e){return this._names.indexOf(e)>=0}};function Bt(e,t){for(var n=Rt(e),r=-1,i=t.length;++r=0&&(t=e.slice(n+1),e=e.slice(0,n)),{type:e,name:t}})}function gn(e){return function(){var t=this.__on;if(t){for(var n=0,r=-1,i=t.length,a;n()=>e;function Rn(e,{sourceEvent:t,subject:n,target:r,identifier:i,active:a,x:o,y:s,dx:c,dy:l,dispatch:u}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},identifier:{value:i,enumerable:!0,configurable:!0},active:{value:a,enumerable:!0,configurable:!0},x:{value:o,enumerable:!0,configurable:!0},y:{value:s,enumerable:!0,configurable:!0},dx:{value:c,enumerable:!0,configurable:!0},dy:{value:l,enumerable:!0,configurable:!0},_:{value:u}})}Rn.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function zn(e){return!e.ctrlKey&&!e.button}function Bn(){return this.parentNode}function Vn(e,t){return t??{x:e.x,y:e.y}}function Hn(){return navigator.maxTouchPoints||`ontouchstart`in this}function Un(){var e=zn,t=Bn,n=Vn,r=Hn,i={},a=we(`start`,`drag`,`end`),o=0,s,c,l,u,d=0;function f(e){e.on(`mousedown.drag`,p).filter(r).on(`touchstart.drag`,g).on(`touchmove.drag`,_,jn).on(`touchend.drag touchcancel.drag`,v).style(`touch-action`,`none`).style(`-webkit-tap-highlight-color`,`rgba(0,0,0,0)`)}function p(n,r){if(!(u||!e.call(this,n,r))){var i=y(this,t.call(this,n,r),n,r,`mouse`);i&&(On(n.view).on(`mousemove.drag`,m,Mn).on(`mouseup.drag`,h,Mn),Fn(n.view),Nn(n),l=!1,s=n.clientX,c=n.clientY,i(`start`,n))}}function m(e){if(Pn(e),!l){var t=e.clientX-s,n=e.clientY-c;l=t*t+n*n>d}i.mouse(`drag`,e)}function h(e){On(e.view).on(`mousemove.drag mouseup.drag`,null),In(e.view,l),Pn(e),i.mouse(`end`,e)}function g(n,r){if(e.call(this,n,r)){var i=n.changedTouches,a=t.call(this,n,r),o=i.length,s,c;for(s=0;s>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?fr(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?fr(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=$n.exec(e))?new hr(t[1],t[2],t[3],1):(t=er.exec(e))?new hr(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=tr.exec(e))?fr(t[1],t[2],t[3],t[4]):(t=nr.exec(e))?fr(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=rr.exec(e))?Sr(t[1],t[2]/100,t[3]/100,1):(t=ir.exec(e))?Sr(t[1],t[2]/100,t[3]/100,t[4]):ar.hasOwnProperty(e)?dr(ar[e]):e===`transparent`?new hr(NaN,NaN,NaN,0):null}function dr(e){return new hr(e>>16&255,e>>8&255,e&255,1)}function fr(e,t,n,r){return r<=0&&(e=t=n=NaN),new hr(e,t,n,r)}function pr(e){return e instanceof Kn||(e=ur(e)),e?(e=e.rgb(),new hr(e.r,e.g,e.b,e.opacity)):new hr}function mr(e,t,n,r){return arguments.length===1?pr(e):new hr(e,t,n,r??1)}function hr(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}Wn(hr,mr,Gn(Kn,{brighter(e){return e=e==null?Jn:Jn**+e,new hr(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?qn:qn**+e,new hr(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new hr(br(this.r),br(this.g),br(this.b),yr(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:gr,formatHex:gr,formatHex8:_r,formatRgb:vr,toString:vr}));function gr(){return`#${xr(this.r)}${xr(this.g)}${xr(this.b)}`}function _r(){return`#${xr(this.r)}${xr(this.g)}${xr(this.b)}${xr((isNaN(this.opacity)?1:this.opacity)*255)}`}function vr(){let e=yr(this.opacity);return`${e===1?`rgb(`:`rgba(`}${br(this.r)}, ${br(this.g)}, ${br(this.b)}${e===1?`)`:`, ${e})`}`}function yr(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function br(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function xr(e){return e=br(e),(e<16?`0`:``)+e.toString(16)}function Sr(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new Tr(e,t,n,r)}function Cr(e){if(e instanceof Tr)return new Tr(e.h,e.s,e.l,e.opacity);if(e instanceof Kn||(e=ur(e)),!e)return new Tr;if(e instanceof Tr)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,i=Math.min(t,n,r),a=Math.max(t,n,r),o=NaN,s=a-i,c=(a+i)/2;return s?(o=t===a?(n-r)/s+(n0&&c<1?0:o,new Tr(o,s,c,e.opacity)}function wr(e,t,n,r){return arguments.length===1?Cr(e):new Tr(e,t,n,r??1)}function Tr(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}Wn(Tr,wr,Gn(Kn,{brighter(e){return e=e==null?Jn:Jn**+e,new Tr(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?qn:qn**+e,new Tr(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,r=n+(n<.5?n:1-n)*t,i=2*n-r;return new hr(Or(e>=240?e-240:e+120,i,r),Or(e,i,r),Or(e<120?e+240:e-120,i,r),this.opacity)},clamp(){return new Tr(Er(this.h),Dr(this.s),Dr(this.l),yr(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(){let e=yr(this.opacity);return`${e===1?`hsl(`:`hsla(`}${Er(this.h)}, ${Dr(this.s)*100}%, ${Dr(this.l)*100}%${e===1?`)`:`, ${e})`}`}}));function Er(e){return e=(e||0)%360,e<0?e+360:e}function Dr(e){return Math.max(0,Math.min(1,e||0))}function Or(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}var kr=e=>()=>e;function Ar(e,t){return function(n){return e+n*t}}function jr(e,t,n){return e**=+n,t=t**+n-e,n=1/n,function(r){return(e+r*t)**+n}}function Mr(e){return(e=+e)==1?Nr:function(t,n){return n-t?jr(t,n,e):kr(isNaN(t)?n:t)}}function Nr(e,t){var n=t-e;return n?Ar(e,n):kr(isNaN(e)?t:e)}var Pr=(function e(t){var n=Mr(t);function r(e,t){var r=n((e=mr(e)).r,(t=mr(t)).r),i=n(e.g,t.g),a=n(e.b,t.b),o=Nr(e.opacity,t.opacity);return function(t){return e.r=r(t),e.g=i(t),e.b=a(t),e.opacity=o(t),e+``}}return r.gamma=e,r})(1);function Fr(e,t){t||=[];var n=e?Math.min(t.length,e.length):0,r=t.slice(),i;return function(a){for(i=0;in&&(a=t.slice(n,a),s[o]?s[o]+=a:s[++o]=a),(r=r[0])===(i=i[0])?s[o]?s[o]+=i:s[++o]=i:(s[++o]=null,c.push({i:o,x:zr(r,i)})),n=Hr.lastIndex;return n180?t+=360:t-e>180&&(e+=360),a.push({i:n.push(i(n)+`rotate(`,null,r)-2,x:zr(e,t)}))}function s(e,t,n,a){e===t?t&&n.push(i(n)+`skewX(`+t+r):a.push({i:n.push(i(n)+`skewX(`,null,r)-2,x:zr(e,t)})}function c(e,t,n,r,a,o){if(e!==n||t!==r){var s=a.push(i(a)+`scale(`,null,`,`,null,`)`);o.push({i:s-4,x:zr(e,n)},{i:s-2,x:zr(t,r)})}else(n!==1||r!==1)&&a.push(i(a)+`scale(`+n+`,`+r+`)`)}return function(t,n){var r=[],i=[];return t=e(t),n=e(n),a(t.translateX,t.translateY,n.translateX,n.translateY,r,i),o(t.rotate,n.rotate,r,i),s(t.skewX,n.skewX,r,i),c(t.scaleX,t.scaleY,n.scaleX,n.scaleY,r,i),t=n=null,function(e){for(var t=-1,n=i.length,a;++t=0&&e._call.call(void 0,t),e=e._next;--si}function Ci(){mi=(pi=gi.now())+hi,si=ci=0;try{Si()}finally{si=0,Ti(),mi=0}}function wi(){var e=gi.now(),t=e-pi;t>ui&&(hi-=t,pi=e)}function Ti(){for(var e,t=di,n,r=1/0;t;)t._call?(r>t._time&&(r=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:di=n);fi=e,Ei(r)}function Ei(e){si||(ci&&=clearTimeout(ci),e-mi>24?(e<1/0&&(ci=setTimeout(Ci,e-gi.now()-hi)),li&&=clearInterval(li)):(li||=(pi=gi.now(),setInterval(wi,ui)),si=1,_i(Ci)))}function Di(e,t,n){var r=new bi;return t=t==null?0:+t,r.restart(n=>{r.stop(),e(n+t)},t,n),r}var Oi=we(`start`,`end`,`cancel`,`interrupt`),ki=[];function Ai(e,t,n,r,i,a){var o=e.__transition;if(!o)e.__transition={};else if(n in o)return;Pi(e,n,{name:t,index:r,group:i,on:Oi,tween:ki,time:a.time,delay:a.delay,duration:a.duration,ease:a.ease,timer:null,state:0})}function ji(e,t){var n=Ni(e,t);if(n.state>0)throw Error(`too late; already scheduled`);return n}function Mi(e,t){var n=Ni(e,t);if(n.state>3)throw Error(`too late; already running`);return n}function Ni(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw Error(`transition not found`);return n}function Pi(e,t,n){var r=e.__transition,i;r[t]=n,n.timer=xi(a,0,n.time);function a(e){n.state=1,n.timer.restart(o,n.delay,n.time),n.delay<=e&&o(e-n.delay)}function o(a){var l,u,d,f;if(n.state!==1)return c();for(l in r)if(f=r[l],f.name===n.name){if(f.state===3)return Di(o);f.state===4?(f.state=6,f.timer.stop(),f.on.call(`interrupt`,e,e.__data__,f.index,f.group),delete r[l]):+l2&&r.state<5,r.state=6,r.timer.stop(),r.on.call(i?`interrupt`:`cancel`,e,e.__data__,r.index,r.group),delete n[o]}a&&delete e.__transition}}function Ii(e){return this.each(function(){Fi(this,e)})}function Li(e,t){var n,r;return function(){var i=Mi(this,e),a=i.tween;if(a!==n){r=n=a;for(var o=0,s=r.length;o=0&&(e=e.slice(0,t)),!e||e===`start`})}function pa(e,t,n){var r,i,a=fa(t)?ji:Mi;return function(){var o=a(this,e),s=o.on;s!==r&&(i=(r=s).copy()).on(t,n),o.on=i}}function ma(e,t){var n=this._id;return arguments.length<2?Ni(this.node(),n).on.on(e):this.each(pa(n,e,t))}function ha(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function ga(){return this.on(`end.remove`,ha(this._id))}function _a(e){var t=this._name,n=this._id;typeof e!=`function`&&(e=Fe(e));for(var r=this._groups,i=r.length,a=Array(i),o=0;o()=>e;function qa(e,{sourceEvent:t,target:n,transform:r,dispatch:i}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:r,enumerable:!0,configurable:!0},_:{value:i}})}function Ja(e,t,n){this.k=e,this.x=t,this.y=n}Ja.prototype={constructor:Ja,scale:function(e){return e===1?this:new Ja(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new Ja(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return`translate(`+this.x+`,`+this.y+`) scale(`+this.k+`)`}};var Ya=new Ja(1,0,0);Xa.prototype=Ja.prototype;function Xa(e){for(;!e.__zoom;)if(!(e=e.parentNode))return Ya;return e.__zoom}function Za(e){e.stopImmediatePropagation()}function Qa(e){e.preventDefault(),e.stopImmediatePropagation()}function $a(e){return(!e.ctrlKey||e.type===`wheel`)&&!e.button}function eo(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e,e.hasAttribute(`viewBox`)?(e=e.viewBox.baseVal,[[e.x,e.y],[e.x+e.width,e.y+e.height]]):[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]):[[0,0],[e.clientWidth,e.clientHeight]]}function to(){return this.__zoom||Ya}function no(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function ro(){return navigator.maxTouchPoints||`ontouchstart`in this}function io(e,t,n){var r=e.invertX(t[0][0])-n[0][0],i=e.invertX(t[1][0])-n[1][0],a=e.invertY(t[0][1])-n[0][1],o=e.invertY(t[1][1])-n[1][1];return e.translate(i>r?(r+i)/2:Math.min(0,r)||Math.max(0,i),o>a?(a+o)/2:Math.min(0,a)||Math.max(0,o))}function ao(){var e=$a,t=eo,n=io,r=no,i=ro,a=[0,1/0],o=[[-1/0,-1/0],[1/0,1/0]],s=250,c=oi,l=we(`start`,`zoom`,`end`),u,d,f,p=500,m=150,h=0,g=10;function _(e){e.property(`__zoom`,to).on(`wheel.zoom`,w,{passive:!1}).on(`mousedown.zoom`,T).on(`dblclick.zoom`,E).filter(i).on(`touchstart.zoom`,D).on(`touchmove.zoom`,O).on(`touchend.zoom touchcancel.zoom`,k).style(`-webkit-tap-highlight-color`,`rgba(0,0,0,0)`)}_.transform=function(e,t,n,r){var i=e.selection?e.selection():e;i.property(`__zoom`,to),e===i?i.interrupt().each(function(){S(this,arguments).event(r).start().zoom(null,typeof t==`function`?t.apply(this,arguments):t).end()}):x(e,t,n,r)},_.scaleBy=function(e,t,n,r){_.scaleTo(e,function(){return this.__zoom.k*(typeof t==`function`?t.apply(this,arguments):t)},n,r)},_.scaleTo=function(e,r,i,a){_.transform(e,function(){var e=t.apply(this,arguments),a=this.__zoom,s=i==null?b(e):typeof i==`function`?i.apply(this,arguments):i,c=a.invert(s),l=typeof r==`function`?r.apply(this,arguments):r;return n(y(v(a,l),s,c),e,o)},i,a)},_.translateBy=function(e,r,i,a){_.transform(e,function(){return n(this.__zoom.translate(typeof r==`function`?r.apply(this,arguments):r,typeof i==`function`?i.apply(this,arguments):i),t.apply(this,arguments),o)},null,a)},_.translateTo=function(e,r,i,a,s){_.transform(e,function(){var e=t.apply(this,arguments),s=this.__zoom,c=a==null?b(e):typeof a==`function`?a.apply(this,arguments):a;return n(Ya.translate(c[0],c[1]).scale(s.k).translate(typeof r==`function`?-r.apply(this,arguments):-r,typeof i==`function`?-i.apply(this,arguments):-i),e,o)},a,s)};function v(e,t){return t=Math.max(a[0],Math.min(a[1],t)),t===e.k?e:new Ja(t,e.x,e.y)}function y(e,t,n){var r=t[0]-n[0]*e.k,i=t[1]-n[1]*e.k;return r===e.x&&i===e.y?e:new Ja(e.k,r,i)}function b(e){return[(+e[0][0]+ +e[1][0])/2,(+e[0][1]+ +e[1][1])/2]}function x(e,n,r,i){e.on(`start.zoom`,function(){S(this,arguments).event(i).start()}).on(`interrupt.zoom end.zoom`,function(){S(this,arguments).event(i).end()}).tween(`zoom`,function(){var e=this,a=arguments,o=S(e,a).event(i),s=t.apply(e,a),l=r==null?b(s):typeof r==`function`?r.apply(e,a):r,u=Math.max(s[1][0]-s[0][0],s[1][1]-s[0][1]),d=e.__zoom,f=typeof n==`function`?n.apply(e,a):n,p=c(d.invert(l).concat(u/d.k),f.invert(l).concat(u/f.k));return function(e){if(e===1)e=f;else{var t=p(e),n=u/t[2];e=new Ja(n,l[0]-t[0]*n,l[1]-t[1]*n)}o.zoom(null,e)}})}function S(e,t,n){return!n&&e.__zooming||new C(e,t)}function C(e,n){this.that=e,this.args=n,this.active=0,this.sourceEvent=null,this.extent=t.apply(e,n),this.taps=0}C.prototype={event:function(e){return e&&(this.sourceEvent=e),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit(`start`)),this},zoom:function(e,t){return this.mouse&&e!==`mouse`&&(this.mouse[1]=t.invert(this.mouse[0])),this.touch0&&e!==`touch`&&(this.touch0[1]=t.invert(this.touch0[0])),this.touch1&&e!==`touch`&&(this.touch1[1]=t.invert(this.touch1[0])),this.that.__zoom=t,this.emit(`zoom`),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit(`end`)),this},emit:function(e){var t=On(this.that).datum();l.call(e,this.that,new qa(e,{sourceEvent:this.sourceEvent,target:_,type:e,transform:this.that.__zoom,dispatch:l}),t)}};function w(t,...i){if(!e.apply(this,arguments))return;var s=S(this,i).event(t),c=this.__zoom,l=Math.max(a[0],Math.min(a[1],c.k*2**r.apply(this,arguments))),u=An(t);if(s.wheel)(s.mouse[0][0]!==u[0]||s.mouse[0][1]!==u[1])&&(s.mouse[1]=c.invert(s.mouse[0]=u)),clearTimeout(s.wheel);else if(c.k===l)return;else s.mouse=[u,c.invert(u)],Fi(this),s.start();Qa(t),s.wheel=setTimeout(d,m),s.zoom(`mouse`,n(y(v(c,l),s.mouse[0],s.mouse[1]),s.extent,o));function d(){s.wheel=null,s.end()}}function T(t,...r){if(f||!e.apply(this,arguments))return;var i=t.currentTarget,a=S(this,r,!0).event(t),s=On(t.view).on(`mousemove.zoom`,d,!0).on(`mouseup.zoom`,p,!0),c=An(t,i),l=t.clientX,u=t.clientY;Fn(t.view),Za(t),a.mouse=[c,this.__zoom.invert(c)],Fi(this),a.start();function d(e){if(Qa(e),!a.moved){var t=e.clientX-l,r=e.clientY-u;a.moved=t*t+r*r>h}a.event(e).zoom(`mouse`,n(y(a.that.__zoom,a.mouse[0]=An(e,i),a.mouse[1]),a.extent,o))}function p(e){s.on(`mousemove.zoom mouseup.zoom`,null),In(e.view,a.moved),Qa(e),a.event(e).end()}}function E(r,...i){if(e.apply(this,arguments)){var a=this.__zoom,c=An(r.changedTouches?r.changedTouches[0]:r,this),l=a.invert(c),u=a.k*(r.shiftKey?.5:2),d=n(y(v(a,u),c,l),t.apply(this,i),o);Qa(r),s>0?On(this).transition().duration(s).call(x,d,c,r):On(this).call(_.transform,d,c,r)}}function D(t,...n){if(e.apply(this,arguments)){var r=t.touches,i=r.length,a=S(this,n,t.changedTouches.length===i).event(t),o,s,c,l;for(Za(t),s=0;s`Seems like you have not used ${e===`svelte`?`SvelteFlowProvider`:`ReactFlowProvider`} as an ancestor. Help: https://${e}flow.dev/error#001`,error002:()=>`It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.`,error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>`The parent container needs a width and a height to render the graph.`,error005:()=>`Only child nodes can use a parent extent.`,error006:()=>`Can't create edge. An edge needs a source and a target.`,error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,{id:t,sourceHandle:n,targetHandle:r})=>`Couldn't create edge for ${e} handle id: "${e===`source`?n:r}", edge id: ${t}.`,error010:()=>`Handle: No node id found. Make sure to only use a Handle inside a custom Node.`,error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(e=`react`)=>`It seems that you haven't loaded the styles. Please import '@xyflow/${e}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>`useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.`,error015:()=>`It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs.`,error016:e=>`Edge with id "${e}" does not exist, it may have been removed. This can happen when an edge is deleted before the "onEdgeClick" handler is called.`},so=[[-1/0,-1/0],[1/0,1/0]],co=[`Enter`,` `,`Escape`],lo={"node.a11yDescription.default":`Press enter or space to select a node. Press delete to remove it and escape to cancel.`,"node.a11yDescription.keyboardDisabled":`Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.`,"node.a11yDescription.ariaLiveMessage":({direction:e,x:t,y:n})=>`Moved selected node ${e}. New position, x: ${t}, y: ${n}`,"edge.a11yDescription.default":`Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.`,"controls.ariaLabel":`Control Panel`,"controls.zoomIn.ariaLabel":`Zoom In`,"controls.zoomOut.ariaLabel":`Zoom Out`,"controls.fitView.ariaLabel":`Fit View`,"controls.interactive.ariaLabel":`Toggle Interactivity`,"minimap.ariaLabel":`Mini Map`,"handle.ariaLabel":`Handle`},uo;(function(e){e.Strict=`strict`,e.Loose=`loose`})(uo||={});var fo;(function(e){e.Free=`free`,e.Vertical=`vertical`,e.Horizontal=`horizontal`})(fo||={});var po;(function(e){e.Partial=`partial`,e.Full=`full`})(po||={});var mo={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null},ho;(function(e){e.Bezier=`default`,e.Straight=`straight`,e.Step=`step`,e.SmoothStep=`smoothstep`,e.SimpleBezier=`simplebezier`})(ho||={});var go;(function(e){e.Arrow=`arrow`,e.ArrowClosed=`arrowclosed`})(go||={});var Z;(function(e){e.Left=`left`,e.Top=`top`,e.Right=`right`,e.Bottom=`bottom`})(Z||={});var _o={[Z.Left]:Z.Right,[Z.Right]:Z.Left,[Z.Top]:Z.Bottom,[Z.Bottom]:Z.Top};function vo(e){return e===null?null:e?`valid`:`invalid`}var yo=e=>`id`in e&&`source`in e&&`target`in e,bo=e=>`id`in e&&`position`in e&&!(`source`in e)&&!(`target`in e),xo=e=>`id`in e&&`internals`in e&&!(`source`in e)&&!(`target`in e),So=(e,t=[0,0])=>{let{width:n,height:r}=ns(e),i=e.origin??t,a=n*i[0],o=r*i[1];return{x:e.position.x-a,y:e.position.y-o}},Co=(e,t={nodeOrigin:[0,0]})=>e.length===0?{x:0,y:0,width:0,height:0}:Ro(e.reduce((e,n)=>{let r=typeof n==`string`,i=!t.nodeLookup&&!r?n:void 0;return t.nodeLookup&&(i=r?t.nodeLookup.get(n):xo(n)?n:t.nodeLookup.get(n.id)),Io(e,i?Bo(i,t.nodeOrigin):{x:0,y:0,x2:0,y2:0})},{x:1/0,y:1/0,x2:-1/0,y2:-1/0})),wo=(e,t={})=>{let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0},r=!1;return e.forEach(e=>{(t.filter===void 0||t.filter(e))&&(n=Io(n,Bo(e)),r=!0)}),r?Ro(n):{x:0,y:0,width:0,height:0}},To=(e,t,[n,r,i]=[0,0,1],a=!1,o=!1)=>{let s=(t.x-n)/i,c=(t.y-r)/i,l=t.width/i,u=t.height/i,d=[];for(let t of e.values()){let{measured:e,selectable:n=!0,hidden:r=!1}=t;if(o&&!n||r)continue;let i=e.width??t.width??t.initialWidth??0,f=e.height??t.height??t.initialHeight??0,{x:p,y:m}=t.internals.positionAbsolute,h=Ho(s,c,l,u,p,m,i,f),g=i*f,_=a&&h>0;(!t.internals.handleBounds||_||h>=g||t.dragging)&&d.push(t)}return d},Eo=(e,t)=>{let n=new Set;return e.forEach(e=>{n.add(e.id)}),t.filter(e=>n.has(e.source)||n.has(e.target))};function Do(e,t){let n=new Map,r=t?.nodes?new Set(t.nodes.map(e=>e.id)):null;return e.forEach(e=>{e.measured.width&&e.measured.height&&(t?.includeHiddenNodes||!e.hidden)&&(!r||r.has(e.id))&&n.set(e.id,e)}),n}async function Oo({nodes:e,width:t,height:n,panZoom:r,minZoom:i,maxZoom:a},o){if(e.size===0)return!0;let s=$o(wo(Do(e,o)),t,n,o?.minZoom??i,o?.maxZoom??a,o?.padding??.1);return await r.setViewport(s,{duration:o?.duration,ease:o?.ease,interpolate:o?.interpolate}),!0}function ko({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:r=[0,0],nodeExtent:i,onError:a}){let o=n.get(e),s=o.parentId?n.get(o.parentId):void 0,{x:c,y:l}=s?s.internals.positionAbsolute:{x:0,y:0},u=o.origin??r,d=o.extent||i;if(o.extent===`parent`&&!o.expandParent){if(!s)a?.(`005`,oo.error005());else{let e=s.measured.width,t=s.measured.height;e&&t&&(d=[[c,l],[c+e,l+t]])}}else s&&ts(o.extent)&&(d=[[o.extent[0][0]+c,o.extent[0][1]+l],[o.extent[1][0]+c,o.extent[1][1]+l]]);let f=ts(d)?Mo(t,d,o.measured):t;return(o.measured.width===void 0||o.measured.height===void 0)&&a?.(`015`,oo.error015()),{position:{x:f.x-c+(o.measured.width??0)*u[0],y:f.y-l+(o.measured.height??0)*u[1]},positionAbsolute:f}}async function Ao({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:r,onBeforeDelete:i}){let a=new Set(e.map(e=>e.id)),o=[];for(let e of n){if(e.deletable===!1)continue;let t=a.has(e.id),n=!t&&e.parentId&&o.find(t=>t.id===e.parentId);(t||n)&&o.push(e)}let s=new Set(t.map(e=>e.id)),c=r.filter(e=>e.deletable!==!1),l=Eo(o,c);for(let e of c)s.has(e.id)&&!l.find(t=>t.id===e.id)&&l.push(e);if(!i)return{edges:l,nodes:o};let u=await i({nodes:o,edges:l});return typeof u==`boolean`?u?{edges:l,nodes:o}:{edges:[],nodes:[]}:u}var jo=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),Mo=(e={x:0,y:0},t,n)=>({x:jo(e.x,t[0][0],t[1][0]-(n?.width??0)),y:jo(e.y,t[0][1],t[1][1]-(n?.height??0))});function No(e,t,n){let{width:r,height:i}=ns(n),{x:a,y:o}=n.internals.positionAbsolute;return Mo(e,[[a,o],[a+r,o+i]],t)}var Po=(e,t,n)=>en?-jo(Math.abs(e-n),1,t)/t:0,Fo=(e,t,n=15,r=40)=>[Po(e.x,r,t.width-r)*n,Po(e.y,r,t.height-r)*n],Io=(e,t)=>({x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x2,t.x2),y2:Math.max(e.y2,t.y2)}),Lo=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),Ro=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),zo=(e,t=[0,0])=>{let{x:n,y:r}=xo(e)?e.internals.positionAbsolute:So(e,t);return{x:n,y:r,width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}},Bo=(e,t=[0,0])=>{let{x:n,y:r}=xo(e)?e.internals.positionAbsolute:So(e,t);return{x:n,y:r,x2:n+(e.measured?.width??e.width??e.initialWidth??0),y2:r+(e.measured?.height??e.height??e.initialHeight??0)}},Vo=(e,t)=>Ro(Io(Lo(e),Lo(t))),Ho=(e,t,n,r,i,a,o,s)=>{let c=Math.max(0,Math.min(e+n,i+o)-Math.max(e,i)),l=Math.max(0,Math.min(t+r,a+s)-Math.max(t,a));return Math.ceil(c*l)},Uo=(e,t)=>Ho(e.x,e.y,e.width,e.height,t.x,t.y,t.width,t.height),Wo=e=>Go(e.width)&&Go(e.height)&&Go(e.x)&&Go(e.y),Go=e=>!isNaN(e)&&isFinite(e),Ko=(e,t)=>(e,t)=>{},qo=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),Jo=({x:e,y:t},[n,r,i],a=!1,o=[1,1])=>{let s={x:(e-n)/i,y:(t-r)/i};return a?qo(s,o):s},Yo=({x:e,y:t},[n,r,i])=>({x:e*i+n,y:t*i+r});function Xo(e,t){if(typeof e==`number`)return Math.floor((t-t/(1+e))*.5);if(typeof e==`string`&&e.endsWith(`px`)){let t=parseFloat(e);if(!Number.isNaN(t))return Math.floor(t)}if(typeof e==`string`&&e.endsWith(`%`)){let n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(t*n*.01)}return console.error(`The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function Zo(e,t,n){if(typeof e==`string`||typeof e==`number`){let r=Xo(e,n),i=Xo(e,t);return{top:r,right:i,bottom:r,left:i,x:i*2,y:r*2}}if(typeof e==`object`){let r=Xo(e.top??e.y??0,n),i=Xo(e.bottom??e.y??0,n),a=Xo(e.left??e.x??0,t),o=Xo(e.right??e.x??0,t);return{top:r,right:o,bottom:i,left:a,x:a+o,y:r+i}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function Qo(e,t,n,r,i,a){let{x:o,y:s}=Yo(e,[t,n,r]),{x:c,y:l}=Yo({x:e.x+e.width,y:e.y+e.height},[t,n,r]),u=i-c,d=a-l;return{left:Math.floor(o),top:Math.floor(s),right:Math.floor(u),bottom:Math.floor(d)}}var $o=(e,t,n,r,i,a)=>{let o=Zo(a,t,n),s=(t-o.x)/e.width,c=(n-o.y)/e.height,l=jo(Math.min(s,c),r,i),u=e.x+e.width/2,d=e.y+e.height/2,f=t/2-u*l,p=n/2-d*l,m=Qo(e,f,p,l,t,n),h={left:Math.min(m.left-o.left,0),top:Math.min(m.top-o.top,0),right:Math.min(m.right-o.right,0),bottom:Math.min(m.bottom-o.bottom,0)};return{x:f-h.left+h.right,y:p-h.top+h.bottom,zoom:l}},es=()=>typeof navigator<`u`&&navigator?.userAgent?.indexOf(`Mac`)>=0;function ts(e){return e!=null&&e!==`parent`}function ns(e){return{width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}}function rs(e){return(e.measured?.width??e.width??e.initialWidth)!==void 0&&(e.measured?.height??e.height??e.initialHeight)!==void 0}function is(e,t={width:0,height:0},n,r,i){let a={...e},o=r.get(n);if(o){let e=o.origin||i;a.x+=o.internals.positionAbsolute.x-(t.width??0)*e[0],a.y+=o.internals.positionAbsolute.y-(t.height??0)*e[1]}return a}function as(e,t){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}function os(){let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}function ss(e){return{...lo,...e||{}}}function cs(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:r,containerBounds:i}){let{x:a,y:o}=ms(e),s=Jo({x:a-(i?.left??0),y:o-(i?.top??0)},r),{x:c,y:l}=n?qo(s,t):s;return{xSnapped:c,ySnapped:l,...s}}var ls=e=>({width:e.offsetWidth,height:e.offsetHeight}),us=e=>e?.getRootNode?.()||window?.document,ds=[`INPUT`,`SELECT`,`TEXTAREA`];function fs(e){let t=e.composedPath?.()?.[0]||e.target;return t?.nodeType===1?ds.includes(t.nodeName)||t.hasAttribute(`contenteditable`)||!!t.closest(`.nokey`):!1}var ps=e=>`clientX`in e,ms=(e,t)=>{let n=ps(e),r=n?e.clientX:e.touches?.[0].clientX,i=n?e.clientY:e.touches?.[0].clientY;return{x:r-(t?.left??0),y:i-(t?.top??0)}},hs=(e,t,n,r,i)=>{let a=t.querySelectorAll(`.${e}`);return!a||!a.length?null:Array.from(a).map(t=>{let a=t.getBoundingClientRect();return{id:t.getAttribute(`data-handleid`),type:e,nodeId:i,position:t.getAttribute(`data-handlepos`),x:(a.left-n.left)/r,y:(a.top-n.top)/r,...ls(t)}})};function gs({sourceX:e,sourceY:t,targetX:n,targetY:r,sourceControlX:i,sourceControlY:a,targetControlX:o,targetControlY:s}){let c=e*.125+i*.375+o*.375+n*.125,l=t*.125+a*.375+s*.375+r*.125;return[c,l,Math.abs(c-e),Math.abs(l-t)]}function _s(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function vs({pos:e,x1:t,y1:n,x2:r,y2:i,c:a}){switch(e){case Z.Left:return[t-_s(t-r,a),n];case Z.Right:return[t+_s(r-t,a),n];case Z.Top:return[t,n-_s(n-i,a)];case Z.Bottom:return[t,n+_s(i-n,a)]}}function ys({sourceX:e,sourceY:t,sourcePosition:n=Z.Bottom,targetX:r,targetY:i,targetPosition:a=Z.Top,curvature:o=.25}){let[s,c]=vs({pos:n,x1:e,y1:t,x2:r,y2:i,c:o}),[l,u]=vs({pos:a,x1:r,y1:i,x2:e,y2:t,c:o}),[d,f,p,m]=gs({sourceX:e,sourceY:t,targetX:r,targetY:i,sourceControlX:s,sourceControlY:c,targetControlX:l,targetControlY:u});return[`M${e},${t} C${s},${c} ${l},${u} ${r},${i}`,d,f,p,m]}function bs({sourceX:e,sourceY:t,targetX:n,targetY:r}){let i=Math.abs(n-e)/2,a=n0}var Cs=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`xy-edge__${e}${t||``}-${n}${r||``}`,ws=(e,t)=>t.some(t=>t.source===e.source&&t.target===e.target&&(t.sourceHandle===e.sourceHandle||!t.sourceHandle&&!e.sourceHandle)&&(t.targetHandle===e.targetHandle||!t.targetHandle&&!e.targetHandle)),Ts=(e,t,n={})=>{if(!e.source||!e.target)return n.onError?.(`006`,oo.error006()),t;let r=n.getEdgeId||Cs,i;return i=yo(e)?{...e}:{...e,id:r(e)},ws(i,t)?t:(i.sourceHandle===null&&delete i.sourceHandle,i.targetHandle===null&&delete i.targetHandle,t.concat(i))};function Es({sourceX:e,sourceY:t,targetX:n,targetY:r}){let[i,a,o,s]=bs({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,i,a,o,s]}var Ds={[Z.Left]:{x:-1,y:0},[Z.Right]:{x:1,y:0},[Z.Top]:{x:0,y:-1},[Z.Bottom]:{x:0,y:1}},Os=({source:e,sourcePosition:t=Z.Bottom,target:n})=>t===Z.Left||t===Z.Right?e.xMath.sqrt((t.x-e.x)**2+(t.y-e.y)**2);function As({source:e,sourcePosition:t=Z.Bottom,target:n,targetPosition:r=Z.Top,center:i,offset:a,stepPosition:o}){let s=Ds[t],c=Ds[r],l={x:e.x+s.x*a,y:e.y+s.y*a},u={x:n.x+c.x*a,y:n.y+c.y*a},d=Os({source:l,sourcePosition:t,target:u}),f=d.x===0?`y`:`x`,p=d[f],m=[],h,g,_={x:0,y:0},v={x:0,y:0},[,,y,b]=bs({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(s[f]*c[f]===-1){f===`x`?(h=i.x??l.x+(u.x-l.x)*o,g=i.y??(l.y+u.y)/2):(h=i.x??(l.x+u.x)/2,g=i.y??l.y+(u.y-l.y)*o);let e=[{x:h,y:l.y},{x:h,y:u.y}],t=[{x:l.x,y:g},{x:u.x,y:g}];m=s[f]===p?f===`x`?e:t:f===`x`?t:e}else{let i=[{x:l.x,y:u.y}],o=[{x:u.x,y:l.y}];if(m=f===`x`?s.x===p?o:i:s.y===p?i:o,t===r){let t=Math.abs(e[f]-n[f]);if(t<=a){let r=Math.min(a-1,a-t);s[f]===p?_[f]=(l[f]>e[f]?-1:1)*r:v[f]=(u[f]>n[f]?-1:1)*r}}if(t!==r){let e=f===`x`?`y`:`x`,t=s[f]===c[e],n=l[e]>u[e],r=l[e]=Math.max(Math.abs(d.y-m[0].y),Math.abs(y.y-m[0].y))?(h=(d.x+y.x)/2,g=m[0].y):(h=m[0].x,g=(d.y+y.y)/2)}let x={x:l.x+_.x,y:l.y+_.y},S={x:u.x+v.x,y:u.y+v.y};return[[e,...x.x!==m[0].x||x.y!==m[0].y?[x]:[],...m,...S.x!==m[m.length-1].x||S.y!==m[m.length-1].y?[S]:[],n],h,g,y,b]}function js(e,t,n,r){let i=Math.min(ks(e,t)/2,ks(t,n)/2,r),{x:a,y:o}=t;if(e.x===a&&a===n.x||e.y===o&&o===n.y)return`L${a} ${o}`;if(e.y===o){let t=e.xe.id===t):e[0])||null}function Rs(e,t){return e?typeof e==`string`?e:`${t?`${t}__`:``}${Object.keys(e).sort().map(t=>`${t}=${e[t]}`).join(`&`)}`:``}function zs(e,{id:t,defaultColor:n,defaultMarkerStart:r,defaultMarkerEnd:i}){let a=new Set;return e.reduce((e,o)=>([o.markerStart||r,o.markerEnd||i].forEach(r=>{if(r&&typeof r==`object`){let i=Rs(r,t);a.has(i)||(e.push({id:i,color:r.color||n,...r}),a.add(i))}}),e),[]).sort((e,t)=>e.id.localeCompare(t.id))}var Bs=1e3,Vs=10,Hs={nodeOrigin:[0,0],nodeExtent:so,elevateNodesOnSelect:!0,zIndexMode:`basic`,defaults:{}},Us={...Hs,checkEquality:!0};function Ws(e,t){let n={...e};for(let e in t)t[e]!==void 0&&(n[e]=t[e]);return n}function Gs(e,t,n){let r=Ws(Hs,n);for(let n of e.values())if(n.parentId)Xs(n,e,t,r);else{let e=Mo(So(n,r.nodeOrigin),ts(n.extent)?n.extent:r.nodeExtent,ns(n));n.internals.positionAbsolute=e}}function Ks(e,t){if(!e.handles)return e.measured?t?.internals.handleBounds:void 0;let n=[],r=[];for(let t of e.handles){let i={id:t.id,width:t.width??1,height:t.height??1,nodeId:e.id,x:t.x,y:t.y,position:t.position,type:t.type};t.type===`source`?n.push(i):t.type===`target`&&r.push(i)}return{source:n,target:r}}function qs(e){return e===`manual`}function Js(e,t,n,r={}){let i=Ws(Us,r),a={i:0},o=new Map(t),s=i?.elevateNodesOnSelect&&!qs(i.zIndexMode)?Bs:0,c=e.length>0,l=!1;t.clear(),n.clear();for(let u of e){let e=o.get(u.id);if(i.checkEquality&&u===e?.internals.userNode)t.set(u.id,e);else{let n=Mo(So(u,i.nodeOrigin),ts(u.extent)?u.extent:i.nodeExtent,ns(u));e={...i.defaults,...u,measured:{width:u.measured?.width,height:u.measured?.height},internals:{positionAbsolute:n,handleBounds:Ks(u,e),z:Zs(u,s,i.zIndexMode),userNode:u}},t.set(u.id,e)}(e.measured===void 0||e.measured.width===void 0||e.measured.height===void 0)&&!e.hidden&&(c=!1),u.parentId&&Xs(e,t,n,r,a),l||=u.selected??!1}return{nodesInitialized:c,hasSelectedNodes:l}}function Ys(e,t){if(!e.parentId)return;let n=t.get(e.parentId);n?n.set(e.id,e):t.set(e.parentId,new Map([[e.id,e]]))}function Xs(e,t,n,r,i){let{elevateNodesOnSelect:a,nodeOrigin:o,nodeExtent:s,zIndexMode:c}=Ws(Hs,r),l=e.parentId,u=t.get(l);if(!u){console.warn(`Parent node ${l} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}Ys(e,n),i&&!u.parentId&&u.internals.rootParentIndex===void 0&&c===`auto`&&(u.internals.rootParentIndex=++i.i,u.internals.z=u.internals.z+i.i*Vs),i&&u.internals.rootParentIndex!==void 0&&(i.i=u.internals.rootParentIndex);let{x:d,y:f,z:p}=Qs(e,u,o,s,a&&!qs(c)?Bs:0,c),{positionAbsolute:m}=e.internals,h=d!==m.x||f!==m.y;(h||p!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:h?{x:d,y:f}:m,z:p}})}function Zs(e,t,n){let r=Go(e.zIndex)?e.zIndex:0;return qs(n)?r:r+(e.selected?t:0)}function Qs(e,t,n,r,i,a){let{x:o,y:s}=t.internals.positionAbsolute,c=ns(e),l=So(e,n),u=ts(e.extent)?Mo(l,e.extent,c):l,d=Mo({x:o+u.x,y:s+u.y},r,c);e.extent===`parent`&&(d=No(d,c,t));let f=Zs(e,i,a),p=t.internals.z??0;return{x:d.x,y:d.y,z:p>=f?p+1:f}}function $s(e,t,n,r=[0,0]){let i=[],a=new Map;for(let n of e){let e=t.get(n.parentId);if(!e)continue;let r=Vo(a.get(n.parentId)?.expandedRect??zo(e),n.rect);a.set(n.parentId,{expandedRect:r,parent:e})}return a.size>0&&a.forEach(({expandedRect:t,parent:a},o)=>{let s=a.internals.positionAbsolute,c=ns(a),l=a.origin??r,u=t.x0||d>0||m||h)&&(i.push({id:o,type:`position`,position:{x:a.position.x-u+m,y:a.position.y-d+h}}),n.get(o)?.forEach(t=>{e.some(e=>e.id===t.id)||i.push({id:t.id,type:`position`,position:{x:t.position.x+u,y:t.position.y+d}})})),(c.width0){let e=$s(f,t,n,i);l.push(...e)}return{changes:l,updatedInternals:c}}async function tc({delta:e,panZoom:t,transform:n,translateExtent:r,width:i,height:a}){if(!t||!e.x&&!e.y)return!1;let o=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[i,a]],r);return!!o&&(o.x!==n[0]||o.y!==n[1]||o.k!==n[2])}function nc(e,t,n,r,i,a){let o=i,s=r.get(o)||new Map;r.set(o,s.set(n,t)),o=`${i}-${e}`;let c=r.get(o)||new Map;if(r.set(o,c.set(n,t)),a){o=`${i}-${e}-${a}`;let s=r.get(o)||new Map;r.set(o,s.set(n,t))}}function rc(e,t,n){e.clear(),t.clear();for(let r of n){let{source:n,target:i,sourceHandle:a=null,targetHandle:o=null}=r,s={edgeId:r.id,source:n,target:i,sourceHandle:a,targetHandle:o},c=`${n}-${a}--${i}-${o}`;nc(`source`,s,`${i}-${o}--${n}-${a}`,e,n,a),nc(`target`,s,c,e,i,o),t.set(r.id,r)}}function ic(e,t){if(!e.parentId)return!1;let n=t.get(e.parentId);return n?n.selected?!0:ic(n,t):!1}function ac(e,t,n){let r=e;do{if(r?.matches?.(t))return!0;if(r===n)return!1;r=r?.parentElement}while(r);return!1}function oc(e,t,n,r){let i=new Map;for(let[a,o]of e)if((o.selected||o.id===r)&&(!o.parentId||!ic(o,e))&&(o.draggable||t&&o.draggable===void 0)){let t=e.get(a);t&&i.set(a,{id:a,position:t.position||{x:0,y:0},distance:{x:n.x-t.internals.positionAbsolute.x,y:n.y-t.internals.positionAbsolute.y},extent:t.extent,parentId:t.parentId,origin:t.origin,expandParent:t.expandParent,internals:{positionAbsolute:t.internals.positionAbsolute||{x:0,y:0}},measured:{width:t.measured.width??0,height:t.measured.height??0}})}return i}function sc({nodeId:e,dragItems:t,nodeLookup:n,dragging:r=!0}){let i=[];for(let[e,a]of t){let t=n.get(e)?.internals.userNode;t&&i.push({...t,position:a.position,dragging:r})}if(!e)return[i[0],i];let a=n.get(e)?.internals.userNode;return[a?{...a,position:t.get(e)?.position||a.position,dragging:r}:i[0],i]}function cc({dragItems:e,snapGrid:t,x:n,y:r}){let i=e.values().next().value;if(!i)return null;let a={x:n-i.distance.x,y:r-i.distance.y},o=qo(a,t);return{x:o.x-a.x,y:o.y-a.y}}function lc({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:r,onDragStop:i}){let a={x:null,y:null},o=0,s=new Map,c=!1,l={x:0,y:0},u=null,d=!1,f=null,p=!1,m=!1,h=null;function g({noDragClassName:g,handleSelector:_,domNode:v,isSelectable:y,nodeId:b,nodeClickDistance:x=0}){f=On(v);function S({x:e,y:n}){let{nodeLookup:i,nodeExtent:o,snapGrid:c,snapToGrid:l,nodeOrigin:u,onNodeDrag:d,onSelectionDrag:f,onError:p,updateNodePositions:g}=t();a={x:e,y:n};let _=!1,v=s.size>1,y=v&&o?Lo(wo(s)):null,x=v&&l?cc({dragItems:s,snapGrid:c,x:e,y:n}):null;for(let[t,r]of s){if(!i.has(t))continue;let a={x:e-r.distance.x,y:n-r.distance.y};l&&(a=x?{x:Math.round(a.x+x.x),y:Math.round(a.y+x.y)}:qo(a,c));let s=null;if(v&&o&&!r.extent&&y){let{positionAbsolute:e}=r.internals,t=e.x-y.x+o[0][0],n=e.x+r.measured.width-y.x2+o[1][0],i=e.y-y.y+o[0][1],a=e.y+r.measured.height-y.y2+o[1][1];s=[[t,i],[n,a]]}let{position:d,positionAbsolute:f}=ko({nodeId:t,nextPosition:a,nodeLookup:i,nodeExtent:s||o,nodeOrigin:u,onError:p});_=_||r.position.x!==d.x||r.position.y!==d.y,r.position=d,r.internals.positionAbsolute=f}if(m||=_,_&&(g(s,!0),h&&(r||d||!b&&f))){let[e,t]=sc({nodeId:b,dragItems:s,nodeLookup:i});r?.(h,s,e,t),d?.(h,e,t),b||f?.(h,t)}}async function C(){if(!u)return;let{transform:e,panBy:n,autoPanSpeed:r,autoPanOnNodeDrag:i}=t();if(!i){c=!1,cancelAnimationFrame(o);return}let[s,d]=Fo(l,u,r);(s!==0||d!==0)&&(a.x=(a.x??0)-s/e[2],a.y=(a.y??0)-d/e[2],await n({x:s,y:d})&&S(a)),o=requestAnimationFrame(C)}function w(r){let{nodeLookup:i,multiSelectionActive:o,nodesDraggable:c,transform:l,snapGrid:f,snapToGrid:p,selectNodesOnDrag:m,onNodeDragStart:h,onSelectionDragStart:g,unselectNodesAndEdges:_}=t();d=!0,(!m||!y)&&!o&&b&&(i.get(b)?.selected||_()),y&&m&&b&&e?.(b);let v=cs(r.sourceEvent,{transform:l,snapGrid:f,snapToGrid:p,containerBounds:u});if(a=v,s=oc(i,c,v,b),s.size>0&&(n||h||!b&&g)){let[e,t]=sc({nodeId:b,dragItems:s,nodeLookup:i});n?.(r.sourceEvent,s,e,t),h?.(r.sourceEvent,e,t),b||g?.(r.sourceEvent,t)}}let T=Un().clickDistance(x).on(`start`,e=>{let{domNode:n,nodeDragThreshold:r,transform:i,snapGrid:o,snapToGrid:s}=t();u=n?.getBoundingClientRect()||null,p=!1,m=!1,h=e.sourceEvent,r===0&&w(e),a=cs(e.sourceEvent,{transform:i,snapGrid:o,snapToGrid:s,containerBounds:u}),l=ms(e.sourceEvent,u)}).on(`drag`,e=>{let{autoPanOnNodeDrag:n,transform:r,snapGrid:i,snapToGrid:o,nodeDragThreshold:f,nodeLookup:m}=t(),g=cs(e.sourceEvent,{transform:r,snapGrid:i,snapToGrid:o,containerBounds:u});if(h=e.sourceEvent,(e.sourceEvent.type===`touchmove`&&e.sourceEvent.touches.length>1||b&&!m.has(b))&&(p=!0),!p){if(!c&&n&&d&&(c=!0,C()),!d){let t=ms(e.sourceEvent,u),n=t.x-l.x,r=t.y-l.y;Math.sqrt(n*n+r*r)>f&&w(e)}(a.x!==g.xSnapped||a.y!==g.ySnapped)&&s&&d&&(l=ms(e.sourceEvent,u),S(g))}}).on(`end`,e=>{if(!d||p){p&&s.size>0&&t().updateNodePositions(s,!1);return}if(c=!1,d=!1,cancelAnimationFrame(o),s.size>0){let{nodeLookup:n,updateNodePositions:r,onNodeDragStop:a,onSelectionDragStop:o}=t();if(m&&=(r(s,!1),!1),i||a||!b&&o){let[t,r]=sc({nodeId:b,dragItems:s,nodeLookup:n,dragging:!1});i?.(e.sourceEvent,s,t,r),a?.(e.sourceEvent,t,r),b||o?.(e.sourceEvent,r)}}}).filter(e=>{let t=e.target;return!e.button&&(!g||!ac(t,`.${g}`,v))&&(!_||ac(t,_,v))});f.call(T)}function _(){f?.on(`.drag`,null)}return{update:g,destroy:_}}function uc(e,t,n){let r=[],i={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(let e of t.values())Uo(i,zo(e))>0&&r.push(e);return r}var dc=250;function fc(e,t,n,r){let i=[],a=1/0,o=uc(e,n,t+dc);for(let n of o){let o=[...n.internals.handleBounds?.source??[],...n.internals.handleBounds?.target??[]];for(let s of o){if(r.nodeId===s.nodeId&&r.type===s.type&&r.id===s.id)continue;let{x:o,y:c}=Is(n,s,s.position,!0),l=Math.sqrt((o-e.x)**2+(c-e.y)**2);l>t||(l1){let e=r.type===`source`?`target`:`source`;return i.find(t=>t.type===e)??i[0]}return i[0]}function pc(e,t,n,r,i,a=!1){let o=r.get(e);if(!o)return null;let s=i===`strict`?o.internals.handleBounds?.[t]:[...o.internals.handleBounds?.source??[],...o.internals.handleBounds?.target??[]],c=(n?s?.find(e=>e.id===n):s?.[0])??null;return c&&a?{...c,...Is(o,c,c.position,!0)}:c}function mc(e,t){return e||(t?.classList.contains(`target`)?`target`:t?.classList.contains(`source`)?`source`:null)}function hc(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}var gc=()=>!0;function _c(e,{connectionMode:t,connectionRadius:n,handleId:r,nodeId:i,edgeUpdaterType:a,isTarget:o,domNode:s,nodeLookup:c,lib:l,autoPanOnConnect:u,flowId:d,panBy:f,cancelConnection:p,onConnectStart:m,onConnect:h,onConnectEnd:g,isValidConnection:_=gc,onReconnectEnd:v,updateConnection:y,getTransform:b,getFromHandle:x,autoPanSpeed:S,dragThreshold:C=1,handleDomNode:w}){let T=us(e.target),E=0,D,{x:O,y:k}=ms(e),A=mc(a,w),j=s?.getBoundingClientRect(),M=!1;if(!j||!A)return;let N=pc(i,A,r,c,t);if(!N)return;let P=ms(e,j),F=!1,I=null,L=!1,R=null;function z(){if(!u||!j)return;let[e,t]=Fo(P,j,S);f({x:e,y:t}),E=requestAnimationFrame(z)}let B={...N,nodeId:i,type:A,position:N.position},V=c.get(i),ee={inProgress:!0,isValid:null,from:Is(V,B,Z.Left,!0),fromHandle:B,fromPosition:B.position,fromNode:V,to:P,toHandle:null,toPosition:_o[B.position],toNode:null,pointer:P};function te(){M=!0,y(ee),m?.(e,{nodeId:i,handleId:r,handleType:A})}C===0&&te();function H(e){if(!M){let{x:t,y:n}=ms(e),r=t-O,i=n-k;if(!(r*r+i*i>C*C))return;te()}if(!x()||!B){U(e);return}let a=b();P=ms(e,j),D=fc(Jo(P,a,!1,[1,1]),n,c,B),F||=(z(),!0);let s=vc(e,{handle:D,connectionMode:t,fromNodeId:i,fromHandleId:r,fromType:o?`target`:`source`,isValidConnection:_,doc:T,lib:l,flowId:d,nodeLookup:c});R=s.handleDomNode,I=s.connection,L=hc(!!D,s.isValid);let u=c.get(i),f=u?Is(u,B,Z.Left,!0):ee.from,p={...ee,from:f,isValid:L,to:s.toHandle&&L?Yo({x:s.toHandle.x,y:s.toHandle.y},a):P,toHandle:s.toHandle,toPosition:L&&s.toHandle?s.toHandle.position:_o[B.position],toNode:s.toHandle?c.get(s.toHandle.nodeId):null,pointer:P};y(p),ee=p}function U(e){if(!(`touches`in e&&e.touches.length>0)){if(M){(D||R)&&I&&L&&h?.(I);let{inProgress:t,...n}=ee,r={...n,toPosition:ee.toHandle?ee.toPosition:null};g?.(e,r),a&&v?.(e,r)}p(),cancelAnimationFrame(E),F=!1,L=!1,I=null,R=null,T.removeEventListener(`mousemove`,H),T.removeEventListener(`mouseup`,U),T.removeEventListener(`touchmove`,H),T.removeEventListener(`touchend`,U)}}T.addEventListener(`mousemove`,H),T.addEventListener(`mouseup`,U),T.addEventListener(`touchmove`,H),T.addEventListener(`touchend`,U)}function vc(e,{handle:t,connectionMode:n,fromNodeId:r,fromHandleId:i,fromType:a,doc:o,lib:s,flowId:c,isValidConnection:l=gc,nodeLookup:u}){let d=a===`target`,f=t?o.querySelector(`.${s}-flow__handle[data-id="${c}-${t?.nodeId}-${t?.id}-${t?.type}"]`):null,{x:p,y:m}=ms(e),h=o.elementFromPoint(p,m),g=h?.classList.contains(`${s}-flow__handle`)?h:f,_={handleDomNode:g,isValid:!1,connection:null,toHandle:null};if(g){let e=mc(void 0,g),t=g.getAttribute(`data-nodeid`),a=g.getAttribute(`data-handleid`),o=g.classList.contains(`connectable`),s=g.classList.contains(`connectableend`);if(!t||!e)return _;let c={source:d?t:r,sourceHandle:d?a:i,target:d?r:t,targetHandle:d?i:a};_.connection=c,_.isValid=o&&s&&(n===uo.Strict?d&&e===`source`||!d&&e===`target`:t!==r||a!==i)&&l(c),_.toHandle=pc(t,e,a,u,n,!0)}return _}var yc={onPointerDown:_c,isValid:vc};function bc({domNode:e,panZoom:t,getTransform:n,getViewScale:r}){let i=On(e);function a({translateExtent:e,width:a,height:o,zoomStep:s=1,pannable:c=!0,zoomable:l=!0,inversePan:u=!1}){let d=e=>{if(e.sourceEvent.type!==`wheel`||!t)return;let r=n(),i=e.sourceEvent.ctrlKey&&es()?10:1,a=-e.sourceEvent.deltaY*(e.sourceEvent.deltaMode===1?.05:e.sourceEvent.deltaMode?1:.002)*s,o=r[2]*2**(a*i);t.scaleTo(o)},f=[0,0],p=ao().on(`start`,e=>{(e.sourceEvent.type===`mousedown`||e.sourceEvent.type===`touchstart`)&&(f=[e.sourceEvent.clientX??e.sourceEvent.touches[0].clientX,e.sourceEvent.clientY??e.sourceEvent.touches[0].clientY])}).on(`zoom`,c?i=>{let s=n();if(i.sourceEvent.type!==`mousemove`&&i.sourceEvent.type!==`touchmove`||!t)return;let c=[i.sourceEvent.clientX??i.sourceEvent.touches[0].clientX,i.sourceEvent.clientY??i.sourceEvent.touches[0].clientY],l=[c[0]-f[0],c[1]-f[1]];f=c;let d=r()*Math.max(s[2],Math.log(s[2]))*(u?-1:1),p={x:s[0]-l[0]*d,y:s[1]-l[1]*d},m=[[0,0],[a,o]];t.setViewportConstrained({x:p.x,y:p.y,zoom:s[2]},m,e)}:null).on(`zoom.wheel`,l?d:null);i.call(p,{})}function o(){i.on(`zoom`,null)}return{update:a,destroy:o,pointer:An}}var xc=e=>({x:e.x,y:e.y,zoom:e.k}),Sc=({x:e,y:t,zoom:n})=>Ya.translate(e,t).scale(n),Cc=(e,t)=>e.target.closest(`.${t}`),wc=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),Tc=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,Ec=(e,t=0,n=Tc,r=()=>{})=>{let i=typeof t==`number`&&t>0;return i||r(),i?e.transition().duration(t).ease(n).on(`end`,r):e},Dc=e=>{let t=e.ctrlKey&&es()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function Oc({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:r,panOnScrollMode:i,panOnScrollSpeed:a,zoomOnPinch:o,onPanZoomStart:s,onPanZoom:c,onPanZoomEnd:l}){return u=>{if(Cc(u,t))return u.ctrlKey&&u.preventDefault(),!1;u.preventDefault(),u.stopImmediatePropagation();let d=n.property(`__zoom`).k||1;if(u.ctrlKey&&o){let e=An(u),t=d*2**Dc(u);r.scaleTo(n,t,e,u);return}let f=u.deltaMode===1?20:1,p=i===fo.Vertical?0:u.deltaX*f,m=i===fo.Horizontal?0:u.deltaY*f;!es()&&u.shiftKey&&i!==fo.Vertical&&(p=u.deltaY*f,m=0),r.translateBy(n,-(p/d)*a,-(m/d)*a,{internal:!0});let h=xc(n.property(`__zoom`));clearTimeout(e.panScrollTimeout),e.isPanScrolling?(c?.(u,h),e.panScrollTimeout=setTimeout(()=>{l?.(u,h),e.isPanScrolling=!1},150)):(e.isPanScrolling=!0,s?.(u,h))}}function kc({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(r,i){let a=r.type===`wheel`,o=!t&&a&&!r.ctrlKey,s=Cc(r,e);if(r.ctrlKey&&a&&s&&r.preventDefault(),o||s)return null;r.preventDefault(),n.call(this,r,i)}}function Ac({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return r=>{if(r.sourceEvent?.internal)return;let i=xc(r.transform);e.mouseButton=r.sourceEvent?.button||0,e.isZoomingOrPanning=!0,e.prevViewport=i,r.sourceEvent?.type===`mousedown`&&t(!0),n&&n?.(r.sourceEvent,i)}}function jc({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:r,onPanZoom:i}){return a=>{e.usedRightMouseButton=!!(n&&wc(t,e.mouseButton??0)),a.sourceEvent?.sync||r([a.transform.x,a.transform.y,a.transform.k]),i&&!a.sourceEvent?.internal&&i?.(a.sourceEvent,xc(a.transform))}}function Mc({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:r,onPanZoomEnd:i,onPaneContextMenu:a}){return o=>{if(!o.sourceEvent?.internal&&(e.isZoomingOrPanning=!1,a&&wc(t,e.mouseButton??0)&&!e.usedRightMouseButton&&o.sourceEvent&&a(o.sourceEvent),e.usedRightMouseButton=!1,r(!1),i)){let t=xc(o.transform);e.prevViewport=t,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{i?.(o.sourceEvent,t)},n?150:0)}}}function Nc({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:n,panOnDrag:r,panOnScroll:i,zoomOnDoubleClick:a,userSelectionActive:o,noWheelClassName:s,noPanClassName:c,lib:l,connectionInProgress:u}){return d=>{let f=e||t,p=n&&d.ctrlKey,m=d.type===`wheel`;if(d.button===1&&d.type===`mousedown`&&(Cc(d,`${l}-flow__node`)||Cc(d,`${l}-flow__edge`)))return!0;if(!r&&!f&&!i&&!a&&!n||o||u&&!m||Cc(d,s)&&m||Cc(d,c)&&(!m||i&&m&&!e)||!n&&d.ctrlKey&&m)return!1;if(!n&&d.type===`touchstart`&&d.touches?.length>1)return d.preventDefault(),!1;if(!f&&!i&&!p&&m||!r&&(d.type===`mousedown`||d.type===`touchstart`)||Array.isArray(r)&&!r.includes(d.button)&&d.type===`mousedown`)return!1;let h=Array.isArray(r)&&r.includes(d.button)||!d.button||d.button<=1;return(!d.ctrlKey||m)&&h}}function Pc({domNode:e,minZoom:t,maxZoom:n,translateExtent:r,viewport:i,onPanZoom:a,onPanZoomStart:o,onPanZoomEnd:s,onDraggingChange:c}){let l={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},u=e.getBoundingClientRect(),d=ao().scaleExtent([t,n]).translateExtent(r),f=On(e).call(d);v({x:i.x,y:i.y,zoom:jo(i.zoom,t,n)},[[0,0],[u.width,u.height]],r);let p=f.on(`wheel.zoom`),m=f.on(`dblclick.zoom`);d.wheelDelta(Dc);async function h(e,t){return f?new Promise(n=>{d?.interpolate(t?.interpolate===`linear`?Kr:oi).transform(Ec(f,t?.duration,t?.ease,()=>n(!0)),e)}):!1}function g({noWheelClassName:e,noPanClassName:t,onPaneContextMenu:n,userSelectionActive:r,panOnScroll:i,panOnDrag:u,panOnScrollMode:h,panOnScrollSpeed:g,preventScrolling:v,zoomOnPinch:y,zoomOnScroll:b,zoomOnDoubleClick:x,zoomActivationKeyPressed:S,lib:C,onTransformChange:w,connectionInProgress:T,paneClickDistance:E,selectionOnDrag:D}){r&&!l.isZoomingOrPanning&&_();let O=i&&!S&&!r;d.clickDistance(D?1/0:!Go(E)||E<0?0:E);let k=O?Oc({zoomPanValues:l,noWheelClassName:e,d3Selection:f,d3Zoom:d,panOnScrollMode:h,panOnScrollSpeed:g,zoomOnPinch:y,onPanZoomStart:o,onPanZoom:a,onPanZoomEnd:s}):kc({noWheelClassName:e,preventScrolling:v,d3ZoomHandler:p});f.on(`wheel.zoom`,k,{passive:!1});let A=Ac({zoomPanValues:l,onDraggingChange:c,onPanZoomStart:o});d.on(`start`,A);let j=jc({zoomPanValues:l,panOnDrag:u,onPaneContextMenu:!!n,onPanZoom:a,onTransformChange:w});d.on(`zoom`,j);let M=Mc({zoomPanValues:l,panOnDrag:u,panOnScroll:i,onPaneContextMenu:n,onPanZoomEnd:s,onDraggingChange:c});d.on(`end`,M);let N=Nc({zoomActivationKeyPressed:S,panOnDrag:u,zoomOnScroll:b,panOnScroll:i,zoomOnDoubleClick:x,zoomOnPinch:y,userSelectionActive:r,noPanClassName:t,noWheelClassName:e,lib:C,connectionInProgress:T});d.filter(N),x?f.on(`dblclick.zoom`,m):f.on(`dblclick.zoom`,null)}function _(){d.on(`zoom`,null)}async function v(e,t,n){let r=Sc(e),i=d?.constrain()(r,t,n);return i&&await h(i),i}async function y(e,t){let n=Sc(e);return await h(n,t),n}function b(e){if(f){let t=Sc(e),n=f.property(`__zoom`);(n.k!==e.zoom||n.x!==e.x||n.y!==e.y)&&d?.transform(f,t,null,{sync:!0})}}function x(){let e=f?Xa(f.node()):{x:0,y:0,k:1};return{x:e.x,y:e.y,zoom:e.k}}async function S(e,t){return f?new Promise(n=>{d?.interpolate(t?.interpolate===`linear`?Kr:oi).scaleTo(Ec(f,t?.duration,t?.ease,()=>n(!0)),e)}):!1}async function C(e,t){return f?new Promise(n=>{d?.interpolate(t?.interpolate===`linear`?Kr:oi).scaleBy(Ec(f,t?.duration,t?.ease,()=>n(!0)),e)}):!1}function w(e){d?.scaleExtent(e)}function T(e){d?.translateExtent(e)}function E(e){let t=!Go(e)||e<0?0:e;d?.clickDistance(t)}return{update:g,destroy:_,setViewport:y,setViewportConstrained:v,getViewport:x,scaleTo:S,scaleBy:C,setScaleExtent:w,setTranslateExtent:T,syncViewport:b,setClickDistance:E}}var Fc;(function(e){e.Line=`line`,e.Handle=`handle`})(Fc||={});function Ic({width:e,prevWidth:t,height:n,prevHeight:r,affectsX:i,affectsY:a}){let o=e-t,s=n-r,c=[o>0?1:o<0?-1:0,s>0?1:s<0?-1:0];return o&&i&&(c[0]*=-1),s&&a&&(c[1]*=-1),c}function Lc(e){return{isHorizontal:e.includes(`right`)||e.includes(`left`),isVertical:e.includes(`bottom`)||e.includes(`top`),affectsX:e.includes(`left`),affectsY:e.includes(`top`)}}function Rc(e,t){return Math.max(0,t-e)}function zc(e,t){return Math.max(0,e-t)}function Bc(e,t,n){return Math.max(0,t-e,e-n)}function Vc(e,t){return e?!t:t}function Hc(e,t,n,r,i,a,o,s){let{affectsX:c,affectsY:l}=t,{isHorizontal:u,isVertical:d}=t,f=u&&d,{xSnapped:p,ySnapped:m}=n,{minWidth:h,maxWidth:g,minHeight:_,maxHeight:v}=r,{x:y,y:b,width:x,height:S,aspectRatio:C}=e,w=Math.floor(u?p-e.pointerX:0),T=Math.floor(d?m-e.pointerY:0),E=x+(c?-w:w),D=S+(l?-T:T),O=-a[0]*x,k=-a[1]*S,A=Bc(E,h,g),j=Bc(D,_,v);if(o){let e=0,t=0;c&&w<0?e=Rc(y+w+O,o[0][0]):!c&&w>0&&(e=zc(y+E+O,o[1][0])),l&&T<0?t=Rc(b+T+k,o[0][1]):!l&&T>0&&(t=zc(b+D+k,o[1][1])),A=Math.max(A,e),j=Math.max(j,t)}if(s){let e=0,t=0;c&&w>0?e=zc(y+w,s[0][0]):!c&&w<0&&(e=Rc(y+E,s[1][0])),l&&T>0?t=zc(b+T,s[0][1]):!l&&T<0&&(t=Rc(b+D,s[1][1])),A=Math.max(A,e),j=Math.max(j,t)}if(i){if(u){let e=Bc(E/C,_,v)*C;if(A=Math.max(A,e),o){let e=0;e=!c&&!l||c&&!l&&f?zc(b+k+E/C,o[1][1])*C:Rc(b+k+(c?w:-w)/C,o[0][1])*C,A=Math.max(A,e)}if(s){let e=0;e=!c&&!l||c&&!l&&f?Rc(b+E/C,s[1][1])*C:zc(b+(c?w:-w)/C,s[0][1])*C,A=Math.max(A,e)}}if(d){let e=Bc(D*C,h,g)/C;if(j=Math.max(j,e),o){let e=0;e=!c&&!l||l&&!c&&f?zc(y+D*C+O,o[1][0])/C:Rc(y+(l?T:-T)*C+O,o[0][0])/C,j=Math.max(j,e)}if(s){let e=0;e=!c&&!l||l&&!c&&f?Rc(y+D*C,s[1][0])/C:zc(y+(l?T:-T)*C,s[0][0])/C,j=Math.max(j,e)}}}T+=T<0?j:-j,w+=w<0?A:-A,i&&(f?E>D*C?T=(Vc(c,l)?-w:w)/C:w=(Vc(c,l)?-T:T)*C:u?(T=w/C,l=c):(w=T*C,c=l));let M=c?y+w:y,N=l?b+T:b;return{width:x+(c?-w:w),height:S+(l?-T:T),x:a[0]*w*(c?-1:1)+M,y:a[1]*T*(l?-1:1)+N}}var Uc={width:0,height:0,x:0,y:0},Wc={...Uc,pointerX:0,pointerY:0,aspectRatio:1};function Gc(e,t,n){let r=t.position.x+e.position.x,i=t.position.y+e.position.y,a=e.measured.width??0,o=e.measured.height??0,s=n[0]*a,c=n[1]*o;return[[r-s,i-c],[r+a-s,i+o-c]]}function Kc({domNode:e,nodeId:t,getStoreItems:n,onChange:r,onEnd:i}){let a=On(e),o={controlDirection:Lc(`bottom-right`),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function s({controlPosition:e,boundaries:s,keepAspectRatio:c,resizeDirection:l,onResizeStart:u,onResize:d,onResizeEnd:f,shouldResize:p}){let m={...Uc},h={...Wc};o={boundaries:s,resizeDirection:l,keepAspectRatio:c,controlDirection:Lc(e)};let g,_=null,v=[],y,b,x,S=!1,C=Un().on(`start`,e=>{let{nodeLookup:r,transform:i,snapGrid:a,snapToGrid:o,nodeOrigin:s,paneDomNode:c}=n();if(g=r.get(t),!g)return;_=c?.getBoundingClientRect()??null;let{xSnapped:l,ySnapped:d}=cs(e.sourceEvent,{transform:i,snapGrid:a,snapToGrid:o,containerBounds:_});m={width:g.measured.width??0,height:g.measured.height??0,x:g.position.x??0,y:g.position.y??0},h={...m,pointerX:l,pointerY:d,aspectRatio:m.width/m.height},y=void 0,b=ts(g.extent)?g.extent:void 0,g.parentId&&(g.extent===`parent`||g.expandParent)&&(y=r.get(g.parentId)),y&&g.extent===`parent`&&(b=[[0,0],[y.measured.width,y.measured.height]]),v=[],x=void 0;for(let[e,n]of r)if(n.parentId===t&&(v.push({id:e,position:{...n.position},extent:n.extent}),n.extent===`parent`||n.expandParent)){let e=Gc(n,g,n.origin??s);x=x?[[Math.min(e[0][0],x[0][0]),Math.min(e[0][1],x[0][1])],[Math.max(e[1][0],x[1][0]),Math.max(e[1][1],x[1][1])]]:e}u?.(e,{...m})}).on(`drag`,e=>{let{transform:t,snapGrid:i,snapToGrid:a,nodeOrigin:s}=n(),c=cs(e.sourceEvent,{transform:t,snapGrid:i,snapToGrid:a,containerBounds:_}),l=[];if(!g)return;let{x:u,y:f,width:C,height:w}=m,T={},E=g.origin??s,{width:D,height:O,x:k,y:A}=Hc(h,o.controlDirection,c,o.boundaries,o.keepAspectRatio,E,b,x),j=D!==C,M=O!==w,N=k!==u&&j,P=A!==f&&M;if(!N&&!P&&!j&&!M)return;if((N||P||E[0]===1||E[1]===1)&&(T.x=N?k:m.x,T.y=P?A:m.y,m.x=T.x,m.y=T.y,v.length>0)){let e=k-u,t=A-f;for(let n of v)n.position={x:n.position.x-e+E[0]*(D-C),y:n.position.y-t+E[1]*(O-w)},l.push(n)}if((j||M)&&(T.width=j&&(!o.resizeDirection||o.resizeDirection===`horizontal`)?D:m.width,T.height=M&&(!o.resizeDirection||o.resizeDirection===`vertical`)?O:m.height,m.width=T.width,m.height=T.height),y&&g.expandParent){let e=E[0]*(T.width??0);T.x&&T.x{S&&=(f?.(e,{...m}),i?.({...m}),!1)});a.call(C)}function c(){a.on(`.drag`,null)}return{update:s,destroy:c}}var qc=t((e=>{var t=n();function r(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var i=typeof Object.is==`function`?Object.is:r,a=t.useState,o=t.useEffect,s=t.useLayoutEffect,c=t.useDebugValue;function l(e,t){var n=t(),r=a({inst:{value:n,getSnapshot:t}}),i=r[0].inst,l=r[1];return s(function(){i.value=n,i.getSnapshot=t,u(i)&&l({inst:i})},[e,n,t]),o(function(){return u(i)&&l({inst:i}),e(function(){u(i)&&l({inst:i})})},[e]),c(n),n}function u(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!i(e,n)}catch{return!0}}function d(e,t){return t()}var f=typeof window>`u`||window.document===void 0||window.document.createElement===void 0?d:l;e.useSyncExternalStore=t.useSyncExternalStore===void 0?f:t.useSyncExternalStore})),Jc=t(((e,t)=>{t.exports=qc()})),Yc=t((e=>{var t=n(),r=Jc();function i(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var a=typeof Object.is==`function`?Object.is:i,o=r.useSyncExternalStore,s=t.useRef,c=t.useEffect,l=t.useMemo,u=t.useDebugValue;e.useSyncExternalStoreWithSelector=function(e,t,n,r,i){var d=s(null);if(d.current===null){var f={hasValue:!1,value:null};d.current=f}else f=d.current;d=l(function(){function e(e){if(!o){if(o=!0,s=e,e=r(e),i!==void 0&&f.hasValue){var t=f.value;if(i(t,e))return c=t}return c=e}if(t=c,a(s,e))return t;var n=r(e);return i!==void 0&&i(t,n)?(s=e,t):(s=e,c=n)}var o=!1,s,c,l=n===void 0?null:n;return[function(){return e(t())},l===null?void 0:function(){return e(l())}]},[t,n,r,i]);var p=o(e,d[0],d[1]);return c(function(){f.hasValue=!0,f.value=p},[p]),u(p),p}})),Xc=e(t(((e,t)=>{t.exports=Yc()}))(),1),Zc=e=>{let t,n=new Set,r=(e,r)=>{let i=typeof e==`function`?e(t):e;if(!Object.is(i,t)){let e=t;t=r??(typeof i!=`object`||!i)?i:Object.assign({},t,i),n.forEach(n=>n(t,e))}},i=()=>t,a={setState:r,getState:i,getInitialState:()=>o,subscribe:e=>(n.add(e),()=>n.delete(e)),destroy:()=>{n.clear()}},o=t=e(r,i,a);return a},Qc=e=>e?Zc(e):Zc,{useDebugValue:$c}=Y.default,{useSyncExternalStoreWithSelector:el}=Xc.default,tl=e=>e;function nl(e,t=tl,n){let r=el(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return $c(r),r}var rl=(e,t)=>{let n=Qc(e),r=(e,r=t)=>nl(n,e,r);return Object.assign(r,n),r},il=(e,t)=>e?rl(e,t):rl;function al(e,t){if(Object.is(e,t))return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(let[n,r]of e)if(!Object.is(r,t.get(n)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}let n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let r of n)if(!Object.prototype.hasOwnProperty.call(t,r)||!Object.is(e[r],t[r]))return!1;return!0}var ol=(0,Y.createContext)(null),sl=ol.Provider,cl=oo.error001(`react`);function Q(e,t){let n=(0,Y.useContext)(ol);if(n===null)throw Error(cl);return nl(n,e,t)}function $(){let e=(0,Y.useContext)(ol);if(e===null)throw Error(cl);return(0,Y.useMemo)(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}var ll={display:`none`},ul={position:`absolute`,width:1,height:1,margin:-1,border:0,padding:0,overflow:`hidden`,clip:`rect(0px, 0px, 0px, 0px)`,clipPath:`inset(100%)`},dl=`react-flow__node-desc`,fl=`react-flow__edge-desc`,pl=`react-flow__aria-live`,ml=e=>e.ariaLiveMessage,hl=e=>e.ariaLabelConfig;function gl({rfId:e}){let t=Q(ml);return(0,J.jsx)(`div`,{id:`${pl}-${e}`,"aria-live":`assertive`,"aria-atomic":`true`,style:ul,children:t})}function _l({rfId:e,disableKeyboardA11y:t}){let n=Q(hl);return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{id:`${dl}-${e}`,style:ll,children:t?n[`node.a11yDescription.default`]:n[`node.a11yDescription.keyboardDisabled`]}),(0,J.jsx)(`div`,{id:`${fl}-${e}`,style:ll,children:n[`edge.a11yDescription.default`]}),!t&&(0,J.jsx)(gl,{rfId:e})]})}var vl=(0,Y.forwardRef)(({position:e=`top-left`,children:t,className:n,style:r,...i},a)=>{let o=`${e}`.split(`-`);return(0,J.jsx)(`div`,{className:Se([`react-flow__panel`,n,...o]),style:r,ref:a,...i,children:t})});vl.displayName=`Panel`;var yl=`https://reactflow.dev?utm_source=attribution`;function bl({proOptions:e,position:t=`bottom-right`}){return e?.hideAttribution?null:(0,J.jsx)(vl,{position:t,className:`react-flow__attribution`,"data-message":`Please only hide this attribution when you are subscribed to React Flow Pro: ${yl}`,children:(0,J.jsx)(`a`,{href:yl,target:`_blank`,rel:`noopener noreferrer`,"aria-label":`React Flow attribution`,children:`React Flow`})})}var xl=e=>{let t=[],n=[];for(let[,n]of e.nodeLookup)n.selected&&t.push(n.internals.userNode);for(let[,t]of e.edgeLookup)t.selected&&n.push(t);return{selectedNodes:t,selectedEdges:n}},Sl=e=>e.id;function Cl(e,t){return al(e.selectedNodes.map(Sl),t.selectedNodes.map(Sl))&&al(e.selectedEdges.map(Sl),t.selectedEdges.map(Sl))}function wl({onSelectionChange:e}){let t=$(),{selectedNodes:n,selectedEdges:r}=Q(xl,Cl);return(0,Y.useEffect)(()=>{let i={nodes:n,edges:r};e?.(i),t.getState().onSelectionChangeHandlers.forEach(e=>e(i))},[n,r,e]),null}var Tl=e=>!!e.onSelectionChangeHandlers;function El({onSelectionChange:e}){let t=Q(Tl);return e||t?(0,J.jsx)(wl,{onSelectionChange:e}):null}var Dl=[0,0],Ol={x:0,y:0,zoom:1},kl=[...`nodes.edges.defaultNodes.defaultEdges.onConnect.onConnectStart.onConnectEnd.onClickConnectStart.onClickConnectEnd.nodesDraggable.autoPanOnNodeFocus.nodesConnectable.nodesFocusable.edgesFocusable.edgesReconnectable.elevateNodesOnSelect.elevateEdgesOnSelect.minZoom.maxZoom.nodeExtent.onNodesChange.onEdgesChange.elementsSelectable.connectionMode.snapGrid.snapToGrid.translateExtent.connectOnClick.defaultEdgeOptions.fitView.fitViewOptions.onNodesDelete.onEdgesDelete.onDelete.onNodeDrag.onNodeDragStart.onNodeDragStop.onSelectionDrag.onSelectionDragStart.onSelectionDragStop.onMoveStart.onMove.onMoveEnd.noPanClassName.nodeOrigin.autoPanOnConnect.autoPanOnNodeDrag.onError.connectionRadius.isValidConnection.selectNodesOnDrag.nodeDragThreshold.connectionDragThreshold.onBeforeDelete.debug.autoPanSpeed.ariaLabelConfig.zIndexMode`.split(`.`),`rfId`],Al=e=>({setNodes:e.setNodes,setEdges:e.setEdges,setMinZoom:e.setMinZoom,setMaxZoom:e.setMaxZoom,setTranslateExtent:e.setTranslateExtent,setNodeExtent:e.setNodeExtent,reset:e.reset,setDefaultNodesAndEdges:e.setDefaultNodesAndEdges}),jl={translateExtent:so,nodeOrigin:Dl,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:`nopan`,rfId:`1`};function Ml(e){let{setNodes:t,setEdges:n,setMinZoom:r,setMaxZoom:i,setTranslateExtent:a,setNodeExtent:o,reset:s,setDefaultNodesAndEdges:c}=Q(Al,al),l=$();(0,Y.useEffect)(()=>(c(e.defaultNodes,e.defaultEdges),()=>{u.current=jl,s()}),[]);let u=(0,Y.useRef)(jl);return(0,Y.useEffect)(()=>{for(let s of kl){let c=e[s];c!==u.current[s]&&e[s]!==void 0&&(s===`nodes`?t(c):s===`edges`?n(c):s===`minZoom`?r(c):s===`maxZoom`?i(c):s===`translateExtent`?a(c):s===`nodeExtent`?o(c):s===`ariaLabelConfig`?l.setState({ariaLabelConfig:ss(c)}):s===`fitView`?l.setState({fitViewQueued:c}):s===`fitViewOptions`?l.setState({fitViewOptions:c}):l.setState({[s]:c}))}u.current=e},kl.map(t=>e[t])),null}function Nl(){return typeof window>`u`||!window.matchMedia?null:window.matchMedia(`(prefers-color-scheme: dark)`)}function Pl(e){let[t,n]=(0,Y.useState)(e===`system`?null:e);return(0,Y.useEffect)(()=>{if(e!==`system`){n(e);return}let t=Nl(),r=()=>n(t?.matches?`dark`:`light`);return r(),t?.addEventListener(`change`,r),()=>{t?.removeEventListener(`change`,r)}},[e]),t===null?Nl()?.matches?`dark`:`light`:t}var Fl=typeof document<`u`?document:null;function Il(e=null,t={target:Fl,actInsideInputWithModifier:!0}){let[n,r]=(0,Y.useState)(!1),i=(0,Y.useRef)(!1),a=(0,Y.useRef)(new Set([])),[o,s]=(0,Y.useMemo)(()=>{if(e!==null){let t=(Array.isArray(e)?e:[e]).filter(e=>typeof e==`string`).map(e=>e.replace(`+`,` +`).replace(` + +`,` ++`).split(` +`));return[t,t.reduce((e,t)=>e.concat(...t),[])]}return[[],[]]},[e]);return(0,Y.useEffect)(()=>{let n=t?.target??Fl,c=t?.actInsideInputWithModifier??!0;if(e!==null){let e=e=>{if(i.current=e.ctrlKey||e.metaKey||e.shiftKey||e.altKey,(!i.current||i.current&&!c)&&fs(e))return!1;let n=Rl(e.code,s);if(a.current.add(e[n]),Ll(o,a.current,!1)){let n=e.composedPath?.()?.[0]||e.target,a=n?.nodeName===`BUTTON`||n?.nodeName===`A`;t.preventDefault!==!1&&(i.current||!a)&&e.preventDefault(),r(!0)}},l=e=>{let t=Rl(e.code,s);Ll(o,a.current,!0)?(r(!1),a.current.clear()):a.current.delete(e[t]),e.key===`Meta`&&a.current.clear(),i.current=!1},u=()=>{a.current.clear(),r(!1)};return n?.addEventListener(`keydown`,e),n?.addEventListener(`keyup`,l),window.addEventListener(`blur`,u),window.addEventListener(`contextmenu`,u),()=>{n?.removeEventListener(`keydown`,e),n?.removeEventListener(`keyup`,l),window.removeEventListener(`blur`,u),window.removeEventListener(`contextmenu`,u)}}},[e,r]),n}function Ll(e,t,n){return e.filter(e=>n||e.length===t.size).some(e=>e.every(e=>t.has(e)))}function Rl(e,t){return t.includes(e)?`code`:`key`}var zl=()=>{let e=$();return(0,Y.useMemo)(()=>({zoomIn:async t=>{let{panZoom:n}=e.getState();return n?n.scaleBy(1.2,t):!1},zoomOut:async t=>{let{panZoom:n}=e.getState();return n?n.scaleBy(1/1.2,t):!1},zoomTo:async(t,n)=>{let{panZoom:r}=e.getState();return r?r.scaleTo(t,n):!1},getZoom:()=>e.getState().transform[2],setViewport:async(t,n)=>{let{transform:[r,i,a],panZoom:o}=e.getState();return o?(await o.setViewport({x:t.x??r,y:t.y??i,zoom:t.zoom??a},n),!0):!1},getViewport:()=>{let[t,n,r]=e.getState().transform;return{x:t,y:n,zoom:r}},setCenter:async(t,n,r)=>e.getState().setCenter(t,n,r),fitBounds:async(t,n)=>{let{width:r,height:i,minZoom:a,maxZoom:o,panZoom:s}=e.getState(),c=$o(t,r,i,a,o,n?.padding??.1);return s?(await s.setViewport(c,{duration:n?.duration,ease:n?.ease,interpolate:n?.interpolate}),!0):!1},screenToFlowPosition:(t,n={})=>{let{transform:r,snapGrid:i,snapToGrid:a,domNode:o}=e.getState();if(!o)return t;let{x:s,y:c}=o.getBoundingClientRect(),l={x:t.x-s,y:t.y-c},u=n.snapGrid??i;return Jo(l,r,n.snapToGrid??a,u)},flowToScreenPosition:t=>{let{transform:n,domNode:r}=e.getState();if(!r)return t;let{x:i,y:a}=r.getBoundingClientRect(),o=Yo(t,n);return{x:o.x+i,y:o.y+a}}}),[])};function Bl(e,t){let n=[],r=new Map,i=[];for(let t of e)if(t.type===`add`){i.push(t);continue}else if(t.type===`remove`||t.type===`replace`)r.set(t.id,[t]);else{let e=r.get(t.id);e?e.push(t):r.set(t.id,[t])}for(let e of t){let t=r.get(e.id);if(!t){n.push(e);continue}if(t[0].type===`remove`)continue;if(t[0].type===`replace`){n.push({...t[0].item});continue}let i={...e};for(let e of t)Vl(e,i);n.push(i)}return i.length&&i.forEach(e=>{e.index===void 0?n.push({...e.item}):n.splice(e.index,0,{...e.item})}),n}function Vl(e,t){switch(e.type){case`select`:t.selected=e.selected;break;case`position`:e.position!==void 0&&(t.position=e.position),e.dragging!==void 0&&(t.dragging=e.dragging);break;case`dimensions`:e.dimensions!==void 0&&(t.measured={...e.dimensions},e.setAttributes&&((e.setAttributes===!0||e.setAttributes===`width`)&&(t.width=e.dimensions.width),(e.setAttributes===!0||e.setAttributes===`height`)&&(t.height=e.dimensions.height))),typeof e.resizing==`boolean`&&(t.resizing=e.resizing)}}function Hl(e,t){return Bl(e,t)}function Ul(e,t){return Bl(e,t)}function Wl(e,t){return{id:e,type:`select`,selected:t}}function Gl(e,t=new Set,n=!1){let r=[];for(let[i,a]of e){let e=t.has(i);!(a.selected===void 0&&!e)&&a.selected!==e&&(n&&(a.selected=e),r.push(Wl(a.id,e)))}return r}function Kl({items:e=[],lookup:t}){let n=[],r=new Map(e.map(e=>[e.id,e]));for(let[r,i]of e.entries()){let e=t.get(i.id),a=e?.internals?.userNode??e;a!==void 0&&a!==i&&n.push({id:i.id,item:i,type:`replace`}),a===void 0&&n.push({item:i,type:`add`,index:r})}for(let[e]of t)r.get(e)===void 0&&n.push({id:e,type:`remove`});return n}function ql(e){return{id:e.id,type:`remove`}}var Jl=Ko(`React Flow`,`https://reactflow.dev/`);function Yl(e,t,n={}){return Ts(e,t,{...n,onError:n.onError??Jl})}var Xl=e=>bo(e),Zl=e=>yo(e);function Ql(e){return(0,Y.forwardRef)(e)}var $l=typeof window<`u`?Y.useLayoutEffect:Y.useEffect;function eu(e){let[t,n]=(0,Y.useState)(BigInt(0)),[r]=(0,Y.useState)(()=>tu(()=>n(e=>e+BigInt(1))));return $l(()=>{let t=r.get();t.length&&(e(t),r.reset())},[t]),r}function tu(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}var nu=(0,Y.createContext)(null);function ru({children:e}){let t=$(),n=eu((0,Y.useCallback)(e=>{let{nodes:n=[],setNodes:r,hasDefaultNodes:i,onNodesChange:a,nodeLookup:o,fitViewQueued:s,onNodesChangeMiddlewareMap:c}=t.getState(),l=n;for(let t of e)l=typeof t==`function`?t(l):t;let u=Kl({items:l,lookup:o});for(let e of c.values())u=e(u);i&&r(l),u.length>0?a?.(u):s&&window.requestAnimationFrame(()=>{let{fitViewQueued:e,nodes:n,setNodes:r}=t.getState();e&&r(n)})},[])),r=eu((0,Y.useCallback)(e=>{let{edges:n=[],setEdges:r,hasDefaultEdges:i,onEdgesChange:a,edgeLookup:o}=t.getState(),s=n;for(let t of e)s=typeof t==`function`?t(s):t;i?r(s):a&&a(Kl({items:s,lookup:o}))},[])),i=(0,Y.useMemo)(()=>({nodeQueue:n,edgeQueue:r}),[]);return(0,J.jsx)(nu.Provider,{value:i,children:e})}function iu(){let e=(0,Y.useContext)(nu);if(!e)throw Error(`useBatchContext must be used within a BatchProvider`);return e}var au=e=>!!e.panZoom;function ou(){let e=zl(),t=$(),n=iu(),r=Q(au),i=(0,Y.useMemo)(()=>{let e=e=>t.getState().nodeLookup.get(e),r=e=>{n.nodeQueue.push(e)},i=e=>{n.edgeQueue.push(e)},a=e=>{let{nodeLookup:n,nodeOrigin:r}=t.getState(),i=Xl(e)?e:n.get(e.id),a=i.parentId?is(i.position,i.measured,i.parentId,n,r):i.position;return zo({...i,position:a,width:i.measured?.width??i.width,height:i.measured?.height??i.height})},o=(e,t,n={replace:!1})=>{r(r=>r.map(r=>{if(r.id===e){let e=typeof t==`function`?t(r):t;return n.replace&&Xl(e)?e:{...r,...e}}return r}))},s=(e,t,n={replace:!1})=>{i(r=>r.map(r=>{if(r.id===e){let e=typeof t==`function`?t(r):t;return n.replace&&Zl(e)?e:{...r,...e}}return r}))};return{getNodes:()=>t.getState().nodes.map(e=>({...e})),getNode:t=>e(t)?.internals.userNode,getInternalNode:e,getEdges:()=>{let{edges:e=[]}=t.getState();return e.map(e=>({...e}))},getEdge:e=>t.getState().edgeLookup.get(e),setNodes:r,setEdges:i,addNodes:e=>{let t=Array.isArray(e)?e:[e];n.nodeQueue.push(e=>[...e,...t])},addEdges:e=>{let t=Array.isArray(e)?e:[e];n.edgeQueue.push(e=>[...e,...t])},toObject:()=>{let{nodes:e=[],edges:n=[],transform:r}=t.getState(),[i,a,o]=r;return{nodes:e.map(e=>({...e})),edges:n.map(e=>({...e})),viewport:{x:i,y:a,zoom:o}}},deleteElements:async({nodes:e=[],edges:n=[]})=>{let{nodes:r,edges:i,onNodesDelete:a,onEdgesDelete:o,triggerNodeChanges:s,triggerEdgeChanges:c,onDelete:l,onBeforeDelete:u}=t.getState(),{nodes:d,edges:f}=await Ao({nodesToRemove:e,edgesToRemove:n,nodes:r,edges:i,onBeforeDelete:u}),p=f.length>0,m=d.length>0;if(p){let e=f.map(ql);o?.(f),c(e)}if(m){let e=d.map(ql);a?.(d),s(e)}return(m||p)&&l?.({nodes:d,edges:f}),{deletedNodes:d,deletedEdges:f}},getIntersectingNodes:(e,n=!0,r)=>{let i=Wo(e),o=i?e:a(e),s=r!==void 0;return o?(r||t.getState().nodes).filter(r=>{let a=t.getState().nodeLookup.get(r.id);if(a&&!i&&(r.id===e.id||!a.internals.positionAbsolute))return!1;let c=zo(s?r:a),l=Uo(c,o);return n&&l>0||l>=c.width*c.height||l>=o.width*o.height}):[]},isNodeIntersecting:(e,t,n=!0)=>{let r=Wo(e)?e:a(e);if(!r)return!1;let i=Uo(r,t);return n&&i>0||i>=t.width*t.height||i>=r.width*r.height},updateNode:o,updateNodeData:(e,t,n={replace:!1})=>{o(e,e=>{let r=typeof t==`function`?t(e):t;return n.replace?{...e,data:r}:{...e,data:{...e.data,...r}}},n)},updateEdge:s,updateEdgeData:(e,t,n={replace:!1})=>{s(e,e=>{let r=typeof t==`function`?t(e):t;return n.replace?{...e,data:r}:{...e,data:{...e.data,...r}}},n)},getNodesBounds:e=>{let{nodeLookup:n,nodeOrigin:r}=t.getState();return Co(e,{nodeLookup:n,nodeOrigin:r})},getHandleConnections:({type:e,id:n,nodeId:r})=>Array.from(t.getState().connectionLookup.get(`${r}-${e}${n?`-${n}`:``}`)?.values()??[]),getNodeConnections:({type:e,handleId:n,nodeId:r})=>Array.from(t.getState().connectionLookup.get(`${r}${e?n?`-${e}-${n}`:`-${e}`:``}`)?.values()??[]),fitView:async e=>{let r=t.getState().fitViewResolver??os();return t.setState({fitViewQueued:!0,fitViewOptions:e,fitViewResolver:r}),n.nodeQueue.push(e=>[...e]),r.promise}}},[]);return(0,Y.useMemo)(()=>({...i,...e,viewportInitialized:r}),[r])}var su=e=>e.selected,cu=typeof window<`u`?window:void 0;function lu({deleteKeyCode:e,multiSelectionKeyCode:t}){let n=$(),{deleteElements:r}=ou(),i=Il(e,{actInsideInputWithModifier:!1}),a=Il(t,{target:cu});(0,Y.useEffect)(()=>{if(i){let{edges:e,nodes:t}=n.getState();r({nodes:t.filter(su),edges:e.filter(su)}),n.setState({nodesSelectionActive:!1})}},[i]),(0,Y.useEffect)(()=>{n.setState({multiSelectionActive:a})},[a])}function uu(e){let t=$();(0,Y.useEffect)(()=>{let n=()=>{if(!e.current||!(e.current.checkVisibility?.()??!0))return!1;let n=ls(e.current);(n.height===0||n.width===0)&&t.getState().onError?.(`004`,oo.error004()),t.setState({width:n.width||500,height:n.height||500})};if(e.current){n(),window.addEventListener(`resize`,n);let t=new ResizeObserver(()=>n());return t.observe(e.current),()=>{window.removeEventListener(`resize`,n),t&&e.current&&t.unobserve(e.current)}}},[])}var du={position:`absolute`,width:`100%`,height:`100%`,top:0,left:0},fu=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function pu({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:r=!1,panOnScrollSpeed:i=.5,panOnScrollMode:a=fo.Free,zoomOnDoubleClick:o=!0,panOnDrag:s=!0,defaultViewport:c,translateExtent:l,minZoom:u,maxZoom:d,zoomActivationKeyCode:f,preventScrolling:p=!0,children:m,noWheelClassName:h,noPanClassName:g,onViewportChange:_,isControlledViewport:v,paneClickDistance:y,selectionOnDrag:b}){let x=$(),S=(0,Y.useRef)(null),{userSelectionActive:C,lib:w,connectionInProgress:T}=Q(fu,al),E=Il(f),D=(0,Y.useRef)();uu(S);let O=(0,Y.useCallback)(e=>{_?.({x:e[0],y:e[1],zoom:e[2]}),v||x.setState({transform:e})},[_,v]);return(0,Y.useEffect)(()=>{if(S.current){D.current=Pc({domNode:S.current,minZoom:u,maxZoom:d,translateExtent:l,viewport:c,onDraggingChange:e=>x.setState(t=>t.paneDragging===e?t:{paneDragging:e}),onPanZoomStart:(e,t)=>{let{onViewportChangeStart:n,onMoveStart:r}=x.getState();r?.(e,t),n?.(t)},onPanZoom:(e,t)=>{let{onViewportChange:n,onMove:r}=x.getState();r?.(e,t),n?.(t)},onPanZoomEnd:(e,t)=>{let{onViewportChangeEnd:n,onMoveEnd:r}=x.getState();r?.(e,t),n?.(t)}});let{x:e,y:t,zoom:n}=D.current.getViewport();return x.setState({panZoom:D.current,transform:[e,t,n],domNode:S.current.closest(`.react-flow`)}),()=>{D.current?.destroy()}}},[]),(0,Y.useEffect)(()=>{D.current?.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:n,panOnScroll:r,panOnScrollSpeed:i,panOnScrollMode:a,zoomOnDoubleClick:o,panOnDrag:s,zoomActivationKeyPressed:E,preventScrolling:p,noPanClassName:g,userSelectionActive:C,noWheelClassName:h,lib:w,onTransformChange:O,connectionInProgress:T,selectionOnDrag:b,paneClickDistance:y})},[e,t,n,r,i,a,o,s,E,p,g,C,h,w,O,T,b,y]),(0,J.jsx)(`div`,{className:`react-flow__renderer`,ref:S,style:du,children:m})}var mu=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function hu(){let{userSelectionActive:e,userSelectionRect:t}=Q(mu,al);return e&&t?(0,J.jsx)(`div`,{className:`react-flow__selection react-flow__container`,style:{width:t.width,height:t.height,transform:`translate(${t.x}px, ${t.y}px)`}}):null}var gu=(e,t)=>n=>{n.target===t.current&&e?.(n)},_u=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,dragging:e.paneDragging,panBy:e.panBy,autoPanSpeed:e.autoPanSpeed});function vu({isSelecting:e,selectionKeyPressed:t,selectionMode:n=po.Full,panOnDrag:r,autoPanOnSelection:i,paneClickDistance:a,selectionOnDrag:o,onSelectionStart:s,onSelectionEnd:c,onPaneClick:l,onPaneContextMenu:u,onPaneScroll:d,onPaneMouseEnter:f,onPaneMouseMove:p,onPaneMouseLeave:m,children:h}){let g=(0,Y.useRef)(0),_=$(),{userSelectionActive:v,elementsSelectable:y,dragging:b,panBy:x,autoPanSpeed:S}=Q(_u,al),C=y&&(e||v),w=(0,Y.useRef)(null),T=(0,Y.useRef)(),E=(0,Y.useRef)(new Set),D=(0,Y.useRef)(new Set),O=(0,Y.useRef)(!1),k=(0,Y.useRef)(!1),A=(0,Y.useRef)({x:0,y:0}),j=(0,Y.useRef)(!1),M=e=>{if(k.current||O.current||_.getState().connection.inProgress){k.current=!1,O.current=!1;return}l?.(e),_.getState().resetSelectedElements(),_.setState({nodesSelectionActive:!1})},N=e=>{if(Array.isArray(r)&&r?.includes(2)){e.preventDefault();return}u?.(e)},P=d?e=>d(e):void 0,F=e=>{k.current&&=(e.stopPropagation(),!1)},I=n=>{let{domNode:r,transform:i}=_.getState();if(T.current=r?.getBoundingClientRect(),!T.current)return;let a=n.target===w.current;if(!a&&n.target.closest(`.nokey`)||!e||!(o&&a||t)||n.button!==0||!n.isPrimary)return;n.target?.setPointerCapture?.(n.pointerId),k.current=!1;let{x:s,y:c}=ms(n.nativeEvent,T.current),l=Jo({x:s,y:c},i);_.setState({userSelectionRect:{width:0,height:0,startX:l.x,startY:l.y,x:s,y:c}}),a||(n.stopPropagation(),n.preventDefault())};function L(e,t){let{userSelectionRect:r}=_.getState();if(!r)return;let{transform:i,nodeLookup:a,edgeLookup:o,connectionLookup:s,triggerNodeChanges:c,triggerEdgeChanges:l,defaultEdgeOptions:u}=_.getState(),d={x:r.startX,y:r.startY},{x:f,y:p}=Yo(d,i),m={startX:d.x,startY:d.y,x:ee.id)),D.current=new Set;let v=u?.selectable??!0;for(let e of E.current){let t=s.get(e);if(t)for(let{edgeId:e}of t.values()){let t=o.get(e);t&&(t.selectable??v)&&D.current.add(e)}}as(h,E.current)||c(Gl(a,E.current,!0)),as(g,D.current)||l(Gl(o,D.current)),_.setState({userSelectionRect:m,userSelectionActive:!0,nodesSelectionActive:!1})}function R(){if(!i||!T.current)return;let[e,t]=Fo(A.current,T.current,S);x({x:e,y:t}).then(e=>{if(!k.current||!e){g.current=requestAnimationFrame(R);return}let{x:t,y:n}=A.current;L(t,n),g.current=requestAnimationFrame(R)})}let z=()=>{cancelAnimationFrame(g.current),g.current=0,j.current=!1};(0,Y.useEffect)(()=>()=>z(),[]);let B=e=>{let{userSelectionRect:n,transform:r,resetSelectedElements:i}=_.getState();if(!T.current||!n)return;let{x:o,y:c}=ms(e.nativeEvent,T.current);A.current={x:o,y:c};let l=Yo({x:n.startX,y:n.startY},r);if(!k.current){let n=t?0:a;if(Math.hypot(o-l.x,c-l.y)<=n)return;i(),s?.(e)}k.current=!0,j.current||=(R(),!0),L(o,c)},V=e=>{if(!C){e.target===w.current&&_.getState().connection.inProgress&&(O.current=!0);return}e.button===0&&(e.target?.releasePointerCapture?.(e.pointerId),!v&&e.target===w.current&&_.getState().userSelectionRect&&M?.(e),_.setState({userSelectionActive:!1,userSelectionRect:null}),k.current&&(c?.(e),_.setState({nodesSelectionActive:E.current.size>0})),z())},ee=e=>{e.target?.releasePointerCapture?.(e.pointerId),z()},te=r===!0||Array.isArray(r)&&r.includes(0);return(0,J.jsxs)(`div`,{className:Se([`react-flow__pane`,{draggable:te,dragging:b,selection:e}]),onClick:C?void 0:gu(M,w),onContextMenu:gu(N,w),onWheel:gu(P,w),onPointerEnter:C?void 0:f,onPointerMove:C?B:p,onPointerUp:V,onPointerCancel:C?ee:void 0,onPointerDownCapture:C?I:void 0,onClickCapture:C?F:void 0,onPointerLeave:m,ref:w,style:du,children:[h,(0,J.jsx)(hu,{})]})}function yu({id:e,store:t,unselect:n=!1,nodeRef:r}){let{addSelectedNodes:i,unselectNodesAndEdges:a,multiSelectionActive:o,nodeLookup:s,onError:c}=t.getState(),l=s.get(e);if(!l){c?.(`012`,oo.error012(e));return}t.setState({nodesSelectionActive:!1}),l.selected?(n||l.selected&&o)&&(a({nodes:[l],edges:[]}),requestAnimationFrame(()=>r?.current?.blur())):i([e])}function bu({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:r,nodeId:i,isSelectable:a,nodeClickDistance:o}){let s=$(),[c,l]=(0,Y.useState)(!1),u=(0,Y.useRef)();return(0,Y.useEffect)(()=>{u.current=lc({getStoreItems:()=>s.getState(),onNodeMouseDown:t=>{yu({id:t,store:s,nodeRef:e})},onDragStart:()=>{l(!0)},onDragStop:()=>{l(!1)}})},[]),(0,Y.useEffect)(()=>{if(!(t||!e.current||!u.current))return u.current.update({noDragClassName:n,handleSelector:r,domNode:e.current,isSelectable:a,nodeId:i,nodeClickDistance:o}),()=>{u.current?.destroy()}},[n,r,t,a,e,i,o]),c}var xu=e=>t=>t.selected&&(t.draggable||e&&t.draggable===void 0);function Su(){let e=$();return(0,Y.useCallback)(t=>{let{nodeExtent:n,snapToGrid:r,snapGrid:i,nodesDraggable:a,onError:o,updateNodePositions:s,nodeLookup:c,nodeOrigin:l}=e.getState(),u=new Map,d=xu(a),f=r?i[0]:5,p=r?i[1]:5,m=t.direction.x*f*t.factor,h=t.direction.y*p*t.factor;for(let[,e]of c){if(!d(e))continue;let t={x:e.internals.positionAbsolute.x+m,y:e.internals.positionAbsolute.y+h};r&&(t=qo(t,i));let{position:a,positionAbsolute:s}=ko({nodeId:e.id,nextPosition:t,nodeLookup:c,nodeExtent:n,nodeOrigin:l,onError:o});e.position=a,e.internals.positionAbsolute=s,u.set(e.id,e)}s(u)},[])}var Cu=(0,Y.createContext)(null),wu=Cu.Provider;Cu.Consumer;var Tu=()=>(0,Y.useContext)(Cu),Eu=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),Du=(0,Y.createContext)(null);function Ou({children:e}){let t=Q(Eu,al);return(0,J.jsx)(Du.Provider,{value:t,children:e})}function ku(){let e=(0,Y.useContext)(Du);if(!e)throw Error(`useHandleConfig must be used within a HandleConfigProvider`);return e}var Au={connectingFrom:!1,connectingTo:!1,clickConnecting:!1,isPossibleEndHandle:!0,connectionInProcess:!1,clickConnectionInProcess:!1,valid:!1},ju=(e,t,n)=>r=>{let{connectionClickStartHandle:i,connectionMode:a,connection:o}=r,{fromHandle:s,toHandle:c,isValid:l}=o;if(!s&&!i)return Au;let u=c?.nodeId===e&&c?.id===t&&c?.type===n;return{connectingFrom:s?.nodeId===e&&s?.id===t&&s?.type===n,connectingTo:u,clickConnecting:i?.nodeId===e&&i?.id===t&&i?.type===n,isPossibleEndHandle:a===uo.Strict?s?.type!==n:e!==s?.nodeId||t!==s?.id,connectionInProcess:!!s,clickConnectionInProcess:!!i,valid:u&&l}};function Mu({type:e=`source`,position:t=Z.Top,isValidConnection:n,isConnectable:r=!0,isConnectableStart:i=!0,isConnectableEnd:a=!0,id:o,onConnect:s,children:c,className:l,onMouseDown:u,onTouchStart:d,...f},p){let m=o||null,h=e===`target`,g=$(),_=Tu(),{connectOnClick:v,noPanClassName:y,rfId:b}=ku(),{connectingFrom:x,connectingTo:S,clickConnecting:C,isPossibleEndHandle:w,connectionInProcess:T,clickConnectionInProcess:E,valid:D}=Q(ju(_,m,e),al);_||g.getState().onError?.(`010`,oo.error010());let O=e=>{let{defaultEdgeOptions:t,onConnect:n,hasDefaultEdges:r}=g.getState(),i={...t,...e};if(r){let{edges:e,setEdges:t,onError:n}=g.getState();t(Yl(i,e,{onError:n}))}n?.(i),s?.(i)},k=e=>{if(!_)return;let t=ps(e.nativeEvent);if(i&&(t&&e.button===0||!t)){let t=g.getState();yc.onPointerDown(e.nativeEvent,{handleDomNode:e.currentTarget,autoPanOnConnect:t.autoPanOnConnect,connectionMode:t.connectionMode,connectionRadius:t.connectionRadius,domNode:t.domNode,nodeLookup:t.nodeLookup,lib:t.lib,isTarget:h,handleId:m,nodeId:_,flowId:t.rfId,panBy:t.panBy,cancelConnection:t.cancelConnection,onConnectStart:t.onConnectStart,onConnectEnd:(...e)=>g.getState().onConnectEnd?.(...e),updateConnection:t.updateConnection,onConnect:O,isValidConnection:n||((...e)=>g.getState().isValidConnection?.(...e)??!0),getTransform:()=>g.getState().transform,getFromHandle:()=>g.getState().connection.fromHandle,autoPanSpeed:t.autoPanSpeed,dragThreshold:t.connectionDragThreshold})}t?u?.(e):d?.(e)};return(0,J.jsx)(`div`,{"data-handleid":m,"data-nodeid":_,"data-handlepos":t,"data-id":`${b}-${_}-${m}-${e}`,className:Se([`react-flow__handle`,`react-flow__handle-${t}`,`nodrag`,y,l,{source:!h,target:h,connectable:r,connectablestart:i,connectableend:a,clickconnecting:C,connectingfrom:x,connectingto:S,valid:D,connectionindicator:r&&(!T||w)&&(T||E?a:i)}]),onMouseDown:k,onTouchStart:k,onClick:v?t=>{let{onClickConnectStart:r,onClickConnectEnd:a,connectionClickStartHandle:o,connectionMode:s,isValidConnection:c,lib:l,rfId:u,nodeLookup:d,connection:f}=g.getState();if(!_||!o&&!i)return;if(!o){r?.(t.nativeEvent,{nodeId:_,handleId:m,handleType:e}),g.setState({connectionClickStartHandle:{nodeId:_,type:e,id:m}});return}let p=us(t.target),h=n||c,{connection:v,isValid:y}=yc.isValid(t.nativeEvent,{handle:{nodeId:_,id:m,type:e},connectionMode:s,fromNodeId:o.nodeId,fromHandleId:o.id||null,fromType:o.type,isValidConnection:h,flowId:u,doc:p,lib:l,nodeLookup:d});y&&v&&O(v);let b=structuredClone(f);delete b.inProgress,b.toPosition=b.toHandle?b.toHandle.position:null,a?.(t,b),g.setState({connectionClickStartHandle:null})}:void 0,ref:p,...f,children:c})}var Nu=(0,Y.memo)(Ql(Mu));function Pu({data:e,isConnectable:t,sourcePosition:n=Z.Bottom}){return(0,J.jsxs)(J.Fragment,{children:[e?.label,(0,J.jsx)(Nu,{type:`source`,position:n,isConnectable:t})]})}function Fu({data:e,isConnectable:t,targetPosition:n=Z.Top,sourcePosition:r=Z.Bottom}){return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Nu,{type:`target`,position:n,isConnectable:t}),e?.label,(0,J.jsx)(Nu,{type:`source`,position:r,isConnectable:t})]})}function Iu(){return null}function Lu({data:e,isConnectable:t,targetPosition:n=Z.Top}){return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Nu,{type:`target`,position:n,isConnectable:t}),e?.label]})}var Ru={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},zu={input:Pu,default:Fu,output:Lu,group:Iu};function Bu(e){return e.internals.handleBounds===void 0?{width:e.width??e.initialWidth??e.style?.width,height:e.height??e.initialHeight??e.style?.height}:{width:e.width??e.style?.width,height:e.height??e.style?.height}}var Vu=e=>{let{width:t,height:n,x:r,y:i}=wo(e.nodeLookup,{filter:e=>!!e.selected});return{width:Go(t)?t:null,height:Go(n)?n:null,userSelectionActive:e.userSelectionActive,transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]}) translate(${r}px,${i}px)`}};function Hu({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){let r=$(),{width:i,height:a,transformString:o,userSelectionActive:s}=Q(Vu,al),c=Su(),l=(0,Y.useRef)(null);(0,Y.useEffect)(()=>{n||l.current?.focus({preventScroll:!0})},[n]);let u=!s&&i!==null&&a!==null;if(bu({nodeRef:l,disabled:!u}),!u)return null;let d=e?t=>{e(t,r.getState().nodes.filter(e=>e.selected))}:void 0;return(0,J.jsx)(`div`,{className:Se([`react-flow__nodesselection`,`react-flow__container`,t]),style:{transform:o},children:(0,J.jsx)(`div`,{ref:l,className:`react-flow__nodesselection-rect`,onContextMenu:d,tabIndex:n?void 0:-1,onKeyDown:n?void 0:e=>{Object.prototype.hasOwnProperty.call(Ru,e.key)&&(e.preventDefault(),c({direction:Ru[e.key],factor:e.shiftKey?4:1}))},style:{width:i,height:a}})})}var Uu=typeof window<`u`?window:void 0,Wu=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function Gu({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:i,onPaneContextMenu:a,onPaneScroll:o,paneClickDistance:s,deleteKeyCode:c,selectionKeyCode:l,selectionOnDrag:u,selectionMode:d,onSelectionStart:f,onSelectionEnd:p,multiSelectionKeyCode:m,panActivationKeyCode:h,zoomActivationKeyCode:g,elementsSelectable:_,zoomOnScroll:v,zoomOnPinch:y,panOnScroll:b,panOnScrollSpeed:x,panOnScrollMode:S,zoomOnDoubleClick:C,panOnDrag:w,autoPanOnSelection:T,defaultViewport:E,translateExtent:D,minZoom:O,maxZoom:k,preventScrolling:A,onSelectionContextMenu:j,noWheelClassName:M,noPanClassName:N,disableKeyboardA11y:P,onViewportChange:F,isControlledViewport:I}){let{nodesSelectionActive:L,userSelectionActive:R}=Q(Wu,al),z=Il(l,{target:Uu}),B=Il(h,{target:Uu}),V=B||w,ee=B||b,te=u&&V!==!0,H=z||R||te;return lu({deleteKeyCode:c,multiSelectionKeyCode:m}),(0,J.jsx)(pu,{onPaneContextMenu:a,elementsSelectable:_,zoomOnScroll:v,zoomOnPinch:y,panOnScroll:ee,panOnScrollSpeed:x,panOnScrollMode:S,zoomOnDoubleClick:C,panOnDrag:!z&&V,defaultViewport:E,translateExtent:D,minZoom:O,maxZoom:k,zoomActivationKeyCode:g,preventScrolling:A,noWheelClassName:M,noPanClassName:N,onViewportChange:F,isControlledViewport:I,paneClickDistance:s,selectionOnDrag:te,children:(0,J.jsxs)(vu,{onSelectionStart:f,onSelectionEnd:p,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:i,onPaneContextMenu:a,onPaneScroll:o,panOnDrag:V,autoPanOnSelection:T,isSelecting:!!H,selectionMode:d,selectionKeyPressed:z,paneClickDistance:s,selectionOnDrag:te,children:[e,L&&(0,J.jsx)(Hu,{onSelectionContextMenu:j,noPanClassName:N,disableKeyboardA11y:P})]})})}Gu.displayName=`FlowRenderer`;var Ku=(0,Y.memo)(Gu),qu=e=>t=>e?To(t.nodeLookup,{x:0,y:0,width:t.width,height:t.height},t.transform,!0).map(e=>e.id):Array.from(t.nodeLookup.keys());function Ju(e){return Q((0,Y.useCallback)(qu(e),[e]),al)}var Yu=e=>e.updateNodeInternals;function Xu(){let e=Q(Yu),[t]=(0,Y.useState)(()=>typeof ResizeObserver>`u`?null:new ResizeObserver(t=>{let n=new Map;t.forEach(e=>{let t=e.target.getAttribute(`data-id`);n.set(t,{id:t,nodeElement:e.target,force:!0})}),e(n)}));return(0,Y.useEffect)(()=>()=>{t?.disconnect()},[t]),t}function Zu({node:e,nodeType:t,hasDimensions:n,resizeObserver:r}){let i=$(),a=(0,Y.useRef)(null),o=(0,Y.useRef)(null),s=(0,Y.useRef)(e.sourcePosition),c=(0,Y.useRef)(e.targetPosition),l=(0,Y.useRef)(t),u=n&&!!e.internals.handleBounds;return(0,Y.useEffect)(()=>{a.current&&!e.hidden&&(!u||o.current!==a.current)&&(o.current&&r?.unobserve(o.current),r?.observe(a.current),o.current=a.current)},[u,e.hidden]),(0,Y.useEffect)(()=>()=>{o.current&&=(r?.unobserve(o.current),null)},[]),(0,Y.useEffect)(()=>{if(a.current){let n=l.current!==t,r=s.current!==e.sourcePosition,o=c.current!==e.targetPosition;(n||r||o)&&(l.current=t,s.current=e.sourcePosition,c.current=e.targetPosition,i.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:a.current,force:!0}]])))}},[e.id,t,e.sourcePosition,e.targetPosition]),a}function Qu({id:e,onClick:t,onMouseEnter:n,onMouseMove:r,onMouseLeave:i,onContextMenu:a,onDoubleClick:o,nodesDraggable:s,elementsSelectable:c,nodesConnectable:l,nodesFocusable:u,resizeObserver:d,noDragClassName:f,noPanClassName:p,disableKeyboardA11y:m,rfId:h,nodeTypes:g,nodeClickDistance:_,onError:v}){let{node:y,internals:b,isParent:x}=Q(t=>{let n=t.nodeLookup.get(e),r=t.parentLookup.has(e);return{node:n,internals:n.internals,isParent:r}},al),S=y.type||`default`,C=g?.[S]||zu[S];C===void 0&&(v?.(`003`,oo.error003(S)),S=`default`,C=g?.default||zu.default);let w=!!(y.draggable||s&&y.draggable===void 0),T=!!(y.selectable||c&&y.selectable===void 0),E=!!(y.connectable||l&&y.connectable===void 0),D=!!(y.focusable||u&&y.focusable===void 0),O=$(),k=rs(y),A=Zu({node:y,nodeType:S,hasDimensions:k,resizeObserver:d}),j=bu({nodeRef:A,disabled:y.hidden||!w,noDragClassName:f,handleSelector:y.dragHandle,nodeId:e,isSelectable:T,nodeClickDistance:_}),M=Su();if(y.hidden)return null;let N=ns(y),P=Bu(y),F=T||w||t||n||r||i,I=n?e=>n(e,{...b.userNode}):void 0,L=r?e=>r(e,{...b.userNode}):void 0,R=i?e=>i(e,{...b.userNode}):void 0,z=a?e=>a(e,{...b.userNode}):void 0,B=o?e=>o(e,{...b.userNode}):void 0,V=n=>{let{selectNodesOnDrag:r,nodeDragThreshold:i}=O.getState();T&&(!r||!w||i>0)&&yu({id:e,store:O,nodeRef:A}),t&&t(n,{...b.userNode})},ee=t=>{if(!(fs(t.nativeEvent)||m)){if(co.includes(t.key)&&T){let n=t.key===`Escape`;yu({id:e,store:O,unselect:n,nodeRef:A})}else if(w&&y.selected&&Object.prototype.hasOwnProperty.call(Ru,t.key)){t.preventDefault();let{ariaLabelConfig:e}=O.getState();O.setState({ariaLiveMessage:e[`node.a11yDescription.ariaLiveMessage`]({direction:t.key.replace(`Arrow`,``).toLowerCase(),x:~~b.positionAbsolute.x,y:~~b.positionAbsolute.y})}),M({direction:Ru[t.key],factor:t.shiftKey?4:1})}}},te=()=>{if(m||!A.current?.matches(`:focus-visible`))return;let{transform:t,width:n,height:r,autoPanOnNodeFocus:i,setCenter:a}=O.getState();i&&(To(new Map([[e,y]]),{x:0,y:0,width:n,height:r},t,!0).length>0||a(y.position.x+N.width/2,y.position.y+N.height/2,{zoom:t[2]}))};return(0,J.jsx)(`div`,{className:Se([`react-flow__node`,`react-flow__node-${S}`,{[p]:w},y.className,{selected:y.selected,selectable:T,parent:x,draggable:w,dragging:j}]),ref:A,style:{zIndex:b.z,transform:`translate(${b.positionAbsolute.x}px,${b.positionAbsolute.y}px)`,pointerEvents:F?`all`:`none`,visibility:k?`visible`:`hidden`,...y.style,...P},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:I,onMouseMove:L,onMouseLeave:R,onContextMenu:z,onClick:V,onDoubleClick:B,onKeyDown:D?ee:void 0,tabIndex:D?0:void 0,onFocus:D?te:void 0,role:y.ariaRole??(D?`group`:void 0),"aria-roledescription":`node`,"aria-describedby":m?void 0:`${dl}-${h}`,"aria-label":y.ariaLabel,...y.domAttributes,children:(0,J.jsx)(wu,{value:e,children:(0,J.jsx)(C,{id:e,data:y.data,type:S,positionAbsoluteX:b.positionAbsolute.x,positionAbsoluteY:b.positionAbsolute.y,selected:y.selected??!1,selectable:T,draggable:w,deletable:y.deletable??!0,isConnectable:E,sourcePosition:y.sourcePosition,targetPosition:y.targetPosition,dragging:j,dragHandle:y.dragHandle,zIndex:b.z,parentId:y.parentId,...N})})})}var $u=(0,Y.memo)(Qu),ed=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function td(e){let{nodesDraggable:t,nodesConnectable:n,nodesFocusable:r,elementsSelectable:i,onError:a}=Q(ed,al),o=Ju(e.onlyRenderVisibleElements),s=Xu();return(0,J.jsx)(`div`,{className:`react-flow__nodes`,style:du,children:o.map(o=>(0,J.jsx)($u,{id:o,nodeTypes:e.nodeTypes,nodeExtent:e.nodeExtent,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,resizeObserver:s,nodesDraggable:t,nodesConnectable:n,nodesFocusable:r,elementsSelectable:i,nodeClickDistance:e.nodeClickDistance,onError:a},o))})}td.displayName=`NodeRenderer`;var nd=(0,Y.memo)(td);function rd(e){return Q((0,Y.useCallback)(t=>{if(!e)return t.edges.map(e=>e.id);let n=[];if(t.width&&t.height)for(let e of t.edges){let r=t.nodeLookup.get(e.source),i=t.nodeLookup.get(e.target);r&&i&&Ss({sourceNode:r,targetNode:i,width:t.width,height:t.height,transform:t.transform})&&n.push(e.id)}return n},[e]),al)}var id=({color:e=`none`,strokeWidth:t=1})=>{let n={strokeWidth:t,...e&&{stroke:e}};return(0,J.jsx)(`polyline`,{className:`arrow`,style:n,strokeLinecap:`round`,fill:`none`,strokeLinejoin:`round`,points:`-5,-4 0,0 -5,4`})},ad=({color:e=`none`,strokeWidth:t=1})=>{let n={strokeWidth:t,...e&&{stroke:e,fill:e}};return(0,J.jsx)(`polyline`,{className:`arrowclosed`,style:n,strokeLinecap:`round`,strokeLinejoin:`round`,points:`-5,-4 0,0 -5,4 -5,-4`})},od={[go.Arrow]:id,[go.ArrowClosed]:ad};function sd(e){let t=$();return(0,Y.useMemo)(()=>Object.prototype.hasOwnProperty.call(od,e)?od[e]:(t.getState().onError?.(`009`,oo.error009(e)),null),[e])}var cd=({id:e,type:t,color:n,width:r=12.5,height:i=12.5,markerUnits:a=`strokeWidth`,strokeWidth:o,orient:s=`auto-start-reverse`})=>{let c=sd(t);return c?(0,J.jsx)(`marker`,{className:`react-flow__arrowhead`,id:e,markerWidth:`${r}`,markerHeight:`${i}`,viewBox:`-10 -10 20 20`,markerUnits:a,orient:s,refX:`0`,refY:`0`,children:(0,J.jsx)(c,{color:n,strokeWidth:o})}):null},ld=({defaultColor:e,rfId:t})=>{let n=Q(e=>e.edges),r=Q(e=>e.defaultEdgeOptions),i=(0,Y.useMemo)(()=>zs(n,{id:t,defaultColor:e,defaultMarkerStart:r?.markerStart,defaultMarkerEnd:r?.markerEnd}),[n,r,t,e]);return i.length?(0,J.jsx)(`svg`,{className:`react-flow__marker`,"aria-hidden":`true`,children:(0,J.jsx)(`defs`,{children:i.map(e=>(0,J.jsx)(cd,{id:e.id,type:e.type,color:e.color,width:e.width,height:e.height,markerUnits:e.markerUnits,strokeWidth:e.strokeWidth,orient:e.orient},e.id))})}):null};ld.displayName=`MarkerDefinitions`;var ud=(0,Y.memo)(ld);function dd({x:e,y:t,label:n,labelStyle:r,labelShowBg:i=!0,labelBgStyle:a,labelBgPadding:o=[2,4],labelBgBorderRadius:s=2,children:c,className:l,...u}){let[d,f]=(0,Y.useState)({x:1,y:0,width:0,height:0}),p=Se([`react-flow__edge-textwrapper`,l]),m=(0,Y.useRef)(null);return(0,Y.useEffect)(()=>{if(m.current){let e=m.current.getBBox();f({x:e.x,y:e.y,width:e.width,height:e.height})}},[n]),n?(0,J.jsxs)(`g`,{transform:`translate(${e-d.width/2} ${t-d.height/2})`,className:p,visibility:d.width?`visible`:`hidden`,...u,children:[i&&(0,J.jsx)(`rect`,{width:d.width+2*o[0],x:-o[0],y:-o[1],height:d.height+2*o[1],className:`react-flow__edge-textbg`,style:a,rx:s,ry:s}),(0,J.jsx)(`text`,{className:`react-flow__edge-text`,y:d.height/2,dy:`0.3em`,ref:m,style:r,children:n}),c]}):null}dd.displayName=`EdgeText`;var fd=(0,Y.memo)(dd);function pd({path:e,labelX:t,labelY:n,label:r,labelStyle:i,labelShowBg:a,labelBgStyle:o,labelBgPadding:s,labelBgBorderRadius:c,interactionWidth:l=20,...u}){return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`path`,{...u,d:e,fill:`none`,className:Se([`react-flow__edge-path`,u.className])}),l?(0,J.jsx)(`path`,{d:e,fill:`none`,strokeOpacity:0,strokeWidth:l,className:`react-flow__edge-interaction`}):null,r&&Go(t)&&Go(n)?(0,J.jsx)(fd,{x:t,y:n,label:r,labelStyle:i,labelShowBg:a,labelBgStyle:o,labelBgPadding:s,labelBgBorderRadius:c}):null]})}function md({pos:e,x1:t,y1:n,x2:r,y2:i}){return e===Z.Left||e===Z.Right?[.5*(t+r),n]:[t,.5*(n+i)]}function hd({sourceX:e,sourceY:t,sourcePosition:n=Z.Bottom,targetX:r,targetY:i,targetPosition:a=Z.Top}){let[o,s]=md({pos:n,x1:e,y1:t,x2:r,y2:i}),[c,l]=md({pos:a,x1:r,y1:i,x2:e,y2:t}),[u,d,f,p]=gs({sourceX:e,sourceY:t,targetX:r,targetY:i,sourceControlX:o,sourceControlY:s,targetControlX:c,targetControlY:l});return[`M${e},${t} C${o},${s} ${c},${l} ${r},${i}`,u,d,f,p]}function gd(e){return(0,Y.memo)(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:a,sourcePosition:o,targetPosition:s,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:h,markerStart:g,interactionWidth:_})=>{let[v,y,b]=hd({sourceX:n,sourceY:r,sourcePosition:o,targetX:i,targetY:a,targetPosition:s}),x=e.isInternal?void 0:t;return(0,J.jsx)(pd,{id:x,path:v,labelX:y,labelY:b,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:h,markerStart:g,interactionWidth:_})})}var _d=gd({isInternal:!1}),vd=gd({isInternal:!0});_d.displayName=`SimpleBezierEdge`,vd.displayName=`SimpleBezierEdgeInternal`;function yd(e){return(0,Y.memo)(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:a,label:o,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,sourcePosition:p=Z.Bottom,targetPosition:m=Z.Top,markerEnd:h,markerStart:g,pathOptions:_,interactionWidth:v})=>{let[y,b,x]=Ms({sourceX:n,sourceY:r,sourcePosition:p,targetX:i,targetY:a,targetPosition:m,borderRadius:_?.borderRadius,offset:_?.offset,stepPosition:_?.stepPosition}),S=e.isInternal?void 0:t;return(0,J.jsx)(pd,{id:S,path:y,labelX:b,labelY:x,label:o,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,markerEnd:h,markerStart:g,interactionWidth:v})})}var bd=yd({isInternal:!1}),xd=yd({isInternal:!0});bd.displayName=`SmoothStepEdge`,xd.displayName=`SmoothStepEdgeInternal`;function Sd(e){return(0,Y.memo)(({id:t,...n})=>{let r=e.isInternal?void 0:t;return(0,J.jsx)(bd,{...n,id:r,pathOptions:(0,Y.useMemo)(()=>({borderRadius:0,offset:n.pathOptions?.offset}),[n.pathOptions?.offset])})})}var Cd=Sd({isInternal:!1}),wd=Sd({isInternal:!0});Cd.displayName=`StepEdge`,wd.displayName=`StepEdgeInternal`;function Td(e){return(0,Y.memo)(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:a,label:o,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,markerEnd:p,markerStart:m,interactionWidth:h})=>{let[g,_,v]=Es({sourceX:n,sourceY:r,targetX:i,targetY:a}),y=e.isInternal?void 0:t;return(0,J.jsx)(pd,{id:y,path:g,labelX:_,labelY:v,label:o,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,markerEnd:p,markerStart:m,interactionWidth:h})})}var Ed=Td({isInternal:!1}),Dd=Td({isInternal:!0});Ed.displayName=`StraightEdge`,Dd.displayName=`StraightEdgeInternal`;function Od(e){return(0,Y.memo)(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:a,sourcePosition:o=Z.Bottom,targetPosition:s=Z.Top,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:h,markerStart:g,pathOptions:_,interactionWidth:v})=>{let[y,b,x]=ys({sourceX:n,sourceY:r,sourcePosition:o,targetX:i,targetY:a,targetPosition:s,curvature:_?.curvature}),S=e.isInternal?void 0:t;return(0,J.jsx)(pd,{id:S,path:y,labelX:b,labelY:x,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:h,markerStart:g,interactionWidth:v})})}var kd=Od({isInternal:!1}),Ad=Od({isInternal:!0});kd.displayName=`BezierEdge`,Ad.displayName=`BezierEdgeInternal`;var jd={default:Ad,straight:Dd,step:wd,smoothstep:xd,simplebezier:vd},Md={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null,zIndex:void 0},Nd=(e,t,n)=>n===Z.Left?e-t:n===Z.Right?e+t:e,Pd=(e,t,n)=>n===Z.Top?e-t:n===Z.Bottom?e+t:e,Fd=`react-flow__edgeupdater`;function Id({position:e,centerX:t,centerY:n,radius:r=10,onMouseDown:i,onMouseEnter:a,onMouseOut:o,type:s}){return(0,J.jsx)(`circle`,{onMouseDown:i,onMouseEnter:a,onMouseOut:o,className:Se([Fd,`${Fd}-${s}`]),cx:Nd(t,r,e),cy:Pd(n,r,e),r,stroke:`transparent`,fill:`transparent`})}function Ld({isReconnectable:e,reconnectRadius:t,edge:n,sourceX:r,sourceY:i,targetX:a,targetY:o,sourcePosition:s,targetPosition:c,onReconnect:l,onReconnectStart:u,onReconnectEnd:d,setReconnecting:f,setUpdateHover:p}){let m=$(),h=(e,t)=>{if(e.button!==0)return;let{autoPanOnConnect:r,domNode:i,connectionMode:a,connectionRadius:o,lib:s,onConnectStart:c,cancelConnection:p,nodeLookup:h,rfId:g,panBy:_,updateConnection:v}=m.getState(),y=t.type===`target`;yc.onPointerDown(e.nativeEvent,{autoPanOnConnect:r,connectionMode:a,connectionRadius:o,domNode:i,handleId:t.id,nodeId:t.nodeId,nodeLookup:h,isTarget:y,edgeUpdaterType:t.type,lib:s,flowId:g,cancelConnection:p,panBy:_,isValidConnection:(...e)=>m.getState().isValidConnection?.(...e)??!0,onConnect:e=>l?.(n,e),onConnectStart:(r,i)=>{f(!0),u?.(e,n,t.type),c?.(r,i)},onConnectEnd:(...e)=>m.getState().onConnectEnd?.(...e),onReconnectEnd:(e,r)=>{f(!1),d?.(e,n,t.type,r)},updateConnection:v,getTransform:()=>m.getState().transform,getFromHandle:()=>m.getState().connection.fromHandle,dragThreshold:m.getState().connectionDragThreshold,handleDomNode:e.currentTarget})},g=e=>h(e,{nodeId:n.target,id:n.targetHandle??null,type:`target`}),_=e=>h(e,{nodeId:n.source,id:n.sourceHandle??null,type:`source`}),v=()=>p(!0),y=()=>p(!1);return(0,J.jsxs)(J.Fragment,{children:[(e===!0||e===`source`)&&(0,J.jsx)(Id,{position:s,centerX:r,centerY:i,radius:t,onMouseDown:g,onMouseEnter:v,onMouseOut:y,type:`source`}),(e===!0||e===`target`)&&(0,J.jsx)(Id,{position:c,centerX:a,centerY:o,radius:t,onMouseDown:_,onMouseEnter:v,onMouseOut:y,type:`target`})]})}function Rd({id:e,edgesFocusable:t,edgesReconnectable:n,elementsSelectable:r,onClick:i,onDoubleClick:a,onContextMenu:o,onMouseEnter:s,onMouseMove:c,onMouseLeave:l,reconnectRadius:u,onReconnect:d,onReconnectStart:f,onReconnectEnd:p,rfId:m,edgeTypes:h,noPanClassName:g,onError:_,disableKeyboardA11y:v}){let y=Q(t=>t.edgeLookup.get(e)),b=Q(e=>e.defaultEdgeOptions);y=b?{...b,...y}:y;let x=y.type||`default`,S=h?.[x]||jd[x];S===void 0&&(_?.(`011`,oo.error011(x)),x=`default`,S=h?.default||jd.default);let C=!!(y.focusable||t&&y.focusable===void 0),w=d!==void 0&&(y.reconnectable||n&&y.reconnectable===void 0),T=!!(y.selectable||r&&y.selectable===void 0),E=(0,Y.useRef)(null),[D,O]=(0,Y.useState)(!1),[k,A]=(0,Y.useState)(!1),j=$(),{zIndex:M=y.zIndex,sourceX:N,sourceY:P,targetX:F,targetY:I,sourcePosition:L,targetPosition:R}=Q((0,Y.useCallback)(t=>{let n=t.nodeLookup.get(y.source),r=t.nodeLookup.get(y.target);if(!n||!r)return Md;let i=Ps({id:e,sourceNode:n,targetNode:r,sourceHandle:y.sourceHandle||null,targetHandle:y.targetHandle||null,connectionMode:t.connectionMode,onError:_}),a=xs({selected:y.selected,zIndex:y.zIndex,sourceNode:n,targetNode:r,elevateOnSelect:t.elevateEdgesOnSelect,zIndexMode:t.zIndexMode});return{...i||Md,zIndex:a}},[y.source,y.target,y.sourceHandle,y.targetHandle,y.selected,y.zIndex]),al),z=(0,Y.useMemo)(()=>y.markerStart?`url('#${Rs(y.markerStart,m)}')`:void 0,[y.markerStart,m]),B=(0,Y.useMemo)(()=>y.markerEnd?`url('#${Rs(y.markerEnd,m)}')`:void 0,[y.markerEnd,m]);if(y.hidden||N===null||P===null||F===null||I===null)return null;let V=t=>{let{addSelectedEdges:n,unselectNodesAndEdges:r,multiSelectionActive:a}=j.getState();T&&(j.setState({nodesSelectionActive:!1}),y.selected&&a?(r({nodes:[],edges:[y]}),E.current?.blur()):n([e])),i&&i(t,y)},ee=a?e=>{a(e,{...y})}:void 0,te=o?e=>{o(e,{...y})}:void 0,H=s?e=>{s(e,{...y})}:void 0,U=c?e=>{c(e,{...y})}:void 0,W=l?e=>{l(e,{...y})}:void 0;return(0,J.jsx)(`svg`,{style:{zIndex:M},children:(0,J.jsxs)(`g`,{className:Se([`react-flow__edge`,`react-flow__edge-${x}`,y.className,g,{selected:y.selected,animated:y.animated,inactive:!T&&!i,updating:D,selectable:T}]),onClick:V,onDoubleClick:ee,onContextMenu:te,onMouseEnter:H,onMouseMove:U,onMouseLeave:W,onKeyDown:C?t=>{if(!v&&co.includes(t.key)&&T){let{unselectNodesAndEdges:n,addSelectedEdges:r}=j.getState();t.key===`Escape`?(E.current?.blur(),n({edges:[y]})):r([e])}}:void 0,tabIndex:C?0:void 0,role:y.ariaRole??(C?`group`:`img`),"aria-roledescription":`edge`,"data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":y.ariaLabel===null?void 0:y.ariaLabel||`Edge from ${y.source} to ${y.target}`,"aria-describedby":C?`${fl}-${m}`:void 0,ref:E,...y.domAttributes,children:[!k&&(0,J.jsx)(S,{id:e,source:y.source,target:y.target,type:y.type,selected:y.selected,animated:y.animated,selectable:T,deletable:y.deletable??!0,label:y.label,labelStyle:y.labelStyle,labelShowBg:y.labelShowBg,labelBgStyle:y.labelBgStyle,labelBgPadding:y.labelBgPadding,labelBgBorderRadius:y.labelBgBorderRadius,sourceX:N,sourceY:P,targetX:F,targetY:I,sourcePosition:L,targetPosition:R,data:y.data,style:y.style,sourceHandleId:y.sourceHandle,targetHandleId:y.targetHandle,markerStart:z,markerEnd:B,pathOptions:`pathOptions`in y?y.pathOptions:void 0,interactionWidth:y.interactionWidth}),w&&(0,J.jsx)(Ld,{edge:y,isReconnectable:w,reconnectRadius:u,onReconnect:d,onReconnectStart:f,onReconnectEnd:p,sourceX:N,sourceY:P,targetX:F,targetY:I,sourcePosition:L,targetPosition:R,setUpdateHover:O,setReconnecting:A})]})})}var zd=(0,Y.memo)(Rd),Bd=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function Vd({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:n,edgeTypes:r,noPanClassName:i,onReconnect:a,onEdgeContextMenu:o,onEdgeMouseEnter:s,onEdgeMouseMove:c,onEdgeMouseLeave:l,onEdgeClick:u,reconnectRadius:d,onEdgeDoubleClick:f,onReconnectStart:p,onReconnectEnd:m,disableKeyboardA11y:h}){let{edgesFocusable:g,edgesReconnectable:_,elementsSelectable:v,onError:y}=Q(Bd,al),b=rd(t);return(0,J.jsxs)(`div`,{className:`react-flow__edges`,children:[(0,J.jsx)(ud,{defaultColor:e,rfId:n}),b.map(e=>(0,J.jsx)(zd,{id:e,edgesFocusable:g,edgesReconnectable:_,elementsSelectable:v,noPanClassName:i,onReconnect:a,onContextMenu:o,onMouseEnter:s,onMouseMove:c,onMouseLeave:l,onClick:u,reconnectRadius:d,onDoubleClick:f,onReconnectStart:p,onReconnectEnd:m,rfId:n,onError:y,edgeTypes:r,disableKeyboardA11y:h},e))]})}Vd.displayName=`EdgeRenderer`;var Hd=(0,Y.memo)(Vd),Ud=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function Wd({children:e}){let t=Q(Ud);return(0,J.jsx)(`div`,{className:`react-flow__viewport xyflow__viewport react-flow__container`,style:{transform:t},children:e})}function Gd(e){let t=ou(),n=(0,Y.useRef)(!1);(0,Y.useEffect)(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}var Kd=e=>e.panZoom?.syncViewport;function qd(e){let t=Q(Kd),n=$();return(0,Y.useEffect)(()=>{e&&(t?.(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function Jd(e){return e.connection.inProgress?{...e.connection,to:Jo(e.connection.to,e.transform)}:{...e.connection}}function Yd(e){return e?t=>e(Jd(t)):Jd}function Xd(e){return Q(Yd(e),al)}var Zd=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function Qd({containerStyle:e,style:t,type:n,component:r}){let{nodesConnectable:i,width:a,height:o,isValid:s,inProgress:c}=Q(Zd,al);return a&&i&&c?(0,J.jsx)(`svg`,{style:e,width:a,height:o,className:`react-flow__connectionline react-flow__container`,children:(0,J.jsx)(`g`,{className:Se([`react-flow__connection`,vo(s)]),children:(0,J.jsx)($d,{style:t,type:n,CustomComponent:r,isValid:s})})}):null}var $d=({style:e,type:t=ho.Bezier,CustomComponent:n,isValid:r})=>{let{inProgress:i,from:a,fromNode:o,fromHandle:s,fromPosition:c,to:l,toNode:u,toHandle:d,toPosition:f,pointer:p}=Xd();if(!i)return;if(n)return(0,J.jsx)(n,{connectionLineType:t,connectionLineStyle:e,fromNode:o,fromHandle:s,fromX:a.x,fromY:a.y,toX:l.x,toY:l.y,fromPosition:c,toPosition:f,connectionStatus:vo(r),toNode:u,toHandle:d,pointer:p});let m=``,h={sourceX:a.x,sourceY:a.y,sourcePosition:c,targetX:l.x,targetY:l.y,targetPosition:f};switch(t){case ho.Bezier:[m]=ys(h);break;case ho.SimpleBezier:[m]=hd(h);break;case ho.Step:[m]=Ms({...h,borderRadius:0});break;case ho.SmoothStep:[m]=Ms(h);break;default:[m]=Es(h)}return(0,J.jsx)(`path`,{d:m,fill:`none`,className:`react-flow__connection-path`,style:e})};$d.displayName=`ConnectionLine`;var ef={};function tf(e=ef){(0,Y.useRef)(e),$(),(0,Y.useEffect)(()=>{},[e])}function nf(){$(),(0,Y.useRef)(!1),(0,Y.useEffect)(()=>{},[])}function rf({nodeTypes:e,edgeTypes:t,onInit:n,onNodeClick:r,onEdgeClick:i,onNodeDoubleClick:a,onEdgeDoubleClick:o,onNodeMouseEnter:s,onNodeMouseMove:c,onNodeMouseLeave:l,onNodeContextMenu:u,onSelectionContextMenu:d,onSelectionStart:f,onSelectionEnd:p,connectionLineType:m,connectionLineStyle:h,connectionLineComponent:g,connectionLineContainerStyle:_,selectionKeyCode:v,selectionOnDrag:y,selectionMode:b,multiSelectionKeyCode:x,panActivationKeyCode:S,zoomActivationKeyCode:C,deleteKeyCode:w,onlyRenderVisibleElements:T,elementsSelectable:E,defaultViewport:D,translateExtent:O,minZoom:k,maxZoom:A,preventScrolling:j,defaultMarkerColor:M,zoomOnScroll:N,zoomOnPinch:P,panOnScroll:F,panOnScrollSpeed:I,panOnScrollMode:L,zoomOnDoubleClick:R,panOnDrag:z,autoPanOnSelection:B,onPaneClick:V,onPaneMouseEnter:ee,onPaneMouseMove:te,onPaneMouseLeave:H,onPaneScroll:U,onPaneContextMenu:W,paneClickDistance:G,nodeClickDistance:K,onEdgeContextMenu:ne,onEdgeMouseEnter:re,onEdgeMouseMove:ie,onEdgeMouseLeave:ae,reconnectRadius:oe,onReconnect:se,onReconnectStart:ce,onReconnectEnd:le,noDragClassName:q,noWheelClassName:ue,noPanClassName:de,disableKeyboardA11y:fe,nodeExtent:Y,rfId:pe,viewport:me,onViewportChange:X}){return tf(e),tf(t),nf(),Gd(n),qd(me),(0,J.jsx)(Ku,{onPaneClick:V,onPaneMouseEnter:ee,onPaneMouseMove:te,onPaneMouseLeave:H,onPaneContextMenu:W,onPaneScroll:U,paneClickDistance:G,deleteKeyCode:w,selectionKeyCode:v,selectionOnDrag:y,selectionMode:b,onSelectionStart:f,onSelectionEnd:p,multiSelectionKeyCode:x,panActivationKeyCode:S,zoomActivationKeyCode:C,elementsSelectable:E,zoomOnScroll:N,zoomOnPinch:P,zoomOnDoubleClick:R,panOnScroll:F,panOnScrollSpeed:I,panOnScrollMode:L,panOnDrag:z,autoPanOnSelection:B,defaultViewport:D,translateExtent:O,minZoom:k,maxZoom:A,onSelectionContextMenu:d,preventScrolling:j,noDragClassName:q,noWheelClassName:ue,noPanClassName:de,disableKeyboardA11y:fe,onViewportChange:X,isControlledViewport:!!me,children:(0,J.jsxs)(Wd,{children:[(0,J.jsx)(Hd,{edgeTypes:t,onEdgeClick:i,onEdgeDoubleClick:o,onReconnect:se,onReconnectStart:ce,onReconnectEnd:le,onlyRenderVisibleElements:T,onEdgeContextMenu:ne,onEdgeMouseEnter:re,onEdgeMouseMove:ie,onEdgeMouseLeave:ae,reconnectRadius:oe,defaultMarkerColor:M,noPanClassName:de,disableKeyboardA11y:fe,rfId:pe}),(0,J.jsx)(Qd,{style:h,type:m,component:g,containerStyle:_}),(0,J.jsx)(`div`,{className:`react-flow__edgelabel-renderer`}),(0,J.jsx)(nd,{nodeTypes:e,onNodeClick:r,onNodeDoubleClick:a,onNodeMouseEnter:s,onNodeMouseMove:c,onNodeMouseLeave:l,onNodeContextMenu:u,nodeClickDistance:K,onlyRenderVisibleElements:T,noPanClassName:de,noDragClassName:q,disableKeyboardA11y:fe,nodeExtent:Y,rfId:pe}),(0,J.jsx)(`div`,{className:`react-flow__viewport-portal`})]})})}rf.displayName=`GraphView`;var af=(0,Y.memo)(rf),of=Ko(`React Flow`,`https://reactflow.dev/`),sf=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:i,height:a,fitView:o,fitViewOptions:s,minZoom:c=.5,maxZoom:l=2,nodeOrigin:u,nodeExtent:d,zIndexMode:f=`basic`}={})=>{let p=new Map,m=new Map,h=new Map,g=new Map,_=r??t??[],v=n??e??[],y=u??[0,0],b=d??so;rc(h,g,_);let{nodesInitialized:x}=Js(v,p,m,{nodeOrigin:y,nodeExtent:b,zIndexMode:f}),S=[0,0,1];if(o&&i&&a){let{x:e,y:t,zoom:n}=$o(wo(p,{filter:e=>!!((e.width||e.initialWidth)&&(e.height||e.initialHeight))}),i,a,c,l,s?.padding??.1);S=[e,t,n]}return{rfId:`1`,width:i??0,height:a??0,transform:S,nodes:v,nodesInitialized:x,nodeLookup:p,parentLookup:m,edges:_,edgeLookup:g,connectionLookup:h,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:n!==void 0,hasDefaultEdges:r!==void 0,panZoom:null,minZoom:c,maxZoom:l,translateExtent:so,nodeExtent:b,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:uo.Strict,domNode:null,paneDragging:!1,noPanClassName:`nopan`,nodeOrigin:y,nodeDragThreshold:1,connectionDragThreshold:1,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesReconnectable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,elevateEdgesOnSelect:!0,selectNodesOnDrag:!0,multiSelectionActive:!1,fitViewQueued:o??!1,fitViewOptions:s,fitViewResolver:null,connection:{...mo},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:``,autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:of,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:`react`,debug:!1,ariaLabelConfig:lo,zIndexMode:f,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},cf=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:i,height:a,fitView:o,fitViewOptions:s,minZoom:c,maxZoom:l,nodeOrigin:u,nodeExtent:d,zIndexMode:f})=>il((p,m)=>{async function h(){let{nodeLookup:e,panZoom:t,fitViewOptions:n,fitViewResolver:r,width:i,height:a,minZoom:o,maxZoom:s}=m();t&&(await Oo({nodes:e,width:i,height:a,panZoom:t,minZoom:o,maxZoom:s},n),r?.resolve(!0),p({fitViewResolver:null}))}return{...sf({nodes:e,edges:t,width:i,height:a,fitView:o,fitViewOptions:s,minZoom:c,maxZoom:l,nodeOrigin:u,nodeExtent:d,defaultNodes:n,defaultEdges:r,zIndexMode:f}),setNodes:e=>{let{nodeLookup:t,parentLookup:n,nodeOrigin:r,elevateNodesOnSelect:i,fitViewQueued:a,zIndexMode:o,nodesSelectionActive:s}=m(),{nodesInitialized:c,hasSelectedNodes:l}=Js(e,t,n,{nodeOrigin:r,nodeExtent:d,elevateNodesOnSelect:i,checkEquality:!0,zIndexMode:o}),u=s&&l;a&&c?(h(),p({nodes:e,nodesInitialized:c,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:u})):p({nodes:e,nodesInitialized:c,nodesSelectionActive:u})},setEdges:e=>{let{connectionLookup:t,edgeLookup:n}=m();rc(t,n,e),p({edges:e})},setDefaultNodesAndEdges:(e,t)=>{if(e){let{setNodes:t}=m();t(e),p({hasDefaultNodes:!0})}if(t){let{setEdges:e}=m();e(t),p({hasDefaultEdges:!0})}},updateNodeInternals:e=>{let{triggerNodeChanges:t,nodeLookup:n,parentLookup:r,domNode:i,nodeOrigin:a,nodeExtent:o,debug:s,fitViewQueued:c,zIndexMode:l}=m(),{changes:u,updatedInternals:d}=ec(e,n,r,i,a,o,l);d&&(Gs(n,r,{nodeOrigin:a,nodeExtent:o,zIndexMode:l}),c?(h(),p({fitViewQueued:!1,fitViewOptions:void 0})):p({}),u?.length>0&&(s&&console.log(`React Flow: trigger node changes`,u),t?.(u)))},updateNodePositions:(e,t=!1)=>{let n=[],r=[],{nodeLookup:i,triggerNodeChanges:a,connection:o,updateConnection:s,onNodesChangeMiddlewareMap:c}=m();for(let[a,c]of e){let e=i.get(a),l=!!(e?.expandParent&&e?.parentId&&c?.position),u={id:a,type:`position`,position:l?{x:Math.max(0,c.position.x),y:Math.max(0,c.position.y)}:c.position,dragging:t};if(e&&o.inProgress&&o.fromNode.id===e.id){let t=Is(e,o.fromHandle,Z.Left,!0);s({...o,from:t})}l&&e.parentId&&n.push({id:a,parentId:e.parentId,rect:{...c.internals.positionAbsolute,width:c.measured.width??0,height:c.measured.height??0}}),r.push(u)}if(n.length>0){let{parentLookup:e,nodeOrigin:t}=m(),a=$s(n,i,e,t);r.push(...a)}for(let e of c.values())r=e(r);a(r)},triggerNodeChanges:e=>{let{onNodesChange:t,setNodes:n,nodes:r,hasDefaultNodes:i,debug:a}=m();e?.length&&(i&&n(Hl(e,r)),a&&console.log(`React Flow: trigger node changes`,e),t?.(e))},triggerEdgeChanges:e=>{let{onEdgesChange:t,setEdges:n,edges:r,hasDefaultEdges:i,debug:a}=m();e?.length&&(i&&n(Ul(e,r)),a&&console.log(`React Flow: trigger edge changes`,e),t?.(e))},addSelectedNodes:e=>{let{multiSelectionActive:t,edgeLookup:n,nodeLookup:r,triggerNodeChanges:i,triggerEdgeChanges:a}=m();if(t){i(e.map(e=>Wl(e,!0)));return}i(Gl(r,new Set([...e]),!0)),a(Gl(n))},addSelectedEdges:e=>{let{multiSelectionActive:t,edgeLookup:n,nodeLookup:r,triggerNodeChanges:i,triggerEdgeChanges:a}=m();if(t){a(e.map(e=>Wl(e,!0)));return}a(Gl(n,new Set([...e]))),i(Gl(r,new Set,!0))},unselectNodesAndEdges:({nodes:e,edges:t}={})=>{let{edges:n,nodes:r,nodeLookup:i,triggerNodeChanges:a,triggerEdgeChanges:o}=m(),s=e||r,c=t||n,l=[];for(let e of s){if(!e.selected)continue;let t=i.get(e.id);t&&(t.selected=!1),l.push(Wl(e.id,!1))}let u=[];for(let e of c)e.selected&&u.push(Wl(e.id,!1));a(l),o(u)},setMinZoom:e=>{let{panZoom:t,maxZoom:n}=m();t?.setScaleExtent([e,n]),p({minZoom:e})},setMaxZoom:e=>{let{panZoom:t,minZoom:n}=m();t?.setScaleExtent([n,e]),p({maxZoom:e})},setTranslateExtent:e=>{m().panZoom?.setTranslateExtent(e),p({translateExtent:e})},resetSelectedElements:()=>{let{edges:e,nodes:t,triggerNodeChanges:n,triggerEdgeChanges:r,elementsSelectable:i}=m();if(!i)return;let a=t.reduce((e,t)=>t.selected?[...e,Wl(t.id,!1)]:e,[]),o=e.reduce((e,t)=>t.selected?[...e,Wl(t.id,!1)]:e,[]);n(a),r(o)},setNodeExtent:e=>{let{nodes:t,nodeLookup:n,parentLookup:r,nodeOrigin:i,elevateNodesOnSelect:a,nodeExtent:o,zIndexMode:s}=m();(e[0][0]!==o[0][0]||e[0][1]!==o[0][1]||e[1][0]!==o[1][0]||e[1][1]!==o[1][1])&&(Js(t,n,r,{nodeOrigin:i,nodeExtent:e,elevateNodesOnSelect:a,checkEquality:!1,zIndexMode:s}),p({nodeExtent:e}))},panBy:e=>{let{transform:t,width:n,height:r,panZoom:i,translateExtent:a}=m();return tc({delta:e,panZoom:i,transform:t,translateExtent:a,width:n,height:r})},setCenter:async(e,t,n)=>{let{width:r,height:i,maxZoom:a,panZoom:o}=m();if(!o)return!1;let s=n?.zoom===void 0?a:n.zoom;return await o.setViewport({x:r/2-e*s,y:i/2-t*s,zoom:s},{duration:n?.duration,ease:n?.ease,interpolate:n?.interpolate}),!0},cancelConnection:()=>{p({connection:{...mo}})},updateConnection:e=>{p({connection:e})},reset:()=>p({...sf()})}},Object.is);function lf({initialNodes:e,initialEdges:t,defaultNodes:n,defaultEdges:r,initialWidth:i,initialHeight:a,initialMinZoom:o,initialMaxZoom:s,initialFitViewOptions:c,fitView:l,nodeOrigin:u,nodeExtent:d,zIndexMode:f,children:p}){let[m]=(0,Y.useState)(()=>cf({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:i,height:a,fitView:l,minZoom:o,maxZoom:s,fitViewOptions:c,nodeOrigin:u,nodeExtent:d,zIndexMode:f}));return(0,J.jsx)(sl,{value:m,children:(0,J.jsx)(ru,{children:(0,J.jsx)(Ou,{children:p})})})}function uf({children:e,nodes:t,edges:n,defaultNodes:r,defaultEdges:i,width:a,height:o,fitView:s,fitViewOptions:c,minZoom:l,maxZoom:u,nodeOrigin:d,nodeExtent:f,zIndexMode:p}){return(0,Y.useContext)(ol)?(0,J.jsx)(J.Fragment,{children:e}):(0,J.jsx)(lf,{initialNodes:t,initialEdges:n,defaultNodes:r,defaultEdges:i,initialWidth:a,initialHeight:o,fitView:s,initialFitViewOptions:c,initialMinZoom:l,initialMaxZoom:u,nodeOrigin:d,nodeExtent:f,zIndexMode:p,children:e})}var df={width:`100%`,height:`100%`,overflow:`hidden`,position:`relative`,zIndex:0};function ff({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,className:i,nodeTypes:a,edgeTypes:o,onNodeClick:s,onEdgeClick:c,onInit:l,onMove:u,onMoveStart:d,onMoveEnd:f,onConnect:p,onConnectStart:m,onConnectEnd:h,onClickConnectStart:g,onClickConnectEnd:_,onNodeMouseEnter:v,onNodeMouseMove:y,onNodeMouseLeave:b,onNodeContextMenu:x,onNodeDoubleClick:S,onNodeDragStart:C,onNodeDrag:w,onNodeDragStop:T,onNodesDelete:E,onEdgesDelete:D,onDelete:O,onSelectionChange:k,onSelectionDragStart:A,onSelectionDrag:j,onSelectionDragStop:M,onSelectionContextMenu:N,onSelectionStart:P,onSelectionEnd:F,onBeforeDelete:I,connectionMode:L,connectionLineType:R=ho.Bezier,connectionLineStyle:z,connectionLineComponent:B,connectionLineContainerStyle:V,deleteKeyCode:ee=`Backspace`,selectionKeyCode:te=`Shift`,selectionOnDrag:H=!1,selectionMode:U=po.Full,panActivationKeyCode:W=`Space`,multiSelectionKeyCode:G=es()?`Meta`:`Control`,zoomActivationKeyCode:K=es()?`Meta`:`Control`,snapToGrid:ne,snapGrid:re,onlyRenderVisibleElements:ie=!1,selectNodesOnDrag:ae,nodesDraggable:oe,autoPanOnNodeFocus:se,nodesConnectable:ce,nodesFocusable:le,nodeOrigin:q=Dl,edgesFocusable:ue,edgesReconnectable:de,elementsSelectable:fe=!0,defaultViewport:pe=Ol,minZoom:me=.5,maxZoom:X=2,translateExtent:he=so,preventScrolling:ge=!0,nodeExtent:_e,defaultMarkerColor:ve=`#b1b1b7`,zoomOnScroll:ye=!0,zoomOnPinch:be=!0,panOnScroll:xe=!1,panOnScrollSpeed:Ce=.5,panOnScrollMode:we=fo.Free,zoomOnDoubleClick:Te=!0,panOnDrag:Ee=!0,onPaneClick:De,onPaneMouseEnter:Oe,onPaneMouseMove:ke,onPaneMouseLeave:Ae,onPaneScroll:je,onPaneContextMenu:Me,paneClickDistance:Ne=1,nodeClickDistance:Pe=0,children:Fe,onReconnect:Ie,onReconnectStart:Le,onReconnectEnd:Re,onEdgeContextMenu:ze,onEdgeDoubleClick:Be,onEdgeMouseEnter:Ve,onEdgeMouseMove:He,onEdgeMouseLeave:Ue,reconnectRadius:We=10,onNodesChange:Ge,onEdgesChange:Ke,noDragClassName:qe=`nodrag`,noWheelClassName:Je=`nowheel`,noPanClassName:Ye=`nopan`,fitView:Xe,fitViewOptions:Ze,connectOnClick:Qe,attributionPosition:$e,proOptions:et,defaultEdgeOptions:tt,elevateNodesOnSelect:nt=!0,elevateEdgesOnSelect:rt=!1,disableKeyboardA11y:it=!1,autoPanOnConnect:at,autoPanOnNodeDrag:ot,autoPanOnSelection:st=!0,autoPanSpeed:ct,connectionRadius:lt,isValidConnection:ut,onError:dt,style:ft,id:pt,nodeDragThreshold:mt,connectionDragThreshold:ht,viewport:gt,onViewportChange:_t,width:vt,height:yt,colorMode:bt=`light`,debug:xt,onScroll:St,ariaLabelConfig:Ct,zIndexMode:wt=`basic`,...Tt},Et){let Dt=pt||`1`,Ot=Pl(bt),kt=(0,Y.useCallback)(e=>{e.currentTarget.scrollTo({top:0,left:0,behavior:`instant`}),St?.(e)},[St]);return(0,J.jsx)(`div`,{"data-testid":`rf__wrapper`,...Tt,onScroll:kt,style:{...ft,...df},ref:Et,className:Se([`react-flow`,i,Ot]),id:pt,role:`application`,children:(0,J.jsxs)(uf,{nodes:e,edges:t,width:vt,height:yt,fitView:Xe,fitViewOptions:Ze,minZoom:me,maxZoom:X,nodeOrigin:q,nodeExtent:_e,zIndexMode:wt,children:[(0,J.jsx)(Ml,{nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:p,onConnectStart:m,onConnectEnd:h,onClickConnectStart:g,onClickConnectEnd:_,nodesDraggable:oe,autoPanOnNodeFocus:se,nodesConnectable:ce,nodesFocusable:le,edgesFocusable:ue,edgesReconnectable:de,elementsSelectable:fe,elevateNodesOnSelect:nt,elevateEdgesOnSelect:rt,minZoom:me,maxZoom:X,nodeExtent:_e,onNodesChange:Ge,onEdgesChange:Ke,snapToGrid:ne,snapGrid:re,connectionMode:L,translateExtent:he,connectOnClick:Qe,defaultEdgeOptions:tt,fitView:Xe,fitViewOptions:Ze,onNodesDelete:E,onEdgesDelete:D,onDelete:O,onNodeDragStart:C,onNodeDrag:w,onNodeDragStop:T,onSelectionDrag:j,onSelectionDragStart:A,onSelectionDragStop:M,onMove:u,onMoveStart:d,onMoveEnd:f,noPanClassName:Ye,nodeOrigin:q,rfId:Dt,autoPanOnConnect:at,autoPanOnNodeDrag:ot,autoPanSpeed:ct,onError:dt,connectionRadius:lt,isValidConnection:ut,selectNodesOnDrag:ae,nodeDragThreshold:mt,connectionDragThreshold:ht,onBeforeDelete:I,debug:xt,ariaLabelConfig:Ct,zIndexMode:wt}),(0,J.jsx)(af,{onInit:l,onNodeClick:s,onEdgeClick:c,onNodeMouseEnter:v,onNodeMouseMove:y,onNodeMouseLeave:b,onNodeContextMenu:x,onNodeDoubleClick:S,nodeTypes:a,edgeTypes:o,connectionLineType:R,connectionLineStyle:z,connectionLineComponent:B,connectionLineContainerStyle:V,selectionKeyCode:te,selectionOnDrag:H,selectionMode:U,deleteKeyCode:ee,multiSelectionKeyCode:G,panActivationKeyCode:W,zoomActivationKeyCode:K,onlyRenderVisibleElements:ie,defaultViewport:pe,translateExtent:he,minZoom:me,maxZoom:X,preventScrolling:ge,zoomOnScroll:ye,zoomOnPinch:be,zoomOnDoubleClick:Te,panOnScroll:xe,panOnScrollSpeed:Ce,panOnScrollMode:we,panOnDrag:Ee,autoPanOnSelection:st,onPaneClick:De,onPaneMouseEnter:Oe,onPaneMouseMove:ke,onPaneMouseLeave:Ae,onPaneScroll:je,onPaneContextMenu:Me,paneClickDistance:Ne,nodeClickDistance:Pe,onSelectionContextMenu:N,onSelectionStart:P,onSelectionEnd:F,onReconnect:Ie,onReconnectStart:Le,onReconnectEnd:Re,onEdgeContextMenu:ze,onEdgeDoubleClick:Be,onEdgeMouseEnter:Ve,onEdgeMouseMove:He,onEdgeMouseLeave:Ue,reconnectRadius:We,defaultMarkerColor:ve,noDragClassName:qe,noWheelClassName:Je,noPanClassName:Ye,rfId:Dt,disableKeyboardA11y:it,nodeExtent:_e,viewport:gt,onViewportChange:_t}),(0,J.jsx)(El,{onSelectionChange:k}),Fe,(0,J.jsx)(bl,{proOptions:et,position:$e}),(0,J.jsx)(_l,{rfId:Dt,disableKeyboardA11y:it})]})})}var pf=Ql(ff),mf=e=>e.domNode?.querySelector(`.react-flow__edgelabel-renderer`);function hf({children:e}){let t=Q(mf);return t?(0,pe.createPortal)(e,t):null}function gf(e){let[t,n]=(0,Y.useState)(e);return[t,n,(0,Y.useCallback)(e=>n(t=>Hl(e,t)),[])]}var _f=e=>t=>{if(!e.includeHiddenNodes)return t.nodesInitialized;if(t.nodeLookup.size===0)return!1;for(let[,{internals:e}]of t.nodeLookup)if(e.handleBounds===void 0||!rs(e.userNode))return!1;return!0};function vf(e={includeHiddenNodes:!1}){return Q(_f(e))}oo.error014();function yf({dimensions:e,lineWidth:t,variant:n,className:r}){return(0,J.jsx)(`path`,{strokeWidth:t,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:Se([`react-flow__background-pattern`,n,r])})}function bf({radius:e,className:t}){return(0,J.jsx)(`circle`,{cx:e,cy:e,r:e,className:Se([`react-flow__background-pattern`,`dots`,t])})}var xf;(function(e){e.Lines=`lines`,e.Dots=`dots`,e.Cross=`cross`})(xf||={});var Sf={[xf.Dots]:1,[xf.Lines]:1,[xf.Cross]:6},Cf=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function wf({id:e,variant:t=xf.Dots,gap:n=20,size:r,lineWidth:i=1,offset:a=0,color:o,bgColor:s,style:c,className:l,patternClassName:u}){let d=(0,Y.useRef)(null),{transform:f,patternId:p}=Q(Cf,al),m=r||Sf[t],h=t===xf.Dots,g=t===xf.Cross,_=Array.isArray(n)?n:[n,n],v=[_[0]*f[2]||1,_[1]*f[2]||1],y=m*f[2],b=Array.isArray(a)?a:[a,a],x=g?[y,y]:v,S=[b[0]*f[2]||1+x[0]/2,b[1]*f[2]||1+x[1]/2],C=`${p}${e||``}`;return(0,J.jsxs)(`svg`,{className:Se([`react-flow__background`,l]),style:{...c,...du,"--xy-background-color-props":s,"--xy-background-pattern-color-props":o},ref:d,"data-testid":`rf__background`,children:[(0,J.jsx)(`pattern`,{id:C,x:f[0]%v[0],y:f[1]%v[1],width:v[0],height:v[1],patternUnits:`userSpaceOnUse`,patternTransform:`translate(-${S[0]},-${S[1]})`,children:h?(0,J.jsx)(bf,{radius:y/2,className:u}):(0,J.jsx)(yf,{dimensions:x,lineWidth:i,variant:t,className:u})}),(0,J.jsx)(`rect`,{x:`0`,y:`0`,width:`100%`,height:`100%`,fill:`url(#${C})`})]})}wf.displayName=`Background`;var Tf=(0,Y.memo)(wf);function Ef(){return(0,J.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 32 32`,children:(0,J.jsx)(`path`,{d:`M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z`})})}function Df(){return(0,J.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 32 5`,children:(0,J.jsx)(`path`,{d:`M0 0h32v4.2H0z`})})}function Of(){return(0,J.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 32 30`,children:(0,J.jsx)(`path`,{d:`M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z`})})}function kf(){return(0,J.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 25 32`,children:(0,J.jsx)(`path`,{d:`M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z`})})}function Af(){return(0,J.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 25 32`,children:(0,J.jsx)(`path`,{d:`M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z`})})}function jf({children:e,className:t,...n}){return(0,J.jsx)(`button`,{type:`button`,className:Se([`react-flow__controls-button`,t]),...n,children:e})}var Mf=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function Nf({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:r=!0,fitViewOptions:i,onZoomIn:a,onZoomOut:o,onFitView:s,onInteractiveChange:c,className:l,children:u,position:d=`bottom-left`,orientation:f=`vertical`,"aria-label":p}){let m=$(),{isInteractive:h,minZoomReached:g,maxZoomReached:_,ariaLabelConfig:v}=Q(Mf,al),{zoomIn:y,zoomOut:b,fitView:x}=ou();return(0,J.jsxs)(vl,{className:Se([`react-flow__controls`,f===`horizontal`?`horizontal`:`vertical`,l]),position:d,style:e,"data-testid":`rf__controls`,"aria-label":p??v[`controls.ariaLabel`],children:[t&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(jf,{onClick:()=>{y(),a?.()},className:`react-flow__controls-zoomin`,title:v[`controls.zoomIn.ariaLabel`],"aria-label":v[`controls.zoomIn.ariaLabel`],disabled:_,children:(0,J.jsx)(Ef,{})}),(0,J.jsx)(jf,{onClick:()=>{b(),o?.()},className:`react-flow__controls-zoomout`,title:v[`controls.zoomOut.ariaLabel`],"aria-label":v[`controls.zoomOut.ariaLabel`],disabled:g,children:(0,J.jsx)(Df,{})})]}),n&&(0,J.jsx)(jf,{className:`react-flow__controls-fitview`,onClick:()=>{x(i),s?.()},title:v[`controls.fitView.ariaLabel`],"aria-label":v[`controls.fitView.ariaLabel`],children:(0,J.jsx)(Of,{})}),r&&(0,J.jsx)(jf,{className:`react-flow__controls-interactive`,onClick:()=>{m.setState({nodesDraggable:!h,nodesConnectable:!h,elementsSelectable:!h}),c?.(!h)},title:v[`controls.interactive.ariaLabel`],"aria-label":v[`controls.interactive.ariaLabel`],children:h?(0,J.jsx)(Af,{}):(0,J.jsx)(kf,{})}),u]})}Nf.displayName=`Controls`;var Pf=(0,Y.memo)(Nf);function Ff({id:e,x:t,y:n,width:r,height:i,style:a,color:o,strokeColor:s,strokeWidth:c,className:l,borderRadius:u,shapeRendering:d,selected:f,onClick:p}){let{background:m,backgroundColor:h}=a||{},g=o||m||h;return(0,J.jsx)(`rect`,{className:Se([`react-flow__minimap-node`,{selected:f},l]),x:t,y:n,rx:u,ry:u,width:r,height:i,style:{fill:g,stroke:s,strokeWidth:c},shapeRendering:d,onClick:p?t=>p(t,e):void 0})}var If=(0,Y.memo)(Ff),Lf=e=>e.nodes.map(e=>e.id),Rf=e=>e instanceof Function?e:()=>e;function zf({nodeStrokeColor:e,nodeColor:t,nodeClassName:n=``,nodeBorderRadius:r=5,nodeStrokeWidth:i,nodeComponent:a=If,onClick:o}){let s=Q(Lf,al),c=Rf(t),l=Rf(e),u=Rf(n),d=typeof window>`u`||window.chrome?`crispEdges`:`geometricPrecision`;return(0,J.jsx)(J.Fragment,{children:s.map(e=>(0,J.jsx)(Vf,{id:e,nodeColorFunc:c,nodeStrokeColorFunc:l,nodeClassNameFunc:u,nodeBorderRadius:r,nodeStrokeWidth:i,NodeComponent:a,onClick:o,shapeRendering:d},e))})}function Bf({id:e,nodeColorFunc:t,nodeStrokeColorFunc:n,nodeClassNameFunc:r,nodeBorderRadius:i,nodeStrokeWidth:a,shapeRendering:o,NodeComponent:s,onClick:c}){let{node:l,x:u,y:d,width:f,height:p}=Q(t=>{let n=t.nodeLookup.get(e);if(!n)return{node:void 0,x:0,y:0,width:0,height:0};let r=n.internals.userNode,{x:i,y:a}=n.internals.positionAbsolute,{width:o,height:s}=ns(r);return{node:r,x:i,y:a,width:o,height:s}},al);return!l||l.hidden||!rs(l)?null:(0,J.jsx)(s,{x:u,y:d,width:f,height:p,style:l.style,selected:!!l.selected,className:r(l),color:t(l),borderRadius:i,strokeColor:n(l),strokeWidth:a,shapeRendering:o,onClick:c,id:l.id})}var Vf=(0,Y.memo)(Bf),Hf=(0,Y.memo)(zf),Uf=200,Wf=150,Gf=e=>!e.hidden,Kf=e=>{let t={x:-e.transform[0]/e.transform[2],y:-e.transform[1]/e.transform[2],width:e.width/e.transform[2],height:e.height/e.transform[2]};return{viewBB:t,boundingRect:e.nodeLookup.size>0?Vo(wo(e.nodeLookup,{filter:Gf}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},qf=`react-flow__minimap-desc`;function Jf({style:e,className:t,nodeStrokeColor:n,nodeColor:r,nodeClassName:i=``,nodeBorderRadius:a=5,nodeStrokeWidth:o,nodeComponent:s,bgColor:c,maskColor:l,maskStrokeColor:u,maskStrokeWidth:d,position:f=`bottom-right`,onClick:p,onNodeClick:m,pannable:h=!1,zoomable:g=!1,ariaLabel:_,inversePan:v,zoomStep:y=1,offsetScale:b=5}){let x=$(),S=(0,Y.useRef)(null),{boundingRect:C,viewBB:w,rfId:T,panZoom:E,translateExtent:D,flowWidth:O,flowHeight:k,ariaLabelConfig:A}=Q(Kf,al),j=e?.width??Uf,M=e?.height??Wf,N=C.width/j,P=C.height/M,F=Math.max(N,P),I=F*j,L=F*M,R=b*F,z=C.x-(I-C.width)/2-R,B=C.y-(L-C.height)/2-R,V=I+R*2,ee=L+R*2,te=`${qf}-${T}`,H=(0,Y.useRef)(0),U=(0,Y.useRef)();H.current=F,(0,Y.useEffect)(()=>{if(S.current&&E)return U.current=bc({domNode:S.current,panZoom:E,getTransform:()=>x.getState().transform,getViewScale:()=>H.current}),()=>{U.current?.destroy()}},[E]),(0,Y.useEffect)(()=>{U.current?.update({translateExtent:D,width:O,height:k,inversePan:v,pannable:h,zoomStep:y,zoomable:g})},[h,g,v,y,D,O,k]);let W=p?e=>{let[t,n]=U.current?.pointer(e)||[0,0];p(e,{x:t,y:n})}:void 0,G=m?(0,Y.useCallback)((e,t)=>{let n=x.getState().nodeLookup.get(t).internals.userNode;m(e,n)},[]):void 0,K=_??A[`minimap.ariaLabel`];return(0,J.jsx)(vl,{position:f,style:{...e,"--xy-minimap-background-color-props":typeof c==`string`?c:void 0,"--xy-minimap-mask-background-color-props":typeof l==`string`?l:void 0,"--xy-minimap-mask-stroke-color-props":typeof u==`string`?u:void 0,"--xy-minimap-mask-stroke-width-props":typeof d==`number`?d*F:void 0,"--xy-minimap-node-background-color-props":typeof r==`string`?r:void 0,"--xy-minimap-node-stroke-color-props":typeof n==`string`?n:void 0,"--xy-minimap-node-stroke-width-props":typeof o==`number`?o:void 0},className:Se([`react-flow__minimap`,t]),"data-testid":`rf__minimap`,children:(0,J.jsxs)(`svg`,{width:j,height:M,viewBox:`${z} ${B} ${V} ${ee}`,className:`react-flow__minimap-svg`,role:`img`,"aria-labelledby":te,ref:S,onClick:W,children:[K&&(0,J.jsx)(`title`,{id:te,children:K}),(0,J.jsx)(Hf,{onClick:G,nodeColor:r,nodeStrokeColor:n,nodeBorderRadius:a,nodeClassName:i,nodeStrokeWidth:o,nodeComponent:s}),(0,J.jsx)(`path`,{className:`react-flow__minimap-mask`,d:`M${z-R},${B-R}h${V+R*2}v${ee+R*2}h${-V-R*2}z + M${w.x},${w.y}h${w.width}v${w.height}h${-w.width}z`,fillRule:`evenodd`,pointerEvents:`none`})]})})}Jf.displayName=`MiniMap`;var Yf=(0,Y.memo)(Jf),Xf=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,Zf={[Fc.Line]:`right`,[Fc.Handle]:`bottom-right`};function Qf({nodeId:e,position:t,variant:n=Fc.Handle,className:r,style:i=void 0,children:a,color:o,minWidth:s=10,minHeight:c=10,maxWidth:l=Number.MAX_VALUE,maxHeight:u=Number.MAX_VALUE,keepAspectRatio:d=!1,resizeDirection:f,autoScale:p=!0,shouldResize:m,onResizeStart:h,onResize:g,onResizeEnd:_}){let v=Tu(),y=typeof e==`string`?e:v,b=$(),x=(0,Y.useRef)(null),S=n===Fc.Handle,C=Q((0,Y.useCallback)(Xf(S&&p),[S,p]),al),w=(0,Y.useRef)(null),T=t??Zf[n];(0,Y.useEffect)(()=>{if(!(!x.current||!y))return w.current||=Kc({domNode:x.current,nodeId:y,getStoreItems:()=>{let{nodeLookup:e,transform:t,snapGrid:n,snapToGrid:r,nodeOrigin:i,domNode:a}=b.getState();return{nodeLookup:e,transform:t,snapGrid:n,snapToGrid:r,nodeOrigin:i,paneDomNode:a}},onChange:(e,t)=>{let{triggerNodeChanges:n,nodeLookup:r,parentLookup:i,nodeOrigin:a}=b.getState(),o=[],s={x:e.x,y:e.y},c=r.get(y);if(c&&c.expandParent&&c.parentId){let t=c.origin??a,n=e.width??c.measured.width??0,l=e.height??c.measured.height??0,u=$s([{id:c.id,parentId:c.parentId,rect:{width:n,height:l,...is({x:e.x??c.position.x,y:e.y??c.position.y},{width:n,height:l},c.parentId,r,t)}}],r,i,a);o.push(...u),s.x=e.x?Math.max(t[0]*n,e.x):void 0,s.y=e.y?Math.max(t[1]*l,e.y):void 0}if(s.x!==void 0&&s.y!==void 0){let e={id:y,type:`position`,position:{...s}};o.push(e)}if(e.width!==void 0&&e.height!==void 0){let t={id:y,type:`dimensions`,resizing:!0,setAttributes:f?f===`horizontal`?`width`:`height`:!0,dimensions:{width:e.width,height:e.height}};o.push(t)}for(let e of t){let t={...e,type:`position`};o.push(t)}n(o)},onEnd:({width:e,height:t})=>{let n={id:y,type:`dimensions`,resizing:!1,dimensions:{width:e,height:t}};b.getState().triggerNodeChanges([n])}}),w.current.update({controlPosition:T,boundaries:{minWidth:s,minHeight:c,maxWidth:l,maxHeight:u},keepAspectRatio:d,resizeDirection:f,onResizeStart:h,onResize:g,onResizeEnd:_,shouldResize:m}),()=>{w.current?.destroy()}},[T,s,c,l,u,d,h,g,_,m]);let E=T.split(`-`);return(0,J.jsx)(`div`,{className:Se([`react-flow__resize-control`,`nodrag`,...E,n,r]),ref:x,style:{...i,scale:C,...o&&{[S?`backgroundColor`:`borderColor`]:o}},children:a})}(0,Y.memo)(Qf);var $f=new Set([`running`,`in_progress`,`claimed`]);function ep(e){return e.pending_question?`question`:$f.has(e.status)?`running`:e.status.startsWith(`paused`)||e.status===`blocked`?`paused`:[`done`,`failed`,`aborted`,`skipped`,`superseded`,`pending`,`missing`].includes(e.status)?e.status:`unknown`}function tp(e){let t=new Set,n=[],r=new Map([...e.keys()].map(e=>[e,[]]));for(let[t,n]of e)for(let e of n)r.get(e).push(t);for(let r of e.keys()){let i=[[r,!1]];for(;i.length;){let[r,a]=i.pop();if(a)n.push(r);else if(!t.has(r)){t.add(r),i.push([r,!0]);for(let n of e.get(r))t.has(n)||i.push([n,!1])}}}let i=new Map;for(let e of n.reverse()){if(i.has(e))continue;let t=i.size,n=[e];for(;n.length;){let e=n.pop();if(!i.has(e)){i.set(e,t);for(let t of r.get(e))n.push(t)}}}return i}function np(e){let t=new Map(e.map(e=>[e.id,e])),n=[...t.values()].sort((e,t)=>(e.ts??0)-(t.ts??0)||e.id.localeCompare(t.id)),r=[],i=new Set;for(let e of n)for(let n of new Set(e.deps??[]))t.has(n)||i.add(n),r.push({id:JSON.stringify([`dep`,n,e.id]),source:n,target:e.id,kind:`dependency`,missing:!t.has(n)});let a=[...[...i].map(e=>({id:e,title:`未包含的依赖`,objective:`该引用不在当前数据范围内。`,status:`missing`,deps:[],role:`system`})),...n],o=new Map(a.map(e=>[e.id,0])),s=new Map(a.map(e=>[e.id,[]]));r.forEach(e=>{o.set(e.target,(o.get(e.target)??0)+1),s.get(e.source)?.push(e.target)});let c=a.filter(e=>o.get(e.id)===0).map(e=>e.id),l=0;for(let e=0;et.id!==e.id&&t.plan_id===e.superseded_by_plan_id);t.length&&r.push({id:JSON.stringify([`replacement`,e.id,e.superseded_by_plan_id]),source:e.id,target:t[0].id,kind:`replacement`,target_plan_id:e.superseded_by_plan_id,target_count:t.length})}if(u){let e=tp(s);r.filter(t=>t.kind===`dependency`&&e.get(t.source)===e.get(t.target)).forEach(e=>{e.cycle=!0})}return{tasks:a,links:r,missing:i.size,cyclic:u}}function rp(e,t){let n=e.team_task_id?.match(/route-(\d+)/)?.[1],r=e.team_role===`idea-route`?t?`研究路线`:`Research route`:e.team_role===`idea-review`?t?`独立复核`:`Independent review`:e.team_role===`idea-selector`?t?`方案选择`:`Idea selection`:``;return r?`${r}${n?` ${n}`:``}`:e.title||(t?`并行子任务`:`Parallel task`)}function ip(e){let t=String(e||``).split(/\r?\n/).map(e=>e.replace(/^\s*(?:RESULT|SUMMARY|NEXT_ACTION)\s*=\s*/i,``).trim()).filter(e=>e&&!/^(?:Decision\s*:|(?:MILESTONE_STATUS|NEXT_OWNER|OPERATOR_QUESTION|OPERATOR_OPTIONS)\s*=)/i.test(e)).join(` `);return t.length>160?`${t.slice(0,159)}…`:t}function ap(e){let t=new Map;for(let n of e){if(n.type!==`idea.portfolio.formed`)continue;let e=Number(n.width);if(!Number.isInteger(e)||e<=0)continue;let r=t.get(n.item_id);(!r||n.ts>=r.ts)&&t.set(n.item_id,{ts:n.ts,width:e})}return new Map([...t].map(([e,t])=>[e,t.width]))}function op(e,t,n){let r=new Map;for(let e of t){if(e.type!==`team.task`||!e.item_id)continue;let t=r.get(e.item_id)??new Map;t.set(e.id,e),r.set(e.item_id,t)}if(!r.size)return e;let i=new Set(e.tasks.map(e=>e.id)),a=[],o=[];for(let t of e.tasks){if(t.branch)continue;let e=[...r.get(t.id)?.values()??[]].filter(e=>!i.has(e.id)).sort((e,t)=>e.ts-t.ts||e.id.localeCompare(t.id));if(!e.length)continue;let s=e.slice(0,16),c=new Set(s.map(e=>e.id));for(let e of s)i.add(e.id),a.push({id:e.id,title:rp(e,n),objective:ip(e.text),excerpt:ip(e.text),status:e.status||`unknown`,deps:[],pending_question:e.pending_question,role:`team`,team_role:e.team_role,ts:e.ts,branch:!0,parent_id:t.id});let l=new Set(s.flatMap(e=>(e.deps??[]).filter(t=>c.has(t)&&t!==e.id)));for(let e of s){let n=[...new Set(e.deps??[])].filter(t=>c.has(t)&&t!==e.id);if(n.length)for(let t of n)o.push({id:JSON.stringify([`fanout`,t,e.id]),source:t,target:e.id,kind:`fanout`});else o.push({id:JSON.stringify([`fanout`,t.id,e.id]),source:t.id,target:e.id,kind:`fanout`});l.has(e.id)||o.push({id:JSON.stringify([`fanin`,e.id,t.id]),source:e.id,target:t.id,kind:`fanin`})}let u=e.length-s.length,d=`team-overflow:${t.id}`;u>0&&!i.has(d)&&(i.add(d),a.push({id:d,title:n?`还有 ${u} 条`:`+${u} more`,objective:n?`更多并行子任务收录在所属任务卡片中。`:`The remaining parallel subtasks live inside the owning card.`,status:`recorded`,deps:[],role:`team`,ts:e[16]?.ts,branch:!0,parent_id:t.id,overflow_count:u}),o.push({id:JSON.stringify([`fanout`,t.id,d]),source:t.id,target:d,kind:`fanout`},{id:JSON.stringify([`fanin`,d,t.id]),source:d,target:t.id,kind:`fanin`}))}return a.length?{...e,tasks:[...e.tasks,...a],links:[...e.links,...o]}:e}function sp(e,t,n){let r=e.links.map(e=>{let r=t.find(t=>t.source===e.source&&t.target===e.target);return r&&e.kind===`dependency`?{...e,label:r.label,evidence:`${n?`执行依赖`:`Execution dependency`} · ${r.evidence}`}:e}),i=new Map(e.tasks.map(e=>[e.id,e.id])),a=e=>{let t=i.get(e);return t===e?e:a(t)},o=(e,t)=>{i.set(a(e),a(t))};for(let e of r.filter(e=>e.kind===`dependency`))o(e.source,e.target);for(let n of t)!i.has(n.source)||!i.has(n.target)||e.tasks.findIndex(e=>e.id===n.source)>=e.tasks.findIndex(e=>e.id===n.target)||a(n.source)===a(n.target)||(r.push({...n,kind:`semantic`,id:`semantic:${n.source}:${n.target}`}),o(n.source,n.target));for(let t=1;tcp+Math.min(500,Math.max(0,e-8)*60);function dp(e,t,n,r,i,a,o){let s=new Map(n.map(e=>[e,t[e].y+i[e].height/2]));for(let c=0;c<6;c++)for(let l of c%2?[...e].reverse():e){let e=new Set(l),c=[],u=[],d=0;l.forEach((f,p)=>{let m=s.get(f)*.8,h=.8;for(let o of a[r.get(f)]){let r=n[o.index];e.has(r)||(m+=(t[r].y+i[r].height/2)*o.weight,h+=o.weight)}c.push(d);let g=m/h-i[f].height/2-d;for(u.push({start:p,end:p,sum:g*h,weight:h});u.length>1;){let e=u[u.length-2],t=u[u.length-1];if(e.sum/e.weight<=t.sum/t.weight)break;e.end=t.end,e.sum+=t.sum,e.weight+=t.weight,u.pop()}d+=i[f].height+(p+1[e,t])),a=t.filter(e=>e.kind!==`replacement`&&e.source!==e.target).map(e=>({source:i.get(e.source),target:i.get(e.target),weight:e.kind===`dependency`||e.kind===`continuation`?1:.4})),o=e.map(()=>[]),s=e.map(()=>[]),c=e.map(()=>[]);for(let e of a)o[e.source].push(e.target),s[e.target].push(e.source),c[e.source].push({index:e.target,weight:e.weight}),c[e.target].push({index:e.source,weight:e.weight});let l=e.reduce((e,t)=>e+n[t].width*n[t].height,0),u=Math.sqrt(l/e.length),d=e.reduce((e,t)=>e+n[t].height,0)/e.length,f=Math.ceil(Math.sqrt(e.length)*1.8),p=e.map(()=>[]);for(let e of a)p[Math.max(e.source,e.target)].push(e);let m=e.map((t,n)=>{let r=0;return Array.from({length:Math.min(f,e.length-n)+1},(e,t)=>{if(t)for(let e of p[n+t-1])Math.min(e.source,e.target)1||s[e.target].length>1)&&(r+=e.weight*.9),r+=Math.max(0,Math.abs(e.target-e.source)-1)*e.weight);return r})}),h={},g=1/0,_=new Set;for(let t=1;t<=f;t++){let o=t*d+(t-1)*lp,f=Array(e.length+1).fill(1/0),p=Array(e.length+1).fill(0);f[0]=0;for(let r=1;r<=e.length;r++){let i=0;for(let a=r-1;a>=Math.max(0,r-t);a--){i+=n[e[a]].height+(a===r-1?0:lp);let t=m[a][r-a];a>0&&s[a].some(e=>s[a-1].includes(e))&&(t+=.7);let c=f[a]+.2+(i/o-1)**2+t;c0;t=p[t])v.unshift(e.slice(p[t],t));let y=JSON.stringify(v);if(_.has(y))continue;_.add(y);let b=v.map(e=>Math.max(...e.map(e=>n[e].width))),x=v.map(e=>e.reduce((e,t)=>e+n[t].height,0)+(e.length-1)*lp),S=b.reduce((e,t)=>e+t,0)+(v.length-1)*r,C=Math.max(...x),w={},T=0;v.forEach((e,t)=>{let i=(C-x[t])/2;for(let r of e)w[r]={x:T+(b[t]-n[r].width)/2,y:i},i+=n[r].height+lp;T+=b[t]+r}),dp(v,w,e,i,n,c,()=>lp);let E=Math.min(...e.map(e=>w[e].y));for(let t of e)w[t].y-=E;C=Math.max(...e.map(e=>w[e].y+n[e].height));let D=a.reduce((t,r)=>{let i=w[e[r.source]],a=w[e[r.target]];return t+Math.hypot(a.x+n[e[r.target]].width/2-i.x-n[e[r.source]].width/2,a.y+n[e[r.target]].height/2-i.y-n[e[r.source]].height/2)*r.weight},0)/Math.max(1,a.length)/u,O=2*Math.log(S/C/2.1)**2+.08*S*C/l+.14*D+.08*f[e.length]/v.length;O[e,t])),a=e=>e.source!==e.target&&i.has(e.source)&&i.has(e.target),o=new Set,s=new Map;for(let e of t)!a(e)||e.kind!==`fanout`&&e.kind!==`fanin`||(e.kind===`fanout`?o.add(e.target):o.add(e.source),(s.get(e.source)??s.set(e.source,new Set).get(e.source)).add(e.target),(s.get(e.target)??s.set(e.target,new Set).get(e.target)).add(e.source));let c=e.map(()=>[]),l=t.filter(e=>e.kind!==`replacement`&&a(e)).map(e=>({source:i.get(e.source),target:i.get(e.target),weight:e.kind===`dependency`||e.kind===`continuation`?1:e.kind===`fanout`||e.kind===`fanin`?.8:.4}));for(let e of l)c[e.source].push({index:e.target,weight:e.weight}),c[e.target].push({index:e.source,weight:e.weight});let u=e.map(()=>[]);for(let e of t){if(!pp.has(e.kind)||!a(e))continue;let t=i.get(e.source),n=i.get(e.target);td[e]))+1:f+1;d.push(e),f=Math.max(f,e)}let p=[];e.forEach((e,t)=>{(p[d[t]]??=[]).push(e)});let m=p.filter(e=>e?.length),h=(e,t)=>o.has(e)&&o.has(t)?lp/2:lp,g=e=>e.reduce((t,r,i)=>t+n[r].height+(i?h(e[i-1],r):0),0),_=e.reduce((e,t)=>e+n[t].width*n[t].height,0),v=Math.sqrt(_/e.length),y=e.filter(e=>!o.has(e)),b=(y.length?y:e).reduce((e,t)=>e+n[t].height,0)/Math.max(1,y.length||e.length),x=Math.ceil(Math.sqrt(e.length)*1.8),S={},C=1/0,w=new Set;for(let t=1;t<=x;t++){let a=t*b+(t-1)*lp,u=[];for(let e of m){let t=[],n=()=>{if(!t.length)return;let e=o.has(t[0]);if(e)u.push({nodes:t,isBranch:e});else{let n=[];for(let r of t)n.length&&g([...n,r])>a&&(u.push({nodes:n,isBranch:e}),n=[]),n.push(r);n.length&&u.push({nodes:n,isBranch:e})}t=[]};for(let r of e)t.length&&o.has(t[0])!==o.has(r)&&n(),t.push(r);n()}let d=[],f=[];for(let e of u){let t=d.at(-1),n=t&&e.nodes.some(e=>t.some(t=>s.get(e)?.has(t)));!t||n||f.at(-1)!==e.isBranch||g([...t,...e.nodes])>a?(d.push([...e.nodes]),f.push(e.isBranch)):t.push(...e.nodes)}let p=JSON.stringify(d);if(w.has(p))continue;w.add(p);let y=d.map(e=>Math.max(...e.map(e=>n[e].width))),x=d.map(g),T=y.reduce((e,t)=>e+t,0)+(d.length-1)*r,E=Math.max(...x),D={},O=0;d.forEach((e,t)=>{let i=(E-x[t])/2;e.forEach((r,a)=>{D[r]={x:O+(y[t]-n[r].width)/2,y:i},i+=n[r].height+(a+1D[e].y));for(let t of e)D[t].y-=k;E=Math.max(...e.map(e=>D[e].y+n[e].height));let A=l.reduce((t,r)=>{let i=D[e[r.source]],a=D[e[r.target]];return t+Math.hypot(a.x+n[e[r.target]].width/2-i.x-n[e[r.source]].width/2,a.y+n[e[r.target]].height/2-i.y-n[e[r.source]].height/2)*r.weight},0)/Math.max(1,l.length)/v,j=2*Math.log(T/E/2.1)**2+.08*T*E/_+.14*A;j=e.length*.3?mp(e,t,n):fp(e,t,n)}function gp(e){let t=new Map,n=new Map,r=new Map;return e.map(e=>{let i=`${e.source}\u0000${e.target}`,a=(t.get(e.source)??0)+(n.get(e.target)??0)-(r.get(i)??0);return t.set(e.source,(t.get(e.source)??0)+1),n.set(e.target,(n.get(e.target)??0)+1),r.set(i,(r.get(i)??0)+1),a})}function _p(e,t){if(e.x===t.x&&e.y===t.y)return{sourceHandle:`right`,targetHandle:`bottom`};let n=t.x+t.width/2-e.x-e.width/2,r=t.y+t.height/2-e.y-e.height/2,i=r>0?t.y-e.y-e.height:e.y-t.y-t.height,a=n>0?t.x-e.x-e.width:e.x-t.x-t.width;return i>=0&&a<0?r>=0?{sourceHandle:`bottom`,targetHandle:`top`}:{sourceHandle:`top`,targetHandle:`bottom`}:n>=0?{sourceHandle:`right`,targetHandle:`left`}:{sourceHandle:`left`,targetHandle:`right`}}var vp={width:1440,height:1080},yp=[`plan`,`execution`,`review`,`revision`,`result`];function bp(e,t){let n=e.team_task_id?.match(/route-(\d+)/)?.[1],r=e.team_role===`idea-route`?t?`研究路线`:`Research route`:e.team_role===`idea-review`?t?`独立复核`:`Independent review`:e.team_role===`idea-selector`?t?`方案选择`:`Idea selection`:``;return r?`${r}${n?` ${n}`:``}`:e.title||(t?`并行子任务`:`Parallel task`)}function xp(e,t,n){return e.pending_question?t?`需要答复,展开查看具体问题`:`Needs your input; open to read the question`:e.status===`failed`?t?`本次执行失败,展开查看原因`:`This attempt failed; open to read the reason`:e.status===`blocked`?t?`执行受阻,展开查看原因`:`Work is blocked; open to read the reason`:e.status===`done`?e.team_role===`idea-review`?t?`独立复核已完成,展开查看记录`:`Independent review completed; open to read the record`:t?`子任务执行已完成,展开查看记录`:`Subtask execution completed; open to read the record`:e.status===`pending`?n?t?`等待前置子任务完成后开始`:`Waiting for prerequisite subtasks to finish`:t?`等待分配 Agent 执行`:`Waiting for an agent to start`:$f.has(e.status||``)?e.team_role===`idea-route`?t?`正在开展来源研究,整理候选方案`:`Researching sources and developing a candidate idea`:e.team_role===`idea-review`?t?`正在独立核对依据、创新性和风险`:`Independently checking evidence, novelty and risks`:e.team_role===`idea-selector`?t?`正在对比研究路线及复核意见`:`Comparing research routes and independent reviews`:t?`Agent 正在执行此子任务`:`An agent is working on this subtask`:t?`展开查看子任务执行记录`:`Open to read the subtask record`}var Sp=e=>e?`暂无详细记录`:`No details available yet.`,Cp=[{match:/provider[\s-]?turn/i,bare:/^One Engineer call used its whole per-call provider-turn allowance/,zh:`继续换了个新会话接着做,之前的进展都在`,en:`Continued in a fresh session; earlier progress is kept`},{match:/budget (limit|cap|exhausted)|blocking budget|预算上限/i,bare:/^Paused because this project reached its budget limit/,zh:`花费到了预算上限,先暂停;提高预算后可以继续`,en:`Paused at the budget limit; work resumes once the budget is raised`},{match:/quarantin/i,bare:/^The task signature is quarantined out of planner rotation/,zh:`这个方向连续失败,先搁置,不再自动重试`,en:`This direction kept failing and is set aside; it will not retry on its own`},{match:/backend[\s\S]{0,24}?(fail|unavailable|paused)|backend_failure|provider cooldown|configured model is unavailable/i,bare:/^(?:backend failure; retrying in a fresh|The backend has failed the same way \d+ times in a row)/,zh:`模型服务暂时不稳定,稍后会自动重试`,en:`The model service was briefly unavailable; it retries after a short wait`}];function wp(e,t){let n=String(e||``).trim(),r=n.search(/Runner receipt:/i),i=r>=0?n.slice(r).trim():``,a=i?Cp.find(e=>e.match.test(n)):Cp.find(e=>e.bare?.test(n));return a?{summary:t?a.zh:a.en,receipt:i||n}:{summary:``,receipt:i}}function Tp(e,t=140){let n=e.replace(/\s+/g,` `).trim();if(!n)return``;let r=n.match(/^.*?[。!?!?.](?=\s|$)/),i=(r?r[0]:n).trim();return i.length>t?`${i.slice(0,t-1).trimEnd()}…`:i}function Ep(e){let t=e.replace(/\s+/g,` `).trim().split(/[。!?;;::,,\n]|\.(?=\s|$)|[!?](?=\s|$)/)[0]?.trim();return t&&t.length>=6&&t.length<=40?t:``}function Dp(e){return String(e||``).split(/\r?\n/).filter(e=>!/^(?:Decision\s*:|(?:MILESTONE_STATUS|NEXT_OWNER|OPERATOR_QUESTION|OPERATOR_OPTIONS)\s*=)/i.test(e.trim())).map(e=>e.replace(/^\s*(?:RESULT|SUMMARY)\s*=\s*/i,``).replace(/^\s*NEXT_ACTION\s*=\s*/i,``)).join(` +`).trim()}function Op(e,t,n){let r=[{id:`${e.id}:brief`,kind:`plan`,title:n?`任务目标`:`Task brief`,detail:e.objective||e.title,status:`recorded`,source:`task`,eventIds:[]}],i=new Set,a=0,o=t.filter(t=>t.item_id===e.id).sort((e,t)=>e.ts-t.ts||(e.type===`team.task`&&t.type===`team.task`?(e.team_task_id||e.id).localeCompare(t.team_task_id||t.id):0)),s=new Map(o.filter(e=>e.type===`team.task`).map(e=>[e.id,e]));for(let e of o){if(i.has(e.id))continue;if(i.add(e.id),e.type===`team.task`){let t=[...new Set(e.deps||[])],i=t.map(e=>s.has(e)?bp(s.get(e),n):n?`其他记录中的子任务`:`Task outside this view`),a=Dp(e.text);r.push({id:e.id,kind:e.team_role===`idea-review`||e.role===`reviewer`?`review`:e.team_role===`idea-selector`?`plan`:`execution`,title:bp(e,n),summary:xp(e,n,t.some(e=>s.has(e)&&s.get(e).status!==`done`)),detail:[a,e.reason&&!a.includes(e.reason)?e.reason:``,e.pending_question?`${n?`需要答复`:`Needs input`}: ${e.pending_question}`:``,i.length?`${n?`依赖`:`Depends on`}: ${i.join(` · `)}`:``].filter(Boolean).join(` + +`),status:e.pending_question?`question`:e.status||`unknown`,ts:e.ts,source:`team`,eventIds:[e.id],teamId:e.team_id,teamTaskId:e.team_task_id,teamRole:e.team_role,deps:t,updatedAt:e.updated_ts,revision:e.revision});continue}e.type===`life.mission.started`&&a++;let t=e.type.includes(`review`)||e.type===`life.phase.started`&&e.role===`reviewer`?`review`:e.type===`life.planner.task_added`?`plan`:e.type===`life.mission.completed`||e.type===`life.mission.failed`?`result`:e.type===`round.start`||e.type===`round.main.completed`||e.type===`life.mission.started`||e.type===`life.phase.started`?`execution`:null;if(!t)continue;let o=e.round_index,c=e.type.endsWith(`.completed`)||e.type.endsWith(`.failed`),l=t===`review`&&e.review_skipped===!0,u=(l?`skipped`:e.status)||(e.success===!1||e.type.endsWith(`.failed`)?`failed`:e.success===!0?`done`:c?`recorded`:`started`),d=wp(e.text||``,n),f=String(e.text||``),p=d.receipt?f.lastIndexOf(d.receipt):-1,m=Dp(p>=0?f.slice(0,p):f),h=u===`done`?n?`审查通过`:`Review passed`:u===`continue`?n?`审查:继续推进`:`Review: keep going`:[`blocked`,`replan`,`replan_requested`].includes(u)?n?`审查:需要调整`:`Review: needs a change`:u===`failed`?n?`审查未通过`:`Review failed`:``,g=t===`execution`?Ep(m):``,_=l?n?`审查未执行`:`Review not performed`:t===`review`?c?h||(n?`审查意见`:`Review outcome`):n?`开始审查`:`Review started`:t===`result`?n?`执行结果`:`Execution result`:t===`plan`?n?`任务进入计划`:`Added to plan`:g||(e.type===`life.mission.started`?n?`开始执行`:`Execution started`:e.type===`round.main.completed`?n?`本轮执行记录`:`Round execution`:n?`执行尝试`:`Execution attempt`);r.push({id:e.id,kind:t,title:_,summary:d.summary||Tp(m)||void 0,detail:[m||d.summary||Sp(n),l&&e.next_action?`${n?`下一步`:`Next action`}: ${e.next_action}`:``,d.receipt?`${n?`——运行记录:`:`— runner receipt: `}${d.receipt.replace(/^Runner receipt:\s*/i,``)}`:``].filter(Boolean).join(` + +`),status:u,ts:e.ts,round:o,episode:a,source:e.association===`single_active_window`?`interval`:`event`,eventIds:[e.id]}),!l&&e.next_action&&[`continue`,`blocked`,`replan`,`replan_requested`].includes(e.status||``)&&r.push({id:`${e.id}:next`,kind:`revision`,title:n?`建议的修订`:`Requested revision`,detail:e.next_action,status:`requested`,ts:e.ts,round:o,episode:a,source:e.association===`single_active_window`?`interval`:`event`,eventIds:[e.id]})}!r.some(e=>e.kind===`execution`)&&$f.has(e.status)&&r.push({id:`${e.id}:active`,kind:`execution`,title:n?`执行进展`:`Execution progress`,detail:e.summary||``,status:e.status,source:`task`,eventIds:[]}),!r.some(e=>e.kind===`result`)&&[`done`,`failed`,`aborted`,`skipped`,`superseded`].includes(e.status)&&r.push({id:`${e.id}:outcome`,kind:`result`,title:n?`任务状态记录`:`Recorded task outcome`,detail:e.summary||``,status:e.status,source:`task`,eventIds:[]});let c=[],l=new Map;for(let e of r){let t=e.round!=null&&[`execution`,`review`].includes(e.kind),n=`${e.episode}:${e.round}:${e.kind}`,r=t?l.get(n):void 0;if(r)r.title=e.title,r.summary=e.summary??r.summary,r.detail=e.detail,r.status=e.status,r.eventIds.push(...e.eventIds),e.source===`interval`&&(r.source=`interval`);else{let r={...e,eventIds:[...e.eventIds]};c.push(r),t&&l.set(n,r)}}return c}function kp(e,t,n,r=Op(e,t,n),i=0){let a=1,o=1/0;for(let e=1;e<=Math.min(3,r.length);e++){let t=Math.ceil(r.length/e),n=Math.max(640,t*232+(t-1)*108+96),i=408+(e-1)*236,s=Math.abs(Math.log(n/i/1.6))+.6*(t*e-r.length)/(t*e);s{let o=t*a,s=Math.min(o+a,r.length),c=u+t*340;return r.slice(o,s).forEach((e,t)=>{d[e.id]={x:c,y:180+t*236}}),{id:`steps:${i+o}`,title:n?`环节 ${i+o+1}–${i+s}`:`Steps ${i+o+1}–${i+s}`,x:c,y:142}});return{steps:r,links:jp(r,n),columns:f,positions:d,width:c,height:l}}function Ap(e){let t=Math.max(600/e.height,Math.min(1e3/e.height,vp.width/e.width));return{width:e.width*t,height:e.height*t,scale:t}}function jp(e,t){let n=e.filter(e=>e.source===`team`);if(n.length){let r=e.filter(e=>e.source!==`team`),i=new Map(n.map(e=>[e.id,e])),a=r.find(e=>e.source===`task`&&e.kind===`plan`),o=[];for(let e of n){for(let n of e.deps||[]){let r=i.get(n);!r||r.id===e.id||r.teamId!==e.teamId||o.push({id:`link:${r.id}:${e.id}`,source:r.id,target:e.id,relation:`dependency`,label:t?`前置任务`:`Depends on`,explanation:t?`${e.title} 的任务记录明确依赖 ${r.title}。`:`${e.title} explicitly depends on ${r.title} in its taskboard.`,contextual:!1})}a&&!e.deps?.length&&o.push({id:`link:${a.id}:${e.id}`,source:a.id,target:e.id,relation:`assignment`,label:t?`任务分支`:`Branch`,explanation:t?`该子任务属于当前主任务;此线不表示等待主任务完成。`:`This worker belongs to the current mission; the link does not require the parent to finish first.`,contextual:!0})}return[...jp(r,t),...o]}return e.slice(1).map((n,r)=>{let i=e[r],a=i.episode===n.episode,o=a&&i.round!=null&&i.round===n.round,s=`record_order`,c=t?`后续记录`:`Later record`,l=t?`同一任务的相邻观察,未确认直接因果或执行依赖。`:`Adjacent observations of the same task; no causal dependency is asserted.`;i.kind===`plan`&&[`plan`,`execution`].includes(n.kind)?(s=`assignment`,c=t?n.kind===`plan`?`纳入计划`:`执行此任务`:`Execute`,l=t?`同一任务的目标/计划与其执行记录关联。`:`The task brief or plan is linked to execution of that same task.`):i.kind===`execution`&&n.kind===`review`&&o?(s=`review`,c=t?`提交审查`:`Review`,l=t?`同一个任务、同一执行段、同一轮次的执行与审查记录。`:`Execution and review belong to the same task, episode and numbered round.`):i.kind===`review`&&n.kind===`revision`&&n.eventIds.some(e=>i.eventIds.includes(e))?(s=`revision`,c=t?`提出修订`:`Revise`,l=t?`这条修订建议来自对应的审查记录。`:`This revision was requested in the corresponding review.`):i.kind===`revision`&&n.kind===`execution`&&a&&i.round!=null&&n.round!=null&&n.round>i.round?(s=`next_attempt`,c=t?`进入下轮`:`Next round`,l=t?`修订建议之后出现了同一任务的下一轮执行;不表示建议的全部内容已被采纳。`:`A later round follows the revision request; this does not certify every requested change was applied.`):n.kind===`result`&&n.source===`task`?(s=`snapshot`,c=t?`状态记录`:`Recorded status`,l=t?`任务状态记录;部分执行过程可能缺失。`:`Links to the captured state of this task; intermediate records may be missing.`):n.kind===`result`&&[`review`,`execution`,`revision`].includes(i.kind)&&(s=`outcome`,c=t?`形成结果`:`Outcome`,l=t?`同一任务的后续完成/失败事件,不等同于成功认证。`:`A completion or failure event of this task, not a certification of success.`);let u=[`record_order`,`snapshot`].includes(s)||i.source===`interval`||n.source===`interval`;return(i.source===`interval`||n.source===`interval`)&&(l+=t?` 部分旧记录按唯一活动任务区间归属,因此使用虚线。`:` Some legacy observations are associated by the sole active mission window, so this link is dashed.`),{id:`link:${i.id}:${n.id}`,source:i.id,target:n.id,relation:s,label:c,explanation:l,contextual:u}})}function Mp(e){let t=[],n=[];for(let r=0;r12&&(t.push(n),n=[]),n.push(...i)}return n.length&&t.push(n),t}function Np(e,t,n,r){for(let i of[n,r]){let n={x:(i.x-t.x)/t.zoom,y:(i.y-t.y)/t.zoom},r=e.find(e=>!e.hidden&&n.x>=e.position.x&&n.x<=e.position.x+(e.width??1152)&&n.y>=e.position.y&&n.y<=e.position.y+(e.height??824));if(r)return r.id}return null}function Pp(e,t,n,r,i=sp(e,[],n)){let a=[],o={},s=[],c=new Map;for(let[r,i]of e.tasks.entries()){let e=Op(i,t,n),l=Mp(e),u=l.length,d=e=>e===1?i.id:JSON.stringify([`part`,i.id,e]),f=0;for(let c=1;c<=u;c++){let p=l[c-1],m=d(c);if(a.push({id:m,task:i,ordinal:r+1,part:c,partCount:u,start:f+1,end:f+p.length,totalSteps:e.length,previousId:c>1?d(c-1):void 0,nextId:c1){let t=jp([e[f-1],p[0]],n)[0];s.push({id:JSON.stringify([`continuation`,i.id,c]),source:d(c-1),target:m,kind:`continuation`,label:t?n?`继续`:`Continued`:n?`更多分支`:`More branches`,evidence:t?`${i.title} · ${t.label} · ${e[f-1].title} → ${p[0].title}`:`${i.title} · ${n?`同一任务的其他分支,不表示串行依赖。`:`Other branches of the same mission, without a serial dependency.`}`})}f+=p.length}c.set(i.id,d(u))}let l=Object.fromEntries(Object.entries(o).map(([e,t])=>[e,Ap(t)])),u=[...i.map(e=>({...e,source:c.get(e.source),target:e.target})),...s],d=a.map(e=>e.id),f=JSON.stringify([d.map(e=>[e,l[e].width,l[e].height]),u.map(e=>[e.source,e.target,e.kind])]);return{cards:a,links:u,layouts:o,positions:r?.structure===f?r.positions:hp(d,u,l),frames:l,structure:f}}var Fp=({children:e})=>(0,J.jsxs)(`span`,{children:[e,` `]}),Ip=(0,Y.memo)(function({children:e}){return(0,J.jsx)(s,{remarkPlugins:[c],components:{p:Fp,h1:Fp,h2:Fp,h3:Fp,h4:Fp,h5:Fp,h6:Fp,ul:Fp,ol:Fp,blockquote:Fp,pre:Fp,li:({children:e})=>(0,J.jsxs)(`span`,{className:`markdown-excerpt-item`,children:[e,` `]}),table:Fp,thead:Fp,tbody:Fp,tr:Fp,th:({children:e})=>(0,J.jsxs)(`strong`,{children:[e,` · `]}),td:Fp,a:({children:e})=>(0,J.jsx)(`span`,{className:`markdown-excerpt-link`,children:e}),img:({alt:e})=>(0,J.jsx)(`span`,{children:e}),input:({checked:e})=>(0,J.jsx)(`span`,{children:e?`✓ `:`○ `}),hr:()=>(0,J.jsx)(`span`,{children:` · `}),code:({children:e})=>(0,J.jsx)(`code`,{children:e})},children:C(e)})});function Lp({path:e,delay:t,padding:n=24,children:r}){let i=`map-growth-${(0,Y.useId)().replace(/:/g,``)}`;if(t==null)return(0,J.jsx)(J.Fragment,{children:r});let a=(e.match(/-?\d+(?:\.\d+)?(?:e[+-]?\d+)?/gi)??[]).map(Number),o=a.filter((e,t)=>t%2==0),s=a.filter((e,t)=>t%2==1);if(!o.length||!s.length)return(0,J.jsx)(J.Fragment,{children:r});let c=Math.min(...o)-n,l=Math.min(...s)-n;return(0,J.jsxs)(`g`,{"data-map-growing-edge":`true`,children:[(0,J.jsx)(`defs`,{children:(0,J.jsx)(`mask`,{id:i,maskUnits:`userSpaceOnUse`,x:c,y:l,width:Math.max(...o)-c+n,height:Math.max(...s)-l+n,children:(0,J.jsx)(`path`,{className:`map-growth-mask`,d:e,pathLength:1,fill:`none`,stroke:`white`,strokeWidth:n*2,strokeLinecap:`round`,style:{animationDelay:`${t}ms`}})})}),(0,J.jsx)(`g`,{mask:`url(#${i})`,children:r})]})}function Rp({layout:e,growing:t={},activeStep:n,activeTeamSteps:r=[]}){let i=`submap-arrow-${(0,Y.useId)().replace(/:/g,``)}`;return(0,J.jsxs)(`svg`,{className:`submap-relations`,width:e.width,height:e.height,"aria-label":`Task process relationships`,children:[(0,J.jsx)(`defs`,{children:(0,J.jsx)(`marker`,{id:i,viewBox:`0 0 10 10`,refX:`9`,refY:`5`,markerWidth:`8`,markerHeight:`8`,orient:`auto`,children:(0,J.jsx)(`path`,{d:`M 0 0 L 10 5 L 0 10 z`,fill:`#91a8bc`})})}),e.links.map(a=>{let o=e.positions[a.source],s=e.positions[a.target],c=o.x===s.x&&s.y>o.y,l=o.x+(c?116:232),u=o.y+(c?180:90),d=s.x+(c?116:0),f=s.y+(c?0:90),p=(l+d)/2,m=(u+f)/2,h=c?`M ${l} ${u} L ${d} ${f}`:`M ${l} ${u} C ${p} ${u}, ${p} ${f}, ${d} ${f}`;return(0,J.jsxs)(`g`,{"data-testid":`submap-relation`,"data-relation":a.relation,"data-source":a.source,"data-target":a.target,"aria-label":`${a.label}: ${a.explanation}`,children:[(0,J.jsx)(`title`,{children:a.explanation}),(0,J.jsx)(Lp,{path:h,delay:t[a.id],children:(0,J.jsx)(`path`,{className:`submap-relation-path`,d:h,fill:`none`,stroke:`#91a8bc`,strokeWidth:`2`,strokeDasharray:a.contextual?`5 6`:void 0,markerEnd:`url(#${i})`})}),(n===a.target||r.includes(a.target))&&(0,J.jsx)(`path`,{className:`submap-flow`,d:h,pathLength:1,fill:`none`,stroke:`#4b9cae`,strokeWidth:`3`,strokeDasharray:`.09 .91`,strokeLinecap:`round`,"aria-hidden":`true`}),(0,J.jsxs)(`g`,{className:`submap-relation-label`,transform:`translate(${p}, ${m})`,children:[(0,J.jsx)(`rect`,{x:`-38`,y:`-11`,width:`76`,height:`22`,rx:`6`}),(0,J.jsx)(`text`,{textAnchor:`middle`,dominantBaseline:`central`,children:a.label})]})]},a.id)})]})}var zp=(0,Y.createContext)({notes:{}}),Bp=(0,Y.createContext)({}),Vp={plan:[`Planner`,`Planner`],execution:[`Engineer`,`Engineer`],review:[`Reviewer`,`Reviewer`],revision:[`修订`,`Revise`],result:[`结果`,`Result`]},Hp={plan:l,execution:d,review:I,revision:le,result:O},Up={done:[`已完成`,`Completed`],running:[`进行中`,`In progress`],pending:[`待开始`,`Planned`],failed:[`未通过`,`Failed`],aborted:[`已取消`,`Cancelled`],skipped:[`已跳过`,`Skipped`],superseded:[`已替代`,`Superseded`],question:[`待答复`,`Needs input`],paused:[`已暂停`,`Paused`],paused_external_work:[`等待后台任务`,`Waiting on background work`],missing:[`引用缺失`,`Missing`],unknown:[`状态未知`,`Unknown`],continue:[`需修订`,`Revise`],blocked:[`受阻`,`Blocked`],started:[`开始记录`,`Started`],recorded:[`已记录`,`Recorded`],requested:[`修订建议`,`Suggested`],replan:[`调整计划`,`Revise plan`],replan_requested:[`调整计划`,`Revise plan`]},Wp=(e,t)=>e.source===`team`?t?`子任务工作记录`:`Subtask work record`:e.source===`task`?t?`任务记录`:`Task record`:e.source===`interval`?t?`根据同期记录关联`:`By execution window`:t?`来自任务记录`:`Linked event`,Gp=(0,Y.memo)(function({id:e,data:t}){let{task:n,ordinal:r,zh:i,layout:a,focused:o,detailed:s}=t,{artifacts:c,onOpenArtifact:l}=(0,Y.useContext)(Bp),d=(0,Y.useContext)(zp).notes[n.id]??[],f=Q(e=>{let n=e.transform[2]*t.frame.width;return n<140?`micro`:n<230?`compact`:`full`}),[p]=(0,Y.useState)(()=>!t.restoring&&!t.seenCards?.has(e));(0,Y.useEffect)(()=>{t.seenCards?.add(e)},[t.seenCards,e]);let[m,h]=(0,Y.useState)(null),g=m||a,v=e=>e.source===`team`&&a.steps.find(t=>t.id===e.id)||e,y=t.canvasSize?.width||window.innerWidth,b=t.canvasSize?.height||window.innerHeight;(0,Y.useEffect)(()=>{s||(S(null),h(null))},[s]);let[x,S]=(0,Y.useState)(null),E=(0,Y.useRef)(n.status),[D,O]=(0,Y.useState)(!1);(0,Y.useEffect)(()=>{let e=E.current!==n.status;if(E.current=n.status,!e||n.status!==`done`)return;O(!0);let t=setTimeout(()=>O(!1),1500);return()=>clearTimeout(t)},[n.status]);let k=g.steps.find(e=>e.id===x),A=k?v(k):void 0,N=A?.updatedAt??A?.ts,P=t.part===t.partCount,F=P?n.status===`missing`?`missing`:t.paused&&$f.has(n.status)?`paused`:ep(n):`recorded`,I=F===`paused`&&n.status===`paused_external_work`?n.status:F,L=Math.min(t.frame.width/288,t.frame.height/218),R=t.copy?.cards||{},z=!!R[n.id]?.summary&&R[n.id]?.task_status!==n.status&&($f.has(n.status)||n.status===`pending`),B=e=>{let t=R[e.id];if(e.source!==`team`)return t;let n=t?.event_ids?.indexOf(e.id)??-1;return v(e).revision&&n>=0&&t?.event_revisions?.[n]===v(e).revision?t:void 0},V=(R[n.id]?.title||n.title)+(t.part>1?i?` · 续篇 ${t.part-1}`:` · Continued ${t.part-1}`:``),ee=i?`环节 ${t.start}–${t.end} / ${t.totalSteps}`:`Steps ${t.start}–${t.end} / ${t.totalSteps}`,te=t.partCount>1?g.steps.map(e=>B(e)?.summary||v(e).summary||v(e).detail).filter(e=>e&&![Sp(!0),Sp(!1)].includes(e)).at(-1):void 0,H=Math.min(t.frame.width/g.width,t.frame.height/g.height),U=P&&t.live&&$f.has(n.status)?[...g.steps].reverse().find(e=>e.source!==`team`&&![`plan`,`result`].includes(e.kind))?.id:null,W=t.paused?null:U,G=a.steps.filter(e=>e.source===`team`),K=t.live?G.filter(e=>$f.has(e.status)).map(e=>e.id):[],re=G.filter(e=>e.status===`done`).length,ie=G.filter(e=>$f.has(e.status)).length,ae=e=>e.source===`team`?K.includes(e.id):W===e.id,oe=e=>e.source===`team`?v(e).status:U===e.id?t.paused?`paused`:`running`:e.status,se=e=>({source:t.source,task_id:n.id,task_title:V,lang:i?`zh`:`en`,part:t.partCount>1?t.part:void 0,step_id:e?.id,step_title:e?.title,team_id:e?.teamId,team_task_id:e?.teamTaskId,event_ids:e?e.eventIds:t.partCount>1?[...new Set(g.steps.flatMap(e=>e.eventIds))]:R[n.id]?.event_ids||[]}),ce=Math.min(640,g.width-48,Math.max(260,(y-50)/1.05)),le=Math.min(600,g.height-48,Math.max(300,(b-(y<640?180:160))/1.05)),q=e=>({x:Math.max(24,Math.min(g.positions[e.id].x-16,g.width-ce-24)),y:Math.max(24,Math.min(g.positions[e.id].y-16,g.height-le-24)),width:ce,height:le,scale:H}),ue=A?q(A):null,de=n=>{h(g),S(n.id),t.readStep(e,q(n))};(0,Y.useEffect)(()=>{A&&t.readStep(e,q(A))},[y,b]);let fe=e=>(Up[e===`paused_external_work`?e:e.startsWith(`paused_`)?`paused`:$f.has(e)?`running`:e]??Up.unknown)[+!i];return(0,J.jsxs)(`article`,{className:`map-macro map-state-${F}`,"data-testid":`map-macro`,"data-task-id":n.id,"data-card-id":e,"data-part":t.part,"data-arrive":p,"data-growing":t.growthDelay!=null,"data-dispatch":t.dispatchState,style:{animationDelay:`${t.growthDelay??0}ms`},"data-focused":o,"data-detailed":s,"aria-label":V,"data-overview-density":f,"data-completed-now":D,"data-active":K.length>0||P&&t.live&&!t.paused&&$f.has(n.status),onContextMenu:e=>{e.preventDefault(),e.stopPropagation(),t.menu(se(),{x:e.clientX,y:e.clientY})},children:[[`source`,`target`].flatMap(e=>[Z.Left,Z.Right,Z.Top,Z.Bottom].map(t=>(0,J.jsx)(Nu,{id:t,type:e,position:t,isConnectable:!1},`${e}-${t}`))),(0,J.jsx)(`div`,{className:`macro-summary`,"aria-hidden":s,style:{"--summary-scale":L,"--summary-height":`${t.frame.height/L-20}px`,width:t.frame.width/L-20,transform:`translate(-50%, -50%) scale(${L})`},children:(0,J.jsxs)(`button`,{className:`map-card map-state-${F} nodrag nopan`,"data-testid":`map-card`,"data-task-id":n.id,"data-card-id":e,"data-part":t.part,tabIndex:s?-1:0,onClick:()=>t.open(e),"aria-label":`${V} · ${i?`放大任务`:`Explore task`}`,children:[(0,J.jsxs)(`div`,{className:`map-card-top`,children:[(0,J.jsxs)(`span`,{className:`map-card-number`,children:[String(r).padStart(2,`0`),t.partCount>1&&` · ${t.part}/${t.partCount}`]}),(0,J.jsxs)(`span`,{className:`map-status`,children:[F===`done`?(0,J.jsx)(T,{size:11}):F===`failed`?(0,J.jsx)(j,{size:11}):F===`question`?(0,J.jsx)(w,{size:11}):F===`paused`?(0,J.jsx)(M,{size:11}):(0,J.jsx)(`span`,{className:`map-state-dot`}),fe(I)]})]}),(0,J.jsxs)(`h3`,{children:[(0,J.jsx)(Ip,{children:V}),d.length>0&&(0,J.jsx)(`span`,{className:`macro-note-badge`,title:i?`操作员批注`:`Operator notes`,children:d.length})]}),(0,J.jsx)(`div`,{className:`map-card-copy`,children:(0,J.jsx)(Ip,{children:te||R[n.id]?.summary||n.pending_question||n.summary||n.objective||(i?`放大查看任务内部`:`Zoom to explore`)})}),(0,J.jsx)(`div`,{className:`map-card-stages`,"aria-label":i?`任务阶段`:`Task stages`,children:[`plan`,`execution`,`review`,`result`].map(e=>{let t=Hp[e],n=g.steps.some(t=>t.kind===e),r=g.steps.some(t=>t.kind===e&&ae(t));return(0,J.jsxs)(`span`,{className:`submap-kind-${e}`,"data-present":n,"data-active":r,title:Vp[e][+!i],children:[(0,J.jsx)(t,{size:12}),(0,J.jsx)(`span`,{children:i?{plan:`规划`,execution:`执行`,review:`审查`,result:`交付`}[e]:Vp[e][1]})]},e)})}),G.length>0&&(0,J.jsx)(`span`,{className:`map-card-teambar`,"aria-hidden":!0,children:(0,J.jsx)(`i`,{style:{width:`${Math.round(re/G.length*100)}%`}})}),(0,J.jsxs)(`div`,{className:`map-card-bottom`,children:[(0,J.jsx)(`span`,{className:G.length?`map-card-team-summary`:void 0,title:ee,children:G.length?(i?`子任务 ${re}/${G.length} 完成 · ${ie} 进行中`:`Subtasks ${re}/${G.length} done · ${ie} running`)+((t.plannedWidth??0)>G.length?i?` · 计划并行 ×${t.plannedWidth}`:` · planned ×${t.plannedWidth}`:``):t.plannedWidth&&$f.has(n.status)?i?`并行编队 ×${t.plannedWidth} 展开中`:`Fanning out ×${t.plannedWidth}`:t.partCount>1?ee:`${g.steps.length} ${i?`个环节`:`steps`}`}),(0,J.jsxs)(`span`,{className:`map-card-submap-hint`,children:[z?i?`描述更新中`:`Summary updating`:i?`查看进展`:`View progress`,(0,J.jsx)(u,{size:12})]})]})]})}),(0,J.jsxs)(`div`,{className:`macro-detail ${A?`is-reading`:``}`,"aria-hidden":!s,style:{width:g.width,height:g.height,transform:`scale(${H})`,transformOrigin:`top left`},children:[(0,J.jsxs)(`header`,{className:`macro-heading`,children:[(0,J.jsx)(`span`,{className:`macro-index`,children:String(r).padStart(2,`0`)}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`small`,{children:t.partCount>1?i?`第 ${t.part} / ${t.partCount} 部分`:`Part ${t.part} / ${t.partCount}`:i?`任务内部`:`INSIDE THIS TASK`}),(0,J.jsx)(`h2`,{children:(0,J.jsx)(Ip,{children:V})})]}),(0,J.jsx)(`span`,{className:`macro-state`,children:fe(I)})]}),(0,J.jsx)(`div`,{className:`macro-stage-key`,children:yp.map(e=>(0,J.jsx)(`span`,{className:`submap-kind-${e} ${g.steps.some(t=>t.kind===e)?``:`is-unrecorded`}`,children:Vp[e][+!i]},e))}),d.length>0&&(0,J.jsxs)(`aside`,{className:`macro-notes`,"aria-label":i?`操作员批注`:`Operator notes`,children:[(0,J.jsx)(`small`,{children:i?`批注`:`Notes`}),d.map(e=>(0,J.jsx)(`p`,{children:e.text},e.id))]}),(0,J.jsx)(Rp,{layout:g,growing:t.growingLinks,activeStep:W,activeTeamSteps:K}),g.columns.map(e=>(0,J.jsx)(`div`,{className:`macro-column-label`,style:{left:e.x,top:e.y},children:e.title},e.id)),g.steps.map(e=>{let n=v(e),r=Hp[n.kind];return(0,J.jsxs)(`button`,{className:`submap-step submap-kind-${n.kind} nodrag nopan ${x===n.id?`is-selected`:``}`,"data-testid":`submap-step`,"data-step-id":n.id,"data-source":n.source,"data-team-id":n.teamId,"data-team-task-id":n.teamTaskId,"data-status":oe(n),"data-active":ae(n),"data-growing":t.growingSteps?.[n.id]!=null,onContextMenu:e=>{e.preventDefault(),e.stopPropagation(),t.menu(se(n),{x:e.clientX,y:e.clientY})},style:{animationDelay:`${t.growingSteps?.[n.id]??0}ms`,left:g.positions[n.id].x,top:g.positions[n.id].y},tabIndex:s?0:-1,onClick:()=>de(n),"aria-expanded":x===n.id,children:[(0,J.jsxs)(`div`,{className:`submap-step-meta`,children:[(0,J.jsxs)(`span`,{children:[(0,J.jsx)(r,{size:16}),n.source===`team`?i?`子任务 · `:`Subtask · `:``,Vp[n.kind][+!i],n.round!=null&&(0,J.jsx)(`em`,{className:`submap-round`,children:i?`第 ${n.round} 轮`:`R${n.round}`})]}),(0,J.jsx)(`small`,{children:n.source===`team`&&oe(n)===`failed`?i?`失败`:`Failed`:fe(oe(n))})]}),(0,J.jsx)(`h4`,{children:(0,J.jsx)(Ip,{children:n.title})}),(0,J.jsx)(`div`,{className:`submap-step-copy`,children:(0,J.jsx)(Ip,{children:B(n)?.summary||v(n).summary||n.detail||Sp(i)})}),(0,J.jsxs)(`div`,{className:`submap-step-foot`,children:[(0,J.jsx)(`span`,{title:Wp(n,i),children:i?`查看详情`:`Read more`}),(0,J.jsx)(u,{size:14})]})]},n.id)}),t.partCount>1&&!A&&(0,J.jsxs)(`nav`,{className:`macro-part-nav nodrag nopan`,"aria-label":i?`任务各部分`:`Task parts`,children:[(0,J.jsx)(`span`,{children:ee}),(0,J.jsxs)(`div`,{children:[(0,J.jsxs)(`button`,{disabled:!t.previousId,onClick:()=>t.previousId&&t.open(t.previousId),children:[(0,J.jsx)(ne,{size:14}),i?`上一部分`:`Previous part`]}),(0,J.jsxs)(`button`,{disabled:!t.nextId,onClick:()=>t.nextId&&t.open(t.nextId),children:[i?`下一部分`:`Next part`,(0,J.jsx)(u,{size:14})]})]})]}),A&&ue&&(0,J.jsxs)(`section`,{className:`macro-reader nodrag nopan nowheel`,"data-testid":`map-reader`,"data-kind":A.kind,role:`region`,"aria-label":i?`卡片详情`:`Card details`,style:{left:ue.x,top:ue.y,width:ue.width,height:ue.height},onContextMenu:e=>{e.preventDefault(),e.stopPropagation(),t.menu(se(A),{x:e.clientX,y:e.clientY})},children:[(0,J.jsxs)(`header`,{children:[(0,J.jsx)(`span`,{children:Vp[A.kind][+!i]}),(0,J.jsx)(`button`,{"aria-label":`Close step details`,onClick:()=>{S(null),h(null),t.open(e)},children:(0,J.jsx)(j,{size:20})})]}),(0,J.jsx)(`h3`,{children:(0,J.jsx)(Ip,{children:A.title})}),(0,J.jsx)(`div`,{className:`macro-reader-body`,children:(0,J.jsx)(_,{artifacts:c,onOpenArtifact:l,children:C(B(A)?.detail||A.detail||Sp(i))})}),(0,J.jsxs)(`footer`,{children:[(0,J.jsx)(`span`,{title:Wp(A,i),children:N?new Date(N*1e3).toLocaleString(i?`zh-CN`:`en-US`):``}),!t.readOnly&&(0,J.jsx)(`button`,{onClick:()=>t.quote(se(A)),children:i?`引用此项`:`Reference`})]})]})]})]})});function Kp(e){let t={};for(let n of e)(t[n.node_id]??=[]).push(n);for(let e of Object.values(t))e.sort((e,t)=>e.ts-t.ts||e.id.localeCompare(t.id));return t}var qp={width:640,height:190},Jp={"idea-route":q,"idea-review":I,"idea-selector":oe},Yp={done:`✓`,failed:`✕`,question:`?`,paused:`‖`,running:`▶`,superseded:`↪`},Xp={done:[`已完成`,`Completed`],running:[`进行中`,`In progress`],pending:[`待开始`,`Planned`],failed:[`未通过`,`Failed`],question:[`待答复`,`Needs input`],paused:[`已暂停`,`Paused`],aborted:[`已取消`,`Cancelled`],skipped:[`已跳过`,`Skipped`],superseded:[`已替代`,`Superseded`],unknown:[`已记录`,`Recorded`]},Zp=(0,Y.memo)(function({data:e}){let{task:t,zh:n,fanIndex:r,fanCount:i}=e,a=ep(t),o=t.overflow_count?ae:Jp[t.team_role??``]??l,s=(Xp[a]??Xp.unknown)[+!n],c=Yp[a],u=typeof r==`number`&&typeof i==`number`;return(0,J.jsxs)(`button`,{type:`button`,className:`map-branch map-state-${a} nodrag nopan`,"data-testid":`map-branch`,"data-branch-id":t.id,"data-status":a,"data-overflow":!!t.overflow_count,title:t.excerpt||t.objective||t.title,"aria-label":`${t.title} · ${s} · ${n?`打开所属任务`:`Open the owning task`}`,onClick:()=>e.open(e.parentCardId),children:[[`source`,`target`].flatMap(e=>[Z.Left,Z.Right,Z.Top,Z.Bottom].map(t=>(0,J.jsx)(Nu,{id:t,type:e,position:t,isConnectable:!1},`${e}-${t}`))),(0,J.jsx)(`span`,{className:`map-branch-glyph`,"aria-hidden":`true`,children:(0,J.jsx)(o,{})}),c&&(0,J.jsx)(`span`,{className:`map-branch-state`,"aria-hidden":`true`,children:c}),(0,J.jsx)(`span`,{className:`map-branch-title`,children:t.title}),u&&(0,J.jsx)(`span`,{className:`map-branch-fan`,"data-testid":`map-branch-fan`,title:n?`并行分支 ${r} / ${i}`:`Parallel branch ${r} of ${i}`,children:`${r}/${i}`}),(0,J.jsx)(`span`,{className:`map-branch-dot`,"aria-hidden":`true`})]})}),Qp={x:52,y:125,zoom:.24},$p=.035,em=3.5,tm=(e,t,n)=>Math.max(t,Math.min(n,e));function nm(e){let t=e.getBoundingClientRect(),n=e.querySelector(`.map-canvas-toolbar`)?.getBoundingClientRect(),r=e.querySelector(`.map-composer-dock`)?.getBoundingClientRect(),i=e.querySelector(`.react-flow__minimap`)?.getBoundingClientRect(),a=e.querySelector(`.map-legend`)?.getBoundingClientRect(),o=e.querySelector(`.react-flow__controls`)?.getBoundingClientRect(),s=e.dataset.reading===`true`,c=e.clientWidth<640?20:50,l=Math.max(n?n.bottom-t.top+20:85,!s&&e.clientWidth<640&&a?a.bottom-t.top+16:0,!s&&e.clientWidth<640&&o?o.bottom-t.top+16:0),u=Math.max(r?t.bottom-r.top+24:100,!s&&i?t.bottom-i.top+20:0);return{x:c,y:l,width:Math.max(180,e.clientWidth-c*2),height:Math.max(100,e.clientHeight-l-u)}}var rm=.72,im=.85,am=(e,t)=>e?0:t;function om(e,t,n){let r=Math.min(t.width/n.width,t.height/n.height),i=Math.min(e.width,e.height)/Math.min(n.width,n.height);return Math.min(Math.max(r,rm*i),im*i)}function sm(e,t,n){let r=tm(Math.min(t.width/(n.width+160),t.height/(n.height+160)),$p,.27),i=(e,t,n,r)=>r>t?(n-r)/2:tm((n-r)/2,e,e+t-r);return{x:i(t.x,t.width,e.width,n.width*r)-n.x*r,y:i(t.y,t.height,e.height,n.height*r)-n.y*r,zoom:r}}function cm(e,t,n){let r=Math.min(48,e.height*.35),i=e.height-r,a=Math.min(em,Math.min(1.05,e.width/n.width,i/n.height)/n.scale);return{x:e.x+e.width/2-(t.x+(n.x+n.width/2)*n.scale)*a,y:e.y+r+i/2-(t.y+(n.y+n.height/2)*n.scale)*a,zoom:a}}function lm(e,t=!0){let n=ou(),[r,i]=(0,Y.useState)(null),[a,o]=(0,Y.useState)(!1),[s,c]=(0,Y.useState)({width:0,height:0}),l=(0,Y.useRef)(null),u=(0,Y.useRef)(!1),d=(0,Y.useRef)(!1),f=(0,Y.useRef)(!1),p=(0,Y.useRef)(()=>{}),m=(0,Y.useRef)(null),h=(0,Y.useRef)(null),g=(0,Y.useRef)(()=>{}),_=(0,Y.useRef)(()=>{}),[v,y]=(0,Y.useState)(()=>window.matchMedia(`(prefers-reduced-motion: reduce)`).matches),b=(0,Y.useRef)(Qp),x=(0,Y.useRef)(null),S=(0,Y.useRef)(null),C=(0,Y.useRef)(null),w=(0,Y.useRef)(0),T=(0,Y.useRef)(null),E=(0,Y.useCallback)(()=>{cancelAnimationFrame(w.current),w.current=0,T.current=null},[]),D=(0,Y.useCallback)((t,r)=>{t&&(f.current=!1,d.current=!1);let a=e.current;if(!a)return;let s={x:a.clientWidth/2,y:a.clientHeight/2},c=x.current&&x.current.until>performance.now()?x.current:s,p=S.current??(u.current?m.current:null)??Np(n.getNodes().filter(e=>e.data.frame),r,c,s),h=p&&(n.getNode(p)?.data)?.frame?.scale||1,g=tm((r.zoom-.3)/.14,0,1)*tm((r.zoom*h-.28)/.3,0,1),_=C.current,v=u.current?1:_?.id===p?tm((r.zoom-_.zoom*.65)/(_.zoom*.35),0,1):g;l.current=v>0?p:null,a.style.setProperty(`--detail-alpha`,String(v)),a.style.setProperty(`--summary-alpha`,String(1-v)),a.style.setProperty(`--context-alpha`,String(p?1-v*.72:1)),a.dataset.zoom=r.zoom.toFixed(2),a.style.setProperty(`--map-zoom`,String(r.zoom)),i(v>0&&p?p:null),o(v>=.55),r.zoom<=.32&&!S.current&&!T.current&&!C.current&&(b.current=r)},[n,e]),O=(0,Y.useCallback)(t=>{f.current=!1,E();let r=n.getNode(t),i=e.current;if(!r||!i)return;n.getZoom()<=.32&&!C.current&&(b.current=n.getViewport()),S.current=t,u.current=!1,delete i.dataset.reading,d.current=!0;let a=nm(i),o=r.width||1440,s=r.height||1080,c=tm(Math.max(om({width:i.clientWidth,height:i.clientHeight},a,{width:o,height:s}),i.clientWidth<640||(r.data.layout?.steps.length??0)>20?.6/(r.data.frame?.scale||1):0),$p,em);C.current={id:t,zoom:c};let l=a.x+Math.max(0,(a.width-o*c)/2)-r.position.x*c,p=a.y+Math.max(0,(a.height-s*c)/2)-r.position.y*c;n.setViewport({x:l,y:p,zoom:c},{duration:am(v,380)}).then(()=>{S.current=null})},[E,n,v,e]);_.current=O;let k=(0,Y.useCallback)(()=>{f.current=!1,E(),S.current=null,u.current=!1,e.current&&delete e.current.dataset.reading,d.current=!1,C.current=null,x.current=null;let t=e.current?.querySelector(`.map-macro[data-focused="true"]`)?.dataset.cardId;n.setViewport(b.current,{duration:am(v,320)}).then(()=>{t&&e.current?.querySelector(`[data-testid="map-card"][data-card-id="${CSS.escape(t)}"]`)?.focus({preventScroll:!0})})},[E,n,v,e]),A=(0,Y.useCallback)((t,r)=>{f.current=!1,E(),S.current=t;let i=n.getNode(t),a=e.current;!i||!a||(u.current=!0,a.dataset.reading=`true`,d.current=!0,m.current=t,h.current={id:t,rect:r},n.setViewport(cm(nm(a),i.position,r),{duration:am(v,340)}).then(()=>{S.current=null}))},[E,n,v,e]);g.current=A;let j=(0,Y.useCallback)(e=>{f.current=!1,E(),u.current=!1,d.current=!1,S.current=null,x.current=null,n.setCenter(e.x,e.y,{zoom:n.getZoom(),duration:am(v,180)})},[E,n,v]),M=(0,Y.useCallback)(()=>{f.current=!0,E(),S.current=null,u.current=!1,d.current=!1,C.current=null,x.current=null;let t=e.current,r=n.getNodes().filter(e=>!e.hidden);!t||!r.length||n.setViewport(sm({width:t.clientWidth,height:t.clientHeight},nm(t),n.getNodesBounds(r)),{duration:am(v,320)})},[E,n,v,e]);p.current=M;let N=(0,Y.useCallback)(()=>{f.current?p.current():d.current&&u.current&&h.current?g.current(h.current.id,h.current.rect):d.current&&l.current&&_.current(l.current)},[]);return(0,Y.useEffect)(()=>{let t=e.current;if(!t)return;let n,r=t.querySelector(`.map-composer-dock`),i=-1,a=-1,o=-1,s=new ResizeObserver(()=>{let e=r?.getBoundingClientRect().height||0;(i!==t.clientWidth||a!==t.clientHeight||o!==e)&&(i=t.clientWidth,a=t.clientHeight,o=e,t.style.setProperty(`--map-composer-height`,`${o}px`),c(e=>e.width===i&&e.height===a?e:{width:i,height:a}),clearTimeout(n),n=setTimeout(()=>{d.current&&u.current&&h.current?g.current(h.current.id,h.current.rect):d.current&&l.current&&!u.current?_.current(l.current):f.current&&p.current()},100))});return s.observe(t),r&&s.observe(r),()=>{s.disconnect(),clearTimeout(n)}},[e,t]),(0,Y.useEffect)(()=>{let e=window.matchMedia(`(prefers-reduced-motion: reduce)`),t=()=>y(e.matches);return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]),(0,Y.useEffect)(()=>{let t=e.current;if(!t)return;let r=e=>{if(e.target.closest(`.nowheel, .map-canvas-toolbar, .map-legend, .react-flow__minimap, .react-flow__controls`))return;e.preventDefault(),e.stopPropagation(),f.current=!1,u.current=!1,d.current=!0,S.current=null;let r=t.getBoundingClientRect(),i=e.clientX-r.left,a=e.clientY-r.top;x.current={x:i,y:a,until:performance.now()+1e3};let o=T.current??n.getViewport();!T.current&&o.zoom<=.32&&!C.current&&(b.current=o);let s=e.deltaY*(e.deltaMode===1?16:e.deltaMode===2?t.clientHeight:1),c=tm(o.zoom*Math.exp(-tm(s,-400,400)*.002),$p,em);if(T.current={x:i-(i-o.x)*c/o.zoom,y:a-(a-o.y)*c/o.zoom,zoom:c},v){n.setViewport(T.current),T.current=null;return}if(w.current)return;let l=performance.now(),p=e=>{if(!T.current)return;let t=1-Math.exp(-Math.min(e-l,64)/55);l=e;let r=n.getViewport(),i=T.current,a=Math.abs(i.zoom-r.zoom)<15e-5&&Math.abs(i.x-r.x)+Math.abs(i.y-r.y)<.15;n.setViewport(a?i:{x:r.x+(i.x-r.x)*t,y:r.y+(i.y-r.y)*t,zoom:r.zoom+(i.zoom-r.zoom)*t}),a?(w.current=0,T.current=null):w.current=requestAnimationFrame(p)};w.current=requestAnimationFrame(p)},i=()=>{E(),S.current=null,x.current=null},a=e=>{e.defaultPrevented||document.querySelector(`[role="dialog"][aria-modal="true"]`)||e.key===`Escape`&&![`INPUT`,`TEXTAREA`,`SELECT`].includes(e.target.tagName)&&k()};return t.addEventListener(`wheel`,r,{passive:!1,capture:!0}),t.addEventListener(`pointerdown`,i,!0),window.addEventListener(`keydown`,a),()=>{E(),t.removeEventListener(`wheel`,r,!0),t.removeEventListener(`pointerdown`,i,!0),window.removeEventListener(`keydown`,a)}},[k,E,n,v,e]),{capture:(0,Y.useCallback)(()=>({viewport:n.getViewport(),overview:b.current,focusId:l.current,detailed:!!l.current&&(u.current||!!C.current||n.getZoom()>=.44)}),[n]),restore:(0,Y.useCallback)(e=>{E(),b.current=e.overview;let t=e.focusId&&n.getNode(e.focusId)?e.focusId:null;S.current=e.detailed?t:null,C.current=e.detailed&&t?{id:t,zoom:e.viewport.zoom}:null,d.current=!1,f.current=!1,n.setViewport(e.viewport,{duration:0}),D(null,e.viewport)},[E,n,D]),focusId:r,canvasSize:s,detailed:a,enter:O,back:k,fit:M,fitUpdatedScene:N,navigate:j,readStep:A,onMove:D,reducedMotion:v}}function um(e,t,n,r=!0,i,s,c=!1){let l=n?`zh-CN`:`en-US`,u=e.kind===`live`?`project`:`dataset`,d=e.id.replace(/^live:/,``),f=[`map-copy`,u,d,l,s],m=JSON.stringify(f),h=(0,Y.useRef)(m);h.current=m;let g=a(),_=o({queryKey:f,queryFn:async({signal:e})=>{let t=await p.mapCopy(u,d,l,e,s),n=g.getQueryData(f);return V(n,t,n?.model_revision)},staleTime:1/0,gcTime:72e5,refetchOnWindowFocus:!1}),v=e.tasks.find(e=>e.id===t),y=(0,Y.useMemo)(()=>i??(v?Op(v,e.events,n):[]),[v,e.events,n,i]),[b,x]=(0,Y.useState)(0),[S,C]=(0,Y.useState)(!1),w=(0,Y.useRef)(!0),T=(0,Y.useRef)(null),E=(0,Y.useRef)(c);E.current=c;let D=(0,Y.useRef)(0),O=te(e,y,t).filter(t=>k(t,e,_.data)).slice(0,8),A=JSON.stringify([m,O,O.map(t=>e.tasks.find(e=>e.id===t.task_id)?.revision),_.data?.model_revision]);return(0,Y.useEffect)(()=>(w.current=!0,()=>{w.current=!1}),[]),(0,Y.useEffect)(()=>{D.current=0},[m,c]),(0,Y.useEffect)(()=>{if(!r||!_.data?.available||!O.length||!Number.isFinite(D.current)||T.current)return;let e=_.data?.model_revision,t=setTimeout(()=>{let t=g.fetchQuery({queryKey:[`map-copy-generation`,...f],queryFn:()=>p.generateMapCopy(u,d,{cards:O,locale:l},void 0,s),staleTime:0,gcTime:0,retry:!1});T.current=t,C(!0),t.then(t=>{g.setQueryData(f,n=>V(n,t,e)),h.current===m&&(D.current=t.retry_after?Date.now()+t.retry_after*1e3:0)}).catch(()=>{h.current===m&&(D.current=E.current?1/0:Date.now()+6e4)}).finally(()=>{T.current===t&&(T.current=null),w.current&&h.current===m&&(C(!1),x(e=>e+1))})},Math.max(700,D.current-Date.now()));return()=>clearTimeout(t)},[A,b,_.data?.available,r,c]),{copy:_.data,generating:S,ready:_.isFetched}}function dm({value:e,onChange:t,onSend:n,attachments:r,onAttachmentsChange:i,pending:a,pendingLabel:o,dispatchStatus:s,onCancel:c,focusSignal:l,sessionName:u,historical:d,zh:p,routeOverride:g=`auto`,onRouteOverrideChange:_}){let{t:x}=G(),S=(0,Y.useId)(),C=(0,Y.useRef)(null),w=(0,Y.useRef)(null),E=(0,Y.useRef)(null),D=(0,Y.useRef)(!1),O=(0,Y.useRef)(!0),k=(0,Y.useRef)(),[M,I]=(0,Y.useState)(``),[L,R]=(0,Y.useState)(!1),[B,V]=(0,Y.useState)(()=>!!(e.trim()||r.length)),[ee,te]=(0,Y.useState)(44),H=(0,Y.useRef)(e);H.current=e;let W=!B,{refs:K,text:ne}=A(e),re=!!(e.trim()||r.length),ae=(0,Y.useRef)(re);ae.current=re,(0,Y.useEffect)(()=>{O.current=!0;let e=e=>{let t=e.type===`focusout`?e.relatedTarget:e.target;t?.closest?.(`.map-island-launch, .map-island-stop, .map-composer-brand`)||(w.current?.contains(t)?V(!0):ae.current||V(!1))},t=e=>{let t=e.target;w.current?.contains(t)||t?.closest?.(`.map-context-menu`)||ae.current||(V(!1),w.current?.contains(document.activeElement)&&document.activeElement?.blur())},n=e=>{if(e.key!==`c`||e.metaKey||e.ctrlKey||e.altKey||e.defaultPrevented||e.isComposing)return;let t=e.target;t&&(t.tagName===`INPUT`||t.tagName===`TEXTAREA`||t.tagName===`SELECT`||t.isContentEditable)||t?.closest?.(`[role="dialog"], [role="menu"]`)||(e.preventDefault(),V(!0),C.current?.focus())};return document.addEventListener(`focusin`,e),document.addEventListener(`focusout`,e),document.addEventListener(`pointerdown`,t),document.addEventListener(`keydown`,n),()=>{O.current=!1,clearTimeout(k.current),document.removeEventListener(`focusin`,e),document.removeEventListener(`focusout`,e),document.removeEventListener(`pointerdown`,t),document.removeEventListener(`keydown`,n)}},[]);let oe=(0,Y.useRef)(l);(0,Y.useEffect)(()=>{l!==oe.current&&(oe.current=l,V(!0),C.current?.focus())},[l]);let se=(0,Y.useRef)(K.length);(0,Y.useEffect)(()=>{K.length>se.current&&(V(!0),C.current?.focus()),se.current=K.length},[K.length]);let ce=()=>{if(!C.current)return;C.current.style.height=`0px`;let e=Math.min(156,Math.max(44,C.current.scrollHeight));C.current.style.height=`${e}px`,te(e)};(0,Y.useEffect)(ce,[ne]),(0,Y.useEffect)(()=>(window.addEventListener(`resize`,ce),()=>window.removeEventListener(`resize`,ce)),[]);let le=()=>{V(!0),C.current?.focus()},q=()=>{V(!1),w.current?.contains(document.activeElement)&&document.activeElement?.blur()},ue=(0,Y.useRef)(),de=(0,Y.useRef)(typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(`(hover: hover) and (pointer: fine)`).matches);(0,Y.useEffect)(()=>()=>clearTimeout(ue.current),[]);let fe=()=>{de.current&&(clearTimeout(ue.current),V(!0))},pe=()=>{de.current&&(clearTimeout(ue.current),ue.current=setTimeout(()=>{ae.current||w.current?.contains(document.activeElement)||V(!1)},320))},me=async()=>{if(!(!ne.trim()||a||D.current)){D.current=!0;try{await n(e,r)&&O.current&&(I(``),R(!0),(!H.current.trim()||H.current===e)&&q(),clearTimeout(k.current),k.current=setTimeout(()=>R(!1),1800))}finally{D.current=!1}}},X=e=>{if(a||D.current||!e.length)return;let{accepted:t,issues:n}=N(r,e);i([...r,...t]),I(n.map(e=>e.code===`unsupported`?x(`chat.attachUnsupported`,{name:e.fileName}):e.code===`too-large`?x(`chat.attachTooLarge`,{name:e.fileName,size:v(e.limitBytes)}):e.code===`too-many`?x(`chat.attachTooMany`,{count:e.limitCount}):x(`chat.attachTotalTooLarge`,{size:v(e.limitBytes)})).join(` `))},he=s?{launching:[p?`任务已接收`:`Task accepted`,p?`正在放入地图…`:`Adding it to your map…`],task:[p?`任务已进入地图`:`Your task is on the map`,p?`跟随地图,查看执行进展`:`Follow its progress on the map`],message:[p?`Argus 已回复`:`Argus replied`,p?`在对话中查看回复`:`Open the conversation to read it`],error:[p?`发送没有成功`:`Message could not be sent`,p?`草稿已保留,可以重试`:`Your draft is ready to retry`],cancelled:[p?`已停止等待`:`Waiting stopped`,p?`随时继续对话`:`Continue whenever you are ready`]}[s]:void 0,ge=he?.[0]||(a?p?`Argus 正在处理`:`Argus is working`:L?p?`已发送给 Argus`:`Sent to Argus`:p?`交给 Argus`:`Ask Argus`),_e=he?.[1]||(a?o||(p?`正在处理你的消息…`:`Processing your message…`):L?p?`点此继续对话`:`Tap to keep the conversation going`:re?p?`草稿已保留,点此继续`:`Draft saved — tap to continue`:p?`描述目标,看它变成成果`:`Turn your next idea into a result`),ve=s||(a?`working`:L?`sent`:`idle`);return(0,J.jsxs)(`div`,{ref:w,className:`map-composer-dock map-island-dock`,"data-compact":W,"data-state":ve,"data-pending":a,style:{"--map-editor-height":`${ee}px`},onPointerEnter:fe,onPointerLeave:pe,onTransitionEnd:e=>{e.target===w.current&&e.propertyName===`width`&&ce()},children:[!W&&K.length>0&&(0,J.jsx)(`div`,{className:`map-reference-chips`,children:K.map((e,n)=>(0,J.jsxs)(`span`,{title:`${e.source} · ${e.task_id} ${e.step_id||``}`,children:[(0,J.jsxs)(`span`,{children:[p?`引用`:`Reference`,` · `,e.step_title||e.task_title]}),(0,J.jsx)(`button`,{"aria-label":p?`移除引用`:`Remove reference`,onClick:()=>t(K.filter((e,t)=>n!==t).map(F).join(``)+ne),children:(0,J.jsx)(j,{size:12})})]},`${e.task_id}:${e.step_id}:${n}`))}),!W&&!!r.length&&(0,J.jsx)(`div`,{className:`map-attachment-tray nowheel`,role:`group`,"aria-label":p?`待发送附件`:`Selected attachments`,children:r.map((e,t)=>(0,J.jsx)(P,{file:e,disabled:a,removeLabel:x(`chat.attachRemove`,{name:e.name}),onRemove:()=>{i(r.filter(t=>t!==e)),I(``)}},`${e.name}:${e.lastModified}:${t}`))}),!W&&M&&(0,J.jsx)(`div`,{className:`map-attachment-notice nowheel`,role:`alert`,children:M}),(0,J.jsxs)(`div`,{className:`map-composer map-island-surface`,children:[(0,J.jsx)(`button`,{type:`button`,className:`map-composer-brand map-attach`,"aria-label":x(`chat.attach`),title:x(`chat.attach`),"aria-hidden":W,tabIndex:W?-1:0,disabled:a&&!W,onClick:()=>E.current?.click(),children:(0,J.jsx)(h,{size:25})}),(0,J.jsxs)(`button`,{type:`button`,className:`map-island-launch`,"aria-label":p?`打开消息输入`:`Open message composer`,"aria-expanded":!W,"aria-controls":S,"aria-hidden":!W,tabIndex:W?0:-1,onClick:le,children:[(0,J.jsxs)(`span`,{className:`map-island-copy`,children:[(0,J.jsx)(`strong`,{children:ge}),(0,J.jsx)(`small`,{title:_e,children:_e})]}),(0,J.jsx)(`span`,{className:`map-island-indicator`,"aria-hidden":`true`,children:ve===`working`||ve===`launching`?(0,J.jsxs)(`span`,{className:`map-island-wave`,children:[(0,J.jsx)(`i`,{}),(0,J.jsx)(`i`,{}),(0,J.jsx)(`i`,{})]}):ve===`sent`||ve===`task`||ve===`message`?(0,J.jsx)(T,{size:16}):(0,J.jsx)(ie,{size:15})})]}),W&&a&&(0,J.jsx)(`button`,{type:`button`,className:`map-island-stop`,onClick:c,"aria-label":p?`停止等待`:`Stop waiting`,children:(0,J.jsx)(z,{size:13})}),(0,J.jsxs)(`form`,{id:S,className:`map-composer-editor`,"aria-hidden":W,onSubmit:e=>{e.preventDefault(),me()},children:[(0,J.jsx)(`input`,{ref:E,type:`file`,multiple:!0,accept:f,hidden:!0,disabled:a,onChange:e=>{X(Array.from(e.target.files||[])),e.target.value=``}}),(0,J.jsx)(`textarea`,{ref:C,rows:1,tabIndex:W?-1:0,value:ne,"aria-label":p?`给 Argus 发送消息`:`Message Argus`,placeholder:p?`告诉 Argus,你想完成什么…`:`What would you like Argus to do?`,onFocus:()=>V(!0),onChange:e=>{R(!1),t(K.map(F).join(``)+e.target.value)},onPaste:e=>{let t=y(e.clipboardData);t.length&&(e.preventDefault(),X(t))},onKeyDown:e=>{e.key===`Escape`&&!b(e)&&!ne.trim()&&!r.length&&(e.preventDefault(),e.stopPropagation(),q()),e.key===`Enter`&&!e.shiftKey&&!b(e)&&(e.preventDefault(),me())}}),(0,J.jsxs)(`div`,{className:`map-island-toolbar`,children:[(0,J.jsx)(`button`,{type:`button`,className:`map-island-collapse`,tabIndex:W?-1:0,onClick:q,"aria-label":p?`收起消息输入`:`Collapse message composer`,title:p?`收起(草稿会保留)`:`Collapse (draft is kept)`,children:(0,J.jsx)(U,{size:15})}),(0,J.jsx)(`span`,{className:`map-island-key-hint`,"aria-hidden":`true`,children:p?`Enter 发送`:`Enter to send`}),_&&(0,J.jsxs)(`select`,{className:`map-route-select`,tabIndex:W?-1:0,"aria-label":x(`chat.routeLabel`),title:x(`chat.routeHint`),value:g,disabled:a,onChange:e=>_(e.target.value),children:[(0,J.jsx)(`option`,{value:`auto`,children:x(`chat.routeAuto`)}),(0,J.jsx)(`option`,{value:`task`,children:x(`chat.routeTask`)}),(0,J.jsx)(`option`,{value:`chat`,children:x(`chat.routeChat`)})]}),a?(0,J.jsx)(`button`,{type:`button`,onClick:e=>{e.preventDefault(),c()},tabIndex:W?-1:0,"aria-label":p?`停止等待`:`Stop waiting`,className:`map-send is-pending`,children:(0,J.jsx)(z,{size:15})}):(0,J.jsx)(`button`,{type:`submit`,tabIndex:W?-1:0,disabled:!ne.trim(),"aria-label":p?`发送消息`:`Send message`,className:`map-send`,children:(0,J.jsx)(m,{size:20})})]})]})]}),(0,J.jsx)(`span`,{className:`map-composer-caption`,role:`status`,children:he?`${he[0]} · ${he[1]}`:a?o||(p?`Argus 正在处理…`:`Argus is responding…`):L?p?`已发送`:`Sent`:d?`${p?`发送至`:`Send to`} ${u}`:``})]})}function fm(e,t){let n=1-t;return{x:n**3*e[0].x+3*n**2*t*e[1].x+3*n*t**2*e[2].x+t**3*e[3].x,y:n**3*e[0].y+3*n**2*t*e[1].y+3*n*t**2*e[2].y+t**3*e[3].y}}function pm(e,t,n=!1){if(!e.length)return null;let r=n?[...e].reverse():e,i=0;for(let e=1;e0&&i+n>=t){let a=(t-i)/n;return{x:r[e-1].x+(r[e].x-r[e-1].x)*a,y:r[e-1].y+(r[e].y-r[e-1].y)*a}}i+=n}return r[r.length-1]}function mm(e,t,n=0){return e.x>t.x-n&&e.xt.y-n&&e.y({x:n===`left`?-e.x:e.x,y:n===`up`?-e.y:e.y}),s=o(e),c=o(t);i=i.map(e=>({...e,x:n===`left`?-e.x-e.width:e.x,y:n===`up`?-e.y-e.height:e.y}));let l=Math.max(80,n===`loop`?Math.max(Math.abs(c.x-s.x),Math.abs(c.y-s.y))*2.8:0,Math.abs(a?c.y-s.y:c.x-s.x)*(.4+r*.06)),u=[s,a?{x:s.x+0,y:s.y+l}:{x:s.x+l,y:s.y},n===`loop`?{x:c.x,y:c.y+l}:a?{x:c.x-0,y:c.y-l}:{x:c.x-l,y:c.y},c],d=e=>e.flatMap(e=>Array.from({length:31},(t,n)=>fm(e,n/30))),f=e=>d(e).reduce((e,t)=>e+i.filter(e=>mm(t,e,22)).length,0),p=[u],m=f(p)*1e5;if(m){let e={x:(s.x+c.x)/2,y:(s.y+c.y)/2},t=a?e.x:e.y,n=[...new Set(i.flatMap(e=>a?[e.x-110-r*30,e.x+e.width+110+r*30]:[e.y-110-r*30,e.y+e.height+110+r*30]))].sort((e,n)=>Math.abs(e-t)-Math.abs(n-t)).slice(0,12);for(let e of n){let n=(e-t)*4/3;for(let r of[.25,.4,.55]){let i=Math.max(60,Math.abs(a?c.y-s.y:c.x-s.x)*r),o=[a?[s,{x:s.x+n,y:s.y+i},{x:c.x+n,y:c.y-i},c]:[s,{x:s.x+i,y:s.y+n},{x:c.x-i,y:c.y+n},c]],l=f(o)*1e5+Math.abs(e-t)+Math.abs(r-.4)*100;le.map(o)),{path:`M ${e.x} ${e.y}`+p.map(e=>` C ${e[1].x} ${e[1].y}, ${e[2].x} ${e[2].y}, ${e[3].x} ${e[3].y}`).join(``),points:d(p),labels:[.5,.4,.6,.3,.7,.2,.8,.35,.45,.55,.65,.25,.75,.15,.85].map(e=>{let t=Math.min(p.length-1,Math.floor(e*p.length));return fm(p[t],e*p.length-t)})}}var gm=new WeakMap,_m=.5;function vm(e){return e<_m?0:Math.max(_m,Math.floor(e*8)/8)}function ym(e){return e==null?``:String(e).replace(/\s+/g,` `).trim()}function bm(e){let t=[...ym(e)].reduce((e,t)=>e+(/[^\x00-\x7F]/.test(t)?10.5:6),20);return{width:Math.min(t,166),height:26}}function xm(e,t){let n=e.getState(),r=[...n.nodeLookup.values()].filter(e=>!e.hidden).map(e=>({id:e.id,...e.internals.positionAbsolute,width:e.width||e.measured.width||0,height:e.height||e.measured.height||0}));function i(e,t){let r=n.nodeLookup.get(e);if(!r)return null;let{x:i,y:a}=r.internals.positionAbsolute,o=r.width||r.measured.width||0,s=r.height||r.measured.height||0;return{x:i+(t===`left`?0:t===`right`?o:o/2),y:a+(t===`top`?0:t===`bottom`?s:s/2)}}let a=n.edges.filter(e=>!e.hidden).map(e=>({...e,s:i(e.source,e.sourceHandle),t:i(e.target,e.targetHandle)})),o=JSON.stringify([r,a.map(e=>[e.id,e.s,e.t,e.label,e.data?.lane,e.sourceHandle,e.targetHandle,e.className])]),s=gm.get(e);if(!s||s.key!==o){let t=new Map,n=new Map;for(let e of a)n.set(e.id,/(?:^|\s)map-edge-(\w+)/.exec(e.className??``)?.[1]),e.s&&e.t&&t.set(e.id,hm(e.s,e.t,e.source===e.target?`loop`:e.sourceHandle===`left`?`left`:e.sourceHandle===`top`?`up`:e.sourceHandle===`bottom`,Number(e.data?.lane||0),r.filter(t=>t.id!==e.source&&t.id!==e.target)));s={key:o,routes:t,kinds:n,zoom:-1,labels:new Map},gm.set(e,s)}let c=vm(t);return s.zoom!==c&&(s.zoom=c,s.labels=new Map,c&&Sm(s,a,r,c)),s}function Sm(e,t,n,r){let i=[...n];for(let n of t){let t=e.routes.get(n.id);if(!t||!n.label)continue;let a=bm(n.label),o=a.width/r,s=a.height/r,c=[0,3,4,5,6][Number(n.data?.lane||0)%5],l=[t.labels[c],...t.labels.filter((e,t)=>t!==c)].filter(e=>i.every(t=>e.x+o/2<=t.x||e.x-o/2>=t.x+t.width||e.y+s/2<=t.y||e.y-s/2>=t.y+t.height)),u,d=1/0;for(let t of l){let r={x:t.x-o/2,y:t.y-s/2,width:o,height:s},i=0;for(let[t,a]of e.routes)t!==n.id&&a.points.some(e=>mm(e,r))&&i++;if(iMath.round(e.transform[2]*24)/24||e.transform[2]),a=`relation-arrow-${(0,Y.useId)().replace(/:/g,``)}`,o=xm($(),i),s=o.routes.get(e),c=o.labels.get(e);if(!s)return null;let l=o.kinds.get(e),u=l===`fanout`||l===`fanin`,d=!l||n?.stroke===Cm?n?.stroke||`#7594ad`:`var(--map-edge-${l}, ${n?.stroke||`#7594ad`})`,f=(Number(n?.strokeWidth||2)+(u?.4:0))/i,p=u?pm(s.points,(l===`fanout`?2:15)/i,l===`fanin`):null,m=typeof t==`string`?ym(t):void 0;return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`defs`,{children:(0,J.jsx)(`marker`,{id:a,viewBox:`0 0 10 10`,refX:`9`,refY:`5`,markerWidth:10.5/i,markerHeight:10.5/i,markerUnits:`userSpaceOnUse`,orient:`auto`,children:(0,J.jsx)(`path`,{d:`M 0 0 L 10 5 L 0 10 z`,style:{fill:d}})})}),(0,J.jsxs)(Lp,{path:s.path,delay:r?.growthDelay,padding:24/i,children:[(0,J.jsx)(pd,{id:e,path:s.path,markerEnd:`url(#${a})`,style:{...n,stroke:d,vectorEffect:`none`,strokeWidth:f,strokeDasharray:n?.strokeDasharray?String(n.strokeDasharray).split(/[\s,]+/).map(e=>Number(e)/i).join(` `):void 0}}),p&&(0,J.jsx)(`circle`,{className:`map-edge-joint`,cx:p.x,cy:p.y,r:3.2/i,style:{fill:d},"aria-hidden":`true`})]}),r?.active&&(0,J.jsx)(hf,{children:(0,J.jsx)(`div`,{className:`map-edge-spark`,"aria-hidden":`true`,style:{offsetPath:`path("${s.path}")`,width:8/i,height:8/i,margin:`${-4/i}px 0 0 ${-4/i}px`,animationDelay:`${-((e.charCodeAt(0)*131+e.length*47)%2800)}ms`}})}),t&&m!==``&&c&&(0,J.jsx)(hf,{children:(0,J.jsx)(`div`,{className:`map-relation-label nodrag nopan`,"data-kind":l,title:m,style:{transform:`translate(-50%, -50%) translate(${c.x}px, ${c.y}px) scale(${1/i})`},children:m??t})})]})}function Tm({open:e,info:t,zh:n,onChoose:r,readOnly:i=!1}){return(0,J.jsx)(R,{open:e,onClose:()=>r({mode:`off`}),label:n?`选择地图加载范围`:`Choose map history`,width:`max-w-lg`,children:(0,J.jsxs)(`div`,{className:`map-history-choice`,children:[(0,J.jsx)(`h2`,{children:n?`选择地图加载范围`:`Choose map history`}),(0,J.jsx)(`p`,{children:n?`本会话有 ${t.task_count} 个任务,历史记录约 ${(t.event_bytes/1024/1024).toFixed(1)} MB。`:`This session has ${t.task_count} tasks and about ${(t.event_bytes/1024/1024).toFixed(1)} MB of history.`}),(0,J.jsx)(`p`,{children:i?n?`只读模式只加载历史记录,不调用模型。较长历史需要一些加载时间。`:`Read-only mode loads records without model calls. Long histories take time to load.`:n?`加载较长历史需要一些时间。生成卡片摘要与关系说明会调用已配置的模型,并消耗额外 Token。已有摘要会优先复用。`:`Loading a long history takes time. Card summaries and relationship descriptions use your configured model and consume additional tokens. Existing summaries are reused.`}),(0,J.jsxs)(`div`,{className:`map-history-options`,children:[(0,J.jsxs)(`button`,{type:`button`,onClick:()=>r({mode:`current`,since:t.current_task_ts,eventSince:t.current_event_ts,taskId:t.current_task_id||void 0}),children:[(0,J.jsx)(`strong`,{children:n?`从当前进度加载`:`Start at current progress`}),(0,J.jsx)(`span`,{children:n?`推荐 · 加载当前任务及后续进度,保留相关连接`:`Recommended · Load current and future work with its connections`})]}),(0,J.jsxs)(`button`,{type:`button`,onClick:()=>r({mode:`full`}),children:[(0,J.jsx)(`strong`,{children:n?`从头加载`:`Load from the beginning`}),(0,J.jsx)(`span`,{children:n?`分批加载完整历史,再补齐需要的摘要`:`Load the complete history in pages, then prepare missing summaries`})]}),(0,J.jsxs)(`button`,{type:`button`,onClick:()=>r({mode:`off`}),children:[(0,J.jsx)(`strong`,{children:n?`不开启地图模式`:`Keep map mode off`}),(0,J.jsx)(`span`,{children:n?`不加载地图,也不生成摘要`:`Do not load the map or generate summaries`})]})]}),(0,J.jsx)(`small`,{children:n?`选择仅用于本会话,可随时更改加载范围。`:`This choice applies to this session and can be changed later.`})]})})}function Em(e){try{let t=JSON.parse(e||`null`);return!t||![`full`,`current`,`off`].includes(t.mode)||t.mode===`current`&&![t.since,t.eventSince].every(e=>typeof e==`number`&&Number.isFinite(e)&&e>=0)?null:t}catch{return null}}function Dm(e,t){if(!e||e.id!==t.id||t.reset_history)return t;let n=new Map((!t.incremental||t.tasks_complete?[]:e.tasks).map(e=>[e.id,e]));for(let e of t.tasks)n.set(e.id,e);for(let e of t.removed_task_ids||[])n.delete(e);let r=new Map(e.events.filter(e=>t.incremental&&!t.team_events_complete||e.type!==`team.task`).map(e=>[e.id,e]));for(let e of t.events)r.set(e.id,e);for(let e of t.removed_event_ids||[])r.delete(e);return i(e,{...e,...t,tasks:[...n.values()].sort((e,t)=>(e.ts||0)-(t.ts||0)||e.id.localeCompare(t.id)),events:[...r.values()].filter(e=>n.has(e.item_id))})}function Om(e,t,n){return e?t?.history_loading?400:!km(n)||t?.events.some(e=>e.type===`team.task`&&$f.has(e.status||``))?15e3:!1:!1}function km(e){return!e.daemon.alive||e.continuous?.enabled===!1&&/pause|stop/i.test(e.continuous.done_reason||``)?!0:e.daemon.health?.state===`stopped`}var Am=new Map;function jm(e){let t=Am.get(e);if(t)return t;try{let t=JSON.parse(ee(`argus.map.camera.v1:`+e)||`null`);if(t&&[t.viewport,t.overview].every(e=>e&&[e.x,e.y,e.zoom].every(Number.isFinite)&&e.zoom>=.035&&e.zoom<=3.5)&&(t.focusId===null||typeof t.focusId==`string`)&&typeof t.detailed==`boolean`)return{camera:t}}catch{}return{}}function Mm(e,t){for(Am.delete(e),Am.set(e,t);Am.size>8;)Am.delete(Am.keys().next().value);t.camera&&L(`argus.map.camera.v1:`+e,JSON.stringify(t.camera))}var Nm={task:Gp,branch:Zp},Pm={relation:wm},Fm={done:`#a8cfbb`,running:`#8fb6e4`,question:`#e2c78e`,failed:`#dfab97`,paused:`#d6c6a0`,superseded:`#c8bdd5`,aborted:`#c3c5cb`,skipped:`#c3c5cb`,missing:`#c3c5cb`};function Im({events:e,zh:t}){let n=[...new Map(e.filter(e=>e.type===`team.task`).map(e=>[e.id,e])).values()];if(!n.length)return null;let r=n.filter(e=>e.status===`done`).length,i=n.filter(e=>$f.has(e.status||``)).length,a=n.filter(e=>e.status===`failed`).length;return(0,J.jsxs)(`div`,{className:`map-team-progress`,role:`status`,"aria-label":t?`子任务进度`:`Subtask progress`,children:[(0,J.jsx)(`strong`,{children:t?`子任务`:`Subtasks`}),(0,J.jsxs)(`span`,{children:[(0,J.jsx)(T,{size:12}),(0,J.jsxs)(`b`,{children:[r,`/`,n.length]}),` `,t?`已完成`:`completed`]}),(0,J.jsxs)(`span`,{children:[(0,J.jsx)(`b`,{children:i}),` `,t?`进行中`:`running`]}),(0,J.jsxs)(`span`,{children:[(0,J.jsx)(`b`,{children:a}),` `,t?`失败`:`failed`]})]})}function Lm({data:e,zh:t,composer:n,activePhase:r,snapshot:s,events:c,pendingLabel:f,readOnly:m,sessionId:h,viewKey:g,paused:_,actions:v}){let[y,b]=(0,Y.useState)(!1),[x,S]=(0,Y.useState)(!1),[C,w]=(0,Y.useState)(null),O=(0,Y.useRef)(0),k=(0,Y.useRef)(!0);(0,Y.useEffect)(()=>(k.current=!0,()=>{k.current=!1}),[]);let j=(0,Y.useMemo)(()=>np(e.tasks),[e.tasks]),[N,P,I]=gf([]),L=(0,Y.useRef)(null),R=lm(L,!m),z=vf(),V=(0,Y.useRef)(!1),[ee,te]=(0,Y.useState)(!1),U=(0,Y.useRef)(null);U.current||=jm(g);let[W]=(0,Y.useState)(()=>new Set(U.current?.scene?.cards.map(e=>e.id))),G=N.find(e=>e.id===R.focusId),{copy:re,ready:ie}=um(e,G?.data.task.id||null,t,!m&&!e.history_loading,G?.data.layout.steps,h,_),ae=(0,Y.useMemo)(()=>sp(j,re?.relations||[],t),[j,re?.relations,t]),oe=(0,Y.useRef)(U.current.scene),q=(0,Y.useMemo)(()=>{let n=Pp(j,e.events,t,oe.current,ae);return oe.current=i(oe.current,n),oe.current},[j,e.events,t,ae]),de=(0,Y.useRef)(null),pe=(0,Y.useMemo)(()=>(de.current=i(de.current,op(j,e.events,t)),de.current),[j,e.events,t]),me=(0,Y.useRef)(null),X=(0,Y.useMemo)(()=>{let e=pe.tasks.filter(e=>e.branch);if(!e.length)return{links:q.links,positions:q.positions,frames:q.frames,structure:q.structure,branches:e,branchAnchor:new Map};let t=new Map;for(let e of q.cards)t.set(e.task.id,e.id);let n=new Map(e.map(e=>[e.id,t.get(e.parent_id)??e.parent_id])),r={...q.frames};for(let t of e)r[t.id]={...qp,scale:1};let i=[...q.links,...pe.links.filter(e=>e.kind===`fanout`||e.kind===`fanin`).map(e=>({...e,source:t.get(e.source)??e.source,target:t.get(e.target)??e.target}))],a=new Map;for(let t of e){let e=n.get(t.id);a.set(e,[...a.get(e)??[],t.id])}let o=q.cards.flatMap(e=>[e.id,...a.get(e.id)??[]]),s=JSON.stringify([o.map(e=>[e,r[e].width,r[e].height]),i.map(e=>[e.source,e.target,e.kind])]),c=me.current?.structure===s?me.current.positions:hp(o,i,r);return me.current={structure:s,positions:c},{links:i,positions:c,frames:r,structure:s,branches:e,branchAnchor:n}},[q,pe]),he=xe(q,!!e.history_loading),ge=(0,Y.useMemo)(()=>ap(e.events),[e.events]),ve=async(e,t=[])=>{let r=++O.current,i=L.current?.querySelector(`.map-composer`)?.getBoundingClientRect();w({id:r,text:A(e).text.replace(/\s+/g,` `).slice(0,180),origin:{x:i?.left??20,y:i?.top??innerHeight-100,width:i?.width??260,height:i?.height??56}});let a=!1,o=e=>{e.type===`task`&&(a=!0),k.current&&e.type===`settled`&&e.outcome===`message`&&!a&&(S(!0),b(!1)),k.current&&w(t=>t?.id===r?{...t,result:e}:t)};try{let r=await n.onSend(e,t,o);return r&&k.current&&A(e).refs.length>0&&(S(!0),b(!1)),r||o({type:`settled`,outcome:`error`}),r}catch(e){throw o({type:`settled`,outcome:`error`}),e}},be=()=>{w(e=>e?{...e,result:{type:`settled`,outcome:`cancelled`}}:null),n.onCancel()};(0,Y.useEffect)(()=>{if(!z||V.current||!ie||U.current?.camera&&e.history_loading)return;let t=requestAnimationFrame(()=>{V.current=!0,U.current?.camera?R.restore(U.current.camera):R.fit(),te(!0)});return()=>cancelAnimationFrame(t)},[z,R.fit,R.restore,e.history_loading,ie]),(0,Y.useEffect)(()=>{let e=()=>{V.current&&Mm(g,{scene:oe.current,camera:R.capture()})};return window.addEventListener(`pagehide`,e),()=>{e(),window.removeEventListener(`pagehide`,e)}},[g,R.capture]),(0,Y.useEffect)(()=>{if(!z)return;let e=requestAnimationFrame(R.fitUpdatedScene);return()=>cancelAnimationFrame(e)},[X.structure,z,R.fitUpdatedScene]);let Se=(0,Y.useRef)(n);Se.current=n;let Ce=(0,Y.useCallback)(e=>{if(m)return;let t=Se.current;t.onChange(F(e)+t.value),window.setTimeout(()=>document.querySelector(`.map-composer textarea`)?.focus(),0)},[m]),[we,Te]=(0,Y.useState)(null),Ee=a(),De=o({queryKey:[`map-notes`,h],queryFn:({signal:e})=>p.mapNotes(h,e),enabled:e.kind===`live`&&!m,staleTime:6e4}),Oe=(0,Y.useMemo)(()=>({notes:Kp(De.data?.notes??[])}),[De.data]),[ke,Ae]=(0,Y.useState)(null),[je,Me]=(0,Y.useState)(``),[Ne,Pe]=(0,Y.useState)(!1);(0,Y.useEffect)(()=>{if(!ke)return;let e=e=>{e.target.closest(`.map-note-editor`)||Ae(null)},t=e=>{e.key===`Escape`&&(e.stopPropagation(),Ae(null))};return window.addEventListener(`pointerdown`,e),document.addEventListener(`keydown`,t,!0),()=>{window.removeEventListener(`pointerdown`,e),document.removeEventListener(`keydown`,t,!0)}},[ke]);let Fe=async()=>{let e=ke,t=je.trim();if(!(!e||!t)){Pe(!1);try{await p.addMapNote(h,{node_id:e.ref.task_id,text:t}),await Ee.invalidateQueries({queryKey:[`map-notes`,h]}),Ae(null),Me(``)}catch{Pe(!0)}}},Ie=(0,Y.useCallback)((e,t)=>{m||Te({ref:e,x:Math.min(window.innerWidth-180,t.x),y:Math.min(window.innerHeight-140,t.y)})},[m]);(0,Y.useEffect)(()=>{if(!we)return;let e=e=>{e.target.closest(`.map-context-menu`)||Te(null)},t=e=>{e.key===`Escape`&&(e.stopPropagation(),Te(null))};return window.addEventListener(`pointerdown`,e),document.addEventListener(`keydown`,t,!0),()=>{window.removeEventListener(`pointerdown`,e),document.removeEventListener(`keydown`,t,!0)}},[we]);let[Le,Re]=(0,Y.useState)(``),ze=(0,Y.useCallback)(e=>`${e.task.title} ${e.task.objective??``} ${re?.cards[e.task.id]?.title||``} ${re?.cards[e.task.id]?.summary||``} ${e.part>1?t?`续篇 ${e.part-1}`:`Continued ${e.part-1}`:``}`.toLowerCase(),[re,t]),Be=(0,Y.useMemo)(()=>Le?q.cards.filter(e=>ze(e).includes(Le.toLowerCase())):[],[Le,q.cards,ze]),[Ve,He]=(0,Y.useState)(0);(0,Y.useEffect)(()=>He(0),[Le]);let[Ue,We]=(0,Y.useState)(j.tasks.length),[Ge,Ke]=(0,Y.useState)(!1),[qe,Je]=(0,Y.useState)(!1),[Ye,Xe]=(0,Y.useState)(``);(0,Y.useEffect)(()=>{P(n=>i(n,q.cards.map(n=>({id:n.id,type:`task`,position:X.positions[n.id]??q.positions[n.id],width:q.frames[n.id].width,height:q.frames[n.id].height,style:{width:q.frames[n.id].width,height:q.frames[n.id].height},data:{...n,zh:t,open:R.enter,readStep:R.readStep,menu:Ie,quote:Ce,source:e.id,readOnly:m,live:e.kind===`live`,paused:_,seenCards:W,restoring:!!U.current?.camera&&!V.current,layout:q.layouts[n.id],frame:q.frames[n.id],plannedWidth:ge.get(n.task.id),focused:!1,detailed:!1}}))))},[j,q,X,t,P,R.enter,R.readStep,Ie,Ce,e.id,e.kind,m,_,W,ge]),(0,Y.useEffect)(()=>{We(e=>Math.min(Math.max(e,1),j.tasks.length))},[j.tasks.length]),(0,Y.useEffect)(()=>{if(!Ge||R.detailed)return;let e=window.setInterval(()=>We(e=>e>=j.tasks.length?(Ke(!1),e):e+1),900);return()=>window.clearInterval(e)},[Ge,j.tasks.length,R.detailed]);let Ze=(0,Y.useMemo)(()=>{let t=new Set(q.cards.filter(t=>e.kind===`live`||t.ordinal<=Ue).map(e=>e.id));for(let[e,n]of X.branchAnchor)t.has(n)&&t.add(e);return t},[q.cards,Ue,e.kind,X.branchAnchor]),Qe=(0,Y.useRef)([]),$e=(0,Y.useMemo)(()=>{let e=N.map(e=>({...e,hidden:!Ze.has(e.id),data:{...e.data,copy:re?{cards:Object.fromEntries([e.data.task.id,...e.data.layout.steps.map(e=>e.id)].filter(e=>re.cards[e]).map(e=>[e,re.cards[e]]))}:void 0,focused:e.id===R.focusId,detailed:R.detailed&&e.id===R.focusId,canvasSize:R.canvasSize,growthDelay:he.cards[e.id],dispatchState:C?.result?.type===`task`&&C.result.taskId===e.data.task.id&&!n.historical?C.landed?`landed`:`receiving`:void 0,growingSteps:Object.fromEntries(e.data.layout.steps.flatMap(t=>{let n=he.steps[ye(e.id,t.id)];return n==null?[]:[[t.id,n]]})),growingLinks:Object.fromEntries(e.data.layout.links.flatMap(t=>{let n=he.links[ye(e.id,t.id)];return n==null?[]:[[t.id,n]]}))},style:{...e.style,opacity:Le&&!ze(e.data).includes(Le.toLowerCase())?.22:1}}));return Qe.current=i(Qe.current,e),Qe.current},[N,Ze,R.focusId,R.detailed,R.canvasSize,Le,ze,re,t,he,C,n.historical]),et=(0,Y.useRef)([]),tt=(0,Y.useMemo)(()=>{let e=new Map;for(let t of X.branches){let n=t.parent_id??``;e.set(n,(e.get(n)??0)+1)}let n=new Map,r=X.branches.map(r=>{let i=r.parent_id??``,a=(n.get(i)??0)+1;return n.set(i,a),{id:r.id,type:`branch`,position:X.positions[r.id]??{x:0,y:0},width:qp.width,height:qp.height,style:{width:qp.width,height:qp.height},hidden:!Ze.has(r.id),draggable:!1,selectable:!1,focusable:!1,data:{task:r,zh:t,parentCardId:X.branchAnchor.get(r.id),open:R.enter,fanIndex:a,fanCount:e.get(i)}}});return et.current=i(et.current,r),et.current},[X,Ze,t,R.enter]),nt=(0,Y.useMemo)(()=>tt.length?[...$e,...tt]:$e,[$e,tt]),rt=(0,Y.useMemo)(()=>{let n=X.links.filter(e=>Ze.has(e.source)&&Ze.has(e.target)&&(e.kind!==`replacement`||qe)),r=gp(n),i=new Map(q.cards.map(e=>[e.id,e.task])),a=new Set;if(e.kind===`live`&&!_){for(let e of q.cards)$f.has(e.task.status)&&a.add(e.id);for(let e of X.branches)$f.has(e.status)&&a.add(e.id)}return n.map((e,n)=>{let o=e.kind===`fanout`||e.kind===`fanin`;return{id:e.id,source:e.source,target:e.target,..._p({...X.positions[e.source],...X.frames[e.source]},{...X.positions[e.target],...X.frames[e.target]}),type:`relation`,data:{growthDelay:he.links[e.id],active:a.has(e.target),lane:r[n]},className:`map-edge-${e.kind}`,label:o?void 0:e.label||(e.kind===`replacement`?(i.get(e.source)?.superseded_reason||``).replace(/\s+/g,` `).slice(0,60)||(t?`转入新计划`:`New plan`):e.kind===`dependency`?t?`依赖`:`Dependency`:t?`同一研究`:`Related work`),labelStyle:{fontSize:30,fill:e.kind===`replacement`?`#95809f`:`#6685a4`},labelBgPadding:[12,6],labelBgBorderRadius:12,labelBgStyle:{fill:`var(--map-paper)`,fillOpacity:.96},style:{stroke:e.cycle?`#dc6648`:e.kind===`replacement`?`#a48caf`:e.kind===`dependency`?`#527fa7`:`#7594ad`,strokeWidth:e.kind===`dependency`?1.55:o?.95:1.3,vectorEffect:`non-scaling-stroke`,strokeDasharray:e.kind===`dependency`||o?void 0:e.kind===`context`?`3 10`:`4 5`},markerEnd:{type:go.ArrowClosed,color:e.kind===`replacement`?`#a48caf`:`#8aa5b8`,width:32,height:32},ariaLabel:e.evidence||(o?`Team branch: ${e.source} → ${e.target}`:e.kind===`dependency`?`Dependency: ${e.source} → ${e.target}`:`Plan replacement: ${e.source} → ${e.target_plan_id} (${e.target_count} tasks, representative ${e.target})`)}})},[X,Ze,qe,t,he,e.kind,_,q.cards]),it=j.links.filter(e=>e.kind===`replacement`).length,at=(0,Y.useMemo)(()=>{let t={done:0,running:0,question:0,failed:0,other:0};for(let n of e.tasks)n.status===`done`?t.done++:$f.has(n.status)?t.running++:n.pending_question?t.question++:n.status===`failed`?t.failed++:t.other++;return t},[e.tasks]),ot=at.done,st=at.question+at.failed,ct=e=>{We(t=>Math.max(t,q.cards.find(t=>t.id===e)?.ordinal||1)),R.enter(e)},lt=()=>{let n=e.tasks.find(e=>$f.has(e.status))??e.tasks.find(e=>e.pending_question)??e.tasks.find(e=>e.status===`pending`)??e.tasks.at(-1);n?(ct(q.cards.filter(e=>e.task.id===n.id).at(-1).id),Xe(``)):Xe(t?`发送一个目标,地图就会开始生长`:`Send a goal to start your map`)},ut=()=>{let t=e.tasks.find(e=>e.pending_question)??e.tasks.find(e=>e.status===`failed`);t&&ct(q.cards.filter(e=>e.task.id===t.id).at(-1).id)};(0,Y.useEffect)(()=>{let e=e=>{if(!(e.defaultPrevented||e.metaKey||e.ctrlKey||e.altKey||e.isComposing)&&!e.target?.closest(`input, textarea, select, [contenteditable]`)){if(e.key===`/`)e.preventDefault(),L.current?.querySelector(`.map-search input`)?.focus();else if(e.key===`f`||e.key===`F`)R.fit();else if((e.key===`ArrowRight`||e.key===`ArrowLeft`)&&R.detailed&&R.focusId){let t=q.cards.filter(e=>Ze.has(e.id)),n=t.findIndex(e=>e.id===R.focusId);if(n<0)return;let r=t[n+(e.key===`ArrowRight`?1:-1)];r&&(e.preventDefault(),R.enter(r.id))}}};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[R.fit,R.enter,R.detailed,R.focusId,q.cards,Ze]);let dt=(0,Y.useMemo)(()=>({artifacts:v.artifacts,onOpenArtifact:v.onOpenArtifact}),[v.artifacts,v.onOpenArtifact]);return(0,J.jsx)(zp.Provider,{value:Oe,children:(0,J.jsxs)(Bp.Provider,{value:dt,children:[(0,J.jsx)(`div`,{className:`map-progress-line`,role:`progressbar`,"aria-label":t?`已完成任务`:`Completed tasks`,"aria-valuemin":0,"aria-valuemax":e.tasks.length||1,"aria-valuenow":ot,children:(0,J.jsx)(`span`,{style:{width:`${e.tasks.length?ot/e.tasks.length*100:0}%`}})}),(0,J.jsxs)(`div`,{className:`map-summary`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`span`,{className:`map-summary-value`,title:q.cards.length>j.tasks.length?`${q.cards.length} ${t?`张卡片`:`cards`}`:void 0,children:e.tasks.length}),(0,J.jsx)(`span`,{children:t?`个任务`:`tasks`}),e.tasks.length>0&&(0,J.jsx)(`span`,{className:`map-progress-strip`,role:`img`,"aria-label":t?`已完成 ${at.done},进行中 ${at.running},值得关注 ${st}`:`${at.done} completed, ${at.running} running, ${st} need attention`,children:[`done`,`running`,`question`,`failed`,`other`].map(e=>at[e]>0&&(0,J.jsx)(`i`,{className:`seg-${e}`,style:{flexGrow:at[e]}},e))}),(0,J.jsxs)(`span`,{className:`map-count-chip is-done`,children:[(0,J.jsx)(T,{size:13}),(0,J.jsx)(`strong`,{children:ot}),(0,J.jsx)(`span`,{children:t?`已完成`:`completed`})]}),at.running>0&&(0,J.jsxs)(`span`,{className:`map-count-chip is-running`,children:[(0,J.jsx)(`strong`,{children:at.running}),(0,J.jsx)(`span`,{children:t?`进行中`:`running`})]}),st>0&&(0,J.jsxs)(`button`,{type:`button`,className:`map-count-chip map-attention-jump`,onClick:ut,title:t?`跳到需要你处理的任务`:`Jump to the task waiting on you`,children:[(0,J.jsx)(`span`,{className:`map-attention-dot`}),(0,J.jsx)(`strong`,{children:st}),(0,J.jsx)(`span`,{children:t?`值得关注`:`need attention`})]})]}),n.pending?(0,J.jsxs)(`span`,{className:`map-live-phase`,children:[(0,J.jsx)(`i`,{}),t?`正在处理消息`:`Processing your message`]}):_?(0,J.jsx)(`span`,{className:`map-paused-label`,children:e.tasks.length>0&&ot===e.tasks.length?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(T,{size:13}),t?`已完成`:`Completed`]}):e.tasks.some(e=>$f.has(e.status)||e.status===`pending`)?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(M,{size:13}),t?`已暂停`:`Paused`]}):t?`就绪`:`Ready`}):r&&(0,J.jsxs)(`span`,{className:`map-live-phase`,children:[(0,J.jsx)(`i`,{}),{planner:`Planner`,manager:`Manager`,engineer:`Engineer`,reviewer:`Reviewer`}[r]||r]}),(0,J.jsx)(`span`,{className:`map-summary-note`,children:t?`滚轮缩放 · 点击任务深入 · / 搜索 · F 全览`:`Scroll to zoom · click a task to explore · / search · F fit`})]}),(0,J.jsx)(Im,{events:e.events,zh:t}),e.kind===`live`&&(0,J.jsxs)(`div`,{className:`map-workspace-actions`,children:[(0,J.jsxs)(`button`,{type:`button`,"aria-expanded":x,onClick:()=>{S(e=>!e),b(!1)},children:[(0,J.jsx)(ce,{size:15}),t?`对话`:`Conversation`]}),(0,J.jsxs)(`button`,{type:`button`,"aria-expanded":y,onClick:()=>{b(e=>!e),S(!1)},children:[(0,J.jsx)(`i`,{"data-active":!!r||n.pending}),t?`Agent 动态`:`Agent activity`]}),(0,J.jsxs)(`button`,{type:`button`,className:`map-delivery-toggle`,disabled:!v.deliveryCount,onClick:v.onOpenDelivery,children:[(0,J.jsx)(E,{size:15}),t?`交付成果`:`Deliveries`,v.deliveryCount>0&&(0,J.jsx)(`span`,{children:v.deliveryCount})]})]}),e.kind===`live`&&!m&&(0,J.jsx)(D,{questions:s.pending_questions??[],backlog:s.backlog,onAnswer:v.onAnswer,onLocate:ut}),(0,J.jsx)(`div`,{className:`map-workspace`,children:(0,J.jsxs)(`div`,{ref:L,className:`map-canvas-wrap`,"data-focused":!!R.focusId,"data-detailed":R.detailed,"data-fitted":ee,children:[x&&(0,J.jsx)(fe,{events:v.conversationEvents,connected:v.connected,pending:n.pending,artifacts:v.artifacts,zh:t,onClose:()=>S(!1),onOpenArtifact:v.onOpenArtifact,onOpenDelivery:v.onOpenReceipt}),y&&e.kind===`live`&&(0,J.jsx)(`aside`,{className:`map-agent-drawer nowheel nodrag nopan`,children:(0,J.jsx)(B,{view:s.mission_view,roles:s.roles,events:c,taskId:G?.data.task.id||s.mission_view?.mission.id||void 0,paused:_&&!n.pending,onClose:()=>b(!1)})}),C&&!m&&(0,J.jsx)(_e,{flight:C,canvas:L,zh:t,historical:n.historical,onReveal:t=>{e.tasks.some(e=>e.id===t)&&R.fit()},onLand:e=>w(t=>t?.id===e?{...t,landed:!0}:t),onFinish:e=>w(t=>t?.id===e?null:t)}),(0,J.jsxs)(`div`,{className:`map-canvas-toolbar nowheel`,children:[(0,J.jsxs)(`label`,{className:`map-search`,children:[(0,J.jsx)(ue,{size:14}),(0,J.jsx)(`input`,{"aria-label":t?`搜索地图任务`:`Search map tasks`,placeholder:t?`搜索任务…`:`Find a task…`,title:t?`Enter 逐个跳转匹配`:`Enter jumps through matches`,value:Le,onChange:e=>Re(e.target.value),onKeyDown:e=>{e.key===`Enter`&&Be.length?(ct(Be[Ve%Be.length].id),He(e=>e+1)):e.key===`Escape`&&Le&&(e.stopPropagation(),Re(``))}}),Le&&(0,J.jsx)(`span`,{className:`map-search-count`,"aria-live":`polite`,children:Be.length?`${Ve%Be.length+1}/${Be.length}`:t?`无匹配`:`0 found`})]}),(0,J.jsxs)(`button`,{onClick:lt,title:t?`定位当前或最近任务`:`Locate current or latest task`,children:[(0,J.jsx)(se,{size:15}),(0,J.jsx)(`span`,{children:t?`定位当前`:`Locate current`})]}),(0,J.jsx)(`button`,{onClick:R.fit,title:t?`适配全图`:`Fit map`,"aria-label":`Fit map`,children:(0,J.jsx)(H,{size:15})}),R.detailed&&(0,J.jsxs)(`button`,{onClick:R.back,className:`map-back-button`,"aria-label":`Return to map`,children:[(0,J.jsx)(K,{size:14}),(0,J.jsx)(`span`,{children:t?`返回全图`:`Overview`})]})]}),Ye&&(0,J.jsx)(`div`,{className:`map-feedback`,role:`status`,children:Ye}),R.detailed&&G&&G.data.partCount>1&&(0,J.jsxs)(`nav`,{className:`map-part-switcher nowheel`,"aria-label":t?`切换任务部分`:`Switch task part`,children:[(0,J.jsx)(`button`,{"aria-label":t?`上一部分`:`Previous part`,disabled:!G.data.previousId,onClick:()=>G.data.previousId&&R.enter(G.data.previousId),children:(0,J.jsx)(ne,{size:15})}),(0,J.jsxs)(`span`,{children:[G.data.part,` / `,G.data.partCount]}),(0,J.jsx)(`button`,{"aria-label":t?`下一部分`:`Next part`,disabled:!G.data.nextId,onClick:()=>G.data.nextId&&R.enter(G.data.nextId),children:(0,J.jsx)(u,{size:15})})]}),j.tasks.length===0?(0,J.jsxs)(`div`,{className:`map-empty`,children:[(0,J.jsx)(l,{size:36}),(0,J.jsx)(`h3`,{children:t?`把一个目标,变成可见的成果`:`Turn a goal into a visible result`}),(0,J.jsx)(`p`,{children:m?t?`尚无任务记录。`:`No task records are available.`:t?`描述你想完成的事情,看 Argus 规划、执行、审查,最后在这里交付。`:`Describe your goal. Watch Argus plan, build, review, and deliver here.`}),!m&&(0,J.jsx)(`div`,{className:`map-starters`,children:(t?[[`交互实验`,`做一个交互式实验室,用动画展示 Dijkstra 和 A* 怎样寻找最短路径。让我能画障碍、单步播放、比较探索范围,并验证两个算法的结果一致。`],[`数据洞察`,`用一组可复现的模拟数据,做一个辛普森悖论交互演示。让我能切换整体和分组视角,看结论怎样反转,附上验证过程。`],[`产品原型`,`做一个精致的个人旅行规划网页。我能调整预算和出行天数,比较三种行程方案,并将选中的方案导出。让手机上也方便操作。`]]:[[`Interactive lab`,`Build an interactive Dijkstra vs A* pathfinding lab with editable obstacles, step-by-step animation, and correctness checks.`],[`Data insights`,`Create an interactive Simpson’s paradox demo using reproducible synthetic data, with aggregate and grouped views and validation.`],[`Product prototype`,`Build a polished travel planner. Let me adjust budget and duration, compare three itineraries, and export my choice. Make it easy to use on a phone.`]]).map(([e,t])=>(0,J.jsxs)(`button`,{type:`button`,onClick:()=>{n.onChange(t),requestAnimationFrame(()=>L.current?.querySelector(`textarea`)?.focus())},children:[e,` ↗`]},e))})]}):(0,J.jsxs)(pf,{nodes:nt,edges:rt,nodeTypes:Nm,edgeTypes:Pm,onNodesChange:I,onMove:R.onMove,defaultViewport:Qp,minZoom:.035,maxZoom:3.5,nodesDraggable:!1,nodesFocusable:!1,nodesConnectable:!1,edgesReconnectable:!1,zoomOnScroll:!1,zoomOnPinch:!0,zoomOnDoubleClick:!1,deleteKeyCode:null,selectionKeyCode:null,onlyRenderVisibleElements:!0,proOptions:{hideAttribution:!0},children:[(0,J.jsx)(Tf,{variant:xf.Dots,gap:88,size:3,color:`var(--map-dot)`}),(0,J.jsx)(Pf,{orientation:`horizontal`,showInteractive:!1,onFitView:R.fit,fitViewOptions:{padding:.16,maxZoom:.27,minZoom:.035,duration:R.reducedMotion?0:320}}),(0,J.jsx)(Yf,{nodeColor:e=>e.type===`branch`?`#c5d4e2`:Fm[ep(e.data.task)]??`#a7bfd9`,maskColor:`var(--map-minimap-mask)`,maskStrokeColor:`#85aacf`,maskStrokeWidth:2,onClick:(e,t)=>R.navigate(t),pannable:!0,zoomable:!0,ariaLabel:t?`地图导航预览`:`Map navigation preview`})]}),(0,J.jsxs)(`div`,{className:`map-legend nowheel`,children:[(0,J.jsxs)(`span`,{title:t?`同一会话中的时间归属,不是执行依赖`:`Chronological context, not execution dependencies`,children:[(0,J.jsx)(`b`,{className:`dashed`}),t?`内容关联`:`Related work`]}),(0,J.jsxs)(`span`,{children:[(0,J.jsx)(`b`,{}),t?`任务依赖`:`Dependency`]}),(0,J.jsxs)(`button`,{className:qe?``:`is-muted`,onClick:()=>Je(e=>!e),"aria-pressed":qe,disabled:it===0,"aria-label":`Toggle plan replacements`,children:[(0,J.jsx)(`b`,{className:`replacement`}),t?`计划替代`:`Plan changes`,it?` · ${it}`:``]})]}),!m&&(0,J.jsx)(dm,{...n,pendingLabel:f,dispatchStatus:C?.result?.type===`task`?C.landed||n.historical?`task`:`launching`:C?.result?.outcome,onSend:ve,onCancel:be,overview:!R.detailed}),we&&!m&&(0,J.jsxs)(`div`,{className:`map-context-menu`,role:`menu`,style:{left:we.x,top:we.y},children:[(0,J.jsx)(`button`,{role:`menuitem`,onClick:()=>{Ce(we.ref),Te(null)},children:t?`引用`:`Reference`}),e.kind===`live`&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`button`,{role:`menuitem`,onClick:()=>{Me(``),Ae({ref:we.ref,x:we.x,y:we.y}),Te(null)},children:t?`添加批注`:`Add a note`}),(0,J.jsx)(`button`,{role:`menuitem`,onClick:()=>{n.onRouteOverrideChange?.(`task`),Ce(we.ref),Te(null)},children:t?`从这里展开`:`Branch from here`})]})]}),ke&&!m&&(0,J.jsxs)(`div`,{className:`map-note-editor nodrag nopan`,style:{left:Math.min(window.innerWidth-320,ke.x),top:Math.min(window.innerHeight-240,ke.y)},children:[(0,J.jsx)(`small`,{children:t?`批注《${ke.ref.task_title}》`:`Note on “${ke.ref.task_title}”`}),(0,J.jsx)(`textarea`,{autoFocus:!0,maxLength:2e3,value:je,onChange:e=>Me(e.target.value),placeholder:t?`写下你的观察,Argus 在下个规划周期会读到`:`Your observation; Argus reads it next planning cycle`}),Ne&&(0,J.jsx)(`small`,{className:`map-note-error`,children:t?`没有保存上,稍后再试;草稿还在`:`Not saved; try again — the draft is kept`}),(0,J.jsxs)(`div`,{className:`map-note-actions`,children:[(0,J.jsx)(`button`,{onClick:()=>Ae(null),children:t?`取消`:`Cancel`}),(0,J.jsx)(`button`,{className:`is-primary`,disabled:!je.trim(),onClick:()=>void Fe(),children:t?`保存`:`Save`})]})]}),(j.cyclic||j.missing>0)&&(0,J.jsx)(`div`,{className:`map-graph-warning`,children:j.cyclic?t?`检测到循环引用,保留原始连线。`:`Cyclic references retained.`:`${j.missing} ${t?`个依赖不在当前记录范围内`:`dependencies outside the available history`}`})]})}),e.kind!==`live`&&(0,J.jsxs)(`div`,{className:`map-playback`,children:[(0,J.jsx)(`button`,{"aria-label":Ge?`Pause reveal`:`Play reveal`,onClick:()=>{Ue>=j.tasks.length&&We(1),Ke(e=>!e)},children:Ge?(0,J.jsx)(M,{size:14}):(0,J.jsx)(d,{size:14})}),(0,J.jsx)(`button`,{"aria-label":`Restart reveal`,onClick:()=>{Ke(!1),We(1),R.back()},children:(0,J.jsx)(le,{size:13})}),(0,J.jsx)(`span`,{children:t?`逐卡展开`:`Reveal cards`}),(0,J.jsx)(`input`,{"aria-label":`Visible task count`,type:`range`,min:Math.min(1,j.tasks.length),max:j.tasks.length,value:Ue,onChange:e=>{Ke(!1),We(Number(e.target.value))}}),(0,J.jsxs)(`span`,{className:`map-count`,children:[Ue,` / `,j.tasks.length]}),(0,J.jsx)(`button`,{"aria-label":`Reveal next card`,disabled:Ue>=j.tasks.length,onClick:()=>We(e=>Math.min(j.tasks.length,e+1)),children:(0,J.jsx)(u,{size:14})}),(0,J.jsx)(`small`,{children:t?`时间顺序`:`Chronological order`})]})]})})}var Rm=(0,Y.memo)(function({snapshot:e,events:t,managerSteps:n=[],draft:r,onDraftChange:i,onSend:s,pending:c,onCancel:u,focusSignal:d,readOnly:f=!1,onOpenSettings:m,routeOverride:h,onRouteOverrideChange:g,conversationEvents:_,connected:v,artifacts:y,deliveryCount:b,onOpenDelivery:x,onOpenReceipt:S,onOpenArtifact:C,onAnswer:w}){let{locale:T}=G(),E=T===`zh-CN`,[D,O]=(0,Y.useState)([]),k=(0,Y.useRef)(r);k.current=r;let A=(0,Y.useRef)(!0);(0,Y.useEffect)(()=>(A.current=!0,()=>{A.current=!1}),[]);let j=(0,Y.useCallback)(async(e,t=[],n)=>{let r=await s(e,t,r=>{A.current&&(r.type===`settled`&&r.outcome===`error`&&!k.current.trim()&&(i(e),O(e=>e.length?e:t)),n?.(r))});return r&&A.current&&(k.current===e&&i(``),O(e=>e.filter(e=>!t.includes(e)))),r},[s,i]),[M,N]=(0,Y.useState)(()=>new URLSearchParams(window.location.search).get(`dataset`)||ee(`argus.map.source.v1`)||`live`),P=o({queryKey:[`map-datasets`],queryFn:({signal:e})=>p.mapDatasets(e),staleTime:1/0}),F=o({queryKey:[`map-dataset`,M],queryFn:({signal:e})=>p.mapDataset(M,e),enabled:M!==`live`,staleTime:1/0,retry:!1}),I=a(),R=`argus.map.history.v1:`+e.session.id,[z,B]=(0,Y.useState)(()=>Em(ee(R))),[V,te]=(0,Y.useState)(!1),H=o({queryKey:[`map-info`,e.session.id],queryFn:({signal:t})=>p.mapInfo(e.session.id,t),enabled:M===`live`,staleTime:6e4}),U=z??(H.data&&!H.data.requires_choice?{mode:`full`}:null);(0,Y.useEffect)(()=>{if(!z&&H.data&&!H.data.requires_choice){let e={mode:`full`};B(e),L(R,JSON.stringify(e))}},[H.data,z,R]);let K=M!==`live`||!!U&&U.mode!==`off`&&!V,ne=[`map-live`,e.session.id,U?.mode,U?.since,U?.eventSince,U?.taskId],ie=JSON.stringify([M,e.session.id,T,U]),ae=e=>{B(e),L(R,JSON.stringify(e)),te(!1)},oe=o({queryKey:ne,queryFn:async({signal:t})=>{let n=I.getQueryData(ne),r=U?.mode===`full`?await p.mapHistory(e.session.id,t,n?.history_cursor,n?.cursor):await p.liveMap(e.session.id,t,n?.cursor,U||void 0);return Dm(I.getQueryData(ne),r)},enabled:M===`live`&&K,staleTime:1/0,gcTime:72e5,refetchOnMount:`always`,refetchInterval:t=>Om(K,t.state.data,e)}),se=M===`live`&&km(e),ce=t.filter(e=>e.run_label!==`map-summary`&&/^(life\.(mission\.|phase\.|planner\.task_added)|round\.|agent\.message|team\.|idea\.portfolio\.)/.test(String(e.type))).at(-1),le=JSON.stringify([ce?.ts,ce?.event_id||ce?.id,ce?.revision,ce?.updated_ts,ce?.status,e.backlog,se]),q=(0,Y.useRef)(null),ue=(0,Y.useRef)(0),fe=(0,Y.useRef)(null);(0,Y.useEffect)(()=>{let e=fe.current;if(!e)return;let t=()=>{ue.current=Date.now()+900},n=e=>{e.buttons&&t()};return e.addEventListener(`wheel`,t,{passive:!0}),e.addEventListener(`pointerdown`,t),e.addEventListener(`pointermove`,n),()=>{e.removeEventListener(`wheel`,t),e.removeEventListener(`pointerdown`,t),e.removeEventListener(`pointermove`,n)}},[]),(0,Y.useEffect)(()=>{if(M!==`live`||!K||q.current)return;let t=()=>{let n=ue.current-Date.now();if(n>0){q.current=setTimeout(t,n+120);return}q.current=null,I.invalidateQueries({queryKey:[`map-live`,e.session.id]})};q.current=setTimeout(t,650)},[le,M,e.session.id,I,K]),(0,Y.useEffect)(()=>()=>{q.current&&clearTimeout(q.current),q.current=null},[M,e.session.id,K]);let pe=M===`live`?oe.data:F.data,me=(0,Y.useMemo)(()=>({conversationEvents:_,connected:v,artifacts:y,deliveryCount:b,onOpenDelivery:x,onOpenReceipt:S,onOpenArtifact:C,onAnswer:w}),[_,v,y,b,x,S,C,w]),X=(0,Y.useMemo)(()=>({routeOverride:h,onRouteOverrideChange:g,value:r,onChange:i,onSend:j,attachments:D,onAttachmentsChange:O,pending:c,onCancel:u,focusSignal:d,sessionName:e.session.display_name||e.session.id,historical:M!==`live`,zh:E}),[h,g,r,i,j,D,c,u,d,e.session.display_name,e.session.id,M,E]),he=e=>{N(e),L(`argus.map.source.v1`,e);let t=new URL(window.location.href);t.searchParams.set(`dataset`,e),window.history.replaceState(null,``,t)};return(0,J.jsxs)(`section`,{ref:fe,className:`argus-map`,"aria-label":E?`研究进度地图`:`Research progress map`,children:[(0,J.jsxs)(`header`,{className:`map-header`,children:[(0,J.jsx)(`div`,{className:`map-heading-icon`,children:(0,J.jsx)(l,{size:20})}),(0,J.jsxs)(`div`,{className:`map-heading`,children:[(0,J.jsx)(`div`,{className:`map-eyebrow`,children:`ARGUS / RESEARCH MAP`}),(0,J.jsx)(`h1`,{children:E?`研究地图`:`Research map`})]}),(0,J.jsxs)(`div`,{className:`map-header-actions`,children:[!f&&m&&(0,J.jsx)(`button`,{type:`button`,onClick:m,className:`map-settings`,"aria-label":E?`地图模型设置`:`Map model settings`,title:E?`地图模型设置`:`Map model settings`,children:(0,J.jsx)(de,{size:16})}),M===`live`&&H.data&&(0,J.jsx)(`button`,{type:`button`,className:`map-scope-button`,onClick:()=>te(!0),children:E?`加载范围`:`History range`}),(0,J.jsxs)(`span`,{className:`map-source-badge`,children:[(0,J.jsx)(`span`,{}),M===`live`?E?`当前会话`:`Current session`:pe?.kind===`synthetic`?E?`人工示例`:`Synthetic example`:pe?.kind===`demo`?E?`历史演示`:`Recorded demo`:E?`历史记录`:`Historical records`]})]})]}),(0,J.jsxs)(`div`,{className:`map-dataset-bar`,children:[(0,J.jsx)(re,{size:15}),(0,J.jsxs)(`select`,{"aria-label":E?`地图数据来源`:`Map data source`,value:M,onChange:e=>he(e.target.value),children:[(0,J.jsxs)(`option`,{value:`live`,children:[E?`当前会话`:`Current session`,` ·`,` `,e.session.display_name]}),!P.data?.datasets.some(e=>e.id===M)&&M!==`live`&&(0,J.jsx)(`option`,{value:M,children:M}),P.data?.datasets.map(e=>(0,J.jsxs)(`option`,{value:e.id,children:[e.title,` · `,e.task_count]},e.id))]}),pe?.captured_at&&(0,J.jsxs)(`span`,{className:`map-capture`,children:[(0,J.jsx)(W,{size:12}),new Date(pe.captured_at).toLocaleDateString()]})]}),M===`live`&&H.data&&(0,J.jsx)(Tm,{open:V||!U&&H.data.requires_choice,info:H.data,zh:E,readOnly:f,onChoose:ae}),M===`live`&&H.isError&&(0,J.jsxs)(`div`,{className:`map-data-error`,children:[E?`暂时无法检查历史记录。`:`Could not check session history.`,(0,J.jsx)(`button`,{onClick:()=>void H.refetch(),children:E?`重试`:`Retry`})]}),K&&pe?.history_loading&&(0,J.jsxs)(`div`,{className:`map-history-progress`,role:`status`,children:[E?`正在分批加载历史记录`:`Loading history in pages`,pe.history_progress&&` · ${(pe.history_progress.loaded_bytes/1024/1024).toFixed(1)} / ${(pe.history_progress.total_bytes/1024/1024).toFixed(1)} MB`,(0,J.jsx)(`button`,{onClick:()=>te(!0),children:E?`更改范围`:`Change range`})]}),K&&pe&&(M===`live`?oe.isError:F.isError)&&(0,J.jsxs)(`div`,{className:`map-data-error`,role:`status`,children:[E?`暂时无法更新,已保留加载的地图。`:`Updates are unavailable. Your loaded map is preserved.`,(0,J.jsx)(`button`,{onClick:()=>void(M===`live`?oe.refetch():F.refetch()),children:E?`重试`:`Retry`})]}),P.isError&&(0,J.jsxs)(`div`,{className:`map-data-error`,children:[E?`历史记录列表暂时无法读取,可切换当前会话或重试。`:`Historical maps are unavailable. Open the current session or retry.`,(0,J.jsx)(`button`,{onClick:()=>void P.refetch(),children:E?`重试`:`Retry`})]}),K?(M===`live`?oe.isError:F.isError)&&!pe?(0,J.jsxs)(`div`,{className:`map-empty`,children:[(0,J.jsx)(`h3`,{children:E?`地图暂时无法读取`:`Map unavailable`}),(0,J.jsx)(`p`,{children:String(M===`live`?oe.error:F.error)}),(0,J.jsx)(`button`,{onClick:()=>void(M===`live`?oe.refetch():F.refetch()),children:E?`重试`:`Retry`})]}):pe?(0,J.jsx)(lf,{children:(0,J.jsx)(Lm,{data:pe,actions:me,snapshot:e,events:t,pendingLabel:n.at(-1)?.detail||n.at(-1)?.label,viewKey:ie,paused:se,sessionId:e.session.id,zh:E,readOnly:f,activePhase:M===`live`&&!se?e.roles.find(e=>e.active)?.role:void 0,composer:X})},ie):(0,J.jsxs)(`div`,{className:`map-empty is-loading`,"aria-busy":`true`,children:[(0,J.jsxs)(`div`,{className:`map-ghosts`,"aria-hidden":!0,children:[(0,J.jsx)(`i`,{}),(0,J.jsx)(`i`,{}),(0,J.jsx)(`i`,{})]}),E?`正在载入地图…`:`Loading map…`]}):(0,J.jsxs)(`div`,{className:`map-empty`,children:[(0,J.jsx)(`h3`,{children:E?`地图尚未开启`:`Map is not enabled`}),(0,J.jsx)(`p`,{children:H.isPending?E?`正在检查历史记录规模…`:`Checking history size…`:E?`选择加载范围后查看研究进度。`:`Choose a history range to view research progress.`}),H.data&&(0,J.jsx)(`button`,{onClick:()=>te(!0),children:E?`选择加载范围`:`Choose history range`})]})]})});export{Rm as MapPanel,Im as MapTeamProgress}; \ No newline at end of file diff --git a/frontend/web/dist/assets/ResearchWorkbenchPanel-BOxuXoMY.js b/frontend/web/dist/assets/ResearchWorkbenchPanel-BOxuXoMY.js new file mode 100644 index 000000000..b52f63ba4 --- /dev/null +++ b/frontend/web/dist/assets/ResearchWorkbenchPanel-BOxuXoMY.js @@ -0,0 +1,10 @@ +import{r as e}from"./rolldown-runtime-hePW80VL.js";import{A as t,k as n}from"./icons-2gFhc0pq.js";import{i as r,n as i,t as a}from"./query-CGMsBv4s.js";import{n as o,r as s,t as c}from"./play-DQD97EkU.js";import{C as l,D as u,H as d,O as f,T as p,U as m,V as h,W as g,f as _,g as v,h as y,i as b,m as x,n as S,p as C,t as w,w as T,x as E,y as D,z as O}from"./index-BZHe8e4S.js";var k=f(`ArrowRight`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`m12 5 7 7-7 7`,key:`xquz4c`}]]),A=f(`Circle`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),j=f(`CodeXml`,[[`path`,{d:`m18 16 4-4-4-4`,key:`1inbqp`}],[`path`,{d:`m6 8-4 4 4 4`,key:`15zrgr`}],[`path`,{d:`m14.5 4-5 16`,key:`e7oirm`}]]),M=f(`FileCode2`,[[`path`,{d:`M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4`,key:`1pf5j1`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`path`,{d:`m5 12-3 3 3 3`,key:`oke12k`}],[`path`,{d:`m9 18 3-3-3-3`,key:`112psh`}]]),N=f(`File`,[[`path`,{d:`M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z`,key:`1rqfz7`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}]]),ee=f(`Files`,[[`path`,{d:`M20 7h-3a2 2 0 0 1-2-2V2`,key:`x099mo`}],[`path`,{d:`M9 18a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h7l4 4v10a2 2 0 0 1-2 2Z`,key:`18t6ie`}],[`path`,{d:`M3 7.6v12.8A1.6 1.6 0 0 0 4.6 22h9.8`,key:`1nja0z`}]]),te=f(`FlaskConical`,[[`path`,{d:`M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2`,key:`18mbvz`}],[`path`,{d:`M6.453 15h11.094`,key:`3shlmq`}],[`path`,{d:`M8.5 2h7`,key:`csnxdl`}]]),P=f(`FolderKanban`,[[`path`,{d:`M4 20h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.93a2 2 0 0 1-1.66-.9l-.82-1.2A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13c0 1.1.9 2 2 2Z`,key:`1fr9dc`}],[`path`,{d:`M8 10v4`,key:`tgpxqk`}],[`path`,{d:`M12 10v2`,key:`hh53o1`}],[`path`,{d:`M16 10v6`,key:`1d6xys`}]]),ne=f(`Folder`,[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]),re=f(`Gauge`,[[`path`,{d:`m12 14 4-4`,key:`9kzdfg`}],[`path`,{d:`M3.34 19a10 10 0 1 1 17.32 0`,key:`19p75a`}]]),F=f(`Github`,[[`path`,{d:`M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4`,key:`tonef`}],[`path`,{d:`M9 18c-4.51 2-5-2-7-2`,key:`9comsn`}]]),ie=f(`LockKeyhole`,[[`circle`,{cx:`12`,cy:`16`,r:`1`,key:`1au0dj`}],[`rect`,{x:`3`,y:`10`,width:`18`,height:`12`,rx:`2`,key:`6s8ecr`}],[`path`,{d:`M7 10V7a5 5 0 0 1 10 0v3`,key:`1pqi11`}]]),ae=f(`Radio`,[[`path`,{d:`M4.9 19.1C1 15.2 1 8.8 4.9 4.9`,key:`1vaf9d`}],[`path`,{d:`M7.8 16.2c-2.3-2.3-2.3-6.1 0-8.5`,key:`u1ii0m`}],[`circle`,{cx:`12`,cy:`12`,r:`2`,key:`1c9p78`}],[`path`,{d:`M16.2 7.8c2.3 2.3 2.3 6.1 0 8.5`,key:`1j5fej`}],[`path`,{d:`M19.1 4.9C23 8.8 23 15.1 19.1 19`,key:`10b0cb`}]]),I=f(`Server`,[[`rect`,{width:`20`,height:`8`,x:`2`,y:`2`,rx:`2`,ry:`2`,key:`ngkwjq`}],[`rect`,{width:`20`,height:`8`,x:`2`,y:`14`,rx:`2`,ry:`2`,key:`iecqi9`}],[`line`,{x1:`6`,x2:`6.01`,y1:`6`,y2:`6`,key:`16zg32`}],[`line`,{x1:`6`,x2:`6.01`,y1:`18`,y2:`18`,key:`nzw8ys`}]]),oe=f(`SquareTerminal`,[[`path`,{d:`m7 11 2-2-2-2`,key:`1lz0vl`}],[`path`,{d:`M11 13h4`,key:`1p7l4v`}],[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}]]),se=f(`TimerReset`,[[`path`,{d:`M10 2h4`,key:`n1abiw`}],[`path`,{d:`M12 14v-4`,key:`1evpnu`}],[`path`,{d:`M4 13a8 8 0 0 1 8-7 8 8 0 1 1-5.3 14L4 17.6`,key:`1ts96g`}],[`path`,{d:`M9 17H4v5`,key:`8t5av`}]]),ce=f(`TriangleAlert`,[[`path`,{d:`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`,key:`wmoenq`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),le=f(`UserRound`,[[`circle`,{cx:`12`,cy:`8`,r:`5`,key:`1hypcn`}],[`path`,{d:`M20 21a8 8 0 0 0-16 0`,key:`rfgkzh`}]]),ue=f(`Workflow`,[[`rect`,{width:`8`,height:`8`,x:`3`,y:`3`,rx:`2`,key:`by2w9f`}],[`path`,{d:`M7 11v4a2 2 0 0 0 2 2h4`,key:`xkn7yn`}],[`rect`,{width:`8`,height:`8`,x:`13`,y:`13`,rx:`2`,key:`1cgmvn`}]]),L=e(t(),1),de=12e3;function R(e=!1){let t={...h()};return e&&(t[`Content-Type`]=`application/json`),t}async function z(e,t={}){await m();let n={...t,headers:{...R(!!t.body),...t.headers??{}},cache:`no-store`},r=String(t.method??`GET`).toUpperCase(),i=async n=>{if(!n.ok){let r=await n.text().catch(()=>``),i=r;try{i=JSON.parse(r).detail??r}catch{}throw Error(i||`${t.method??`GET`} ${e} failed (${n.status})`)}return await n.json()};return r===`GET`?g(e,n,de,i):i(await fetch(e,n))}var B=(e,t=``)=>`/api/projects/${encodeURIComponent(e)}${t}`,fe=()=>globalThis.crypto?.randomUUID?.()??`${Date.now()}-${Math.random()}`;function pe(e){let t=e.replaceAll(`\r +`,` +`).split(` + +`),n=t.pop()??``,r=[];return t.forEach(e=>{e.split(` +`).forEach(e=>{if(e.startsWith(`data:`))try{let t=JSON.parse(e.slice(5).trim());r.push(t)}catch{}})}),{frames:r,rest:n}}function me(e,t){let n=String(e.type??``);if(n===`phase`)t.onPhase?.(String(e.label??``),String(e.role??`manager`),String(e.detail??``),e.heartbeat===!0);else if(n===`delta`)t.onDelta?.(String(e.text??``),String(e.fragment_mode??`auto`));else if(n===`done`){let n=e.result??{};return t.onDone?.(n),n}else if(n===`error`)throw Error(String(e.error??`Manager stream failed`));return null}var V={projects:e=>z(`/api/projects`,{signal:e}),snapshot:(e,t)=>z(B(e,`/snapshot?events_limit=40&compact=false`),{signal:t}),status:(e,t)=>z(B(e,`/status`),{signal:t}),events:(e,t=180,n)=>z(B(e,`/events?limit=${t}&view=ui`),{signal:n}).then(e=>e.events),transcript:(e,t=100,n)=>z(B(e,`/transcript?n=${t}`),{signal:n}).then(e=>e.turns),journal:(e,t=80,n)=>z(B(e,`/journal?n=${t}`),{signal:n}).then(e=>e.journal),artifacts:(e,t)=>z(B(e,`/artifacts`),{signal:t}).then(e=>e.artifacts),counterexamples:(e,t)=>z(B(e,`/counterexamples`),{signal:t}),artifact:(e,t,n)=>z(B(e,`/artifact?${new URLSearchParams({path:t})}`),{signal:n}),artifactBlob:async(e,t,n=!1,r)=>{await m();let i=new URLSearchParams({path:t});n&&i.set(`download`,`true`);let a=B(e,`/artifact/raw?${i}`);return g(a,{headers:R(),signal:r,cache:`no-store`},de,async e=>{if(!e.ok)throw Error(`Artifact unavailable (${e.status})`);return e.blob()})},gitDiff:(e,t)=>z(B(e,`/git-diff`),{signal:t}),rewritePrompt:(e,t,n)=>z(B(e,`/prompt/rewrite`),{method:`POST`,body:JSON.stringify({text:t}),signal:n}),note:(e,t)=>z(B(e,`/note`),{method:`POST`,body:JSON.stringify({text:t})}),uploadAttachments:async(e,t,n)=>{await m();let r=new FormData;t.forEach(e=>r.append(`files`,e,e.name));let i=await fetch(B(e,`/attachments`),{method:`POST`,headers:R(),body:r,signal:n});if(!i.ok)throw Error(await i.text()||`attachment upload failed (${i.status})`);return await i.json()},createDaemon:(e,t=``,n=``)=>z(`/api/daemons`,{method:`POST`,body:JSON.stringify({objective:e,name:t,workdir:n,command_id:fe()})}),createFinalReview:(e,t)=>z(B(e,`/reviews/final`),{method:`POST`,body:JSON.stringify(t)}),startDaemon:(e,t)=>z(B(e,`/daemon/start`),{method:`POST`,body:JSON.stringify({command_id:fe(),expected_revision:t})}),stopDaemon:(e,t,n)=>z(B(e,`/daemon/stop`),{method:`POST`,body:JSON.stringify({drain:t,command_id:fe(),expected_revision:n})}),async messageStream(e,t,n={},r,i=[]){await m();let a=B(e,`/message/stream`),o=await fetch(a,{method:`POST`,headers:R(!0),body:JSON.stringify(i.length?{text:t,attachments:i}:{text:t}),signal:r});if(!o.ok){let e=await o.text().catch(()=>``);throw Error(e||`Manager request failed (${o.status})`)}if(!o.body)throw Error(`Manager returned an empty stream`);let s=o.body.getReader(),c=new TextDecoder,l=``,u={};for(;;){let e=await s.read();if(e.done)break;l+=c.decode(e.value,{stream:!0});let t=pe(l);l=t.rest,t.frames.forEach(e=>{let t=me(e,n);t&&(u=t)})}return pe(`${l}\n\n`).frames.forEach(e=>{let t=me(e,n);t&&(u=t)}),u}};function he(e,t,n){let r=!1,i=null,a,o=800,s=()=>{if(r)return;let c=window.location.protocol===`https:`?`wss:`:`ws:`,l=new URLSearchParams({replay:`40`,view:`ui`}),u=d();u&&l.set(`token`,u),i=new WebSocket(`${c}//${window.location.host}${B(e,`/stream`)}?${l}`),i.onopen=()=>{o=800,n(!0)},i.onmessage=e=>{try{t(JSON.parse(String(e.data)))}catch{}},i.onerror=()=>i?.close(),i.onclose=e=>{n(!1),!(r||e.code===4401||e.code===4404)&&(a=window.setTimeout(s,o),o=Math.min(o*1.7,8e3))}};return s(),{close:()=>{r=!0,a&&window.clearTimeout(a),i?.close()}}}var ge={active:[`进行中`,`In progress`],claimed:[`进行中`,`In progress`],in_progress:[`进行中`,`In progress`],running:[`进行中`,`In progress`],working:[`进行中`,`In progress`],pending:[`等待中`,`Waiting`],queued:[`等待中`,`Waiting`],waiting:[`等待中`,`Waiting`],idle:[`等待中`,`Waiting`],accepted:[`已完成`,`Completed`],complete:[`已完成`,`Completed`],completed:[`已完成`,`Completed`],done:[`已完成`,`Completed`],success:[`已完成`,`Completed`],blocked:[`已阻塞`,`Blocked`],failed:[`失败`,`Failed`],error:[`失败`,`Failed`],rejected:[`需要修改`,`Needs changes`],continue:[`需要修改`,`Needs changes`],replan:[`需要重新规划`,`Needs replanning`],skipped:[`已跳过`,`Skipped`],paused:[`已暂停`,`Paused`],stopped:[`已暂停`,`Paused`],cancelled:[`已暂停`,`Paused`],aborted:[`已暂停`,`Paused`],not_started:[`等待中`,`Waiting`],healthy:[`状态正常`,`Healthy`],degraded:[`部分受限`,`Limited`]},_e={manager:[`Manager`,`Manager`],planner:[`Planner`,`Planner`],engineer:[`Engineer`,`Engineer`],reviewer:[`Reviewer`,`Reviewer`],system:[`Argus`,`Argus`],operator:[`你`,`You`],stopped:[`已暂停`,`Paused`],idle:[`等待中`,`Waiting`]},ve={scope:[`研究定义`,`Scope`],research:[`文献与假设`,`Literature and hypotheses`],implementation:[`方法实现`,`Implementation`],experiment:[`实验验证`,`Experiments`],analysis:[`结果分析`,`Analysis`],writing:[`论文写作`,`Writing`],review:[`最终审核`,`Final review`],delivery:[`成果交付`,`Delivery`]},ye={certified:[`阶段已通过`,`Stage approved`],not_certified:[`阶段未通过`,`Stage not approved`],revoked:[`阶段批准已撤回`,`Stage approval revoked`],intentionally_skipped:[`无需阶段审核`,`Stage review not needed`],deferred:[`阶段审核待定`,`Stage review pending`],not_assessed:[`尚未审核阶段`,`Stage not reviewed`]};function be(e,t,n,r){let i=t[String(e??``).toLowerCase()]??n;return r(i[0],i[1])}function H(e,t){return be(e,ge,[`状态已更新`,`Status updated`],t)}function U(e,t){return be(e,_e,[`Argus`,`Argus`],t)}function xe(e,t){return be(e,ve,[`未分阶段`,`Unstaged`],t)}function Se(e,t){return be(e,ye,[`阶段状态已更新`,`Stage status updated`],t)}function W(){let{locale:e}=O();return{locale:e,text:(0,L.useCallback)((t,n)=>e===`zh-CN`?t:n,[e])}}function G(...e){return e.filter(Boolean).join(` `)}function K(e){let t=Math.max(0,Math.floor(Number(e??0)));if(t<60)return`${t}s`;let n=Math.floor(t/86400),r=Math.floor(t%86400/3600),i=Math.floor(t%3600/60);return n?`${n}d ${r}h`:r?`${r}h ${i}m`:`${i}m`}function Ce(e,t){return e?new Date(e*1e3).toLocaleTimeString(t,{hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hour12:!1}):`—`}function we(e){let t=String(e??``).toLowerCase();return/failed|error|blocked|rejected|stalled|dead|abort/.test(t)?`danger`:/warn|waiting|paused|hold|queued|pending|continue/.test(t)?`warn`:/done|complete|completed|accepted|healthy|success|passed/.test(t)?`success`:/run|active|work|claimed|progress|live/.test(t)?`live`:/research|plan|info|ready/.test(t)?`info`:`neutral`}function Te(e){let t=String(e.agent_layer??e.actor??``).toLowerCase();if(t===`main`||t.startsWith(`engineer`))return`engineer`;if(t.startsWith(`review`))return`reviewer`;if(t.startsWith(`plan`))return`planner`;if(t.startsWith(`manager`))return`manager`;let n=String(e.type??``);return/review/.test(n)?`reviewer`:/planner/.test(n)?`planner`:/manager/.test(n)?`manager`:/engineer|round/.test(n)?`engineer`:`system`}function q(e){let t=String(e.action_summary??``).trim();if(t)return t;let n=String(e.title??``).trim();if(n)return n;let r=String(e.kind??``).trim();return r?r.replaceAll(`_`,` `):String(e.type??`event`).split(`.`).slice(-2).join(` · `).replaceAll(`_`,` `)}function Ee(e,t=400){let n=String(e.text??e.reason??e.summary??e.detail??``).trim();return n?n.length>t?`${n.slice(0,t)}…`:n:``}var J=n();function Y({children:e,tone:t=`neutral`,dot:n=!1,className:r}){return(0,J.jsxs)(`span`,{className:G(`badge`,`badge--${t}`,r),children:[n?(0,J.jsx)(`span`,{className:G(`badge__dot`,t===`live`&&`is-pulsing`)}):null,e]})}function De({title:e,eyebrow:t,action:n,children:r,className:i,bodyClassName:a}){return(0,J.jsxs)(`section`,{className:G(`panel`,i),children:[e||t||n?(0,J.jsxs)(`header`,{className:`panel__header`,children:[(0,J.jsxs)(`div`,{className:`panel__heading`,children:[t?(0,J.jsx)(`div`,{className:`eyebrow`,children:t}):null,e?(0,J.jsx)(`div`,{className:`panel__title`,children:e}):null]}),n?(0,J.jsx)(`div`,{className:`panel__action`,children:n}):null]}):null,(0,J.jsx)(`div`,{className:G(`panel__body`,a),children:r})]})}function X({icon:e=N,title:t,description:n,action:r}){return(0,J.jsxs)(`div`,{className:`empty-state`,children:[(0,J.jsx)(`span`,{className:`empty-state__icon`,children:(0,J.jsx)(e,{size:19})}),(0,J.jsx)(`div`,{className:`empty-state__title`,children:t}),n?(0,J.jsx)(`p`,{children:n}):null,r?(0,J.jsx)(`div`,{className:`empty-state__action`,children:r}):null]})}function Oe({label:e}){let{text:t}=W();return(0,J.jsxs)(`span`,{className:`spinner`,role:`status`,children:[(0,J.jsx)(D,{size:15,className:`spin`}),` `,e||t(`加载中`,`Loading`)]})}function ke({events:e,limit:t=24,empty:n,dense:r=!1}){let{locale:i,text:a}=W(),o=e.slice(-t).reverse();return o.length?(0,J.jsx)(`div`,{className:G(`event-list`,r&&`event-list--dense`),children:o.map((e,t)=>{let n=Te(e),o=q(e),s=Ee(e,r?180:480),c=we(String(e.status??e.kind??e.type??``));return(0,J.jsxs)(`article`,{className:`event-row`,children:[(0,J.jsx)(`div`,{className:G(`event-row__marker`,`event-row__marker--${c}`)}),(0,J.jsxs)(`div`,{className:`event-row__content`,children:[(0,J.jsxs)(`div`,{className:`event-row__meta`,children:[(0,J.jsx)(`span`,{className:G(`role-label`,`role-label--${n}`),children:U(n,a)}),(0,J.jsx)(`time`,{children:Ce(e.ts,i)})]}),(0,J.jsx)(`div`,{className:`event-row__title`,children:o}),s?(0,J.jsx)(`div`,{className:`event-row__detail`,children:s}):null]})]},`${e.type}-${e.ts}-${e.message_id??t}`)})}):(0,J.jsx)(X,{icon:ae,title:n||a(`还没有可展示的实时动态`,`No activity to show yet`)})}var Ae=new Set([`done`,`completed`,`accepted`,`success`]),je=new Set([`running`,`in_progress`,`claimed`,`active`,`working`]);function Me(e){if(!e.length)return null;let t=[...e].sort((e,t)=>e-t),n=Math.floor(t.length/2);return t.length%2?t[n]:(t[n-1]+t[n])/2}function Ne(e){return[...e].reverse().find(e=>{let t=String(e.kind??``),n=String(e.type??``);return t!==`reasoning`&&!n.startsWith(`provider.`)&&![`ui.operator`,`ui.argus`].includes(n)})??null}function Pe(e){return e.backlog.find(e=>je.has(e.status))??e.backlog.find(e=>e.status===`pending`)??e.backlog.at(-1)??null}function Fe(e,t,n=Date.now()/1e3,r=`zh-CN`){let i=(e,t)=>r===`zh-CN`?e:t,a=e.mission_view,o=a?.dag?.length?a.dag:e.backlog,s=o.length,c=o.filter(e=>Ae.has(e.status)).length,l=o.filter(e=>/pending|queued|waiting/.test(e.status)).length,u=Pe(e),d=a?.active_role||e.roles.find(e=>e.active)?.role||``,f=u?.started_ts||a?.mission.started_at||e.daemon.uptime_seconds&&n-e.daemon.uptime_seconds||n,p=t.filter(e=>Number(e.ts??0)>=Number(f||0)),m=Ne(p),h=String(a?.mission.status??``).toLowerCase(),g=[`complete`,`completed`,`done`].includes(h),_=[`incomplete`,`failed`,`blocked`,`aborted`,`stopped`,`cancelled`].includes(h),v=g||!_&&!!(s&&c===s),y=!e.daemon.alive,b=u?.finished_ts||a?.mission.completed_at||(y?Number(m?.ts??f):null),x=Math.max(0,Number(b??n)-Number(f||n)),S=!!(u&&je.has(u.status)&&e.daemon.alive),C=p.filter(e=>String(e.kind??``)===`command_execution`).length,w=p.filter(e=>/^(read|write|edit):/i.test(Ee(e,80))||String(e.kind??``)===`file_change`).length,T=!!a?.role_work?.some(e=>e.role===`engineer`&&/handoff|main completed/i.test(`${e.kind} ${e.title}`)&&e.ts>=Number(f||0)),E=p.some(e=>/review.*started/i.test(String(e.type??``))),D=p.some(e=>/review.*completed/i.test(String(e.type??``))),O=!!(u&&/failed|blocked|error/.test(u.status)),k=!!(a?.review?.status&&/replan|blocked|rejected|continue/.test(a.review.status)),A=0;u&&Ae.has(u.status)?A=1:u&&je.has(u.status)&&e.daemon.alive&&(A=.14,(C||w)&&(A=Math.min(.58,.27+Math.log2(1+C+w)*.055)),T&&(A=.7),(E||d===`reviewer`)&&(A=.8),D&&(A=.93));let j=v?1:_&&s&&c===s?.95:s?c/s:0,M=u&&o.some(e=>e.id===u.id)&&S&&!k,N=v?1:k?j:s?Math.min(1,(c+(M?A:0))/s):null,ee=s?Math.max(.05,Math.min(.18,.45/s)):0,te=v?[1,1]:k?[j,j]:N==null?null:[Math.max(j,N-ee*.45),Math.min(.99,Math.max(N,N+ee))],P=e.backlog.map(e=>e.started_ts&&e.finished_ts?e.finished_ts-e.started_ts:0).filter(e=>e>=5&&e<=604800),ne=Me(P),re=null,F=``;if(v)F=i(`项目已完成,无需预计完成时间`,`Project complete; no finish-time estimate is needed`);else if(y)F=i(`Argus 已停止,预计完成时间暂停更新`,`Argus stopped; the expected finish time is paused`);else if(!S)F=i(`当前没有执行中的任务,暂时无法预计完成时间`,`No active task; the expected finish time is unavailable`);else if(k)F=i(`Reviewer 正在改变任务范围,暂时无法预计完成时间`,`The Reviewer is changing scope, so the expected finish time is unavailable`);else if(!ne)F=i(`同类已完成任务不足,正在建立时间基线`,`Not enough completed tasks to establish a time baseline`);else if(!s||N==null)F=i(`任务路线尚未稳定,暂不预计完成时间`,`The task route is not stable enough to estimate a finish time`);else{let e=Math.max(0,s-c-(M?A:0))*ne;re={minSeconds:Math.max(60,e*.68),maxSeconds:Math.max(180,e*(P.length>=3?1.45:1.75)),basis:i(`${P.length} 个已完成任务的中位耗时`,`Median duration of ${P.length} completed tasks`)}}let ie=s>=4&&P.length>=3?`high`:s>=2&&P.length>=1?`medium`:`low`,ae=e.roles.find(e=>e.role===`planner`)?.status===`done`||!!u,I=[{id:`plan`,label:i(`规划任务`,`Plan task`),detail:ae?i(`Planner 已形成当前任务`,`Planner created the current task`):i(`等待 Planner`,`Waiting for Planner`),status:ae?`done`:d===`planner`?`active`:`pending`},{id:`start`,label:i(`启动执行`,`Start execution`),detail:u?.started_ts?i(`任务已领取并启动`,`Task claimed and started`):i(`等待执行`,`Waiting to execute`),status:u?.started_ts?`done`:u?.status===`pending`?`pending`:O?`blocked`:`active`},{id:`work`,label:i(`运行与产出`,`Execution and outputs`),detail:i(`${C} 条命令 · ${w} 次文件动作`,`${C} commands · ${w} file actions`),status:T?`done`:C||w?`active`:O?`blocked`:`pending`},{id:`handoff`,label:i(`提交 Reviewer`,`Ready for review`),detail:T?i(`已提交 Reviewer`,`Submitted to Reviewer`):i(`等待可审读的结果`,`Waiting for results the Reviewer can read`),status:T||d===`reviewer`?`done`:`pending`},{id:`review`,label:i(`Reviewer 认证`,`Reviewer certification`),detail:D?i(`本轮审查已完成`,`Round review complete`):E||d===`reviewer`?i(`Reviewer 正在检查`,`Reviewer is checking`):i(`等待审查`,`Waiting for review`),status:D?`done`:E||d===`reviewer`?`active`:O?`blocked`:`pending`}];return v?I=I.map(e=>({...e,status:`done`,detail:e.status===`done`?e.detail:i(`项目已完成`,`Project complete`)})):k?I=I.map(e=>e.status===`done`?e:{...e,status:`blocked`,detail:i(`等待 Reviewer 重新规划任务范围`,`Waiting for Reviewer to replan scope`)}):y&&(I=I.map(e=>e.status===`active`?{...e,status:`blocked`,detail:i(`Argus 已停止`,`Argus stopped`)}:e)),{confirmed:j,estimate:N,range:te,confidence:ie,basis:k?i(`Reviewer 正在重新规划,仅显示确定完成部分`,`Reviewer is replanning; only confirmed completion is shown`):s?i(`根据任务状态和事件里程碑估算`,`Estimated from task status and event milestones`):i(`任务路线尚未建立`,`Task route not established`),currentTask:u?.title||a?.mission.title||i(`等待新任务`,`Waiting for a new task`),currentRole:y?`stopped`:d||Te(m??{})||`idle`,currentStep:v?i(`项目已完成`,`Project complete`):k?i(`Reviewer 要求重新规划 · ${H(a?.review?.status||`replan`,i)}`,`Reviewer requested replanning · ${H(a?.review?.status||`replan`,i)}`):y?i(`已停止 · 最后执行到 ${m?q(m):H(u?.status,i)}`,`Stopped · last step: ${m?q(m):H(u?.status,i)}`):m?q(m):u?.status?H(u.status,i):i(`等待动态`,`Waiting for activity`),currentDetail:m?Ee(m,700):u?.objective||``,elapsedSeconds:x,eta:re,etaUnavailableReason:F,checkpoints:I,completedTasks:c,totalTasks:s,pendingTasks:l,currentFraction:k?0:A}}var Ie=new Set([`done`,`completed`,`accepted`,`success`]),Le=new Set([`running`,`in_progress`,`claimed`,`active`,`working`]),Re=[`manager`,`planner`,`engineer`,`reviewer`],ze=[`scope`,`research`,`implementation`,`experiment`,`analysis`,`writing`,`review`];function Be(e){let t=e.toLowerCase();return/review|delivery/.test(t)?6:/writ|draft|paper/.test(t)?5:/analy|select/.test(t)?4:/experiment|pilot|run|eval/.test(t)?3:/implement|build|engineer/.test(t)?2:+!!/research|literature|idea/.test(t)}function Ve(e){return e==null?`—`:`${Math.round(e*100)}%`}function He(e,t,n,r){let i=t=>new Date((e+t)*1e3).toLocaleTimeString(r,{hour:`2-digit`,minute:`2-digit`,hour12:!1});return`${i(t)}–${i(n)}`}function Ue(e){let{locale:t,text:n}=W(),[r,i]=(0,L.useState)(()=>Date.now()/1e3),[a,o]=(0,L.useState)(``);(0,L.useEffect)(()=>{if(!e.active||!e.snapshot.daemon.alive)return;i(Date.now()/1e3);let t=window.setInterval(()=>i(Date.now()/1e3),1e3);return()=>clearInterval(t)},[e.active,e.snapshot.daemon.alive]);let l=(0,L.useMemo)(()=>Fe(e.snapshot,e.events,r,t),[t,r,e.events,e.snapshot]),d=e.snapshot.mission_view,f=d?.dag?.length?d.dag:e.snapshot.backlog.map(e=>({id:e.id,title:e.title,objective:e.objective,status:e.status,deps:e.deps??[],branch_id:e.id,parent_branch_id:``})),m=f.find(e=>Le.has(e.status))??f.find(e=>/pending|queued/.test(e.status))??f.at(-1),h=f.find(e=>e.id===a)??m,g=Be(d?.stage.id||d?.stage.label||`scope`),_=Math.round(l.confirmed*100),b=Math.round((l.range?.[0]??l.confirmed)*100),S=Math.round((l.range?.[1]??l.confirmed)*100),w=Math.round((l.estimate??l.confirmed)*100),T=e.snapshot.daemon.health?.state||(e.snapshot.daemon.alive?`active`:`stopped`),D=d?.review?.status&&!Ie.has(d.review.status)?d.review:null,O=e.events.filter(e=>String(e.kind??``)!==`reasoning`&&!String(e.type??``).startsWith(`provider.`)),k=async t=>{let r=t?n(`确认完成当前步骤后停止 Argus?`,`Stop Argus after the current step finishes?`):n(`确认立即停止 Argus?当前步骤可能被中断。`,`Stop Argus now? The current step may be interrupted.`);confirm(r)&&await e.controls.stop(t)};return(0,J.jsxs)(`div`,{className:`ros-page experiment-v3`,children:[(0,J.jsxs)(`header`,{className:`ros-page-header`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`div`,{className:`eyebrow`,children:`EXPERIMENT PROGRESS`}),(0,J.jsx)(`h1`,{children:n(`实验进程`,`Experiment progress`)}),(0,J.jsx)(`p`,{children:n(`查看当前步骤、预计进度范围、预计完成时间,以及估算的可信程度。`,`See the current step, estimated progress range, expected finish time, and how confident Argus is in the estimate.`)})]}),(0,J.jsxs)(`div`,{className:`experiment-header-actions`,children:[(0,J.jsxs)(`button`,{className:`button button--secondary`,type:`button`,onClick:()=>void e.refresh(),children:[(0,J.jsx)(y,{size:14}),n(`刷新`,`Refresh`)]}),e.snapshot.daemon.control_available===!1?null:e.snapshot.daemon.alive?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`button`,{className:`button button--secondary`,type:`button`,disabled:e.controls.busy,onClick:()=>void k(!0),children:[(0,J.jsx)(v,{size:14}),n(`当前步后停止`,`Stop after step`)]}),(0,J.jsxs)(`button`,{className:`button button--danger`,type:`button`,disabled:e.controls.busy,onClick:()=>void k(!1),children:[(0,J.jsx)(C,{size:13}),n(`立即停止`,`Stop now`)]})]}):(0,J.jsxs)(`button`,{className:`button button--primary`,type:`button`,disabled:e.controls.busy,onClick:()=>void e.controls.start(),children:[(0,J.jsx)(c,{size:14}),n(`继续运行`,`Resume`)]})]})]}),(0,J.jsxs)(`section`,{className:`experiment-progress-hero`,children:[(0,J.jsxs)(`div`,{className:`progress-hero-main`,children:[(0,J.jsxs)(`div`,{className:`progress-live-line`,children:[(0,J.jsx)(Y,{tone:e.snapshot.daemon.alive?`live`:`neutral`,dot:!0,children:e.snapshot.daemon.alive?n(`ARGUS 运行中`,`ARGUS RUNNING`):n(`ARGUS 已停止`,`ARGUS STOPPED`)}),(0,J.jsx)(`span`,{children:d?.stage.label||xe(d?.stage.id,n)}),(0,J.jsx)(`span`,{children:U(l.currentRole,n)})]}),(0,J.jsx)(`h2`,{children:l.currentTask}),(0,J.jsxs)(`div`,{className:`current-step-callout`,children:[(0,J.jsx)(`span`,{children:(0,J.jsx)(u,{size:17})}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`small`,{children:e.snapshot.daemon.alive?n(`当前正在进行`,`In progress`):n(`最后执行位置`,`Last execution point`)}),(0,J.jsx)(`strong`,{children:l.currentStep}),l.currentDetail?(0,J.jsx)(`code`,{children:l.currentDetail}):null]})]})]}),(0,J.jsxs)(`div`,{className:`progress-number`,children:[(0,J.jsx)(`span`,{children:n(`预计进度`,`Estimated progress`)}),(0,J.jsx)(`strong`,{children:Ve(l.estimate)}),(0,J.jsxs)(`small`,{children:[n(`预计范围`,`Likely range`),` `,b,`–`,S,`%`]})]}),(0,J.jsxs)(`div`,{className:`truthful-progress`,"aria-label":n(`预计完成 ${w}%`,`Estimated completion ${w}%`),children:[(0,J.jsxs)(`div`,{className:`truthful-progress__track`,children:[(0,J.jsx)(`span`,{className:`confirmed`,style:{width:`${_}%`}}),(0,J.jsx)(`span`,{className:`estimated-range`,style:{left:`${b}%`,width:`${Math.max(1,S-b)}%`}}),(0,J.jsx)(`i`,{style:{left:`${w}%`}})]}),(0,J.jsxs)(`div`,{className:`truthful-progress__legend`,children:[(0,J.jsxs)(`span`,{children:[(0,J.jsx)(`b`,{className:`confirmed-dot`}),n(`确定完成`,`Confirmed`),` `,_,`%`]}),(0,J.jsxs)(`span`,{children:[(0,J.jsx)(`b`,{className:`range-dot`}),n(`估计范围`,`Estimated range`),` `,b,`–`,S,`%`]}),(0,J.jsx)(`span`,{children:l.basis})]})]}),(0,J.jsxs)(`div`,{className:`progress-metrics`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsxs)(`span`,{children:[(0,J.jsx)(E,{size:15}),n(`当前任务已运行`,`Current task elapsed`)]}),(0,J.jsx)(`strong`,{children:K(l.elapsedSeconds)}),(0,J.jsx)(`small`,{children:n(`从任务领取开始`,`Since task claim`)})]}),(0,J.jsxs)(`div`,{children:[(0,J.jsxs)(`span`,{children:[(0,J.jsx)(se,{size:15}),n(`预计完成时间`,`Expected finish time`)]}),(0,J.jsx)(`strong`,{children:l.eta?`${K(l.eta.minSeconds)}–${K(l.eta.maxSeconds)}`:n(`暂不可用`,`Unavailable`)}),(0,J.jsx)(`small`,{children:l.eta?He(r,l.eta.minSeconds,l.eta.maxSeconds,t):l.etaUnavailableReason})]}),(0,J.jsxs)(`div`,{children:[(0,J.jsxs)(`span`,{children:[(0,J.jsx)(re,{size:15}),n(`估算置信度`,`Estimate confidence`)]}),(0,J.jsx)(`strong`,{className:`confidence-${l.confidence}`,children:l.confidence===`high`?n(`高`,`High`):l.confidence===`medium`?n(`中`,`Medium`):n(`低`,`Low`)}),(0,J.jsx)(`small`,{children:l.eta?.basis||n(`需要更多历史任务`,`More task history is needed`)})]}),(0,J.jsxs)(`div`,{children:[(0,J.jsxs)(`span`,{children:[(0,J.jsx)(ue,{size:15}),n(`任务路线`,`Task route`)]}),(0,J.jsxs)(`strong`,{children:[l.completedTasks,` / `,l.totalTasks||`—`]}),(0,J.jsxs)(`small`,{children:[n(`${l.pendingTasks} 项等待中`,`${l.pendingTasks} waiting`),` · `,n(`当前步骤`,`current step`),` `,Math.round(l.currentFraction*100),`%`]})]})]})]}),(0,J.jsx)(`section`,{className:`research-stage-rail`,children:ze.map((e,t)=>(0,J.jsxs)(`div`,{className:t(0,J.jsxs)(`button`,{type:`button`,className:h?.id===e.id?`is-active`:``,onClick:()=>o(e.id),children:[(0,J.jsx)(`span`,{className:`task-state task-state--${we(e.status)}`,children:Ie.has(e.status)?(0,J.jsx)(p,{size:12}):Le.has(e.status)?(0,J.jsx)(u,{size:12}):(0,J.jsx)(A,{size:9})}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`strong`,{children:e.title||e.objective||n(`未命名任务`,`Untitled task`)}),(0,J.jsxs)(`small`,{children:[H(e.status,n),e.deps.length?n(` · 需等待前置任务 ${e.deps.length} 项`,` · Starts after ${e.deps.length} earlier tasks`):``]})]})]},e.id)):(0,J.jsx)(X,{icon:ue,title:n(`尚无任务路线`,`No task route yet`)})})]}),(0,J.jsxs)(`main`,{className:`experiment-v3-center`,children:[(0,J.jsxs)(`section`,{className:`ros-card checkpoint-card`,children:[(0,J.jsxs)(`header`,{children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`span`,{children:`CURRENT CHECKPOINTS`}),(0,J.jsx)(`h2`,{children:n(`当前任务走到哪一步`,`Current task checkpoints`)})]}),(0,J.jsxs)(Y,{tone:`info`,children:[Math.round(l.currentFraction*100),`%`]})]}),(0,J.jsx)(`div`,{className:`checkpoint-list`,children:l.checkpoints.map((e,t)=>(0,J.jsxs)(`div`,{className:`checkpoint checkpoint--${e.status}`,children:[(0,J.jsx)(`span`,{children:e.status===`done`?(0,J.jsx)(p,{size:13}):e.status===`active`?(0,J.jsx)(u,{size:13}):e.status===`blocked`?(0,J.jsx)(ce,{size:13}):t+1}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`strong`,{children:e.label}),(0,J.jsx)(`p`,{children:e.detail})]}),t{let r=e.snapshot.roles.find(e=>e.role===t);return(0,J.jsxs)(`article`,{className:r?.active?`is-active`:``,children:[(0,J.jsx)(`span`,{"data-role-dot":t,className:`role-dot role-dot--${t}`,"aria-hidden":`true`}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`strong`,{children:U(t,n)}),(0,J.jsx)(`p`,{children:r?.label||H(`waiting`,n)}),(0,J.jsx)(`small`,{children:H(r?.status||`idle`,n)})]}),r?.active?(0,J.jsx)(Y,{tone:`live`,dot:!0,children:H(`active`,n)}):(0,J.jsx)(Y,{tone:we(r?.status),children:H(r?.status||`idle`,n)})]},t)})})]}),(0,J.jsxs)(`section`,{className:`ros-card estimate-note`,children:[(0,J.jsx)(`header`,{children:(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`span`,{children:`ESTIMATE HEALTH`}),(0,J.jsx)(`h2`,{children:n(`估算与风险`,`Estimate and risk`)})]})}),(0,J.jsxs)(`div`,{children:[(0,J.jsxs)(`p`,{children:[(0,J.jsx)(`strong`,{children:n(`估算说明`,`Estimate note`)}),n(`当前百分比根据任务状态和事件里程碑估算,可能随新进展调整。`,`The percentage is estimated from task state and event milestones and may change as work progresses.`)]}),D?(0,J.jsxs)(`div`,{className:`estimate-risk`,children:[(0,J.jsx)(ce,{size:15}),(0,J.jsxs)(`span`,{children:[(0,J.jsxs)(`strong`,{children:[U(`reviewer`,n),` · `,H(D.status,n)]}),D.reason||n(`任务范围可能变化,预计完成时间已暂停更新。`,`Scope may change, so the expected finish time is paused.`)]})]}):(0,J.jsxs)(`div`,{className:`estimate-ok`,children:[(0,J.jsx)(x,{size:15}),(0,J.jsxs)(`span`,{children:[(0,J.jsx)(`strong`,{children:n(`当前估算可用`,`Estimate available`)}),H(T,n),` · `,n(`最近进度`,`last progress`),` `,K(e.snapshot.daemon.health?.seconds_since_progress)]})]}),e.controls.error?(0,J.jsx)(`div`,{className:`inline-error`,children:e.controls.error}):null]})]})]})]})]})}async function Z(e,t,n){let r=new URLSearchParams(t),i=await fetch(`${e}?${r}`,{headers:R(),signal:n,cache:`no-store`});if(!i.ok){let t=await i.json().catch(()=>({}));throw Error(t.detail||t.error||`${e} failed (${i.status})`)}return i.json()}var Q=(e,t)=>({sid:e,workspace_id:t}),$={profiles:(e,t)=>Z(`/api/v2/workspaces`,{sid:e},t),tree:(e,t,n)=>Z(`/api/v2/workspace/tree`,Q(e,t),n),file:(e,t,n,r)=>Z(`/api/v2/workspace/file`,{...Q(e,t),path:n},r),git:(e,t,n)=>Z(`/api/v2/workspace/git`,Q(e,t),n),literature:(e,t,n)=>Z(`/api/v2/workspace/literature`,Q(e,t),n),rawUrl:(e,t,n)=>`/api/v2/workspace/raw?${new URLSearchParams({...Q(e,t),path:n})}`,rawBlob:async(e,t,n,r)=>{let i=await fetch(`/api/v2/workspace/raw?${new URLSearchParams({...Q(e,t),path:n})}`,{headers:R(),signal:r,cache:`no-store`});if(!i.ok){let e=await i.json().catch(()=>({}));throw Error(e.detail||`raw preview failed (${i.status})`)}return i.blob()}};function We(e){let t=new Map;e.forEach(e=>t.set(e.path,{...e,children:[]}));let n=[];t.forEach(e=>{let r=e.path.lastIndexOf(`/`),i=r>=0?e.path.slice(0,r):``,a=i?t.get(i):null;a?a.children.push(e):n.push(e)});let r=e=>{e.sort((e,t)=>e.type===t.type?e.name.localeCompare(t.name):e.type===`directory`?-1:1),e.forEach(e=>r(e.children))};return r(n),n}function Ge(e,t,n){let[r,i]=(0,L.useState)(``),[a,o]=(0,L.useState)(``);return(0,L.useEffect)(()=>{if(i(``),o(``),!e||!t||!n)return;let r=new AbortController,a=``;return $.rawBlob(e,t,n,r.signal).then(e=>{a=URL.createObjectURL(e),i(a)},e=>{r.signal.aborted||o(e.message)}),()=>{r.abort(),a&&URL.revokeObjectURL(a)}},[n,e,t]),{url:r,error:a}}function Ke(e,t,n=!0){let r=i({queryKey:[`workspace-profiles`,e],queryFn:({signal:t})=>$.profiles(e,t),staleTime:1e4,enabled:!!e&&n}),a=`argus-v2-workspace-profile:${t}:${e}`,[o,s]=(0,L.useState)(()=>w(a)||``),c=(0,L.useMemo)(()=>{let e=r.data?.profiles??[];return e.find(e=>e.id===o)??e.find(e=>e.id===r.data?.default_id)??e.find(e=>e.canonical)??e[0]??null},[r.data,o]);return(0,L.useEffect)(()=>{c&&c.id!==o&&s(c.id)},[c,o]),{profiles:r,active:c,workspaceId:c?.id??``,setWorkspaceId:e=>{s(e),S(a,e)}}}function qe({node:e,depth:t,selected:n,expanded:r,onToggle:i,onSelect:a}){let o=e.type===`directory`,c=r.has(e.path);return(0,J.jsxs)(`div`,{className:`workspace-node`,children:[(0,J.jsxs)(`button`,{type:`button`,className:n===e.path?`is-selected`:``,style:{paddingLeft:7+t*13},onClick:()=>o?i(e.path):a(e.path),children:[o?c?(0,J.jsx)(T,{size:13}):(0,J.jsx)(s,{size:13}):(0,J.jsx)(`span`,{className:`node-spacer`}),o?(0,J.jsx)(ne,{size:14}):(0,J.jsx)(M,{size:14}),(0,J.jsx)(`span`,{children:e.name}),e.skipped?(0,J.jsx)(`small`,{children:`restricted`}):null]}),o&&c?e.children.map(e=>(0,J.jsx)(qe,{node:e,depth:t+1,selected:n,expanded:r,onToggle:i,onSelect:a},e.path)):null]})}function Je({sid:e,workspaceId:t,path:n,active:r}){let{text:a}=W(),o=n.toLowerCase().slice(n.lastIndexOf(`.`)),s=[`.pdf`,`.png`,`.jpg`,`.jpeg`,`.webp`,`.svg`].includes(o),c=i({queryKey:[`workspace-file`,e,t,n],queryFn:({signal:r})=>$.file(e,t,n,r),enabled:!!(r&&n&&t&&!s),refetchInterval:5e3}),l=Ge(s?e:``,s?t:``,s?n:``);if(!n)return(0,J.jsx)(X,{icon:N,title:a(`打开一个文件开始阅读`,`Open a file to start reading`),description:a(`左侧文件树直接映射已批准的服务器工作区。`,`The file tree maps the approved server workspace.`)});if(s)return l.error?(0,J.jsx)(X,{icon:ie,title:`Preview unavailable`,description:l.error}):l.url?o===`.pdf`?(0,J.jsx)(b,{src:l.url,name:n.split(`/`).at(-1)||n,className:`workspace-pdf`}):(0,J.jsx)(`img`,{className:`workspace-image`,src:l.url,alt:n}):(0,J.jsx)(`div`,{className:`editor-loading`,children:`Loading preview…`});if(c.isLoading)return(0,J.jsxs)(`div`,{className:`editor-loading`,children:[`Opening `,n,`…`]});if(c.isError)return(0,J.jsx)(X,{icon:ie,title:`Preview unavailable`,description:c.error.message});let u=(c.data?.content??``).split(` +`);return(0,J.jsxs)(`div`,{className:`vscode-code`,tabIndex:0,"aria-label":a(`文件内容`,`File contents`),children:[(0,J.jsx)(`div`,{className:`vscode-line-numbers`,children:u.map((e,t)=>(0,J.jsx)(`span`,{children:t+1},t))}),(0,J.jsx)(`pre`,{children:(0,J.jsx)(`code`,{children:c.data?.content})})]})}function Ye(e){let{locale:t,text:n}=W(),r=Ke(e.sid,`ide`,e.active),a=r.workspaceId,c=r.active?.path||``,[u,d]=(0,L.useState)(``),[f,m]=(0,L.useState)(new Set),h=(0,L.useRef)(``),g=(0,L.useRef)(null),v=e=>{d(e);let t=g.current,n=t?.closest(`.vscode-shell`),r=t?.closest(`.ros-content`);t&&n&&r&&getComputedStyle(n).display===`flex`&&r.scrollTo({top:r.scrollTop+t.getBoundingClientRect().top-r.getBoundingClientRect().top-12,behavior:window.matchMedia(`(prefers-reduced-motion: reduce)`).matches?`auto`:`smooth`})},[b,x]=(0,L.useState)(`files`),[S,C]=(0,L.useState)(`repository`),w=i({queryKey:[`workspace-tree`,e.sid,a],queryFn:({signal:t})=>$.tree(e.sid,a,t),enabled:!!(e.active&&a),refetchInterval:8e3}),E=i({queryKey:[`workspace-git`,e.sid,a],queryFn:({signal:t})=>$.git(e.sid,a,t),enabled:!!(e.active&&a),refetchInterval:8e3}),D=(0,L.useMemo)(()=>We(w.data?.entries??[]),[w.data?.entries]);(0,L.useEffect)(()=>{d(``),m(new Set),h.current=``},[a]),(0,L.useEffect)(()=>{!a||!D.length||h.current===a||(h.current=a,m(new Set(D.filter(e=>e.type===`directory`).slice(0,5).map(e=>e.path))))},[D,a]);let O=e.events.filter(e=>[`command_execution`,`tool_use`,`tool_result`,`file_change`].includes(String(e.kind??``))).slice(-100),k=(E.data?.status??``).split(` +`).filter(Boolean),A=(E.data?.log??``).split(` +`).filter(Boolean).map(e=>{let[t,n,r,...i]=e.split(` `);return{hash:t,date:n,author:r,subject:i.join(` `)}}),M=E.data;return(0,J.jsxs)(`div`,{className:`ros-page ide-v3`,children:[(0,J.jsxs)(`header`,{className:`ros-page-header`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`div`,{className:`eyebrow`,children:`AI IDE`}),(0,J.jsx)(`h1`,{children:n(`服务器代码工作区`,`Server code workspace`)}),(0,J.jsx)(`p`,{children:n(`接近 VS Code 的只读工作台:文件浏览、源码阅读、Git/GitHub 就绪状态和 Argus 终端轨迹。`,`A read-only VS Code-style workspace for files, source, Git/GitHub readiness, and Argus terminal activity.`)})]}),(0,J.jsxs)(Y,{tone:`info`,children:[(0,J.jsx)(ie,{size:12}),n(`只读安全模式`,`Read-only safe mode`)]})]}),(0,J.jsxs)(`div`,{className:`ide-context-strip`,children:[(0,J.jsx)(I,{size:15}),(0,J.jsx)(`select`,{"aria-label":n(`选择已批准工作区`,`Select approved workspace`),value:a,onChange:e=>r.setWorkspaceId(e.target.value),children:r.profiles.data?.profiles.map(e=>(0,J.jsx)(`option`,{value:e.id,children:e.label},e.id))}),(0,J.jsx)(`code`,{children:c}),w.isError?(0,J.jsx)(Y,{tone:`danger`,children:n(`连接失败`,`Connection failed`)}):w.isFetching?(0,J.jsx)(Y,{tone:`live`,dot:!0,children:n(`同步中`,`Syncing`)}):(0,J.jsxs)(Y,{tone:`success`,children:[(0,J.jsx)(l,{size:11}),`Synced`]}),(0,J.jsxs)(`small`,{children:[w.data?.entries.length??0,` entries`]}),(0,J.jsx)(`button`,{type:`button`,onClick:()=>{w.refetch(),E.refetch()},"aria-label":n(`刷新工作区`,`Refresh workspace`),children:(0,J.jsx)(y,{size:14})})]}),(0,J.jsxs)(`div`,{className:`vscode-shell`,children:[(0,J.jsxs)(`nav`,{className:`vscode-activitybar`,children:[(0,J.jsx)(`button`,{type:`button`,className:b===`files`?`is-active`:``,onClick:()=>x(`files`),title:`Explorer`,"aria-label":`Explorer`,children:(0,J.jsx)(ee,{size:21})}),(0,J.jsxs)(`button`,{type:`button`,className:b===`git`?`is-active`:``,onClick:()=>x(`git`),title:`Source Control`,"aria-label":`Source Control`,children:[(0,J.jsx)(o,{size:21}),k.length?(0,J.jsx)(`i`,{children:k.length}):null]})]}),(0,J.jsxs)(`aside`,{className:`vscode-sidebar`,children:[(0,J.jsxs)(`header`,{children:[(0,J.jsx)(`span`,{children:b===`git`?`SOURCE CONTROL`:`EXPLORER`}),(0,J.jsx)(`button`,{type:`button`,onClick:()=>void w.refetch(),"aria-label":n(`刷新文件树`,`Refresh file tree`),children:(0,J.jsx)(y,{size:14})})]}),b===`files`?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`vscode-root`,children:[(0,J.jsx)(T,{size:13}),(0,J.jsx)(`strong`,{children:c.split(`/`).at(-1)||c})]}),(0,J.jsx)(`div`,{className:`workspace-tree`,children:w.isError?(0,J.jsx)(X,{icon:I,title:n(`目录连接失败`,`Directory connection failed`),description:w.error.message}):D.map(e=>(0,J.jsx)(qe,{node:e,depth:0,selected:u,expanded:f,onToggle:e=>m(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),onSelect:v},e.path))})]}):(0,J.jsx)(`div`,{className:`vscode-changes`,children:k.length?k.map(e=>(0,J.jsxs)(`button`,{type:`button`,onClick:()=>{let t=e.slice(3).trim(),n=t.includes(` -> `)?t.split(` -> `).at(-1):t;n.endsWith(`/`)||v(n)},children:[(0,J.jsx)(`b`,{children:e.slice(0,2).trim()||`?`}),(0,J.jsx)(`span`,{children:e.slice(3)})]},e)):(0,J.jsx)(`p`,{children:`No changes`})})]}),(0,J.jsxs)(`main`,{className:`vscode-editor`,ref:g,children:[(0,J.jsx)(`div`,{className:`vscode-tabs`,children:(0,J.jsxs)(`button`,{type:`button`,className:`is-active`,children:[(0,J.jsx)(j,{size:13}),u||`Welcome`]})}),(0,J.jsx)(`div`,{className:`vscode-breadcrumbs`,children:u?u.split(`/`).map((e,t)=>(0,J.jsxs)(`span`,{children:[e,tC(`changes`),children:`Changes`}),(0,J.jsx)(`button`,{type:`button`,className:S===`timeline`?`is-active`:``,onClick:()=>C(`timeline`),children:`Timeline`}),(0,J.jsx)(`button`,{type:`button`,className:S===`repository`?`is-active`:``,onClick:()=>C(`repository`),children:`Repository`})]}),(0,J.jsx)(`div`,{className:`vscode-git-content`,children:M?.available?S===`changes`?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`pre`,{className:`vscode-status`,children:M.status||`Working tree clean`}),M.diff?(0,J.jsx)(`pre`,{className:`vscode-diff`,children:M.diff}):null]}):S===`timeline`?(0,J.jsx)(`div`,{className:`vscode-commits`,children:A.map(e=>(0,J.jsxs)(`article`,{children:[(0,J.jsx)(o,{size:13}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`strong`,{children:e.subject}),(0,J.jsxs)(`small`,{children:[e.author,` · `,e.date?.slice(0,10)]})]})]},e.hash))}):(0,J.jsxs)(`div`,{className:`repository-readiness`,children:[(0,J.jsx)(`h3`,{children:`Repository readiness`}),(0,J.jsxs)(`dl`,{children:[(0,J.jsxs)(`div`,{children:[(0,J.jsxs)(`dt`,{children:[(0,J.jsx)(o,{size:13}),`Remote`]}),(0,J.jsx)(`dd`,{children:M.remotes.length?M.remotes.map(e=>`${e.name}: ${e.fetch}`).join(` +`):`Not configured`}),(0,J.jsx)(`i`,{className:M.remotes.length?`ok`:`missing`,children:M.remotes.length?(0,J.jsx)(p,{size:12}):(0,J.jsx)(_,{size:12})})]}),(0,J.jsxs)(`div`,{children:[(0,J.jsxs)(`dt`,{children:[(0,J.jsx)(o,{size:13}),`Upstream`]}),(0,J.jsxs)(`dd`,{children:[M.upstream||`Not configured`,M.upstream?` · ahead ${M.ahead}, behind ${M.behind}`:``]}),(0,J.jsx)(`i`,{className:M.upstream?`ok`:`missing`,children:M.upstream?(0,J.jsx)(p,{size:12}):(0,J.jsx)(_,{size:12})})]}),(0,J.jsxs)(`div`,{children:[(0,J.jsxs)(`dt`,{children:[(0,J.jsx)(le,{size:13}),`Commit identity`]}),(0,J.jsx)(`dd`,{children:M.identity.name&&M.identity.email?`${M.identity.name} <${M.identity.email}>`:`Not configured`}),(0,J.jsx)(`i`,{className:M.identity.valid?`ok`:`missing`,children:M.identity.valid?(0,J.jsx)(p,{size:12}):(0,J.jsx)(_,{size:12})})]}),(0,J.jsxs)(`div`,{children:[(0,J.jsxs)(`dt`,{children:[(0,J.jsx)(F,{size:13}),`GitHub CLI`]}),(0,J.jsx)(`dd`,{children:M.github.authenticated?`${M.github.login} · ${M.github.protocol}`:`Not authenticated`}),(0,J.jsx)(`i`,{className:M.github.authenticated?`ok`:`missing`,children:M.github.authenticated?(0,J.jsx)(p,{size:12}):(0,J.jsx)(_,{size:12})})]})]}),(0,J.jsx)(`p`,{children:M.publish_ready?`Repository is ready for an explicitly approved push.`:`Configure the missing items before publishing. No credentials are shown in this UI.`})]}):(0,J.jsx)(X,{icon:o,title:`Not a Git repository`})})]}),(0,J.jsxs)(`section`,{className:`vscode-terminal`,children:[(0,J.jsxs)(`header`,{children:[(0,J.jsx)(`strong`,{children:`ARGUS ACTIVITY`}),(0,J.jsxs)(`span`,{children:[(0,J.jsx)(oe,{size:13}),`read-only`]})]}),(0,J.jsx)(`div`,{children:O.length?O.map((e,n)=>(0,J.jsxs)(`article`,{children:[(0,J.jsx)(`time`,{children:Ce(e.ts,t)}),(0,J.jsx)(`b`,{className:`terminal-role terminal-role--${Te(e)}`,children:Te(e)}),(0,J.jsx)(`span`,{children:`›`}),(0,J.jsx)(`code`,{children:Ee(e,800)||q(e)})]},`${e.ts}-${n}`)):(0,J.jsx)(`p`,{children:`$ waiting for Argus activity`})})]}),(0,J.jsxs)(`footer`,{className:`vscode-statusbar`,children:[(0,J.jsxs)(`span`,{children:[(0,J.jsx)(o,{size:12}),M?.branch||`no branch`]}),(0,J.jsx)(`span`,{children:w.isError?`Workspace error`:w.isFetching?`Workspace syncing`:w.data?.truncated?`Tree truncated`:`Workspace synced`}),(0,J.jsx)(`span`,{children:M?.github.authenticated?`GitHub: ${M.github.login}`:`GitHub: offline`}),(0,J.jsx)(`span`,{children:`UTF-8`}),(0,J.jsx)(`span`,{children:u.split(`.`).at(-1)?.toUpperCase()||`Plain Text`})]})]})]})}var Xe=[{id:`experiments`,zh:`运行进程`,en:`Execution`,zhDesc:`查看当前步骤、任务路线和角色交接。`,enDesc:`Follow the current step, task route, and role handoffs.`,icon:te,color:`blue`},{id:`ide`,zh:`AI IDE`,en:`AI IDE`,zhDesc:`阅读项目文件,查看 Git 状态与 Argus 活动。`,enDesc:`Read project files, Git state, and Argus activity.`,icon:j,color:`emerald`}],Ze=[{id:`overview`,zh:`项目概览`,en:`Project overview`,icon:P},...Xe];function Qe(e){let{text:t}=W(),n=e.snapshot.mission_view,r=n?.routing.vertical===`research`,i=n?.active_role||e.status?.active_role||`idle`,a=[H(n?.mission.status||`idle`,t),n?.outcome.stage_certification?Se(n.outcome.stage_certification,t):``].filter(Boolean).join(` · `);return(0,J.jsxs)(`div`,{className:`overview-page`,children:[(0,J.jsxs)(`section`,{className:`overview-hero`,children:[(0,J.jsxs)(`div`,{className:`overview-hero__copy`,children:[(0,J.jsxs)(`div`,{className:`overview-hero__badges`,children:[(0,J.jsx)(Y,{tone:e.snapshot.daemon.alive?`live`:`neutral`,dot:!0,children:e.snapshot.daemon.alive?t(`Argus 正在运行`,`Argus running`):t(`Argus 已停止`,`Argus stopped`)}),(0,J.jsx)(Y,{tone:we(n?.stage.id),children:n?.stage.label||xe(n?.stage.id,t)})]}),(0,J.jsx)(`h1`,{children:e.snapshot.session.display_name||e.project.label}),(0,J.jsx)(`p`,{children:n?.mission.objective||e.status?.continuous?.objective||e.project.objective||t(`尚未设置目标。`,`No objective has been set.`)})]}),(0,J.jsxs)(`div`,{className:`overview-hero__stats`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`span`,{children:t(`当前角色`,`Active role`)}),(0,J.jsx)(`strong`,{children:U(i,t)}),(0,J.jsx)(`small`,{children:e.snapshot.roles.find(e=>e.active)?.label||H(`waiting`,t)})]}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`span`,{children:r?t(`研究阶段`,`Research stage`):t(`工作流阶段`,`Workflow stage`)}),(0,J.jsx)(`strong`,{children:n?.stage.label||xe(n?.stage.id,t)}),(0,J.jsx)(`small`,{children:a})]}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`span`,{children:t(`累计运行`,`Elapsed`)}),(0,J.jsx)(`strong`,{children:K(n?.mission.campaign_elapsed_seconds||e.snapshot.daemon.uptime_seconds)}),(0,J.jsx)(`small`,{children:n?.round.current?t(`第 ${n.round.current}/${n.round.max||`—`} 轮`,`Round ${n.round.current}/${n.round.max||`—`}`):t(`暂无轮次`,`No round`)})]})]})]}),(0,J.jsx)(`div`,{className:`overview-section-heading`,children:(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`h2`,{children:t(`项目工作区`,`Project workspace`)}),(0,J.jsx)(`p`,{children:t(`所有模块共享同一个 Argus 项目、项目文件和实时动态。`,`All modules share the same Argus project, project files, and live activity.`)})]})}),(0,J.jsx)(`section`,{className:`module-grid`,children:Xe.map(n=>{let r=n.icon;return(0,J.jsxs)(`button`,{className:`module-card`,type:`button`,onClick:()=>e.navigate(n.id),children:[(0,J.jsx)(`span`,{className:`module-card__icon module-card__icon--${n.color}`,children:(0,J.jsx)(r,{size:20})}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`h3`,{children:t(n.zh,n.en)}),(0,J.jsx)(`p`,{children:t(n.zhDesc,n.enDesc)})]}),(0,J.jsx)(k,{size:16})]},n.id)})}),(0,J.jsxs)(`section`,{className:`overview-lower`,children:[(0,J.jsx)(De,{eyebrow:`CURRENT MISSION`,title:t(`当前任务`,`Current mission`),children:(0,J.jsxs)(`div`,{className:`overview-mission`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(se,{size:18}),(0,J.jsx)(`span`,{children:H(n?.mission.status||`idle`,t)})]}),(0,J.jsx)(`h3`,{children:n?.mission.title||e.project.current_task||t(`等待新任务`,`Waiting for a new task`)}),(0,J.jsx)(`p`,{children:n?.mission.summary||n?.frontier.summary||n?.review.reason||t(`Argus 的下一步和 Reviewer 边界会在这里同步。`,`Argus next steps and reviewer boundaries appear here.`)}),(0,J.jsxs)(`button`,{className:`button button--secondary`,type:`button`,onClick:()=>e.navigate(`experiments`),children:[t(`查看完整实验进程`,`View experiment progress`),` `,(0,J.jsx)(k,{size:14})]})]})}),(0,J.jsx)(De,{eyebrow:`RECENT ACTIVITY`,title:t(`最近活动`,`Recent activity`),bodyClassName:`panel__body--flush`,children:(0,J.jsx)(ke,{events:e.events,limit:7,dense:!0})})]})]})}function $e(e){let t=String(e.event_id??e.id??``);if(t)return t;let n=String(e.message_id??``);return n?`${e.type??``}:${n}:${e.kind??``}`:[e.type??``,e.ts??``,e.agent_layer??e.actor??``,e.kind??``,String(e.text??e.title??e.reason??``).slice(0,160)].join(`|`)}function et(e,t){let n=[...e],r=new Map(n.map((e,t)=>[$e(e),t]));return t.forEach(e=>{let t=$e(e),i=r.get(t);i==null?(r.set(t,n.length),n.push(e)):n[i]={...n[i],...e}}),n.sort((e,t)=>Number(e.ts??0)-Number(t.ts??0)).slice(-600)}function tt(e=!0){return i({queryKey:[`v2-projects`],queryFn:({signal:e})=>V.projects(e),enabled:e,refetchInterval:1e4})}function nt(e,t=!0){let n=r(),[o,s]=(0,L.useState)([]),[c,l]=(0,L.useState)(!1),u=(0,L.useRef)(null),d=!!e&&t,f=i({queryKey:[`v2-snapshot`,e],queryFn:({signal:t})=>V.snapshot(e,t),enabled:d,refetchInterval:5e3}),p=i({queryKey:[`v2-status`,e],queryFn:({signal:t})=>V.status(e,t),enabled:d,refetchInterval:6e3}),m=i({queryKey:[`v2-events`,e],queryFn:({signal:t})=>V.events(e,220,t),enabled:d,refetchInterval:15e3});(0,L.useEffect)(()=>{s([]),l(!1)},[e]),(0,L.useEffect)(()=>{!e||!m.data||s(e=>et(e,m.data))},[m.data,e]),(0,L.useEffect)(()=>{if(!e||!t){l(!1);return}let r=he(e,t=>{s(e=>et(e,[t])),u.current??=window.setTimeout(()=>{u.current=null,n.invalidateQueries({queryKey:[`v2-snapshot`,e]}),n.invalidateQueries({queryKey:[`v2-status`,e]})},900)},l);return()=>{r.close(),l(!1),u.current!=null&&(window.clearTimeout(u.current),u.current=null)}},[t,n,e]);let h=async()=>{e&&await Promise.all([n.invalidateQueries({queryKey:[`v2-snapshot`,e]}),n.invalidateQueries({queryKey:[`v2-status`,e]}),n.invalidateQueries({queryKey:[`v2-events`,e]})])},g=a({mutationFn:()=>V.startDaemon(e,f.data?.daemon_commands?.revision),onSuccess:h}),_=a({mutationFn:t=>V.stopDaemon(e,t,f.data?.daemon_commands?.revision),onSuccess:h}),v=(0,L.useMemo)(()=>{let e=[f,p,m].find(e=>e.error);return e?.error instanceof Error?e.error:null},[m,f,p]);return{snapshot:f,status:p,events:o,connected:c,refresh:h,controls:{start:g,stop:_},error:v}}function rt({sid:e,active:t}){let{locale:n}=O(),[r,i]=(0,L.useState)(()=>{let e=new URLSearchParams(window.location.search).get(`module`);return Ze.find(t=>t.id===e)?.id??`overview`}),[a,o]=(0,L.useState)(()=>new Set([r])),s=(0,L.useCallback)(e=>{i(e),o(t=>t.has(e)?t:new Set([...t,e]))},[]),c=tt(t),l=c.data?.projects??[],u=(0,L.useMemo)(()=>l.find(t=>t.id===e)??null,[l,e]),d=nt(e,t),f=r,p=d.controls.start.error||d.controls.stop.error,m=u&&d.snapshot.data?{sid:e,active:t,project:u,snapshot:d.snapshot.data,status:d.status.data,events:d.events,connected:d.connected,snapshotUpdatedAt:d.snapshot.dataUpdatedAt,refresh:d.refresh,controls:{start:async()=>{try{return await d.controls.start.mutateAsync()}catch{return null}},stop:async e=>{try{return await d.controls.stop.mutateAsync(e)}catch{return null}},busy:d.controls.start.isPending||d.controls.stop.isPending,error:p instanceof Error?p.message:``},navigate:s}:null;return(0,J.jsxs)(`section`,{className:`integrated-workbench flex min-h-0 flex-1 flex-col bg-transparent text-ink`,children:[(0,J.jsx)(`nav`,{className:`workbench-module-tabs shrink-0 border-b border-line/60 px-3 py-2`,"aria-label":n===`zh-CN`?`工作台模块`:`Workbench modules`,children:(0,J.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:Ze.map(({id:e,zh:t,en:r,icon:i})=>(0,J.jsxs)(`button`,{type:`button`,className:`workbench-module-tab`,"data-module":e,"data-selected":f===e,"aria-pressed":f===e,onClick:()=>s(e),children:[(0,J.jsx)(i,{size:14}),(0,J.jsx)(`span`,{children:n===`zh-CN`?t:r})]},e))})}),c.isError&&!u||d.snapshot.isError&&!d.snapshot.data?(0,J.jsx)(X,{title:n===`zh-CN`?`工作台读取失败`:`Workbench unavailable`,description:`Argus API did not return the selected project.`}):m?Ze.filter(({id:e})=>a.has(e)).map(({id:n})=>(0,J.jsx)(`div`,{className:`ros-content min-h-0 flex-1 overflow-x-hidden overflow-y-auto ${f===n?``:`hidden`}`,"aria-hidden":f!==n,children:n===`overview`?(0,J.jsx)(Qe,{...m,active:t&&f===n}):n===`experiments`?(0,J.jsx)(Ue,{...m,active:t&&f===n}):(0,J.jsx)(Ye,{...m,active:t&&f===n})},`${e}:${n}`)):(0,J.jsx)(`div`,{className:`boot-state`,children:(0,J.jsx)(Oe,{label:n===`zh-CN`?`正在载入工作台`:`Loading workbench`})})]})}export{rt as ResearchWorkbenchPanel}; \ No newline at end of file diff --git a/frontend/web/dist/assets/index-BZHe8e4S.js b/frontend/web/dist/assets/index-BZHe8e4S.js new file mode 100644 index 000000000..3eda8dacb --- /dev/null +++ b/frontend/web/dist/assets/index-BZHe8e4S.js @@ -0,0 +1,32 @@ +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/motion-sqs9Ax-g.js","assets/rolldown-runtime-hePW80VL.js","assets/ResearchWorkbenchPanel-BOxuXoMY.js","assets/icons-2gFhc0pq.js","assets/query-CGMsBv4s.js","assets/play-DQD97EkU.js","assets/ResearchWorkbenchPanel-BXRghxPt.css","assets/MapPanel-BZxjl6ME.js","assets/markdown-BtnlLdzu.js","assets/markdown-B3MBJsZb.css","assets/MapPanel-7aVAJo-I.css"])))=>i.map(i=>d[i]); +import{r as e,t}from"./rolldown-runtime-hePW80VL.js";import{A as n,C as r,D as i,E as a,O as o,S as s,T as c,_ as l,a as u,b as d,c as f,d as p,f as m,g as h,h as g,i as _,k as v,l as y,m as b,n as x,o as S,p as C,r as w,s as T,t as E,u as D,v as ee,w as O,x as te,y as ne}from"./icons-2gFhc0pq.js";import{_ as k,a as re,b as A,c as j,d as ie,f as ae,h as M,i as oe,l as se,m as N,n as ce,o as le,p as ue,r as de,s as fe,t as P,u as F,v as pe,y as me}from"./query-CGMsBv4s.js";import{i as he,n as ge,r as _e,t as ve}from"./markdown-BtnlLdzu.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var ye=t((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0>>1,a=e[r];if(0>>1;ri(c,n))li(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(li(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=typeof setTimeout==`function`?setTimeout:null,_=typeof clearTimeout==`function`?clearTimeout:null,v=typeof setImmediate<`u`?setImmediate:null;typeof navigator<`u`&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function y(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function b(e){if(h=!1,y(e),!m){if(n(c)!==null)m=!0,k(x);else{var t=n(l);t!==null&&re(b,t.startTime-e)}}}function x(t,i){m=!1,h&&(h=!1,_(w),w=-1),p=!0;var a=f;try{for(y(i),d=n(c);d!==null&&(!(d.expirationTime>i)||t&&!D());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=i);i=e.unstable_now(),typeof s==`function`?d.callback=s:d===n(c)&&r(c),y(i)}else r(c);d=n(c)}if(d!==null)var u=!0;else{var g=n(l);g!==null&&re(b,g.startTime-i),u=!1}return u}finally{d=null,f=a,p=!1}}var S=!1,C=null,w=-1,T=5,E=-1;function D(){return!(e.unstable_now()-Ee||125o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(_(w),w=-1):h=!0,re(b,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,k(x))),r},e.unstable_shouldYield=D,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),be=t(((e,t)=>{t.exports=ye()})),xe=t((e=>{var t=n(),r=be();function i(e){for(var t=`https://reactjs.org/docs/error-decoder.html?invariant=`+e,n=1;n`u`||window.document===void 0||window.document.createElement===void 0),u=Object.prototype.hasOwnProperty,d=/^[: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]*$/,f={},p={};function m(e){return u.call(p,e)?!0:u.call(f,e)?!1:d.test(e)?p[e]=!0:(f[e]=!0,!1)}function h(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?(e=e.toLowerCase().slice(0,5),e!==`data-`&&e!==`aria-`):!n.acceptsBooleans;default:return!1}}function g(e,t,n,r){if(t==null||h(e,t,n,r))return!0;if(r)return!1;if(n!==null)switch(n.type){case 3:return!t;case 4:return!1===t;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}function _(e,t,n,r,i,a,o){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=r,this.attributeNamespace=i,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=a,this.removeEmptyString=o}var v={};`children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style`.split(` `).forEach(function(e){v[e]=new _(e,0,!1,e,null,!1,!1)}),[[`acceptCharset`,`accept-charset`],[`className`,`class`],[`htmlFor`,`for`],[`httpEquiv`,`http-equiv`]].forEach(function(e){var t=e[0];v[t]=new _(t,1,!1,e[1],null,!1,!1)}),[`contentEditable`,`draggable`,`spellCheck`,`value`].forEach(function(e){v[e]=new _(e,2,!1,e.toLowerCase(),null,!1,!1)}),[`autoReverse`,`externalResourcesRequired`,`focusable`,`preserveAlpha`].forEach(function(e){v[e]=new _(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){v[e]=new _(e,3,!1,e.toLowerCase(),null,!1,!1)}),[`checked`,`multiple`,`muted`,`selected`].forEach(function(e){v[e]=new _(e,3,!0,e,null,!1,!1)}),[`capture`,`download`].forEach(function(e){v[e]=new _(e,4,!1,e,null,!1,!1)}),[`cols`,`rows`,`size`,`span`].forEach(function(e){v[e]=new _(e,6,!1,e,null,!1,!1)}),[`rowSpan`,`start`].forEach(function(e){v[e]=new _(e,5,!1,e.toLowerCase(),null,!1,!1)});var y=/[\-:]([a-z])/g;function b(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(y,b);v[t]=new _(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(y,b);v[t]=new _(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(y,b);v[t]=new _(t,1,!1,e,`http://www.w3.org/XML/1998/namespace`,!1,!1)}),[`tabIndex`,`crossOrigin`].forEach(function(e){v[e]=new _(e,1,!1,e.toLowerCase(),null,!1,!1)}),v.xlinkHref=new _(`xlinkHref`,1,!1,`xlink:href`,`http://www.w3.org/1999/xlink`,!0,!1),[`src`,`href`,`action`,`formAction`].forEach(function(e){v[e]=new _(e,1,!1,e.toLowerCase(),null,!0,!0)});function x(e,t,n,r){var i=v.hasOwnProperty(t)?v[t]:null;(i===null?r||!(2s||i[o]!==a[s]){var c=` +`+i[o].replace(` at new `,` at `);return e.displayName&&c.includes(``)&&(c=c.replace(``,e.displayName)),c}while(1<=o&&0<=s);break}}}finally{N=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:``)?se(e):``}function le(e){switch(e.tag){case 5:return se(e.type);case 16:return se(`Lazy`);case 13:return se(`Suspense`);case 19:return se(`SuspenseList`);case 0:case 2:case 15:return e=ce(e.type,!1),e;case 11:return e=ce(e.type.render,!1),e;case 1:return e=ce(e.type,!0),e;default:return``}}function ue(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 T:return`Fragment`;case w:return`Portal`;case D:return`Profiler`;case E:return`StrictMode`;case ne:return`Suspense`;case k:return`SuspenseList`}if(typeof e==`object`)switch(e.$$typeof){case O:return(e.displayName||`Context`)+`.Consumer`;case ee:return(e._context.displayName||`Context`)+`.Provider`;case te:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case re:return t=e.displayName||null,t===null?ue(e.type)||`Memo`:t;case A:t=e._payload,e=e._init;try{return ue(e(t))}catch{}}return null}function de(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`:`ForwardRef(`+e+`)`);case 7:return`Fragment`;case 5:return t;case 4:return`Portal`;case 3:return`Root`;case 6:return`Text`;case 16:return ue(t);case 8:return t===E?`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 fe(e){switch(typeof e){case`boolean`:case`number`:case`string`:case`undefined`:return e;case`object`:return e;default:return``}}function P(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()===`input`&&(t===`checkbox`||t===`radio`)}function F(e){var t=P(e)?`checked`:`value`,n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=``+e[t];if(!e.hasOwnProperty(t)&&n!==void 0&&typeof n.get==`function`&&typeof n.set==`function`){var i=n.get,a=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return i.call(this)},set:function(e){r=``+e,a.call(this,e)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(e){r=``+e},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function pe(e){e._valueTracker||=F(e)}function me(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r=``;return e&&(r=P(e)?e.checked?`true`:`false`:e.value),e=r,e!==n&&(t.setValue(e),!0)}function he(e){if(e||=typeof document<`u`?document:void 0,e===void 0)return null;try{return e.activeElement||e.body}catch{return e.body}}function ge(e,t){var n=t.checked;return M({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function _e(e,t){var n=t.defaultValue==null?``:t.defaultValue,r=t.checked==null?t.defaultChecked:t.checked;n=fe(t.value==null?n:t.value),e._wrapperState={initialChecked:r,initialValue:n,controlled:t.type===`checkbox`||t.type===`radio`?t.checked!=null:t.value!=null}}function ve(e,t){t=t.checked,t!=null&&x(e,`checked`,t,!1)}function ye(e,t){ve(e,t);var n=fe(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`)?Se(e,t.type,n):t.hasOwnProperty(`defaultValue`)&&Se(e,t.type,fe(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function xe(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 Se(e,t,n){(t!==`number`||he(e.ownerDocument)!==e)&&(n==null?e.defaultValue=``+e._wrapperState.initialValue:e.defaultValue!==``+n&&(e.defaultValue=``+n))}var Ce=Array.isArray;function we(e,t,n,r){if(e=e.options,t){t={};for(var i=0;i`+t.valueOf().toString()+``,t=Ae.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function Me(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var Ne={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},Pe=[`Webkit`,`ms`,`Moz`,`O`];Object.keys(Ne).forEach(function(e){Pe.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),Ne[t]=Ne[e]})});function Fe(e,t,n){return t==null||typeof t==`boolean`||t===``?``:n||typeof t!=`number`||t===0||Ne.hasOwnProperty(e)&&Ne[e]?(``+t).trim():t+`px`}function Ie(e,t){for(var n in e=e.style,t)if(t.hasOwnProperty(n)){var r=n.indexOf(`--`)===0,i=Fe(n,t[n],r);n===`float`&&(n=`cssFloat`),r?e.setProperty(n,i):e[n]=i}}var Le=M({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 Re(e,t){if(t){if(Le[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(i(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(i(60));if(typeof t.dangerouslySetInnerHTML!=`object`||!(`__html`in t.dangerouslySetInnerHTML))throw Error(i(61))}if(t.style!=null&&typeof t.style!=`object`)throw Error(i(62))}}function ze(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 Be=null;function Ve(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var He=null,Ue=null,We=null;function Ge(e){if(e=ji(e)){if(typeof He!=`function`)throw Error(i(280));var t=e.stateNode;t&&(t=Ni(t),He(e.stateNode,e.type,t))}}function Ke(e){Ue?We?We.push(e):We=[e]:Ue=e}function qe(){if(Ue){var e=Ue,t=We;if(We=Ue=null,Ge(e),t)for(e=0;e>>=0,e===0?32:31-(xt(e)/St|0)|0}var wt=64,Tt=4194304;function Et(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 Dt(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,i=e.suspendedLanes,a=e.pingedLanes,o=n&268435455;if(o!==0){var s=o&~i;s===0?(a&=o,a!==0&&(r=Et(a))):r=Et(s)}else o=n&~i,o===0?a!==0&&(r=Et(a)):r=Et(o);if(r===0)return 0;if(t!==0&&t!==r&&(t&i)===0&&(i=r&-r,a=t&-t,i>=a||i===16&&a&4194240))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 Nt(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-bt(t),e[t]=n}function Pt(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=Jn),Zn=` `,J=!1;function Qn(e,t){switch(e){case`keyup`:return Kn.indexOf(t.keyCode)!==-1;case`keydown`:return t.keyCode!==229;case`keypress`:case`mousedown`:case`focusout`:return!0;default:return!1}}function Y(e){return e=e.detail,typeof e==`object`&&`data`in e?e.data:null}var $n=!1;function er(e,t){switch(e){case`compositionend`:return Y(t);case`keypress`:return t.which===32?(J=!0,Zn):null;case`textInput`:return e=t.data,e===Zn&&J?null:e;default:return null}}function tr(e,t){if($n)return e===`compositionend`||!qn&&Qn(e,t)?(e=_n(),gn=hn=mn=null,$n=!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}a:{for(;n;){if(n.nextSibling){n=n.nextSibling;break a}n=n.parentNode}n=void 0}n=Cr(n)}}function Tr(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Tr(e,t.parentNode):`contains`in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Er(){for(var e=window,t=he();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href==`string`}catch{n=!1}if(n)e=t.contentWindow;else break;t=he(e.document)}return t}function Dr(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 Or(e){var t=Er(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&Tr(n.ownerDocument.documentElement,n)){if(r!==null&&Dr(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 i=n.textContent.length,a=Math.min(r.start,i);r=r.end===void 0?a:Math.min(r.end,i),!e.extend&&a>r&&(i=r,r=a,a=i),i=wr(n,a);var o=wr(n,r);i&&o&&(e.rangeCount!==1||e.anchorNode!==i.node||e.anchorOffset!==i.offset||e.focusNode!==o.node||e.focusOffset!==o.offset)&&(t=t.createRange(),t.setStart(i.node,i.offset),e.removeAllRanges(),a>r?(e.addRange(t),e.extend(o.node,o.offset)):(t.setEnd(o.node,o.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,Ar=null,jr=null,Mr=null,Nr=!1;function Pr(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Nr||Ar==null||Ar!==he(r)||(r=Ar,`selectionStart`in r&&Dr(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}),Mr&&Sr(Mr,r)||(Mr=r,r=ii(jr,`onSelect`),0Fi||(e.current=Pi[Fi],Pi[Fi]=null,Fi--)}function Ri(e,t){Fi++,Pi[Fi]=e.current,e.current=t}var zi={},Bi=Ii(zi),Vi=Ii(!1),Hi=zi;function Ui(e,t){var n=e.type.contextTypes;if(!n)return zi;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var i={},a;for(a in n)i[a]=t[a];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=i),i}function Wi(e){return e=e.childContextTypes,e!=null}function Gi(){Li(Vi),Li(Bi)}function Ki(e,t,n){if(Bi.current!==zi)throw Error(i(168));Ri(Bi,t),Ri(Vi,n)}function qi(e,t,n){var r=e.stateNode;if(t=t.childContextTypes,typeof r.getChildContext!=`function`)return n;for(var a in r=r.getChildContext(),r)if(!(a in t))throw Error(i(108,de(e)||`Unknown`,a));return M({},n,r)}function Ji(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||zi,Hi=Bi.current,Ri(Bi,e),Ri(Vi,Vi.current),!0}function Yi(e,t,n){var r=e.stateNode;if(!r)throw Error(i(169));n?(e=qi(e,t,Hi),r.__reactInternalMemoizedMergedChildContext=e,Li(Vi),Li(Bi),Ri(Bi,e)):Li(Vi),Ri(Vi,n)}var Xi=null,Zi=!1,Qi=!1;function $i(e){Xi===null?Xi=[e]:Xi.push(e)}function ea(e){Zi=!0,$i(e)}function ta(){if(!Qi&&Xi!==null){Qi=!0;var e=0,t=K;try{var n=Xi;for(K=1;e>=o,i-=o,la=1<<32-bt(t)+i|n<h?(g=d,d=null):g=d.sibling;var _=p(i,d,s[h],c);if(_===null){d===null&&(d=g);break}e&&d&&_.alternate===null&&t(i,d),a=o(_,a,h),u===null?l=_:u.sibling=_,u=_,d=g}if(h===s.length)return n(i,d),_a&&da(i,h),l;if(d===null){for(;hg?(_=h,h=null):_=h.sibling;var y=p(a,h,v.value,l);if(y===null){h===null&&(h=_);break}e&&h&&y.alternate===null&&t(a,h),s=o(y,s,g),d===null?u=y:d.sibling=y,d=y,h=_}if(v.done)return n(a,h),_a&&da(a,g),u;if(h===null){for(;!v.done;g++,v=c.next())v=f(a,v.value,l),v!==null&&(s=o(v,s,g),d===null?u=v:d.sibling=v,d=v);return _a&&da(a,g),u}for(h=r(a,h);!v.done;g++,v=c.next())v=m(h,a,g,v.value,l),v!==null&&(e&&v.alternate!==null&&h.delete(v.key===null?g:v.key),s=o(v,s,g),d===null?u=v:d.sibling=v,d=v);return e&&h.forEach(function(e){return t(a,e)}),_a&&da(a,g),u}function _(e,r,i,o){if(typeof i==`object`&&i&&i.type===T&&i.key===null&&(i=i.props.children),typeof i==`object`&&i){switch(i.$$typeof){case C:a:{for(var c=i.key,l=r;l!==null;){if(l.key===c){if(c=i.type,c===T){if(l.tag===7){n(e,l.sibling),r=a(l,i.props.children),r.return=e,e=r;break a}}else if(l.elementType===c||typeof c==`object`&&c&&c.$$typeof===A&&ja(c)===l.type){n(e,l.sibling),r=a(l,i.props),r.ref=ka(e,l,i),r.return=e,e=r;break a}n(e,l);break}t(e,l),l=l.sibling}i.type===T?(r=Zl(i.props.children,e.mode,o,i.key),r.return=e,e=r):(o=Xl(i.type,i.key,i.props,null,e.mode,o),o.ref=ka(e,r,i),o.return=e,e=o)}return s(e);case w:a:{for(l=i.key;r!==null;){if(r.key===l){if(r.tag===4&&r.stateNode.containerInfo===i.containerInfo&&r.stateNode.implementation===i.implementation){n(e,r.sibling),r=a(r,i.children||[]),r.return=e,e=r;break a}n(e,r);break}t(e,r),r=r.sibling}r=eu(i,e.mode,o),r.return=e,e=r}return s(e);case A:return l=i._init,_(e,r,l(i._payload),o)}if(Ce(i))return h(e,r,i,o);if(ae(i))return g(e,r,i,o);Aa(e,i)}return typeof i==`string`&&i!==``||typeof i==`number`?(i=``+i,r!==null&&r.tag===6?(n(e,r.sibling),r=a(r,i),r.return=e,e=r):(n(e,r),r=$l(i,e.mode,o),r.return=e,e=r),s(e)):n(e,r)}return _}var Na=Ma(!0),Pa=Ma(!1),Fa=Ii(null),Ia=null,La=null,Ra=null;function za(){Ra=La=Ia=null}function Ba(e){var t=Fa.current;Li(Fa),e._currentValue=t}function Va(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)===t?r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t):(e.childLanes|=t,r!==null&&(r.childLanes|=t)),e===n)break;e=e.return}}function Ha(e,t){Ia=e,Ra=La=null,e=e.dependencies,e!==null&&e.firstContext!==null&&((e.lanes&t)!==0&&(Ms=!0),e.firstContext=null)}function Ua(e){var t=e._currentValue;if(Ra!==e){if(e={context:e,memoizedValue:t,next:null},La===null){if(Ia===null)throw Error(i(308));La=e,Ia.dependencies={lanes:0,firstContext:e}}else La=La.next=e}return t}var Wa=null;function Ga(e){Wa===null?Wa=[e]:Wa.push(e)}function Ka(e,t,n,r){var i=t.interleaved;return i===null?(n.next=n,Ga(t)):(n.next=i.next,i.next=n),t.interleaved=n,qa(e,r)}function qa(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 Ja=!1;function Ya(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Xa(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 Za(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function Qa(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,$&2){var i=r.pending;return i===null?t.next=t:(t.next=i.next,i.next=t),r.pending=t,qa(e,n)}return i=r.interleaved,i===null?(t.next=t,Ga(r)):(t.next=i.next,i.next=t),r.interleaved=t,qa(e,n)}function $a(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,n&4194240)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Ft(e,n)}}function eo(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var i=null,a=null;if(n=n.firstBaseUpdate,n!==null){do{var o={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};a===null?i=a=o:a=a.next=o,n=n.next}while(n!==null);a===null?i=a=t:a=a.next=t}else i=a=t;n={baseState:r.baseState,firstBaseUpdate:i,lastBaseUpdate:a,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 to(e,t,n,r){var i=e.updateQueue;Ja=!1;var a=i.firstBaseUpdate,o=i.lastBaseUpdate,s=i.shared.pending;if(s!==null){i.shared.pending=null;var c=s,l=c.next;c.next=null,o===null?a=l:o.next=l,o=c;var u=e.alternate;u!==null&&(u=u.updateQueue,s=u.lastBaseUpdate,s!==o&&(s===null?u.firstBaseUpdate=l:s.next=l,u.lastBaseUpdate=c))}if(a!==null){var d=i.baseState;o=0,u=l=c=null,s=a;do{var f=s.lane,p=s.eventTime;if((r&f)===f){u!==null&&(u=u.next={eventTime:p,lane:0,tag:s.tag,payload:s.payload,callback:s.callback,next:null});a:{var m=e,h=s;switch(f=t,p=n,h.tag){case 1:if(m=h.payload,typeof m==`function`){d=m.call(p,d,f);break a}d=m;break a;case 3:m.flags=m.flags&-65537|128;case 0:if(m=h.payload,f=typeof m==`function`?m.call(p,d,f):m,f==null)break a;d=M({},d,f);break a;case 2:Ja=!0}}s.callback!==null&&s.lane!==0&&(e.flags|=64,f=i.effects,f===null?i.effects=[s]:f.push(s))}else p={eventTime:p,lane:f,tag:s.tag,payload:s.payload,callback:s.callback,next:null},u===null?(l=u=p,c=d):u=u.next=p,o|=f;if(s=s.next,s===null){if(s=i.shared.pending,s===null)break;f=s,s=f.next,f.next=null,i.lastBaseUpdate=f,i.shared.pending=null}}while(1);if(u===null&&(c=d),i.baseState=c,i.firstBaseUpdate=l,i.lastBaseUpdate=u,t=i.shared.interleaved,t!==null){i=t;do o|=i.lane,i=i.next;while(i!==t)}else a===null&&(i.shared.lanes=0);Jc|=o,e.lanes=o,e.memoizedState=d}}function no(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;tn?n:4,e(!0);var r=vo.transition;vo.transition={};try{e(!1),t()}finally{K=n,vo.transition=r}}function as(){return Mo().memoizedState}function os(e,t,n){var r=pl(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},cs(e))ls(t,n);else if(n=Ka(e,t,n,r),n!==null){var i=fl();ml(n,e,r,i),us(n,t,r)}}function ss(e,t,n){var r=pl(e),i={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(cs(e))ls(t,i);else{var a=e.alternate;if(e.lanes===0&&(a===null||a.lanes===0)&&(a=t.lastRenderedReducer,a!==null))try{var o=t.lastRenderedState,s=a(o,n);if(i.hasEagerState=!0,i.eagerState=s,xr(s,o)){var c=t.interleaved;c===null?(i.next=i,Ga(t)):(i.next=c.next,c.next=i),t.interleaved=i;return}}catch{}n=Ka(e,t,i,r),n!==null&&(i=fl(),ml(n,e,r,i),us(n,t,r))}}function cs(e){var t=e.alternate;return e===bo||t!==null&&t===bo}function ls(e,t){wo=Co=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function us(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Ft(e,n)}}var ds={readContext:Ua,useCallback:Do,useContext:Do,useEffect:Do,useImperativeHandle:Do,useInsertionEffect:Do,useLayoutEffect:Do,useMemo:Do,useReducer:Do,useRef:Do,useState:Do,useDebugValue:Do,useDeferredValue:Do,useTransition:Do,useMutableSource:Do,useSyncExternalStore:Do,useId:Do,unstable_isNewReconciler:!1},fs={readContext:Ua,useCallback:function(e,t){return jo().memoizedState=[e,t===void 0?null:t],e},useContext:Ua,useEffect:Jo,useImperativeHandle:function(e,t,n){return n=n==null?null:n.concat([e]),Ko(4194308,4,Qo.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Ko(4194308,4,e,t)},useInsertionEffect:function(e,t){return Ko(4,2,e,t)},useMemo:function(e,t){var n=jo();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=jo();return t=n===void 0?t:n(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=os.bind(null,bo,e),[r.memoizedState,e]},useRef:function(e){var t=jo();return e={current:e},t.memoizedState=e},useState:Uo,useDebugValue:es,useDeferredValue:function(e){return jo().memoizedState=e},useTransition:function(){var e=Uo(!1),t=e[0];return e=is.bind(null,e[1]),jo().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=bo,a=jo();if(_a){if(n===void 0)throw Error(i(407));n=n()}else{if(n=t(),Vc===null)throw Error(i(349));yo&30||Ro(r,t,n)}a.memoizedState=n;var o={value:n,getSnapshot:t};return a.queue=o,Jo(Bo.bind(null,r,o,e),[e]),r.flags|=2048,Wo(9,zo.bind(null,r,o,n,t),void 0,null),n},useId:function(){var e=jo(),t=Vc.identifierPrefix;if(_a){var n=ua,r=la;n=(r&~(1<<32-bt(r)-1)).toString(32)+n,t=`:`+t+`R`+n,n=To++,0<\/script>`,e=e.removeChild(e.firstChild)):typeof r.is==`string`?e=c.createElement(n,{is:r.is}):(e=c.createElement(n),n===`select`&&(c=e,r.multiple?c.multiple=!0:r.size&&(c.size=r.size))):e=c.createElementNS(e,n),e[wi]=t,e[Ti]=r,nc(e,t,!1,!1),t.stateNode=e;a:{switch(c=ze(n,r),n){case`dialog`:Zr(`cancel`,e),Zr(`close`,e),a=r;break;case`iframe`:case`object`:case`embed`:Zr(`load`,e),a=r;break;case`video`:case`audio`:for(a=0;ael&&(t.flags|=128,r=!0,ac(s,!1),t.lanes=4194304)}}else{if(!r){if(e=mo(c),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),ac(s,!0),s.tail===null&&s.tailMode===`hidden`&&!c.alternate&&!_a)return oc(t),null}else 2*W()-s.renderingStartTime>el&&n!==1073741824&&(t.flags|=128,r=!0,ac(s,!1),t.lanes=4194304)}s.isBackwards?(c.sibling=t.child,t.child=c):(n=s.last,n===null?t.child=c:n.sibling=c,s.last=c)}return s.tail===null?(oc(t),null):(t=s.tail,s.rendering=t,s.tail=t.sibling,s.renderingStartTime=W(),t.sibling=null,n=po.current,Ri(po,r?n&1|2:n&1),t);case 22:case 23:return wl(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?Wc&1073741824&&(oc(t),t.subtreeFlags&6&&(t.flags|=8192)):oc(t),null;case 24:return null;case 25:return null}throw Error(i(156,t.tag))}function cc(e,t){switch(ma(t),t.tag){case 1:return Wi(t.type)&&Gi(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return lo(),Li(Vi),Li(Bi),go(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return fo(t),null;case 13:if(Li(po),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(i(340));Ea()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return Li(po),null;case 4:return lo(),null;case 10:return Ba(t.type._context),null;case 22:case 23:return wl(),null;case 24:return null;default:return null}}var lc=!1,uc=!1,dc=typeof WeakSet==`function`?WeakSet:Set,Q=null;function fc(e,t){var n=e.ref;if(n!==null){if(typeof n==`function`)try{n(null)}catch(n){Rl(e,t,n)}else n.current=null}}function pc(e,t,n){try{n()}catch(n){Rl(e,t,n)}}var mc=!1;function hc(e,t){if(fi=q,e=Er(),Dr(e)){if(`selectionStart`in e)var n={start:e.selectionStart,end:e.selectionEnd};else a:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var a=r.anchorOffset,o=r.focusNode;r=r.focusOffset;try{n.nodeType,o.nodeType}catch{n=null;break a}var s=0,c=-1,l=-1,u=0,d=0,f=e,p=null;b:for(;;){for(var m;f!==n||a!==0&&f.nodeType!==3||(c=s+a),f!==o||r!==0&&f.nodeType!==3||(l=s+r),f.nodeType===3&&(s+=f.nodeValue.length),(m=f.firstChild)!==null;)p=f,f=m;for(;;){if(f===e)break b;if(p===n&&++u===a&&(c=s),p===o&&++d===r&&(l=s),(m=f.nextSibling)!==null)break;f=p,p=f.parentNode}f=m}n=c===-1||l===-1?null:{start:c,end:l}}else n=null}n||={start:0,end:0}}else n=null;for(pi={focusedElem:e,selectionRange:n},q=!1,Q=t;Q!==null;)if(t=Q,e=t.child,t.subtreeFlags&1028&&e!==null)e.return=t,Q=e;else for(;Q!==null;){t=Q;try{var h=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(h!==null){var g=h.memoizedProps,_=h.memoizedState,v=t.stateNode;v.__reactInternalSnapshotBeforeUpdate=v.getSnapshotBeforeUpdate(t.elementType===t.type?g:hs(t.type,g),_)}break;case 3:var y=t.stateNode.containerInfo;y.nodeType===1?y.textContent=``:y.nodeType===9&&y.documentElement&&y.removeChild(y.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(i(163))}}catch(e){Rl(t,t.return,e)}if(e=t.sibling,e!==null){e.return=t.return,Q=e;break}Q=t.return}return h=mc,mc=!1,h}function gc(e,t,n){var r=t.updateQueue;if(r=r===null?null:r.lastEffect,r!==null){var i=r=r.next;do{if((i.tag&e)===e){var a=i.destroy;i.destroy=void 0,a!==void 0&&pc(t,n,a)}i=i.next}while(i!==r)}}function _c(e,t){if(t=t.updateQueue,t=t===null?null:t.lastEffect,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 vc(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 yc(e){var t=e.alternate;t!==null&&(e.alternate=null,yc(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[wi],delete t[Ti],delete t[Di],delete t[Oi],delete t[ki])),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 bc(e){return e.tag===5||e.tag===3||e.tag===4}function xc(e){a:for(;;){for(;e.sibling===null;){if(e.return===null||bc(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 a;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function Sc(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=di));else if(r!==4&&(e=e.child,e!==null))for(Sc(e,t,n),e=e.sibling;e!==null;)Sc(e,t,n),e=e.sibling}function Cc(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(Cc(e,t,n),e=e.sibling;e!==null;)Cc(e,t,n),e=e.sibling}var wc=null,Tc=!1;function Ec(e,t,n){for(n=n.child;n!==null;)Dc(e,t,n),n=n.sibling}function Dc(e,t,n){if(vt&&typeof vt.onCommitFiberUnmount==`function`)try{vt.onCommitFiberUnmount(G,n)}catch{}switch(n.tag){case 5:uc||fc(n,t);case 6:var r=wc,i=Tc;wc=null,Ec(e,t,n),wc=r,Tc=i,wc!==null&&(Tc?(e=wc,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):wc.removeChild(n.stateNode));break;case 18:wc!==null&&(Tc?(e=wc,n=n.stateNode,e.nodeType===8?bi(e.parentNode,n):e.nodeType===1&&bi(e,n),on(e)):bi(wc,n.stateNode));break;case 4:r=wc,i=Tc,wc=n.stateNode.containerInfo,Tc=!0,Ec(e,t,n),wc=r,Tc=i;break;case 0:case 11:case 14:case 15:if(!uc&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){i=r=r.next;do{var a=i,o=a.destroy;a=a.tag,o!==void 0&&(a&2||a&4)&&pc(n,t,o),i=i.next}while(i!==r)}Ec(e,t,n);break;case 1:if(!uc&&(fc(n,t),r=n.stateNode,typeof r.componentWillUnmount==`function`))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(e){Rl(n,t,e)}Ec(e,t,n);break;case 21:Ec(e,t,n);break;case 22:n.mode&1?(uc=(r=uc)||n.memoizedState!==null,Ec(e,t,n),uc=r):Ec(e,t,n);break;default:Ec(e,t,n)}}function Oc(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new dc),t.forEach(function(t){var r=Hl.bind(null,e,t);n.has(t)||(n.add(t),t.then(r,r))})}}function kc(e,t){var n=t.deletions;if(n!==null)for(var r=0;ra&&(a=s),r&=~o}if(r=a,r=W()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*Lc(r/1960))-r,10e?16:e,ol===null)var r=!1;else{if(e=ol,ol=null,sl=0,$&6)throw Error(i(331));var a=$;for($|=4,Q=e.current;Q!==null;){var o=Q,s=o.child;if(Q.flags&16){var c=o.deletions;if(c!==null){for(var l=0;lW()-$c?Tl(e,0):Xc|=n),hl(e,t)}function Bl(e,t){t===0&&(e.mode&1?(t=Tt,Tt<<=1,!(Tt&130023424)&&(Tt=4194304)):t=1);var n=fl();e=qa(e,t),e!==null&&(Nt(e,t,n),hl(e,n))}function Vl(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),Bl(e,n)}function Hl(e,t){var n=0;switch(e.tag){case 13:var r=e.stateNode,a=e.memoizedState;a!==null&&(n=a.retryLane);break;case 19:r=e.stateNode;break;default:throw Error(i(314))}r!==null&&r.delete(t),Bl(e,n)}var Ul=function(e,t,n){if(e!==null){if(e.memoizedProps!==t.pendingProps||Vi.current)Ms=!0;else{if((e.lanes&n)===0&&!(t.flags&128))return Ms=!1,tc(e,t,n);Ms=!!(e.flags&131072)}}else Ms=!1,_a&&t.flags&1048576&&fa(t,aa,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;$s(e,t),e=t.pendingProps;var a=Ui(t,Bi.current);Ha(t,n),a=ko(null,t,r,e,a,n);var o=Ao();return t.flags|=1,typeof a==`object`&&a&&typeof a.render==`function`&&a.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,Wi(r)?(o=!0,Ji(t)):o=!1,t.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,Ya(t),a.updater=_s,t.stateNode=a,a._reactInternals=t,xs(t,r,e,n),t=Vs(null,t,r,!0,o,n)):(t.tag=0,_a&&o&&pa(t),Ns(null,t,a,n),t=t.child),t;case 16:r=t.elementType;a:{switch($s(e,t),e=t.pendingProps,a=r._init,r=a(r._payload),t.type=r,a=t.tag=Jl(r),e=hs(r,e),a){case 0:t=zs(null,t,r,e,n);break a;case 1:t=Bs(null,t,r,e,n);break a;case 11:t=Ps(null,t,r,e,n);break a;case 14:t=Fs(null,t,r,hs(r.type,e),n);break a}throw Error(i(306,r,``))}return t;case 0:return r=t.type,a=t.pendingProps,a=t.elementType===r?a:hs(r,a),zs(e,t,r,a,n);case 1:return r=t.type,a=t.pendingProps,a=t.elementType===r?a:hs(r,a),Bs(e,t,r,a,n);case 3:a:{if(Hs(t),e===null)throw Error(i(387));r=t.pendingProps,o=t.memoizedState,a=o.element,Xa(e,t),to(t,r,null,n);var s=t.memoizedState;if(r=s.element,o.isDehydrated){if(o={element:r,isDehydrated:!1,cache:s.cache,pendingSuspenseBoundaries:s.pendingSuspenseBoundaries,transitions:s.transitions},t.updateQueue.baseState=o,t.memoizedState=o,t.flags&256){a=Ss(Error(i(423)),t),t=Us(e,t,r,n,a);break a}if(r!==a){a=Ss(Error(i(424)),t),t=Us(e,t,r,n,a);break a}for(ga=xi(t.stateNode.containerInfo.firstChild),ha=t,_a=!0,va=null,n=Pa(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling}else{if(Ea(),r===a){t=ec(e,t,n);break a}Ns(e,t,r,n)}t=t.child}return t;case 5:return uo(t),e===null&&Sa(t),r=t.type,a=t.pendingProps,o=e===null?null:e.memoizedProps,s=a.children,mi(r,a)?s=null:o!==null&&mi(r,o)&&(t.flags|=32),Rs(e,t),Ns(e,t,s,n),t.child;case 6:return e===null&&Sa(t),null;case 13:return Ks(e,t,n);case 4:return co(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=Na(t,null,r,n):Ns(e,t,r,n),t.child;case 11:return r=t.type,a=t.pendingProps,a=t.elementType===r?a:hs(r,a),Ps(e,t,r,a,n);case 7:return Ns(e,t,t.pendingProps,n),t.child;case 8:return Ns(e,t,t.pendingProps.children,n),t.child;case 12:return Ns(e,t,t.pendingProps.children,n),t.child;case 10:a:{if(r=t.type._context,a=t.pendingProps,o=t.memoizedProps,s=a.value,Ri(Fa,r._currentValue),r._currentValue=s,o!==null){if(xr(o.value,s)){if(o.children===a.children&&!Vi.current){t=ec(e,t,n);break a}}else for(o=t.child,o!==null&&(o.return=t);o!==null;){var c=o.dependencies;if(c!==null){s=o.child;for(var l=c.firstContext;l!==null;){if(l.context===r){if(o.tag===1){l=Za(-1,n&-n),l.tag=2;var u=o.updateQueue;if(u!==null){u=u.shared;var d=u.pending;d===null?l.next=l:(l.next=d.next,d.next=l),u.pending=l}}o.lanes|=n,l=o.alternate,l!==null&&(l.lanes|=n),Va(o.return,n,t),c.lanes|=n;break}l=l.next}}else if(o.tag===10)s=o.type===t.type?null:o.child;else if(o.tag===18){if(s=o.return,s===null)throw Error(i(341));s.lanes|=n,c=s.alternate,c!==null&&(c.lanes|=n),Va(s,n,t),s=o.sibling}else s=o.child;if(s!==null)s.return=o;else for(s=o;s!==null;){if(s===t){s=null;break}if(o=s.sibling,o!==null){o.return=s.return,s=o;break}s=s.return}o=s}}Ns(e,t,a.children,n),t=t.child}return t;case 9:return a=t.type,r=t.pendingProps.children,Ha(t,n),a=Ua(a),r=r(a),t.flags|=1,Ns(e,t,r,n),t.child;case 14:return r=t.type,a=hs(r,t.pendingProps),a=hs(r.type,a),Fs(e,t,r,a,n);case 15:return Is(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,a=t.pendingProps,a=t.elementType===r?a:hs(r,a),$s(e,t),t.tag=1,Wi(r)?(e=!0,Ji(t)):e=!1,Ha(t,n),ys(t,r,a),xs(t,r,a,n),Vs(null,t,r,!0,e,n);case 19:return Qs(e,t,n);case 22:return Ls(e,t,n)}throw Error(i(156,t.tag))};function Wl(e,t){return lt(e,t)}function Gl(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 Kl(e,t,n,r){return new Gl(e,t,n,r)}function ql(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Jl(e){if(typeof e==`function`)return+!!ql(e);if(e!=null){if(e=e.$$typeof,e===te)return 11;if(e===re)return 14}return 2}function Yl(e,t){var n=e.alternate;return n===null?(n=Kl(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 Xl(e,t,n,r,a,o){var s=2;if(r=e,typeof e==`function`)ql(e)&&(s=1);else if(typeof e==`string`)s=5;else a:switch(e){case T:return Zl(n.children,a,o,t);case E:s=8,a|=8;break;case D:return e=Kl(12,n,t,a|2),e.elementType=D,e.lanes=o,e;case ne:return e=Kl(13,n,t,a),e.elementType=ne,e.lanes=o,e;case k:return e=Kl(19,n,t,a),e.elementType=k,e.lanes=o,e;case j:return Ql(n,a,o,t);default:if(typeof e==`object`&&e)switch(e.$$typeof){case ee:s=10;break a;case O:s=9;break a;case te:s=11;break a;case re:s=14;break a;case A:s=16,r=null;break a}throw Error(i(130,e==null?e:typeof e,``))}return t=Kl(s,n,t,a),t.elementType=e,t.type=r,t.lanes=o,t}function Zl(e,t,n,r){return e=Kl(7,e,r,t),e.lanes=n,e}function Ql(e,t,n,r){return e=Kl(22,e,r,t),e.elementType=j,e.lanes=n,e.stateNode={isHidden:!1},e}function $l(e,t,n){return e=Kl(6,e,null,t),e.lanes=n,e}function eu(e,t,n){return t=Kl(4,e.children===null?[]:e.children,e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function tu(e,t,n,r,i){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=Mt(0),this.expirationTimes=Mt(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Mt(0),this.identifierPrefix=r,this.onRecoverableError=i,this.mutableSourceEagerHydrationData=null}function nu(e,t,n,r,i,a,o,s,c){return e=new tu(e,t,n,s,c),t===1?(t=1,!0===a&&(t|=8)):t=0,a=Kl(3,null,null,t),e.current=a,a.stateNode=e,a.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},Ya(a),e}function ru(e,t,n){var r=3{function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=`function`))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=xe()})),Ce=t((e=>{var t=Se();e.createRoot=t.createRoot,e.hydrateRoot=t.hydrateRoot})),we=class extends A{constructor(e={}){super(),this.config=e,this.#e=new Set,this.#t=new Map,this.#n=0}#e;#t;#n;build(e,t,n){let r=new re({client:e,mutationCache:this,mutationId:++this.#n,options:e.defaultMutationOptions(t),state:n});return this.add(r),r}add(e){this.#e.add(e);let t=Te(e);if(typeof t==`string`){let n=this.#t.get(t);n?n.push(e):this.#t.set(t,[e])}this.notify({type:`added`,mutation:e})}remove(e){if(this.#e.delete(e)){let t=Te(e);if(typeof t==`string`){let n=this.#t.get(t);if(n){if(n.length>1){let t=n.indexOf(e);t!==-1&&n.splice(t,1)}else n[0]===e&&this.#t.delete(t)}}}this.notify({type:`removed`,mutation:e})}canRun(e){let t=Te(e);if(typeof t==`string`){let n=this.#t.get(t)?.find(e=>e.state.status===`pending`);return!n||n===e}return!0}runNext(e){let t=Te(e);return typeof t==`string`?(this.#t.get(t)?.find(t=>t!==e&&t.state.isPaused))?.continue()??Promise.resolve():Promise.resolve()}clear(){j.batch(()=>{this.#e.forEach(e=>{this.notify({type:`removed`,mutation:e})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(e){let t={exact:!0,...e};return this.getAll().find(e=>ae(t,e))}findAll(e={}){return this.getAll().filter(t=>ae(e,t))}notify(e){j.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){let e=this.getAll().filter(e=>e.state.isPaused);return j.batch(()=>Promise.all(e.map(e=>e.continue().catch(N))))}};function Te(e){return e.options.scope?.id}var Ee=class extends A{constructor(e={}){super(),this.config=e,this.#e=new Map}#e;build(e,t,n){let r=t.queryKey,i=t.queryHash??ie(r,t),a=this.get(i);return a||(a=new le({client:e,queryKey:r,queryHash:i,options:e.defaultQueryOptions(t),state:n,defaultOptions:e.getQueryDefaults(r)}),this.add(a)),a}add(e){this.#e.has(e.queryHash)||(this.#e.set(e.queryHash,e),this.notify({type:`added`,query:e}))}remove(e){let t=this.#e.get(e.queryHash);t&&(e.destroy(),t===e&&this.#e.delete(e.queryHash),this.notify({type:`removed`,query:e}))}clear(){j.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#e.get(e)}getAll(){return[...this.#e.values()]}find(e){let t={exact:!0,...e};return this.getAll().find(e=>ue(t,e))}findAll(e={}){let t=this.getAll();return Object.keys(e).length>0?t.filter(t=>ue(e,t)):t}notify(e){j.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){j.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){j.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},De=class{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e={}){this.#e=e.queryCache||new Ee,this.#t=e.mutationCache||new we,this.#n=e.defaultOptions||{},this.#r=new Map,this.#i=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#o=me.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#s=fe.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#a--,this.#a===0&&(this.#o?.(),this.#o=void 0,this.#s?.(),this.#s=void 0)}isFetching(e){return this.#e.findAll({...e,fetchStatus:`fetching`}).length}isMutating(e){return this.#t.findAll({...e,status:`pending`}).length}getQueryData(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state.data}ensureQueryData(e){let t=this.defaultQueryOptions(e),n=this.#e.build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(k(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return this.#e.findAll(e).map(({queryKey:e,state:t})=>[e,t.data])}setQueryData(e,t,n){let r=this.defaultQueryOptions({queryKey:e}),i=this.#e.get(r.queryHash)?.state.data,a=se(t,i);if(a!==void 0)return this.#e.build(this,r).setData(a,{...n,manual:!0})}setQueriesData(e,t,n){return j.batch(()=>this.#e.findAll(e).map(({queryKey:e})=>[e,this.setQueryData(e,t,n)]))}getQueryState(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state}removeQueries(e){let t=this.#e;j.batch(()=>{t.findAll(e).forEach(e=>{t.remove(e)})})}resetQueries(e,t){let n=this.#e;return j.batch(()=>(n.findAll(e).forEach(e=>{e.reset()}),this.refetchQueries({type:`active`,...e},t)))}cancelQueries(e,t={}){let n={revert:!0,...t},r=j.batch(()=>this.#e.findAll(e).map(e=>e.cancel(n)));return Promise.all(r).then(N).catch(N)}invalidateQueries(e,t={}){return j.batch(()=>(this.#e.findAll(e).forEach(e=>{e.invalidate()}),e?.refetchType===`none`?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??`active`},t)))}refetchQueries(e,t={}){let n={...t,cancelRefetch:t.cancelRefetch??!0},r=j.batch(()=>this.#e.findAll(e).filter(e=>!e.isDisabled()&&!e.isStatic()).map(e=>{let t=e.fetch(void 0,n);return n.throwOnError||(t=t.catch(N)),e.state.fetchStatus===`paused`?Promise.resolve():t}));return Promise.all(r).then(N)}fetchQuery(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let n=this.#e.build(this,t);return n.isStaleByTime(k(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(N).catch(N)}fetchInfiniteQuery(e){return e._type=`infinite`,this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(N).catch(N)}ensureInfiniteQueryData(e){return e._type=`infinite`,this.ensureQueryData(e)}resumePausedMutations(){return fe.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#n}setDefaultOptions(e){this.#n=e}setQueryDefaults(e,t){this.#r.set(F(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){let t=[...this.#r.values()],n={};return t.forEach(t=>{M(e,t.queryKey)&&Object.assign(n,t.defaultOptions)}),n}setMutationDefaults(e,t){this.#i.set(F(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){let t=[...this.#i.values()],n={};return t.forEach(t=>{M(e,t.mutationKey)&&Object.assign(n,t.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;let t={...this.#n.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||=ie(t.queryKey,t),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!==`always`),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode=`offlineFirst`),t.queryFn===pe&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#n.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}},I=e(n(),1),Oe=e(Ce(),1),ke=class extends Error{status;method;path;constructor(e,t,n,r){super(e),this.name=`ApiError`,this.status=t,this.method=n,this.path=r}};function Ae(e){let t=e.replace(/\s+/g,` `).trim();if(!t)return``;try{let t=JSON.parse(e);for(let e of[`detail`,`error`,`message`]){let n=t[e];if(typeof n==`string`&&n.trim())return n.trim();if(Array.isArray(n)){let e=n.map(e=>e&&typeof e==`object`?String(e.msg??``):``).filter(Boolean);if(e.length)return e.join(`; `)}}}catch{}return t.startsWith(`typeof e==`string`):[],o=Re(r?.major),s=Re(r?.minor);if(!n||!r||!i)return{compatible:!1,reason:`malformed /api/meta response`};if(typeof i.source_root!=`string`||Re(i.pid)===null||typeof i.package_version!=`string`||typeof i.release_id!=`string`)return{compatible:!1,reason:`malformed /api/meta runtime identity`};if(n.service!==`argus-skill-webapi`)return{compatible:!1,reason:`unexpected service ${String(n.service||`unknown`)}`};let c=e;if(r.name!==Pe.name||o!==Pe.major)return{compatible:!1,reason:`protocol ${String(r.name||`unknown`)}/${String(o)} is incompatible with client ${Pe.name}/${Pe.major}`,meta:c};if(s===null||s!a.includes(e));if(l.length>0)return{compatible:!1,reason:`missing capabilities: ${l.join(`, `)}`,meta:c};if(i.source_root_matches_config===!1)return{compatible:!1,reason:`backend is running from a different installation than configured`,meta:c};if(i.release_id!==t.releaseId)return{compatible:!1,reason:`backend and client installations are out of sync; restart or reinstall Argus`,meta:c};if(t.sourceDigest){if(typeof i.runtime_source_digest!=`string`||!i.runtime_source_digest)return{compatible:!1,reason:`backend cannot verify this local installation; restart it from the current checkout`,meta:c};if(i.runtime_source_digest!==t.sourceDigest)return{compatible:!1,reason:`backend is running code from a different local installation; restart it`,meta:c}}return{compatible:!0,reason:``,warning:i.release_matches_source===!1?Fe:void 0,meta:c}}function Be(e,t){let n=ze(e);if(!n.compatible||!n.meta)throw Error(`incompatible Argus API: ${n.reason}`);return n.warning&&t?.(n.warning),n.meta}function Ve(e){let t=Le(e),n=Le(t?.daemon);if(!t||t.schema_version!==7)throw Error(`incompatible snapshot schema: expected 7, got ${String(t?.schema_version??`missing`)}`);if(!n)throw Error(`invalid snapshot: daemon section is missing`);let r=[`global_daily_cap_usd`,`read_status`,`read_error`,`protocol_compatible`,`protocol_error`].filter(e=>!Object.hasOwn(n,e));if(r.length>0)throw Error(`invalid snapshot: daemon fields missing: ${r.join(`, `)}`);let i=[`spend_usd`,`spend_status`,`usage_summary`,`request_usage`,`cost_control`,`daemon_commands`,`observability`,`mission_view`,`partial`,`diagnostics`].filter(e=>!Object.hasOwn(t,e));if(i.length>0)throw Error(`invalid snapshot: fields missing: ${i.join(`, `)}`);if(!Array.isArray(t.diagnostics))throw Error(`invalid snapshot: diagnostics must be an array`);return e}var He=`argus_web_token`,Ue=null;function We(){let e;try{e=new URLSearchParams(window.location.search)}catch{return}let t=e.get(`token`);if(t){Ue=t;try{localStorage.setItem(He,t)}catch{}try{e.delete(`token`);let t=e.toString();window.history.replaceState(null,``,`${window.location.pathname}${t?`?${t}`:``}${window.location.hash}`)}catch{}}}var Ge=()=>{if(Ue)return Ue;try{return new URLSearchParams(window.location.search).get(`token`)||localStorage.getItem(He)}catch{return null}};function Ke(){let e=Ge();return e?{Authorization:`Bearer ${e}`}:{}}function qe(){return Ge()??``}var Je=8e3,Ye=12e3,Xe=class extends Error{constructor(){super(`This browser is not paired with Argus. Reopen it from Argus Desktop or use a fresh pairing link.`),this.name=`PairingRequiredError`}},Ze=class extends Error{method;path;constructor(e,t,n=`could not reach the local Argus service`){super(`${e.toUpperCase()} ${t} ${n}. Make sure Argus Desktop is running, then retry.`),this.name=`LocalArgusUnavailableError`,this.method=e.toUpperCase(),this.path=t}};function L(e){return e instanceof Xe||!!(e&&typeof e==`object`&&Number(e.status)===401)}function Qe(e){return L(e)||e instanceof Ze}async function $e(e,t){try{return await fetch(e,t)}catch(n){throw t.signal?.aborted?n:new Ze(String(t.method??`GET`),e)}}async function et(e,t,n,r){let i=new AbortController,a=t.signal??void 0,o=!1,s=()=>{};if(a){let e=()=>i.abort(a.reason);a.aborted?e():(a.addEventListener(`abort`,e,{once:!0}),s=()=>a.removeEventListener(`abort`,e))}let c,l=(async()=>await r(await $e(e,{...t,signal:i.signal})))(),u=new Promise((e,t)=>{c=setTimeout(()=>{o=!0;let e=Error(`request timed out after ${n}ms`);i.abort(e),t(e)},n)});try{return await Promise.race([l,u])}catch(r){if(o){let r=Math.round(n/1e3);throw new Ze(String(t.method??`GET`),e,`timed out after ${r}s because the local Argus service did not respond`)}throw r}finally{c&&clearTimeout(c),s()}}async function R(e,t,n){return et(e,{headers:Ke(),signal:t},n??Ye,async t=>(await Me(t,`GET`,e),await t.json()))}async function z(e,t,n){let r=await fetch(e,{method:`POST`,headers:{"Content-Type":`application/json`,...Ke()},body:t===void 0?void 0:JSON.stringify(t),signal:n});return await Me(r,`POST`,e),await r.json()}async function tt(e,t,n){let r=await fetch(e,{method:`POST`,headers:Ke(),body:t,signal:n});return await Me(r,`POST`,e),await r.json()}function nt(e){let t=e&&typeof e==`object`?e:{},n=String(t.command_status??``);if(Number(t.rc??0)!==0||n===`failed`||n===`rejected`)throw Error(String(t.error||`daemon command ${n||`failed`}`));return e}async function rt(e,t,n){let r=await fetch(t,{method:e,headers:{"Content-Type":`application/json`,...Ke()},body:n===void 0?void 0:JSON.stringify(n)});return await Me(r,e,t),await r.json()}async function it(e,t){let n=await fetch(e,{headers:Ke(),signal:t});return await Me(n,`GET`,e),n.blob()}var B=(e,t=``)=>`/api/projects/${encodeURIComponent(e)}${t}`,at=()=>globalThis.crypto?.randomUUID?.()??`${Date.now()}-${Math.random()}`,ot;function st(e){return!!(e&&typeof e==`object`&&`aborted`in e&&typeof e.aborted==`boolean`)}function V(e,t,n){let r={text:e};return t?.length&&(r.attachments=t),n&&n!==`auto`&&(r.route_override=n),r}function H(){if(!ot){let e=(async()=>{let e=`/api/meta`,t=await et(e,{headers:Ke()},Je,async t=>{if(t.status===404)throw Error(`incompatible Argus API: service does not expose /api/meta`);return await Me(t,`GET`,e),Be(await t.json(),e=>console.warn(`Argus API compatibility warning: ${e}`))});if(t.authentication?.required&&!t.authentication.authenticated)throw new Xe;return t})();ot=e,e.catch(t=>{ot===e&&!(t instanceof Xe)&&(ot=void 0)})}return ot}function ct(e){let t=[],n;for(;(n=e.indexOf(` + +`))>=0;){let r=e.slice(0,n);e=e.slice(n+2);for(let e of r.split(` +`)){let n=e.trim();if(n.startsWith(`data:`))try{t.push(JSON.parse(n.slice(5).trim()))}catch{}}}return{frames:t,rest:e}}var lt=null,U={liveMap:(e,t,n,r)=>{let i=new URLSearchParams;return n&&i.set(`after`,n),r?.mode===`current`&&(i.set(`since`,String(r.since)),i.set(`event_since`,String(r.eventSince)),r.taskId&&i.set(`start_task`,r.taskId)),R(B(e,`/map`)+(i.size?`?${i}`:``),t)},mapInfo:(e,t)=>R(B(e,`/map-info`),t),mapHistory:(e,t,n,r)=>{let i=new URLSearchParams;return n&&i.set(`after`,n),r&&i.set(`task_after`,r),R(B(e,`/map-history`)+(i.size?`?${i}`:``),t)},mapCopy:(e,t,n,r,i)=>R(`/api/map-copy/${e}/${encodeURIComponent(t)}?locale=${n}${i?`&session_id=${encodeURIComponent(i)}`:``}`,r),generateMapCopy:(e,t,n,r,i)=>z(`/api/map-copy/${e}/${encodeURIComponent(t)}${i?`?session_id=${encodeURIComponent(i)}`:``}`,n,r),mapDatasets:e=>R(`/api/map-datasets`,e),mapDataset:(e,t)=>R(`/api/map-datasets/${encodeURIComponent(e)}`,t),meta:H,projectIndex:async()=>(await H(),R(`/api/projects`,void 0,Ye)),listProjects:async()=>(await H(),R(`/api/projects`,void 0,Ye).then(e=>e.projects)),projectCosts:async e=>(await H(),R(`/api/projects/costs`,e)),createDaemon:async(e,t=``,n=``,r)=>{let i=`/api/daemons`,a={objective:e,name:t,workdir:n,command_id:at(),expected_revision:r},o=()=>fetch(i,{method:`POST`,headers:{"Content-Type":`application/json`,...Ke()},body:JSON.stringify(a),cache:`no-store`}),s=await o();return s.status===400&&/Invalid HTTP request received/i.test(await s.clone().text())&&(s=await o()),await Me(s,`POST`,i),nt(await s.json())},updateProject:(e,t)=>rt(`PATCH`,B(e),{name:t}),deleteProject:e=>rt(`DELETE`,B(e)),snapshot:async(e,t,n=!1)=>(await H(),Ve(await R(B(e,`/snapshot?compact=true&events_limit=1${n?`&prewarm=true`:``}`),t,Ye))),activeSnapshot:async(e,t)=>{let n=lt!==e;n&&(lt=e);try{return await U.snapshot(e,t,n)}catch(t){throw n&<===e&&(lt=null),t}},prefetchSnapshot:(e,t)=>U.snapshot(e,t,!1),status:(e,t)=>R(B(e,`/status`),t),journal:(e,t=20,n)=>R(B(e,`/journal?n=${t}`),n).then(e=>e.journal),doctor:(e,t)=>R(B(e,`/doctor`),t),config:(e,t)=>R(B(e,`/config`),t),identity:(e,t)=>R(B(e,`/identity`),t).then(e=>e.identity),transcript:(e,t=30,n)=>R(B(e,`/transcript?n=${t}`),n).then(e=>e.turns),events:(e,t=80,n)=>R(B(e,`/events?limit=${t}&view=ui`),n).then(e=>e.events),backlogItem:(e,t,n)=>R(B(e,`/backlog/${encodeURIComponent(t)}`),n).then(e=>e.item),artifacts:(e,t)=>R(B(e,`/artifacts`),t).then(e=>e.artifacts),artifact:(e,t,n)=>R(B(e,`/artifact?${new URLSearchParams({path:t})}`),n),artifactPreview:(e,t,n)=>R(B(e,`/artifact/preview?${new URLSearchParams({path:t})}`),n),artifactBundle:(e,t,n)=>it(B(e,`/artifact/bundle?${new URLSearchParams({path:t})}`),n),artifactBlob:(e,t,n=!1,r)=>{let i=new URLSearchParams({path:t});return n&&i.set(`download`,`true`),it(B(e,`/artifact/raw?${i}`),r)},gitDiff:(e,t)=>R(B(e,`/git-diff`),t),metrics:e=>R(`/api/metrics`,e),sourceUpdateStatus:e=>R(`/api/runtime/source-update`,e),checkSourceUpdate:()=>z(`/api/runtime/source-update/check`),applySourceUpdate:()=>z(`/api/runtime/source-update/apply`),resources:e=>R(`/api/system/resources`,e),trash:(e=``,t=100,n=0,r)=>R(`/api/trash?${new URLSearchParams({query:e,limit:String(t),offset:String(n)})}`,r),restoreTrash:e=>z(`/api/trash/${encodeURIComponent(e)}/restore`),addTask:(e,t)=>z(B(e,`/tasks`),{text:t}).then(e=>e.item),abortMission:(e,t)=>z(B(e,`/mission/abort`),{reason:t}),mapNotes:(e,t)=>R(B(e,`/map-notes`),t),addMapNote:(e,t)=>z(B(e,`/map-notes`),t),answerPending:(e,t,n)=>z(B(e,`/backlog/${encodeURIComponent(t)}/answer`),{text:n}),resolveDecision:(e,t,n,r)=>z(B(e,`/decisions/${encodeURIComponent(t)}/resolve`),{option_id:n,note:r}),uploadAttachments:async(e,t,n)=>{await H();let r=new FormData;return t.forEach(e=>r.append(`files`,e,e.name)),tt(B(e,`/attachments`),r,n)},message:(e,t,n)=>{let r=st(n)?n:n?.signal,i=st(n)?void 0:n?.attachments,a=st(n)?void 0:n?.routeOverride;return z(B(e,`/message`),V(t,i,a),r)},messageStream:async(e,t,n,r)=>{let i=st(r)?r:r?.signal,a=st(r)?void 0:r?.attachments,o=st(r)?void 0:r?.routeOverride,s=await fetch(B(e,`/message/stream`),{method:`POST`,headers:{"Content-Type":`application/json`,...Ke()},body:JSON.stringify(V(t,a,o)),signal:i});if(await Me(s,`POST`,B(e,`/message/stream`)),!s.body)throw Error(`Manager stream returned no response body`);let c=!1,l=e=>{if(!i?.aborted){if(e.type===`phase`){let t=Number(e.quiet_s??0);n.onPhase?.(String(e.label??``),String(e.role??`manager`),{heartbeat:e.heartbeat===!0,quietS:Number.isFinite(t)?t:0,kind:String(e.kind??``),detail:String(e.detail??``)})}else e.type===`delta`?n.onDelta?.(String(e.text??``),String(e.message_id??``),String(e.fragment_mode??`auto`)):e.type===`done`?(c=!0,n.onDone?.(e.result??{})):e.type===`error`&&(c=!0,n.onError?.(Error(String(e.error??`stream error`))))}},u=s.body.getReader(),d=new TextDecoder,f=``;for(;;){let{done:e,value:t}=await u.read();if(e)break;f+=d.decode(t,{stream:!0});let n=ct(f);f=n.rest,n.frames.forEach(l)}if(!i?.aborted&&(ct(f+` + +`).frames.forEach(l),!c))throw Error(`Manager stream ended before a terminal event`)},nudge:(e,t)=>z(B(e,`/nudge`),{text:t}),note:(e,t)=>z(B(e,`/note`),{text:t}),previewPlan:(e,t)=>z(B(e,`/plan`),{text:t}),rewritePrompt:(e,t)=>z(B(e,`/prompt/rewrite`),{text:t}),setConfig:(e,t,n)=>z(B(e,`/config/set`),{name:t,value:n}),setBudgets:(e,t)=>z(B(e,`/config/budget`),{values:t}),setIdentity:(e,t)=>z(B(e,`/identity`),{text:t}),resetManager:e=>z(B(e,`/reset`)),skills:(e,t=`ls`)=>z(B(e,`/skills`),{args:t}).then(e=>e.text),setLaunchCwd:(e,t)=>z(B(e,`/launch-cwd`),{launch_cwd:t}),setWorkdir:(e,t)=>z(B(e,`/workdir`),{workdir:t}),disposeBacklog:(e,t,n)=>z(B(e,`/backlog/${encodeURIComponent(t)}/dispose`),{op:n}),stopBacklog:(e,t)=>z(B(e,`/backlog/${encodeURIComponent(t)}/stop`)),setContinuous:(e,t,n=``)=>z(B(e,`/continuous`),{enabled:t,objective:n}).then(e=>{if(!t)return e;if(!e.daemon)throw Error(`daemon start returned no result`);return nt(e.daemon),e}),startDaemon:(e,t)=>z(B(e,`/daemon/start`),{command_id:at(),expected_revision:t}).then(nt),stopDaemon:(e,t=!1,n,r=!1)=>z(B(e,`/daemon/stop`),{drain:t,force:r,command_id:at(),expected_revision:n}).then(nt),replaceDaemon:(e,t,n=!1,r)=>z(B(e,`/daemon/replace`),{victim_sid:t,resume_continuous:n,command_id:at(),expected_revision:r}).then(nt),upgradeDaemon:(e,t)=>z(B(e,`/daemon/upgrade`),{command_id:at(),expected_revision:t}).then(nt)},ut=new Set([4401,4404]);function dt(e,t,n={}){let r=window.location.protocol===`https:`?`wss:`:`ws:`,i=new URLSearchParams;n.replay!=null&&i.set(`replay`,String(n.replay)),i.set(`view`,`ui`);let a=Ge();a&&i.set(`token`,a);let o=`${r}//${window.location.host}${B(e,`/stream`)}?${i}`,s=null,c=!1,l,u=()=>{c||(s=new WebSocket(o),s.onopen=()=>n.onOpen?.(),s.onmessage=e=>{try{let n=JSON.parse(e.data);n&&typeof n==`object`&&t(n)}catch{}},s.onclose=e=>{let t=!ut.has(e.code);n.onClose?.({code:e.code,reason:e.reason,retryable:t}),!c&&t&&(l=setTimeout(u,1e3))},s.onerror=()=>s?.close())};return u(),()=>{c=!0,l&&clearTimeout(l),s?.close()}}var W={accent:`rgb(var(--blue))`,success:`rgb(var(--ok))`,error:`rgb(var(--err))`,warning:`rgb(var(--warn))`,info:`rgb(var(--blue))`,ink:`rgb(var(--ink))`,inkDim:`rgb(var(--ink-dim))`,inkFaint:`rgb(var(--ink-faint))`,role:{manager:`rgb(var(--role-manager))`,planner:`rgb(var(--role-planner))`,engineer:`rgb(var(--role-engineer))`,reviewer:`rgb(var(--role-reviewer))`}};function ft(e){switch(e){case`medium`:return W.inkDim;case`high`:return W.info;case`xhigh`:return W.accent;case`max`:return W.error;default:return W.inkFaint}}var pt=e=>String(e??``).trim(),mt=/^[a-z][a-z -]+ requires an operator-owned decision before continuing\.?$/i,ht=e=>{let t=pt(e);return mt.test(t)?``:t},gt=(e,t)=>{let n=/[\u3400-\u9fff]/.test(`${e}\n${t}`);return{id:`custom`,label:n?`自己输入`:`Write my own answer`,description:n?`直接告诉 Argus 你的决定。`:`Tell Argus your decision directly.`,requires_note:!0}};function _t(e,t){let n=[...e,...t],r=[],i=new Set;for(let e of n){let t=pt(e.id),n=e.operator_decision;if(n&&typeof n==`object`&&!Array.isArray(n)){let a=n,o=pt(a.id);if(!o||i.has(o)||pt(a.status)!==`pending`)continue;i.add(o);let s=pt(a.options_source)===`agent`&&Array.isArray(a.options)?a.options.filter(e=>!!pt(e?.id)&&!!pt(e?.label)).map(e=>({...e,requires_note:e.requires_note===!0})):[];s.push(gt(pt(a.title),pt(a.question))),r.push({id:o,item_id:pt(a.item_id)||t,revision:Number(a.revision??1),status:`pending`,title:pt(a.title)||pt(e.title)||`Decision required`,reason:ht(a.reason),question:pt(a.question)||pt(e.pending_question),evidence:Array.isArray(a.evidence)?a.evidence.filter(e=>pt(e?.label)!==`Acceptance check`):[],options:s,options_source:s.length?`agent`:`none`,selected_option:``,note:``});continue}let a=pt(e.pending_question??e.question??e.text);if(!t||!a)continue;let o=`legacy-${t}`;i.has(o)||(i.add(o),r.push({id:o,item_id:t,revision:1,status:`pending`,title:pt(e.title??e.objective)||`Blocked task`,reason:``,question:a,evidence:[],options:[gt(pt(e.title??e.objective),a)],options_source:`none`,selected_option:``,note:``,legacy:!0}))}return r}var G={AGENT_IO_START:`agent.io.start`,AGENT_IO_STREAM:`agent.io.stream`,AGENT_IO_COMPLETE:`agent.io.complete`,AGENT_IO_ERROR:`agent.io.error`,USAGE_RECORDED:`usage.recorded`,PROVIDER_REQUEST_STARTED:`provider.request.started`,PROVIDER_REQUEST_COMPLETED:`provider.request.completed`,PROVIDER_REQUEST_DENIED:`provider.request.denied`,CODEX_UTIL_COMPLETED:`codex.util.completed`,SKILL_COST_COMPLETED:`skill.cost.completed`,BUDGET_RESERVATION_CREATED:`budget.reservation.created`,BUDGET_RESERVATION_DENIED:`budget.reservation.denied`,BUDGET_RESERVATION_SETTLED:`budget.reservation.settled`,BUDGET_RESERVATION_RELEASED:`budget.reservation.released`,BUDGET_UNPRICED_BLOCKED:`budget.unpriced.blocked`,LOOP_START:`loop.start`,LOOP_DONE:`loop.done`,ROUND_START:`round.start`,ROUND_MAIN_COMPLETED:`round.main.completed`,ROUND_REVIEW_STARTED:`round.review.started`,ROUND_REVIEW_DEFERRED:`round.review.deferred`,ROUND_REVIEW_COMPLETED:`round.review.completed`,ROUND_CHECKPOINT_RECORDED:`round.checkpoint.recorded`,ROUND_CHECKPOINT_FAILED:`round.checkpoint.failed`,ROUND_SECRET_REDACTED:`round.secret_redacted`,ROUND_ESCALATED:`round.escalated`,ROUND_STALL:`round.stall`,ROUND_REVIEWER_BACKEND_FAILURE:`round.reviewer_backend_failure`,ROLE_SESSION_TURN:`role.session.turn`,ENGINEER_PROGRESS:`engineer.progress`,ENGINEER_SKILL_MAINTENANCE_COMPLETED:`engineer.skill_maintenance.completed`,LIFE_STATUS:`life.status`,LIFE_PHASE_STARTED:`life.phase.started`,LIFE_MISSION_STARTED:`life.mission.started`,LIFE_MISSION_COMPLETED:`life.mission.completed`,LIFE_MISSION_FAILED:`life.mission.failed`,LIFE_MISSION_SKIPPED:`life.mission.skipped`,LIFE_MISSION_ORPHANED:`life.mission.orphaned`,LIFE_MISSION_REQUEUED:`life.mission.requeued`,LIFE_MANAGER_INTENT_STARTED:`life.manager.intent.started`,LIFE_MANAGER_INTENT_COMPLETED:`life.manager.intent.completed`,LIFE_MANAGER_INTENT_FAILED:`life.manager.intent.failed`,LIFE_MANAGER_STAGE_DECISION:`life.manager.stage_decision`,LIFE_MANAGER_PLAN_CHALLENGE_DECIDED:`life.manager.plan_challenge.decided`,LIFE_VERTICAL_RESOLVED:`life.vertical.resolved`,LIFE_MANAGER_BACKEND_RESOLVED:`life.manager.backend_resolved`,LIFE_PLANNER_BACKEND_RESOLVED:`life.planner.backend_resolved`,LIFE_ENGINEER_BACKEND_RESOLVED:`life.engineer.backend_resolved`,LIFE_REVIEWER_BACKEND_RESOLVED:`life.reviewer.backend_resolved`,LIFE_CURATOR_BACKEND_RESOLVED:`life.curator.backend_resolved`,LIFE_PLANNER_START:`life.planner.start`,LIFE_PLANNER_NORMALIZED:`life.planner.normalized`,LIFE_PLANNER_TASK_ADDED:`life.planner.task_added`,LIFE_PLANNER_TASK_SKIPPED:`life.planner.task_skipped`,LIFE_PLANNER_VERDICT:`life.planner.verdict`,LIFE_PLANNER_WAITING:`life.planner.waiting`,LIFE_PLANNER_WAITING_WOKEN:`life.planner.waiting_woken`,LIFE_PLANNER_TERMINAL_IDLE:`life.planner.terminal_idle`,LIFE_PLANNER_VERIFICATION_PROBE:`life.planner.verification_probe`,LIFE_PLANNER_STALL_ESCALATION:`life.planner.stall_escalation`,LIFE_PLANNER_DEPENDENCY_DROPPED:`life.planner.dependency_dropped`,LIFE_PLANNER_PARALLEL_DROPPED:`life.planner.parallel_dropped`,LIFE_PLANNER_ERROR:`life.planner.error`,LIFE_RUNTIME_FAILURE_CIRCUIT_OPENED:`life.runtime_failure.circuit_opened`,LIFE_RUNTIME_FAILURE_CIRCUIT_BLOCKED:`life.runtime_failure.circuit_blocked`,LIFE_RUNTIME_FAILURE_CANARY_PASSED:`life.runtime_failure.canary_passed`,LIFE_PLAN_REVISION_PROPOSED:`life.plan.revision.proposed`,LIFE_PLAN_REVISION_REJECTED:`life.plan.revision.rejected`,LIFE_PLAN_REVISION_COMMITTED:`life.plan.revision.committed`,LIFE_PLAN_NODE_SUPERSEDED:`life.plan.node.superseded`,LIFE_RESEARCH_SECOND_READING:`life.research.second_reading`,LIFE_LETTER_WRITTEN:`life.letter.written`,LIFE_BUDGET_PAUSE:`life.budget.pause`,LIFE_LIFECYCLE_BLOCK:`life.lifecycle.block`,LIFE_LIFECYCLE_TRANSITION:`life.lifecycle.transition`,LIFE_INBOX_QUEUED:`life.inbox.queued`,LIFE_INBOX_DRAINED:`life.inbox.drained`,LIFE_OPERATOR_QUESTION_PENDING:`life.operator_question.pending`,LIFE_OPERATOR_QUESTION_ANSWERED:`life.operator_question.answered`,LIFE_DAEMON_IDLE_TIMEOUT:`life.daemon.idle_timeout`,PROJECT_COMPLETED:`project.completed`,PROJECT_COMPLETION_REFUSED:`project.completion_refused`,DAEMON_PARKED:`daemon.parked`,DAEMON_COMMAND_SUBMITTED:`daemon.command.submitted`,DAEMON_COMMAND_COMPLETED:`daemon.command.completed`,DAEMON_COMMAND_REJECTED:`daemon.command.rejected`,IDEA_SEARCH_STARTED:`idea.search.started`,IDEA_SEARCH_COMPLETED:`idea.search.completed`,IDEA_SEARCH_SKIPPED:`idea.search.skipped`,VENUE_RESEARCH_STARTED:`venue.research.started`,VENUE_RESEARCH_COMPLETED:`venue.research.completed`,RESEARCH_ACHIEVEMENT_CERTIFIED:`research.achievement.certified`,SKILL_LIBRARY_AVAILABLE:`skill.library.available`,SKILL_CREATED:`skill.created`,SKILL_UPDATED:`skill.updated`,SKILL_ARCHIVED:`skill.archived`,SKILL_TIDIED:`skill.tidied`,SKILL_HISTORY_COMPRESSED:`skill.history.compressed`,SKILL_EVOLUTION_COMPLETED:`skill.evolution.completed`,WIKI_INITIALIZED:`wiki.initialized`,WIKI_HOOK_WARNING:`wiki.hook.warning`,WIKI_CREATED:`wiki.created`,WIKI_UPDATED:`wiki.updated`,WIKI_RETIRED:`wiki.retired`,WIKI_PROMOTION_PROMOTED:`wiki.promotion.promoted`,WIKI_PROMOTION_DEMOTED:`wiki.promotion.demoted`,WIKI_RETIRED_COMPRESSED:`wiki.retired.compressed`,WIKI_EVOLUTION_COMPLETED:`wiki.evolution.completed`,OPERATOR_ALERT:`operator_alert`},vt={"loop.started":G.LOOP_START,"loop.completed":G.LOOP_DONE,"round.started":G.ROUND_START,"mission.started":G.LIFE_MISSION_STARTED,"mission.completed":G.LIFE_MISSION_COMPLETED,"mission.error":G.LIFE_MISSION_FAILED};G.LIFE_MANAGER_BACKEND_RESOLVED,G.LIFE_PLANNER_BACKEND_RESOLVED,G.LIFE_ENGINEER_BACKEND_RESOLVED,G.LIFE_REVIEWER_BACKEND_RESOLVED,G.LIFE_CURATOR_BACKEND_RESOLVED,G.LOOP_START,G.LOOP_DONE,G.ROUND_START,G.ROUND_MAIN_COMPLETED,G.ROUND_REVIEW_DEFERRED,G.ROUND_REVIEW_COMPLETED,G.ROUND_CHECKPOINT_RECORDED,G.ROUND_CHECKPOINT_FAILED,G.ROUND_SECRET_REDACTED,G.ROUND_ESCALATED,G.ROUND_STALL,G.ROUND_REVIEWER_BACKEND_FAILURE,G.ENGINEER_SKILL_MAINTENANCE_COMPLETED,G.SKILL_LIBRARY_AVAILABLE,G.SKILL_CREATED,G.SKILL_UPDATED,G.SKILL_ARCHIVED,G.SKILL_TIDIED,G.SKILL_HISTORY_COMPRESSED,G.SKILL_EVOLUTION_COMPLETED,G.WIKI_INITIALIZED,G.WIKI_HOOK_WARNING,G.WIKI_CREATED,G.WIKI_UPDATED,G.WIKI_RETIRED,G.WIKI_PROMOTION_PROMOTED,G.WIKI_PROMOTION_DEMOTED,G.WIKI_RETIRED_COMPRESSED,G.WIKI_EVOLUTION_COMPLETED,G.LIFE_MISSION_STARTED,G.LIFE_MISSION_COMPLETED,G.LIFE_MANAGER_INTENT_STARTED,G.LIFE_MANAGER_INTENT_COMPLETED,G.LIFE_MANAGER_INTENT_FAILED,G.LIFE_MANAGER_STAGE_DECISION,G.LIFE_MANAGER_PLAN_CHALLENGE_DECIDED,G.LIFE_VERTICAL_RESOLVED,G.LIFE_PLANNER_START,G.LIFE_PLANNER_TASK_ADDED,G.LIFE_PLANNER_TASK_SKIPPED,G.LIFE_PLANNER_DEPENDENCY_DROPPED,G.LIFE_PLANNER_PARALLEL_DROPPED,G.LIFE_PLANNER_VERDICT,G.LIFE_PLANNER_WAITING,G.LIFE_PLANNER_WAITING_WOKEN,G.LIFE_PLANNER_TERMINAL_IDLE,G.LIFE_PLANNER_VERIFICATION_PROBE,G.LIFE_PLANNER_STALL_ESCALATION,G.LIFE_RUNTIME_FAILURE_CIRCUIT_OPENED,G.LIFE_RUNTIME_FAILURE_CIRCUIT_BLOCKED,G.LIFE_RUNTIME_FAILURE_CANARY_PASSED,G.LIFE_PLAN_REVISION_PROPOSED,G.LIFE_PLAN_REVISION_REJECTED,G.LIFE_PLAN_REVISION_COMMITTED,G.LIFE_PLAN_NODE_SUPERSEDED,G.LIFE_RESEARCH_SECOND_READING,G.LIFE_LETTER_WRITTEN,G.LIFE_BUDGET_PAUSE,G.BUDGET_RESERVATION_DENIED,G.BUDGET_UNPRICED_BLOCKED,G.LIFE_LIFECYCLE_BLOCK,G.LIFE_LIFECYCLE_TRANSITION,G.PROVIDER_REQUEST_STARTED,G.PROVIDER_REQUEST_COMPLETED,G.PROVIDER_REQUEST_DENIED,G.LIFE_INBOX_QUEUED,G.LIFE_INBOX_DRAINED,G.LIFE_DAEMON_IDLE_TIMEOUT,G.PROJECT_COMPLETED,G.PROJECT_COMPLETION_REFUSED,G.DAEMON_PARKED,G.DAEMON_COMMAND_COMPLETED,G.DAEMON_COMMAND_REJECTED,G.IDEA_SEARCH_STARTED,G.IDEA_SEARCH_COMPLETED,G.IDEA_SEARCH_SKIPPED,G.VENUE_RESEARCH_STARTED,G.VENUE_RESEARCH_COMPLETED,G.RESEARCH_ACHIEVEMENT_CERTIFIED,G.OPERATOR_ALERT,G.AGENT_IO_START,G.AGENT_IO_COMPLETE,G.AGENT_IO_ERROR,G.PROVIDER_REQUEST_STARTED,G.PROVIDER_REQUEST_COMPLETED,G.PROVIDER_REQUEST_DENIED,G.USAGE_RECORDED;function yt(e){let t=String(e??``).trim();return vt[t]??t}function bt(e){if(typeof e!=`object`||!e)return JSON.stringify(e);if(Array.isArray(e))return`[${e.map(bt).join(`,`)}]`;let t=e;return`{${Object.keys(t).sort().map(e=>`${JSON.stringify(e)}:${bt(t[e])}`).join(`,`)}}`}function xt(e){let t=2166136261;for(let n=0;n>>0).toString(36)}function St(e){let t=e.event_id??e.id??e.seq??e._offset,n=String(e.type??`event`);return t!=null&&t!==``?`${n}-${String(t)}`:`${n}-${String(e.ts??e.time??``)}-${xt(bt(e))}`}function Ct(e){return e.type===G.ENGINEER_PROGRESS&&e.kind===`reasoning`}function wt(e){if(e.type!==G.ENGINEER_PROGRESS||![`assistant_message`,`agent_message`,`message`].includes(String(e.kind??``)))return!1;let t=String(e.agent_layer??e.actor??``);return String(e.text??``).trimStart().startsWith(`{`)?t===`reviewer`||t===`planner`:!1}var Tt=/^(?:[-*+]\s*)?[`*_]*(?:ARGUS_)?(?:MILESTONE_STATUS|NEXT_OWNER|OPERATOR_QUESTION|OPERATOR_OPTIONS|ROLE_DECISION)[`*_]*\s*[:=]|^(?:final\s+)?decision\s*:\s*$/i;function Et(e){return String(e??``).split(/\r?\n/).filter(e=>!Tt.test(e.trim())).join(` +`).trim()}function Dt(e){let t=String(e.fragment_mode??``);return t===`append`||t===`snapshot`?t:e.replace===!0?`snapshot`:`auto`}function Ot(e,t){let n=Math.min(e.length,t.length);for(let r=n;r>=8;--r)if(e.endsWith(t.slice(0,r)))return r;return 0}function kt(e,t,n=`auto`){let r=(e||``).trim(),i=(t||``).trim();if(!r)return i;if(!i)return r;if(n===`snapshot`)return i;if(r.includes(i))return r;if(n===`append`)return`${r}\n${i}`;if(i.includes(r))return i;let a=Ot(r,i);return a?`${r}${i.slice(a)}`:`${r}\n${i}`}var At=[`all`,`attention`,`milestones`,`messages`],jt=new Set([G.LIFE_MISSION_STARTED,G.LIFE_MISSION_COMPLETED,G.LIFE_MISSION_FAILED,G.LOOP_START,G.LOOP_DONE,G.LIFE_PLANNER_VERDICT,`final.report.ready`,`pptx.report.ready`,`plan.completed`,G.LIFE_BUDGET_PAUSE,G.LIFE_LIFECYCLE_BLOCK]);function Mt(e,t,n=`all`,r=``){let i=yt(e.canonical_type??e.type),a=String(e.kind??``);if(n===`attention`&&![`warn`,`err`].includes(String(t.tone??``))&&e.operator_alert!==!0||n===`milestones`&&!(t.rule&&!i.startsWith(`ui.`))&&!jt.has(i)||n===`messages`&&t.tone!==`bright`&&![`assistant_message`,`agent_message`,`message`].includes(a)&&![`ui.operator`,`ui.argus`].includes(i))return!1;let o=r.trim().toLocaleLowerCase();return!o||[i,a,t.role,t.label,t.text,e.title,e.objective,e.text,e.summary,e.reason,e.error,e.status,e.action_summary,e.command,e.path,Array.isArray(e.tags)?e.tags.join(` `):e.tags].some(e=>String(e??``).toLocaleLowerCase().includes(o))}var Nt=[{id:`status`,name:`/status`,argument:`none`,desc:`roles, queued work, journal, and health`,group:`Everyday`,kind:`panel`},{id:`roles`,name:`/roles`,argument:`none`,desc:`per-role backend / model / effort + live activity`,group:`Everyday`,kind:`panel`},{id:`journal`,name:`/journal`,arg:`[N]`,argument:`optional`,desc:`recent journal entries (default 10)`,group:`Everyday`,kind:`panel`},{id:`backlog`,name:`/backlog`,arg:`[all]`,argument:`optional`,desc:`pending tasks (all = incl. done/skipped)`,group:`Everyday`,kind:`panel`},{id:`artifacts`,name:`/artifacts`,argument:`none`,desc:`result files the Reviewer has checked (Enter previews)`,group:`Everyday`,kind:`panel`},{id:`artifact`,name:`/artifact`,arg:``,argument:`required`,desc:`preview one reviewed result file`,group:`Everyday`,kind:`panel`},{id:`events`,name:`/events`,arg:`[filter] [query]`,argument:`optional`,desc:`search feed: all / watch / milestones / messages`,group:`Everyday`,kind:`panel`},{id:`find`,name:`/find`,arg:``,argument:`required`,desc:`search the current event buffer`,group:`Everyday`,kind:`panel`},{id:`cancel`,name:`/cancel`,argument:`none`,desc:`stop waiting for the current Manager reply`,group:`Everyday`,kind:`local`},{id:`ask`,name:`/ask`,arg:``,argument:`required`,desc:`answer inline — no task queued, no Planner/Engineer/Reviewer`,aliases:[`/chat`],group:`Everyday`,kind:`action`},{id:`crystalpilot`,name:`/crystalpilot`,arg:`[status|off|use ]`,argument:`optional`,desc:`enable crystallography tools in this Argus conversation`,group:`Everyday`,kind:`action`},{id:`task`,name:`/task`,arg:``,argument:`required`,desc:`queue work directly`,aliases:[`/add`],group:`Task management`,kind:`action`},{id:`plan`,name:`/plan`,arg:``,argument:`required`,desc:`preview a Planner-authored execution plan`,group:`Task management`,kind:`action`},{id:`rewrite`,name:`/rewrite`,arg:`[text]`,argument:`optional`,desc:`let the Manager rewrite your prompt before sending`,aliases:[`/refine`],group:`Task management`,kind:`action`},{id:`nudge`,name:`/nudge`,arg:``,argument:`required`,desc:`inject guidance into the running mission`,aliases:[`/inject`,`/notify`],group:`Task management`,kind:`action`},{id:`abort`,name:`/abort`,argument:`none`,desc:`immediately stop the running mission`,group:`Task management`,kind:`action`},{id:`note`,name:`/note`,arg:``,argument:`required`,desc:`append a manual note to the timeline`,group:`Task management`,kind:`action`},{id:`done`,name:`/done`,arg:``,argument:`required`,desc:`mark a task done`,group:`Task management`,kind:`action`},{id:`skip`,name:`/skip`,arg:``,argument:`required`,desc:`skip a task`,aliases:[`/rm`],group:`Task management`,kind:`action`},{id:`stop`,name:`/stop`,arg:``,argument:`required`,desc:`stop a task's auto-iteration`,group:`Task management`,kind:`action`},{id:`item`,name:`/item`,arg:``,argument:`required`,desc:`inspect a full task contract`,group:`Task management`,kind:`panel`},{id:`run`,name:`/run`,argument:`none`,desc:`return to the always-live mission feed`,group:`Task management`,kind:`local`},{id:`new`,name:`/new`,arg:`[objective]`,argument:`optional`,desc:`review, create, and switch to a fresh conversation`,group:`Sessions & diagnostics`,kind:`action`},{id:`daemons`,name:`/daemons`,arg:`[query]`,argument:`optional`,desc:`find every session + switch or create`,group:`Sessions & diagnostics`,kind:`panel`},{id:`resume`,name:`/resume`,arg:`[list|]`,argument:`optional`,desc:`switch to another project/session`,group:`Sessions & diagnostics`,kind:`action`},{id:`attach`,name:`/attach`,arg:``,argument:`required`,desc:`follow another project (read the stream)`,group:`Sessions & diagnostics`,kind:`action`},{id:`rename`,name:`/rename`,arg:``,argument:`required`,desc:`rename the current conversation`,group:`Sessions & diagnostics`,kind:`action`},{id:`doctor`,name:`/doctor`,argument:`none`,desc:`diagnose 'why isn't anything running'`,group:`Sessions & diagnostics`,kind:`panel`},{id:`backend`,name:`/backend`,arg:`[codex|claude|copilot|cursor|opencode|pi|grok|qoder|dsh]`,argument:`optional`,desc:`view or change the shared runner backend`,group:`Configuration`,kind:`action`},{id:`config`,name:`/config`,arg:`[key=value …]`,argument:`optional`,desc:`view or change runtime settings`,group:`Configuration`,kind:`panel`},{id:`identity`,name:`/identity`,arg:`[set ]`,argument:`optional`,desc:`view or replace the operator identity card`,group:`Configuration`,kind:`panel`},{id:`reset`,name:`/reset`,argument:`none`,desc:`drop the warm Manager conversation context`,group:`Configuration`,kind:`action`},{id:`skills`,name:`/skills`,arg:`[ls|promote ]`,argument:`optional`,desc:`inspect or promote runtime skills`,group:`Configuration`,kind:`action`},{id:`clear`,name:`/clear`,argument:`none`,desc:`clear the event feed view`,group:`Other`,kind:`local`},{id:`reconnect`,name:`/reconnect`,argument:`none`,desc:`reconnect the live event stream`,group:`Other`,kind:`local`},{id:`help`,name:`/help`,argument:`none`,desc:`keys + full command reference`,aliases:[`/?`,`/commands`],group:`Other`,kind:`local`},{id:`quit`,name:`/quit`,argument:`none`,desc:`leave the cockpit (background work keeps running)`,aliases:[`/exit`,`/q`],group:`Other`,kind:`local`}];new Map(Nt.map(e=>[e.id,e]));var Pt=new Map;for(let e of Nt)for(let t of[e.name,...e.aliases??[]])Pt.set(t.toLowerCase(),e);function Ft(e){return e.argument===`required`}var K=/^\/[A-Za-z0-9_-]+$/;function It(e){if(!e.startsWith(`/`))return!1;let t=e.indexOf(` `),n=t===-1?e:e.slice(0,t);return K.test(n)}function Lt(e){return e.startsWith(`/`)&&!e.includes(` `)&&!e.slice(1).includes(`/`)}function Rt(e){if(!Lt(e))return[];let t=e.toLowerCase(),n=new Set,r=[];for(let e of Nt)[e.name,...e.aliases??[]].some(e=>e.toLowerCase().startsWith(t))&&!n.has(e.name)&&(n.add(e.name),r.push(e));return r.sort((e,n)=>Number(zt(n,t))-Number(zt(e,t)))}function zt(e,t){return[e.name,...e.aliases??[]].some(e=>e.toLowerCase()===t)}function Bt(e){return e.arg?`${e.name} `:e.name}function Vt(e){let t=e.trim();if(!t)return{filter:`all`,query:``};let[n,...r]=t.split(/\s+/);return n.toLowerCase()===`watch`?{filter:`attention`,query:r.join(` `)}:At.includes(n.toLowerCase())?{filter:n.toLowerCase(),query:r.join(` `)}:{filter:`all`,query:t}}function Ht(e){if(!It(e))return null;let t=e.indexOf(` `),n=(t===-1?e:e.slice(0,t)).toLowerCase(),r=t===-1?``:e.slice(t+1).trim(),i=Pt.get(n)??null;return{cmd:i,name:i?i.name:n,rest:r}}function Ut(e){let t=e.toLowerCase(),n=null,r=0;for(let e of Pt.keys()){let i=Wt(t,e);i>r&&(r=i,n=Pt.get(e).name)}return r>=.6?n:null}function Wt(e,t){return 1-Gt(e,t)/(Math.max(e.length,t.length)||1)}function Gt(e,t){let n=e.length,r=t.length,i=Array.from({length:n+1},(e,t)=>[t,...Array(r).fill(0)]);for(let e=0;e<=r;e+=1)i[0][e]=e;for(let a=1;a<=n;a+=1)for(let n=1;n<=r;n+=1)i[a][n]=Math.min(i[a-1][n]+1,i[a][n-1]+1,i[a-1][n-1]+(e[a-1]===t[n-1]?0:1));return i[n][r]}var Kt=new Set([`done`,`success`,`completed`]),qt=new Set([`research_incomplete`,`paused_no_breakthrough`,`exhausted_current_methods`]),Jt=new Set([`no_progress`,`max_rounds`]),Yt=new Set([`blocked`,`infra_blocked`]),Xt=new Set([`error`,`failed`,`supervisor_error`]),Zt={completed:{glyph:`🎉`,tone:`ok`,missionStatus:`complete`},incomplete:{glyph:`◌`,tone:`warn`,missionStatus:`incomplete`},stalled:{glyph:`⏸`,tone:`warn`,missionStatus:`stalled`},blocked:{glyph:`⛔`,tone:`err`,missionStatus:`blocked`},failed:{glyph:`💥`,tone:`err`,missionStatus:`failed`},ended:{glyph:`■`,tone:`info`,missionStatus:`ended`}},Qt={completed:`Task completed`,incomplete:`Mission incomplete`,stalled:`Mission stalled`,blocked:`Mission blocked`,failed:`Mission failed`,ended:`Mission ended`};function $t(e){return String(e??``).trim().toLowerCase()}function en(e){let t=$t(e);switch(t){case`completed`:case`incomplete`:case`stalled`:case`blocked`:case`failed`:case`ended`:return t;default:return null}}function tn(e){let t=$t(e.status);return e.success===!0||Kt.has(t)?`completed`:qt.has(t)?`incomplete`:Jt.has(t)?`stalled`:Yt.has(t)?`blocked`:Xt.has(t)?`failed`:`ended`}function nn(e){let t=e.outcome;if(t&&typeof t==`object`&&!Array.isArray(t)){let n=t;return{execution_status:$t(n.execution_status)||tn(e),review_status:$t(n.review_status)||`not_assessed`,stage_certification:$t(n.stage_certification)||`not_assessed`,interruption_kind:$t(n.interruption_kind)||`none`,resumable:n.resumable===!0}}return{execution_status:tn(e),review_status:`not_assessed`,stage_certification:`not_assessed`,interruption_kind:$t(e.stop_kind)||`none`,resumable:e.resumable===!0}}function rn(e){if(e.success===!0&&e.campaign_continues===!0)return{outcomeClass:`completed`,label:`Task continued`,glyph:`↻`,tone:`info`,missionStatus:`continued`};let t=en(e.outcome_class)??tn(e),n=String(e.status??``).trim(),r=Zt[t];return{outcomeClass:t,label:t===`completed`&&e.final_submission_certified===!0?`Submission certified`:t===`ended`&&n?`Mission ended · ${n}`:Qt[t],glyph:r.glyph,tone:r.tone,missionStatus:r.missionStatus}}var an=[`manager`,`planner`,`engineer`,`reviewer`],on=new Set([`planner`,`engineer`,`reviewer`]),sn=new Set([`running`,`in_progress`,`claimed`]),q=(e,t)=>String(e[t]??``).trim(),cn=(e,t)=>{let n=Number(e[t]);return Number.isFinite(n)?n:null};function ln(e){let t=[e.route?e.route.toUpperCase():``,e.vertical,e.workflow_mode?e.workflow_mode.toUpperCase():``].filter(Boolean);return e.lifetime===`standing`?t.push(`STANDING · OPEN-ENDED`):e.lifetime===`bounded_increment`?t.push(`BOUNDED INCREMENT`):e.lifetime===`bounded`&&e.continuous?t.push(`BOUNDED · FINITE CONTINUOUS`):e.lifetime&&t.push(e.lifetime.toUpperCase()),t.join(` · `)}function un(e){return JSON.parse(JSON.stringify(e))}function dn(){return{schema_version:6,bootstrapped:!1,mission:{id:``,title:``,objective:``,summary:``,final_output:``,status:`idle`,started_at:null,completed_at:null,elapsed_seconds:0,campaign_started_at:null,campaign_elapsed_seconds:0},stage:{id:``,label:``},routing:{route:``,vertical:``,workflow_mode:``,lifetime:``,continuous:!1,open_ended:!1},round:{current:0,max:0},active_role:``,roles:an.map(e=>({role:e,status:`waiting`,label:`Waiting`,updated_at:0})),role_work:[],dag:[],timeline:[],artifacts:[],learned_skills:[],learned_wiki_pages:[],storage:{project_skill_dir:``,global_skill_dir:``,project_skill_count:0,global_skill_count:0,skill_history_compressed:0,wiki_retired_compressed:0,skill_history_bytes_saved:0,wiki_retired_bytes_saved:0,wiki_paths:[]},achievement:null,review:{status:``,reason:``,rejected_attempts:0},frontier:{change:``,summary:``,updated_at:0},delivery:null,outcome:{},last_event_ts:0,updated_at:0}}function fn(e,t,n,r){if(n==null||n===``)return;let i=e.findIndex(e=>e[t]===n);i>=0?e[i]={...e[i],...r}:e.push(r)}function pn(e,t,n,r,i){if(!an.includes(t))return;n===`active`&&on.has(t)&&e.roles.forEach(e=>{on.has(e.role)&&e.role!==t&&e.status===`active`&&Object.assign(e,{status:`done`,label:`Handed off`,updated_at:i})});let a={role:t,status:n,label:r,updated_at:i};fn(e.roles,`role`,t,a),n===`active`?e.active_role=t:e.active_role===t&&(e.active_role=``)}function mn(e,t,n,r,i=``,a=`neutral`){let o=St(t);if(e.timeline.some(e=>e.id===o))return;let s={id:o,ts:Number(t.ts??Date.now()/1e3),type:yt(t.type),role:n,title:r.slice(0,180),detail:i.slice(0,500),tone:a};[`item_id`,`branch_id`].forEach(e=>{let n=q(t,e);n&&(s[e]=n)}),e.timeline=[...e.timeline,s].slice(-120)}function hn(e,t,n,r,i,a=``,o=``){if(!an.includes(n))return;let s=q(t,`message_id`),c=s?`${n}:${s}`:St(t),l=e.role_work.find(e=>e.id===c),u=l&&l.detail.length>a.length?l.detail:a,d={id:c,ts:Number(t.ts??Date.now()/1e3),role:n,kind:r,title:i.slice(0,240),detail:u.slice(0,4e3),status:o,item_id:q(t,`item_id`),mission_id:e.mission.id,mission_title:e.mission.title.slice(0,240),round_index:cn(t,`round_index`)},f=e.role_work.findIndex(e=>e.id===c);f>=0?e.role_work[f]=d:e.role_work.push(d);let p=new Set;an.forEach(t=>{e.role_work.filter(e=>e.role===t).slice(-40).forEach(e=>p.add(e.id))}),e.role_work=e.role_work.filter(e=>p.has(e.id))}function gn(e){return e===`ok`?`success`:e===`err`?`error`:`info`}var _n={agent_message:`Reporting progress`,assistant_message:`Reporting progress`,command_execution:`Running a command`,reasoning:`Reasoning`,tool_use:`Using a tool`,tool_result:`Inspecting tool output`,codex_idle:`Waiting for model output`};function vn(e,t){let n=yt(t.type),r=Number(t.ts??Date.now()/1e3);if(e.last_event_ts=Math.max(e.last_event_ts,r),n===G.LIFE_MANAGER_INTENT_STARTED)e.mission.id=q(t,`item_id`)||q(t,`intent_id`),e.mission.title=q(t,`objective`).slice(0,240),e.mission.objective=q(t,`objective`),e.mission.summary=``,e.mission.final_output=``,e.mission.started_at=null,e.mission.completed_at=null,e.mission.status=`grounding`,pn(e,`manager`,`active`,`Grounding project`,r),mn(e,t,`manager`,`Project grounding started`,q(t,`objective`)),hn(e,t,`manager`,`grounding`,`Grounding project`,q(t,`objective`),`active`);else if(n===G.LIFE_MANAGER_INTENT_COMPLETED){e.mission.id=q(t,`item_id`),e.mission.title=q(t,`objective`).slice(0,240),e.mission.objective=q(t,`objective`),e.mission.summary=``,e.mission.final_output=``,e.mission.started_at=null,e.mission.completed_at=null,e.mission.status=`framed`,e.routing.route=q(t,`route`)||e.routing.route||`team`,e.routing.vertical=q(t,`vertical`)||e.routing.vertical,e.routing.workflow_mode=q(t,`workflow_mode`)||e.routing.workflow_mode,e.routing.lifetime=q(t,`lifetime`)||e.routing.lifetime,`continuous`in t&&(e.routing.continuous=t.continuous===!0),`open_ended`in t&&(e.routing.open_ended=t.open_ended===!0);let n=q(t,`current_stage`),i=Array.isArray(t.stages)?t.stages:[];if(n)e.stage={id:n,label:n.replaceAll(`_`,` `)};else if(!e.stage.id&&i[0]){let t=String(i[0]);e.stage={id:t,label:t.replaceAll(`_`,` `)}}pn(e,`manager`,`done`,`Goal framed`,r),mn(e,t,`manager`,`Goal framed`,q(t,`reason`),`success`),hn(e,t,`manager`,`decision`,`Goal framed`,q(t,`reason`)||q(t,`execution_task`),`done`)}else if(n===G.LIFE_MANAGER_INTENT_FAILED)e.mission.status=`failed`,pn(e,`manager`,`error`,`Manager routing failed`,r),mn(e,t,`manager`,`Manager routing failed`,q(t,`error`)||q(t,`reason`),`error`),hn(e,t,`manager`,`grounding`,`Manager routing failed`,q(t,`error`)||q(t,`reason`),`error`);else if(n===G.LIFE_MANAGER_STAGE_DECISION){let n=q(t,`target_stage`)||q(t,`stage`)||q(t,`current_stage`);n&&(e.stage={id:n,label:n.replaceAll(`_`,` `)}),pn(e,`manager`,`done`,n?`Stage · ${n}`:`Stage reviewed`,r),mn(e,t,`manager`,n?`Stage → ${n}`:`Stage reviewed`,q(t,`reason`)),hn(e,t,`manager`,`stage_decision`,n?`Stage → ${n}`:`Stage reviewed`,q(t,`reason`),q(t,`action`))}else if(n===G.LIFE_PLANNER_START)pn(e,`planner`,`active`,`Planning next work`,r),hn(e,t,`planner`,`planning`,`Planning next work`,q(t,`objective`),`active`);else if(n===G.LIFE_PLANNER_TASK_ADDED){let n=q(t,`item_id`),i={id:n,title:q(t,`title`),objective:q(t,`objective`),status:`pending`,deps:Array.isArray(t.deps)?t.deps.map(String):[],branch_id:q(t,`branch_id`)||n,parent_branch_id:q(t,`parent_branch_id`)||null};fn(e.dag,`id`,n,i);let a=e.routing.vertical===`research`?`Research branch added`:`Task added`;pn(e,`planner`,`done`,a,r),mn(e,t,`planner`,a,i.title,`info`),hn(e,t,`planner`,`task`,i.title||`Task added`,i.objective,`pending`)}else if(n===G.LIFE_PLANNER_VERDICT){let n=!!t.project_done,i=n&&t.delivery&&typeof t.delivery==`object`&&!Array.isArray(t.delivery)?JSON.parse(JSON.stringify(t.delivery)):null,a=i?`Task completed`:n?`Project reviewed`:`Planning complete`;i&&(e.delivery=i,e.mission.status=`complete`,e.mission.summary=i.summary||``,e.mission.completed_at=r),pn(e,`planner`,`done`,a,r),mn(e,t,`planner`,a,q(t,`reason`),n?`success`:`neutral`),hn(e,t,`planner`,`verdict`,a,q(t,`reason`),n?`done`:`planned`)}else if(n===G.LIFE_PLANNER_WAITING){pn(e,`planner`,`waiting`,`Waiting on external work`,r);let n=q(t,`reason`)||q(t,`waiting_reason`);mn(e,t,`planner`,`Planner waiting`,n),hn(e,t,`planner`,`waiting`,`Planner waiting`,n,`waiting`)}else if(n===G.LIFE_MISSION_STARTED)e.review={status:``,reason:``,rejected_attempts:0},e.delivery=null,e.mission.campaign_started_at??=r,e.mission={...e.mission,id:q(t,`item_id`),title:q(t,`title`),objective:q(t,`objective`),summary:``,final_output:``,status:`working`,started_at:r,completed_at:null},pn(e,`reviewer`,`waiting`,`Waiting for the Engineer to finish`,r),pn(e,`engineer`,`active`,`Starting mission`,r),mn(e,t,`engineer`,`Mission started`,q(t,`title`),`info`),hn(e,t,`engineer`,`task`,q(t,`title`)||`Mission started`,q(t,`objective`),`active`);else if(n===G.ROUND_START)e.round={current:cn(t,`round_index`)??0,max:cn(t,`round_max`)??e.round.max},pn(e,`engineer`,`active`,`Running round ${e.round.current}`,r),mn(e,t,`engineer`,`Round ${e.round.current} started`);else if(n===G.ENGINEER_PROGRESS){let n=q(t,`agent_layer`)||q(t,`actor`)||`engineer`,i=n===`main`?`engineer`:n,a=q(t,`kind`),o=_n[a]??`Working`;pn(e,i,`active`,o,r),i===`engineer`&&[`assistant_message`,`agent_message`,`message`].includes(a)&&t.final_delivery===!0&&e.mission.started_at!=null&&e.mission.completed_at==null&&r>=e.mission.started_at&&(!t.item_id||q(t,`item_id`)===e.mission.id)&&(e.mission.final_output=Et(t.text));let s=q(t,`action_summary`)||q(t,`text`);s&&!Ct(t)&&!wt(t)&&hn(e,t,i,a||`progress`,o,s,`active`),[`reasoning`,`assistant_message`,`agent_message`].includes(a)||mn(e,t,i,o,q(t,`action_summary`)||q(t,`text`))}else if(n===G.ROUND_MAIN_COMPLETED)pn(e,`engineer`,`done`,`Work ready for review`,r),hn(e,t,`engineer`,`handoff`,`Work ready for review`,q(t,`text`)||q(t,`summary`),`done`);else if(n===G.ROUND_REVIEW_STARTED)e.review={status:``,reason:``,rejected_attempts:e.review.rejected_attempts},pn(e,`reviewer`,`active`,`Reviewing benchmark evidence`,r),hn(e,t,`reviewer`,`review`,`Review started`,``,`active`);else if(n===G.ROUND_REVIEW_DEFERRED){let n=q(t,`next_step`);pn(e,`engineer`,`active`,`Continuing before review`,r),pn(e,`reviewer`,`waiting`,`Review deferred for one round`,r),mn(e,t,`engineer`,`Continued before review`,n,`info`)}else if(n===G.ROUND_REVIEW_COMPLETED){let n=t.review_skipped===!0,i=n?`skipped`:q(t,`status`),a=q(t,`reason`);e.review={status:i,reason:a,rejected_attempts:e.review.rejected_attempts+ +!![`continue`,`blocked`].includes(i)};let o=q(t,`frontier_change`);o&&(e.frontier={change:o,summary:q(t,`frontier_summary`),updated_at:r});let s=n?`Review not performed`:i===`done`?`Evidence accepted`:`Attempt rejected`;pn(e,`reviewer`,n?`waiting`:i===`done`?`done`:`rejected`,n?s:i===`done`?`Accepted evidence`:`Requested another attempt`,r),mn(e,t,`reviewer`,s,a,n?`info`:i===`done`?`success`:`error`);let c=q(t,`next_action`);hn(e,t,`reviewer`,n?`review`:`verdict`,s,c?`${a}\n\nNext action: ${c}`:a,i)}else if([G.SKILL_CREATED,G.SKILL_UPDATED].includes(n)){let i=q(t,`skill_id`)||q(t,`name`);i&&(fn(e.learned_skills,`id`,i,{id:i,name:q(t,`name`),version:cn(t,`version`)??1,scope:q(t,`scope`),path:q(t,`path`),status:`active`,updated_at:r,mission_id:e.mission.id,mission_title:e.mission.title}),mn(e,t,`reviewer`,n===G.SKILL_CREATED?`Capability unlocked`:`Capability upgraded`,q(t,`name`),`skill`))}else if(n===G.SKILL_EVOLUTION_COMPLETED)e.storage.project_skill_dir=q(t,`project_skill_dir`)||e.storage.project_skill_dir,e.storage.global_skill_dir=q(t,`global_skill_dir`)||e.storage.global_skill_dir,e.storage.project_skill_count=cn(t,`project_skill_count`)??e.storage.project_skill_count,e.storage.global_skill_count=cn(t,`global_skill_count`)??e.storage.global_skill_count;else if(n===G.SKILL_HISTORY_COMPRESSED)e.storage.skill_history_compressed+=cn(t,`count`)??0,e.storage.skill_history_bytes_saved+=cn(t,`bytes_saved`)??0;else if(n===G.SKILL_TIDIED){let n=q(t,`name`);if(n){let i=e.learned_skills.find(e=>e.name===n),a={source_path:q(t,`path`),source_placement:q(t,`placement`),source_vertical:q(t,`vertical`),updated_at:r};i?Object.assign(i,a):fn(e.learned_skills,`id`,n,{id:n,name:n,version:1,scope:``,path:``,status:`active`,...a}),mn(e,t,`manager`,`Capability promoted to source`,n,`skill`)}}else if([G.WIKI_INITIALIZED,G.WIKI_EVOLUTION_COMPLETED].includes(n)){let n=[...(Array.isArray(t.paths)?t.paths:[]).map(e=>String(e)),q(t,`path`)].filter(Boolean);e.storage.wiki_paths=[...new Set([...e.storage.wiki_paths,...n])]}else if(n===G.WIKI_RETIRED_COMPRESSED)e.storage.wiki_retired_compressed+=cn(t,`count`)??0,e.storage.wiki_retired_bytes_saved+=cn(t,`bytes_saved`)??0;else if([G.WIKI_CREATED,G.WIKI_UPDATED].includes(n)){let i=q(t,`page_id`);i&&(fn(e.learned_wiki_pages,`id`,i,{id:i,title:q(t,`title`)||i,card_type:q(t,`card_type`),status:q(t,`status`)||`scratch`,path:q(t,`path`),updated_at:r}),mn(e,t,`reviewer`,n===G.WIKI_CREATED?`Knowledge captured`:`Knowledge refined`,q(t,`title`)||i,`skill`))}else if(n===G.WIKI_RETIRED){let n=q(t,`page_id`);if(n){let i=e.learned_wiki_pages.find(e=>e.id===n);i?Object.assign(i,{status:`retired`,updated_at:r}):fn(e.learned_wiki_pages,`id`,n,{id:n,title:n,card_type:q(t,`card_type`),status:`retired`,path:``,updated_at:r}),mn(e,t,`reviewer`,`Knowledge retired`,n,`error`)}}else if([G.WIKI_PROMOTION_PROMOTED,G.WIKI_PROMOTION_DEMOTED].includes(n)){let i=q(t,`page_id`);if(i){let a=e.learned_wiki_pages.find(e=>e.id===i);a?Object.assign(a,{status:q(t,`to_status`),updated_at:r}):fn(e.learned_wiki_pages,`id`,i,{id:i,title:i,card_type:q(t,`card_type`),status:q(t,`to_status`),path:``,updated_at:r});let o=n===G.WIKI_PROMOTION_PROMOTED;mn(e,t,`reviewer`,o?`Knowledge promoted`:`Knowledge demoted`,`${i} → ${q(t,`to_status`)}`,o?`success`:`neutral`)}}else if(n===G.RESEARCH_ACHIEVEMENT_CERTIFIED)e.achievement={id:q(t,`achievement_id`),title:q(t,`title`),goal:q(t,`goal`),summary:q(t,`summary`),rejected_attempts:e.review.rejected_attempts,skills_learned:e.learned_skills.filter(e=>e.status===`active`).length,artifacts:e.artifacts.length,elapsed_seconds:e.mission.elapsed_seconds,evidence:Array.isArray(t.evidence)?t.evidence.map(String):[],reviewer_certified:!0,certified_at:r};else if([G.LIFE_MISSION_COMPLETED,G.LIFE_MISSION_FAILED].includes(n)){let i=n===G.LIFE_MISSION_FAILED?rn({...t,outcome_class:`failed`,status:q(t,`status`)||`failed`,success:!1}):rn(t),a=`final_output`in t?q(t,`final_output`):q(t,`item_id`)===e.mission.id&&e.mission.started_at!=null&&(e.mission.completed_at==null||e.mission.completed_at===r)&&e.mission.final_output||``;e.mission.id=q(t,`item_id`)||e.mission.id,e.mission.title=q(t,`title`)||e.mission.title,e.mission.objective=q(t,`objective`)||e.mission.objective,e.mission.summary=q(t,`summary`),e.mission.final_output=a,e.mission.status=i.missionStatus,e.mission.completed_at=r;let o=t.delivery;t.success===!0&&o&&typeof o==`object`&&!Array.isArray(o)?e.delivery=JSON.parse(JSON.stringify(o)):t.success!==!0&&(e.delivery=null),e.outcome=nn(t),pn(e,`engineer`,i.missionStatus===`complete`?`done`:i.missionStatus,i.label,r),mn(e,t,`engineer`,i.label,q(t,`summary`)||q(t,`title`)||q(t,`status`),gn(i.tone)),hn(e,t,`engineer`,`completion`,i.label,q(t,`summary`)||q(t,`title`)||q(t,`status`),i.missionStatus)}return e.updated_at=Date.now()/1e3,e}function yn(e,t,n){let r=t.backlog.find(e=>sn.has(e.status)),i=t.backlog.find(e=>e.status===`pending`),a=t.backlog.find(t=>t.id===e.mission.id),o=r??a,s=!!(r||i||t.continuous?.enabled||t.continuous?.done_reason||t.continuous?.done_at||e.mission.id||![``,`idle`].includes(e.mission.status));t.continuous?.enabled&&(e.routing.route=e.routing.route||`team`,e.routing.continuous=!0,e.routing.open_ended=t.continuous.open_ended===!0,e.routing.lifetime=e.routing.open_ended?`standing`:e.routing.lifetime||`bounded`);let c=o?.objective||o?.title||(t.continuous?.enabled?t.continuous.objective:``)||t.session.objective||(e.mission.id?``:i?.objective)||(e.mission.id?``:i?.title)||e.mission.objective;c&&(e.mission.objective=c,o?e.mission.title=(o.title||c.split(` +`)[0]).slice(0,240):e.mission.title||(e.mission.title=c.split(` +`)[0].slice(0,240))),r?((r.id!==e.mission.id||r.started_ts!=null&&r.started_ts!==e.mission.started_at||e.mission.completed_at!=null)&&(e.mission.summary=``,e.mission.final_output=``,e.mission.started_at=r.started_ts??null,e.mission.completed_at=null),e.mission.id=r.id,e.mission.status=`working`,e.mission.started_at=e.mission.started_at??r.started_ts??null):a?a.status===`pending`&&(e.mission.status=`queued`):t.continuous?.done_reason||t.continuous?.done_at?e.mission.status=`complete`:i||t.continuous?.enabled?e.mission.status=`queued`:t.daemon.alive&&(e.mission.status=`idle`),t.roles.forEach(t=>{t.active?pn(e,t.role,`active`,t.label||t.status||`Working`,Date.now()/1e3-(t.age_s??0)):s||pn(e,t.role,`waiting`,`Waiting`,Date.now()/1e3);let n=e.roles.find(e=>e.role===t.role);n&&Object.assign(n,{backend:t.backend,model:t.model,effort:t.effort})});let l=t.roles.filter(e=>e.active);l.length?e.active_role=l[l.length-1].role:s||(e.active_role=``),t.backlog.forEach(t=>{let n={id:t.id,title:t.title,objective:t.objective,status:t.status,deps:t.deps??[],branch_id:t.id,parent_branch_id:t.deps?.[0]??null,acceptance_check:t.acceptance_check??``,plan_hypothesis:t.plan_hypothesis??``,goal_contribution:t.goal_contribution??``,expected_regressions:t.expected_regressions??``,decision_rule:t.decision_rule??``,non_goals:t.non_goals??[]};fn(e.dag,`id`,n.id,n)});let u=o?.outcome?.execution_status?o.outcome:e.mission.id?void 0:[...t.backlog].filter(e=>e.outcome?.execution_status).sort((e,t)=>Number(e.finished_ts??0)-Number(t.finished_ts??0)).at(-1)?.outcome;return!r&&u&&(e.outcome=nn({outcome:u,status:`done`,success:!0})),n.forEach(t=>{fn(e.artifacts,`path`,t.path,{id:t.path,path:t.path,title:t.name,kind:t.kind,why:t.why,exists:t.exists,storage_path:t.storage_path,source:t.source})}),s}function bn(e,t,n,r){r||(t.roles.forEach(t=>{t.active||pn(e,t.role,`waiting`,`Waiting`,Date.now()/1e3)}),e.active_role=``);let i=Date.now()/1e3,a=e.mission.campaign_started_at??t.session.created??e.mission.started_at;a&&(e.mission.campaign_started_at=a,e.mission.campaign_elapsed_seconds=Math.max(0,i-a)),e.mission.started_at&&e.mission.status===`working`?e.mission.elapsed_seconds=Math.max(0,i-e.mission.started_at):e.mission.started_at&&e.mission.completed_at&&(e.mission.elapsed_seconds=Math.max(0,e.mission.completed_at-e.mission.started_at)),e.achievement?.reviewer_certified&&(e.achievement.elapsed_seconds=e.mission.elapsed_seconds,e.achievement.rejected_attempts=e.review.rejected_attempts,e.achievement.skills_learned=e.learned_skills.filter(e=>e.status===`active`).length,e.achievement.artifacts=n.filter(e=>e.exists).length)}function xn(e,t=[],n=[]){let r=e.mission_view?un(e.mission_view):dn();r.storage??=dn().storage,r.storage.skill_history_compressed??=0,r.storage.wiki_retired_compressed??=0,r.storage.skill_history_bytes_saved??=0,r.storage.wiki_retired_bytes_saved??=0,r.learned_wiki_pages??=[],r.role_work??=[],r.delivery??=null,r.outcome??={};let i=r.last_event_ts,a=yn(r,e,n),o=[...t].sort((e,t)=>Number(e.ts??0)-Number(t.ts??0));return o.filter(e=>e.ts==null||Number(e.ts)>i).forEach(e=>vn(r,e)),r.mission.final_output||(r.mission.final_output=Sn(o,r.mission)),bn(r,e,n,a),r}function Sn(e,t){if(!t.id||[`working`,`queued`,`grounding`,`framed`].includes(t.status))return``;let n=e.reduce(vn,dn()).mission;return n.id!==t.id||n.started_at==null||n.completed_at==null||t.started_at!=null&&n.started_at!==t.started_at||t.completed_at!=null&&n.completed_at!==t.completed_at?``:n.final_output||``}function Cn(e){return String(e||``).replace(/\\([*_`~])/g,`$1`).replace(/\\\\(?=[A-Za-z])/g,`\\`)}function wn(e){let t=Math.max(0,Math.floor(e)),n=Math.floor(t/3600),r=Math.floor(t%3600/60);return n?`${n}h ${r}m`:r?`${r}m`:`${t}s`}function Tn(e){let t=Math.ceil(e);return t<60?`${t}s`:t<3600?`${Math.floor(t/60)}m ${t%60}s`:t<86400?`${Math.floor(t/3600)}h ${Math.floor(t%3600/60)}m`:`${Math.floor(t/86400)}d ${Math.floor(t%86400/3600)}h`}function En(e){let t=(e.label||e.display_name||``).trim();return!!(t&&t!==e.id)}function Dn(e){return[...e].sort((e,t)=>{if(e.daemon_alive!==t.daemon_alive)return e.daemon_alive?-1:1;let n=En(e);return n===En(t)?(t.last_active||0)-(e.last_active||0):n?-1:1})}function On(e){return Dn(e)[0]}function kn(e,t){let n=t?.trim()||null;return n&&e.some(e=>e.id===n)?{id:n,requested:n,recovered:!1}:{id:On(e)?.id??null,requested:n,recovered:!!n}}function An(e,t,n){if(n){let e=t?.trim()||null;return{id:e,requested:e,recovered:!1}}return kn(e,t)}function jn(e,t){let n=t.trim().toLowerCase().split(/\s+/).filter(Boolean);if(!n.length)return!0;let r=e.daemon_alive?`live running`:`stopped idle`,i=[e.id,e.label,e.display_name,e.objective,r].filter(Boolean).join(` `).toLowerCase();return n.every(e=>i.includes(e))}function Mn(e,t){return e.filter(e=>jn(e,t))}var Nn={[G.LIFE_LIFECYCLE_BLOCK]:`block`,[G.ROUND_REVIEWER_BACKEND_FAILURE]:`block`,[G.LIFE_BUDGET_PAUSE]:`warn`,[G.ROUND_STALL]:`warn`,[G.ROUND_ESCALATED]:`warn`,[G.LIFE_PLANNER_STALL_ESCALATION]:`warn`},Pn=new Set([G.BUDGET_RESERVATION_DENIED,G.BUDGET_UNPRICED_BLOCKED]),Fn=new Set([G.LIFE_MISSION_STARTED,G.ROUND_MAIN_COMPLETED,G.LIFE_MISSION_COMPLETED,G.LOOP_DONE,G.ROUND_START,`ui.operator`]),In=new Set([G.BUDGET_RESERVATION_CREATED,G.PROVIDER_REQUEST_STARTED]);function Ln(e){let t=yt(e.canonical_type??e.type);if(e.event_validation?.status===`invalid`)return t===G.ROLE_SESSION_TURN?null:{tone:`warn`,kind:`validation`,text:`invalid event ${t||`unknown`}: ${e.event_validation.errors.join(`; `)}`};if(Pn.has(t))return{tone:`block`,kind:`budget`,text:`Budget exhausted or blocked — ${String(e.reason??e.text??t).trim()}`};let n=e.operator_alert===!0?`block`:Nn[t];return n?{tone:n,text:String(e.text??e.reason??t).trim()}:null}function Rn(e){let t=null;for(let n of e){let e=yt(n.canonical_type??n.type),r=Ln(n);r?t=r:(t?.kind===`validation`||t?.kind===`budget`&&In.has(e)||t&&t.kind!==`budget`&&Fn.has(e))&&(t=null)}return t}var zn=new Set([`done`,`completed`,`failed`,`skipped`]);function Bn(e){return zn.has(e.status)}function Vn(e,t){return e.filter(e=>Bn(e)===t)}Math.max(...[` ╭───────────────────────────────────────────────────────────────────────────────────╮╮`,` │ ││`,` │ ◉ argus-skill · Autonomous Work Lab ││`,` │ ││`,` ╰───────────────────────────────────────────────────────────────────────────────────╯│`,` │`].map(e=>[...e].length));var Hn=[`⠋`,`⠙`,`⠹`,`⠸`,`⠼`,`⠴`,`⠦`,`⠧`,`⠇`,`⠏`];function Un(e){return Hn[e%Hn.length]}var Wn=()=>Date.now()/1e3;function Gn(e){return e.trim().replace(/[.…]+$/u,``).toLowerCase()}function Kn(e,t,n=Wn()){let r=(t.label??``).trim();if(!r)return e;let i=t.heartbeat===!0,a=e.slice(),o=a[a.length-1];if(o&&!o.endedTs){if(Gn(o.label)===Gn(r)||i&&o.heartbeat)return a[a.length-1]={...o,label:r,detail:t.detail||o.detail,kind:t.kind||o.kind,heartbeat:i,endedTs:0},a;a[a.length-1]={...o,endedTs:n}}return a.push({id:`${a.length}:${r}:${n}`,role:(t.role||`manager`).trim()||`manager`,label:r,detail:(t.detail||``).trim(),kind:(t.kind||``).trim(),startedTs:n,endedTs:0,heartbeat:i}),a}function qn(e,t=Wn()){if(e.length===0)return[];let n=e.slice(),r=n[n.length-1];return r&&!r.endedTs&&(n[n.length-1]={...r,endedTs:t}),n}function Jn(e,t=6){let n=Math.max(1,t);return e.length<=n?e:e.slice(e.length-n)}function Yn(e,t=Wn()){let n=e.endedTs||t;return Math.max(0,n-e.startedTs)}function Xn(e){if(!Number.isFinite(e)||e<1)return``;if(e<60)return`${Math.floor(e)}s`;let t=Math.floor(e/60),n=Math.floor(e%60);return n?`${t}m${n}s`:`${t}m`}function Zn(e,t=!1,n=!1){return(t||n)&&e.toLowerCase()===`r`}function J(e,t){let n=(e||``).replace(/```[a-z]*\n?/gi,``).replace(/\[([^\]]+)\]\([^)]+\)/g,`[$1]`).trim();return n.length<=t?n:n.slice(0,t-1).trimEnd()+`…`}var Qn=e=>String(e??``).split(` +`)[0]?.trim()??``,Y=(e,t)=>String(e[t]??``);function $n(e,t){let n=(e,n)=>t===`zh-CN`?n:e,r=Y(e,`phase`),i=Y(e,`cause`)||Y(e,`backend_error`),a=Y(e,`error`);if(!r||!i)return`${n(`routing failed`,`分流失败`)} ${J(a,140)}`;let o={backend:n(`backend`,`后端`),parse:n(`parse`,`解析`),contract:n(`contract:`,`契约:`),timeout:n(`timeout`,`超时`)},s=Number(e.attempts||0),c=s>1?n(` (attempt ${s})`,` (第${s}次尝试)`):``,l=`${n(`routing failed`,`分流失败`)} · ${o[r]||r} ${i}${c}`;return a?`${l} · ${n(`raw`,`原始错误`)}: ${a}`:l}var er=e=>{let t=e,n=t.round_index??t.round;return typeof n==`string`||typeof n==`number`?n:`?`},tr={manager:`Manager`,planner:`Planner`,engineer:`Engineer`,reviewer:`Reviewer`,critic:`Critic`,system:`Argus`},nr={manager:`Manager`,planner:`Planner`,engineer:`Engineer`,reviewer:`Reviewer`,critic:`Critic`,system:`Argus`},rr=e=>({bright:W.ink,dim:W.inkDim,accent:W.accent,ok:W.success,warn:W.warning,err:W.error,info:W.info})[e];function ir(e,t=`en`){let n=Y(e,`type`),r=(e,n)=>t===`zh-CN`?n:e,i=e=>(t===`zh-CN`?nr:tr)[e]||e;if(n===`ui.operator`){let t=Et(Y(e,`text`));return t?{role:`operator`,label:r(`You`,`你`),glyph:`›`,text:t,tone:`bright`,rule:!0}:null}if(n===`ui.argus`){let t=Y(e,`text`);return t?{role:`manager`,label:`Argus`,glyph:`◆`,text:t,tone:`bright`,rule:!0}:null}if(n===`engineer.progress`){let t=Y(e,`kind`),n=Y(e,`agent_layer`)||`engineer`,a=Qn(e.text??e.action_summary);if(t===`reasoning`){let t=J(Y(e,`text`),280);return t?{role:n,label:i(n),glyph:`∴`,text:t,tone:`dim`,reasoning:!0}:null}if(t===`assistant_message`||t===`agent_message`||t===`message`){if(wt(e))return null;let t=Et(Y(e,`text`));return t?{role:n,label:i(n),glyph:`▌`,text:t,tone:`bright`}:null}if(t===`command_execution`){let t=Y(e,`text`)||Y(e,`command`)||Y(e,`action_summary`);return t?{role:n,label:i(n),glyph:`▸ $`,text:t,tone:`dim`}:null}if(t===`file_change`){let t=Y(e,`text`)||Y(e,`action_summary`);return{role:n,label:i(n),glyph:`✎`,text:t||r(`(file change)`,`(文件变更)`),tone:`dim`}}if(t===`tool_use`){let t=Y(e,`text`)||Y(e,`action_summary`);return{role:n,label:i(n),glyph:`⚙`,text:t||r(`(tool)`,`(工具)`),tone:`dim`}}return a?{role:n,label:i(n),glyph:`▸`,text:J(a,160),tone:`dim`}:null}if(n===`life.manager.intent.started`)return{role:`manager`,label:`Manager`,glyph:`🧭`,text:r(`classifying request…`,`判断任务归属…`),tone:`info`};if(n===`life.manager.intent.completed`)return{role:`manager`,label:`Manager`,glyph:`🧭`,text:`→ ${ln({route:Y(e,`route`)||`team`,vertical:Y(e,`vertical`),workflow_mode:Y(e,`workflow_mode`),lifetime:Y(e,`lifetime`),continuous:e.continuous===!0,open_ended:e.open_ended===!0})||Y(e,`kind`)||r(`resolved`,`已确定`)}`,tone:`info`};if(n===`life.manager.intent.failed`)return{role:`manager`,label:`Manager`,glyph:`⚠`,text:$n(e,t),tone:`err`};if(n===`life.manager.stage_decision`){let t=Y(e,`target_stage`)||Y(e,`stage`)||Y(e,`current_stage`);return{role:`manager`,label:`Manager`,glyph:`🧭`,text:`${Y(e,`action`)}${t?` → ${t}`:``} ${J(Y(e,`reason`),120)}`,tone:`info`}}if(n===`life.research.second_reading`){let t=Y(e,`agent_layer`)||`manager`,n=J(Y(e,`supported`),160),a=r(`reread the evidence and reworked the plan`,`重读了证据并重排了计划`);return{role:t,label:i(t),glyph:`📖`,text:n?`${a} · ${n}`:a,tone:`info`}}if(n===`life.letter.written`){let t=Y(e,`agent_layer`)||`manager`;return{role:t,label:i(t),glyph:`✉`,text:r(`wrote you a letter`,`给你写了一封信`),tone:`accent`}}if(n===`life.planner.start`)return{role:`planner`,label:`Planner`,glyph:`📋`,text:`${r(`planning`,`正在规划`)} ${J(Y(e,`objective`),140)}`,tone:`accent`};if(n===`life.planner.verdict`)return Y(e,`status`)===`done`||e.project_done===!0?{role:`planner`,label:`Planner`,glyph:`🏁`,text:r(`project done`,`项目已完成`),tone:`ok`}:{role:`planner`,label:`Planner`,glyph:`📋`,text:r(`queued ${Y(e,`queued`)||Y(e,`n`)||`next`} task(s)`,`已加入 ${Y(e,`queued`)||Y(e,`n`)||`下一`} 个任务`),tone:`accent`};if(n===`life.planner.task_added`)return{role:`planner`,label:`Planner`,glyph:`+`,text:`${r(`added`,`已添加`)} ${J(Y(e,`title`)||Y(e,`objective`),140)}`,tone:`accent`};if(n===`life.planner.task_skipped`)return{role:`planner`,label:`Planner`,glyph:`⏭`,text:`${r(`skipped duplicate`,`已跳过重复任务`)} ${J(Y(e,`title`),120)}`,tone:`dim`};if(n===`life.planner.error`)return{role:`planner`,label:`Planner`,glyph:`⚠`,text:`${r(`planner error`,`Planner 错误`)} ${J(Y(e,`error`)||Y(e,`text`),140)}`,tone:`err`};if(n===`life.mission.started`||n===`mission.started`)return{role:`engineer`,label:`Engineer`,glyph:`🚀`,text:J(Y(e,`title`)||Y(e,`objective`)||Y(e,`text`)||r(`mission started`,`任务已开始`),160),tone:`info`,rule:!0};if(n===`round.started`||n===`round.start`)return{role:`engineer`,label:`Engineer`,glyph:`──`,text:r(`round ${er(e)}`,`第 ${er(e)} 轮`),tone:`dim`,rule:!0};if(n===`life.phase.started`){let t=Y(e,`label`)||Y(e,`phase`);if(!t)return null;let n=Y(e,`agent_layer`)||`engineer`;return{role:n,label:i(n),glyph:`🔄`,text:r(`entering ${t}`,`进入 ${t}`),tone:`info`}}if(n===`round.review.started`)return{role:`reviewer`,label:`Reviewer`,glyph:`🔄`,text:r(`review round ${er(e)}`,`审核第 ${er(e)} 轮`),tone:`info`};if(n===`round.review.deferred`)return{role:`engineer`,label:`Engineer`,glyph:`↪`,text:r(`continues before review · ${J(Y(e,`next_step`),160)}`,`审核前继续执行 · ${J(Y(e,`next_step`),160)}`),tone:`info`};if(n===`round.main.completed`)return{role:`engineer`,label:`Engineer`,glyph:`✅`,text:r(`round ${er(e)} completed`,`第 ${er(e)} 轮已完成`),tone:`info`};if(n===`round.review.completed`){if(e.review_skipped===!0)return{role:`reviewer`,label:`Reviewer`,glyph:`↪`,text:`${r(`review not performed`,`审查未执行`)} · ${J(Y(e,`reason`),160)}`,tone:`info`};let t=Y(e,`status`),n=t===`done`?`ok`:t===`blocked`||t===`no_progress`?`err`:`warn`;return{role:`reviewer`,label:`Reviewer`,glyph:t===`done`?`✅`:t===`blocked`||t===`no_progress`?`⛔`:`↻`,text:`${t||`?`} · ${J(Y(e,`reason`),160)}`,tone:n}}if(n===`life.iteration.critic`)return{role:`critic`,label:`Critic`,glyph:`👔`,text:`${Y(e,`decision`)||``} ${J(Y(e,`reason`),140)}`,tone:`info`};if(n===`life.iteration.continued`)return{role:`critic`,label:`Critic`,glyph:`🔁`,text:r(`queued next iteration`,`已加入下一轮迭代`),tone:`dim`};if(n===`life.mission.completed`||n===`mission.completed`||n===`loop.completed`){let t=rn(e),n=J(Y(e,`summary`),240);return{role:`engineer`,label:`Engineer`,glyph:t.glyph,text:n?`${t.label} · ${n}`:t.label,tone:t.tone,rule:!0}}if(n===`life.mission.failed`||n===`mission.error`)return{role:`engineer`,label:`Engineer`,glyph:`❌`,text:`${r(`mission failed`,`任务失败`)} ${J(Y(e,`reason`)||Y(e,`error`),140)}`,tone:`err`,rule:!0};if(n===`loop.start`)return{role:`engineer`,label:`Engineer`,glyph:`▶`,text:J(Y(e,`text`)||Y(e,`objective`),160),tone:`info`};if(n===`loop.done`)return{role:`engineer`,label:`Engineer`,glyph:`🏁`,text:`${r(`loop done`,`循环完成`)} ${J(Y(e,`text`),120)}`,tone:`dim`};if(n===`life.inbox.queued`)return{role:`system`,label:r(`You`,`你`),glyph:`📥`,text:`${r(`nudge`,`追加指导`)} · ${J(Y(e,`text`),160)}`,tone:`accent`};if(n===`final.report.ready`||n===`pptx.report.ready`)return{role:`system`,label:`Argus`,glyph:`📄`,text:r(`report ready`,`报告已就绪`),tone:`accent`};if(n===`plan.completed`)return{role:`planner`,label:`Planner`,glyph:`📋`,text:r(`plan completed`,`计划已完成`),tone:`accent`};if(n===`daemon.stopping`)return{role:`system`,label:`Argus`,glyph:`🛑`,text:r(`stopping`,`正在停止`),tone:`err`};if(n===`round.reviewer_backend_failure`)return{role:`system`,label:r(`Notice`,`通知`),glyph:`!`,text:r(`reviewer backend down — holding · ${J(Y(e,`text`),150)}`,`Reviewer 后端不可用 — 已暂停 · ${J(Y(e,`text`),150)}`),tone:`err`,rule:!0};if(n===`round.stall`)return{role:`system`,label:r(`Notice`,`通知`),glyph:`!`,text:J(Y(e,`text`)||r(`no forward progress`,`没有取得进展`),170),tone:`warn`};if(n===`round.escalated`)return{role:`system`,label:r(`Notice`,`通知`),glyph:`!`,text:J(Y(e,`text`)||r(`soft round limit — escalating external blockers`,`达到软轮次上限 — 正在升级外部阻塞`),170),tone:`warn`};if(n===`life.planner.stall_escalation`)return{role:`system`,label:r(`Notice`,`通知`),glyph:`!`,text:`${r(`planner stalled`,`Planner 停滞`)} — ${J(Y(e,`reason`)||Y(e,`text`),150)}`,tone:`warn`};if(n===`life.budget.pause`)return{role:`system`,label:r(`Watch`,`监控`),glyph:`⏸`,text:r(`budget cap reached — paused · ${J(Y(e,`text`)||Y(e,`reason`),140)}`,`已达到预算上限 — 已暂停 · ${J(Y(e,`text`)||Y(e,`reason`),140)}`),tone:`warn`};if(n===`budget.reservation.denied`)return{role:`system`,label:r(`Budget`,`预算`),glyph:`$`,text:`${r(`budget denied`,`预算申请被拒绝`)} — ${J(Y(e,`reason`)||Y(e,`text`),150)}`,tone:`err`,rule:!0};if(n===`budget.unpriced.blocked`)return{role:`system`,label:r(`Budget`,`预算`),glyph:`$`,text:`${r(`budget blocked by unresolved cost`,`预算因成本未确定而阻塞`)} — ${J(Y(e,`reason`)||Y(e,`text`),150)}`,tone:`err`,rule:!0};if(n===`life.lifecycle.block`)return null;if(n===`life.daemon.idle_timeout`)return{role:`system`,label:r(`Watch`,`监控`),glyph:`🟦`,text:J(Y(e,`text`)||r(`idle timeout — standing by`,`空闲超时 — 正在待命`),150),tone:`dim`};if(n===`round.watchdog.restart_requested`)return{role:`system`,label:r(`Watch`,`监控`),glyph:`🔄`,text:r(`stall caught — restarting the round · ${J(Y(e,`reason`),160)}`,`检测到停滞 — 正在重启本轮 · ${J(Y(e,`reason`),160)}`),tone:`warn`};if(n===`engineer.failure_nudge`)return{role:`engineer`,label:`Engineer`,glyph:`⚠`,text:`${r(`repeated tool failure`,`工具重复失败`)} — ${J(Y(e,`text`)||Y(e,`reason`),160)}`,tone:`warn`};if(n===`mission.idle`)return{role:`system`,label:`Argus`,glyph:`🟦`,text:J(Y(e,`text`)||r(`idle — awaiting the next mission`,`空闲 — 正在等待下一个任务`),160),tone:`dim`};if(e.operator_alert===!0){let t=J(Y(e,`text`)||Y(e,`reason`)||n,170);if(t)return{role:`system`,label:r(`Notice`,`通知`),glyph:`!`,text:t,tone:`err`,rule:!0}}return null}function ar(e,t){return St(e)}function or(e,t,n){e.setQueryData([`snapshot`,t],e=>e&&{...e,session:{...e.session,display_name:n}}),e.setQueryData([`projects`],e=>e&&{...e,projects:e.projects.map(e=>e.id===t?{...e,display_name:n,label:n||e.objective||e.id}:e)})}var sr=15e3,cr=5e3,lr=8e3,ur=2e3,dr=1e4,fr=1e4;function pr(e,t){return!L(t)&&e<1}function mr(e){return!L(e)&&cr}function hr(e){return e?.projects.some(e=>e.daemon_alive)?ur:sr}function gr(e){return e?.daemon.alive?ur:lr}var _r=()=>ce({queryKey:[`projects`],queryFn:U.projectIndex,refetchInterval:e=>hr(e.state.data)}),vr=()=>ce({queryKey:[`project-costs`],queryFn:({signal:e})=>U.projectCosts(e),retry:pr,refetchInterval:e=>mr(e.state.error),refetchIntervalInBackground:!1}),yr=e=>ce({queryKey:[`snapshot`,e],queryFn:({signal:t})=>U.activeSnapshot(e,t),enabled:!!e,refetchInterval:e=>gr(e.state.data)}),br=(e,t=30,n=!0)=>ce({queryKey:[`journal`,e,t],queryFn:({signal:n})=>U.journal(e,t,n),enabled:!!e&&n,refetchInterval:n?8e3:!1}),xr=(e,t)=>ce({queryKey:[`doctor`,e],queryFn:({signal:t})=>U.doctor(e,t),enabled:!!e&&t}),Sr=(e,t)=>ce({queryKey:[`config`,e],queryFn:({signal:t})=>U.config(e,t),enabled:!!e&&t}),Cr=(e,t)=>ce({queryKey:[`identity`,e],queryFn:({signal:t})=>U.identity(e,t),enabled:!!e&&t}),wr=(e,t,n=30)=>ce({queryKey:[`transcript`,e,n],queryFn:({signal:t})=>U.transcript(e,n,t),enabled:!!e&&t}),Tr=(e,t=!0)=>ce({queryKey:[`artifacts`,e],queryFn:({signal:t})=>U.artifacts(e,t),enabled:!!e&&t,refetchInterval:t?dr:!1}),Er=(e,t,n=null)=>ce({queryKey:[`artifact`,e,t,n],queryFn:({signal:n})=>U.artifact(e,t,n),enabled:!!e&&!!t,refetchInterval:e=>t&&/(?:^|[\\/])REVIEW\.md$/i.test(t)&&!L(e.state.error)?2e3:!1}),Dr=(e,t=!0)=>ce({queryKey:[`git-diff`,e],queryFn:({signal:t})=>U.gitDiff(e,t),enabled:!!e&&t,refetchInterval:t?fr:!1}),Or=(e,t)=>ce({queryKey:[`backlog-item`,e,t],queryFn:({signal:n})=>U.backlogItem(e,t,n),enabled:!!e&&!!t});function kr(e,t){let n=oe(),r=e=>{n.invalidateQueries({queryKey:[`snapshot`,e]}),n.invalidateQueries({queryKey:[`status`,e]}),n.invalidateQueries({queryKey:[`projects`]}),n.invalidateQueries({queryKey:[`backlog-item`,e]})},i=()=>r(e);return{addTask:P({mutationFn:t=>U.addTask(e,t),onSuccess:i}),nudge:P({mutationFn:t=>U.nudge(e,t)}),note:P({mutationFn:t=>U.note(e,t)}),startDaemon:P({mutationFn:()=>U.startDaemon(e,t),onSuccess:i}),stopDaemon:P({mutationFn:n=>U.stopDaemon(e,n,t),onSuccess:i}),forceStopDaemon:P({mutationFn:()=>U.stopDaemon(e,!1,t,!0),onSuccess:i}),updateProject:P({mutationFn:e=>U.updateProject(e.sid,e.name),onSuccess:e=>{or(n,e.sid,e.name),r(e.sid)}}),deleteProject:P({mutationFn:()=>U.deleteProject(e),onSuccess:async()=>{let t=e;if(t){let e=e=>e.queryKey.some(e=>e===t);await n.cancelQueries({predicate:e}),n.removeQueries({predicate:e})}await n.invalidateQueries({queryKey:[`projects`]})}}),disposeBacklog:P({mutationFn:t=>U.disposeBacklog(e,t.id,t.op),onSuccess:i}),stopBacklog:P({mutationFn:t=>U.stopBacklog(e,t),onSuccess:i}),setContinuous:P({mutationFn:t=>U.setContinuous(e,t.enabled,t.objective??``),onSuccess:i})}}var Ar=2e3;function jr(e,t){if(t.kind===`reset`)return{sid:t.sid,events:[],seen:new Set};if(t.sid!==e.sid)return e;if(t.kind===`seed`){let n=new Set,r=[];[...t.events,...e.events].forEach((e,t)=>{let i=ar(e,t);n.has(i)||(n.add(i),r.push(e))});let i=r.slice(-2e3);return{sid:e.sid,events:i,seen:new Set(i.map((e,t)=>ar(e,t)))}}let n=t.kind===`push`?[t.ev]:t.events,r=null,i=null;for(let t of n){let n=r??e.events,a=i??e.seen,o=ar(t,n.length);a.has(o)||((!r||!i)&&(r=[...e.events],i=new Set(e.seen)),i.add(o),r.push(t))}return!r||!i?e:(r.length>Ar&&r.splice(0,r.length-Ar).forEach((e,t)=>i.delete(ar(e,t))),{sid:e.sid,events:r,seen:i})}var Mr=new Set([`manager.live_view.updated`,`round.review.completed`,`life.mission.completed`]);function Nr(e){for(let t=e.length-1;t>=0;--t){let n=e[t],r=String(n.type??``);if(Mr.has(r)||r===`engineer.progress`&&n.kind===`file_change`)return ar(n,t)}return``}var Pr=new Set([`life.operator_question.pending`,`life.operator_question.answered`,`life.planner.task_added`,`life.planner.verdict`,`life.mission.started`,`life.mission.completed`,`life.mission.failed`,`round.review.completed`]);function Fr(e){for(let t=e.length-1;t>=0;--t){let n=e[t];if(Pr.has(String(n.type??``)))return ar(n,t)}return``}function Ir(e,t=0){let[n,r]=(0,I.useReducer)(jr,{sid:null,events:[],seen:new Set}),[i,a]=(0,I.useState)({sid:null,connected:!1}),o=(0,I.useRef)(e);return o.current=e,(0,I.useEffect)(()=>{if(r({kind:`reset`,sid:e}),a({sid:e,connected:!1}),!e)return;let t=!1,n=new AbortController,i=[],s,c=()=>{if(s=void 0,t||o.current!==e||i.length===0){i=[];return}let n=i;i=[],r({kind:`push-many`,sid:e,events:n})};U.events(e,120,n.signal).then(n=>{!t&&o.current===e&&r({kind:`seed`,sid:e,events:n})}).catch(()=>{});let l=dt(e,n=>{!t&&o.current===e&&(i.push(n),s===void 0&&(s=window.setTimeout(c,40)))},{replay:40,onOpen:()=>{!t&&o.current===e&&a({sid:e,connected:!0})},onClose:()=>{!t&&o.current===e&&a({sid:e,connected:!1})}});return()=>{t=!0,n.abort(),s!==void 0&&window.clearTimeout(s),i=[],l()}},[e,t]),{events:n.sid===e?n.events:[],connected:i.sid===e&&i.connected}}var Lr=`argus.message.route.v2`;function Rr(){try{let e=localStorage.getItem(Lr);if(e===`auto`||e===`chat`||e===`task`)return e}catch{}return`auto`}var X=v();function zr(e){return!Number.isFinite(e)||e<=0?`$0.00`:e>=100?`$${e.toFixed(0)}`:e>=10?`$${e.toFixed(1)}`:e>=1?`$${e.toFixed(2)}`:`$${e.toFixed(3)}`}function Br({settledUsd:e,knownUsd:t=0,status:n=`empty`}){let r=typeof e==`number`&&Number.isFinite(e)?e:t,i=n===`partial`||n===`unpriced`;return`${zr(Math.max(0,r||0))}${i?`+`:``}`}function Vr({settledUsd:e,knownUsd:t,status:n,calls:r=0,premiumRequests:i=0,live:a=!1,compact:o=!1}){let s=Br({settledUsd:e,knownUsd:t,status:n}),c=[`Cumulative settled project spend`,`${r} model call${r===1?``:`s`}`,i>0?`${i.toFixed(1)} premium requests`:``,n&&n!==`empty`?`pricing: ${n}`:``].filter(Boolean).join(` · `);return(0,X.jsxs)(`span`,{title:c,"aria-label":`Project spend ${s}`,className:`inline-flex shrink-0 items-center rounded-full border border-gold/25 bg-gold/8 font-mono tabular-nums text-gold ${o?`h-6 gap-1 px-2 text-[10px]`:`h-5 gap-1 px-1.5 text-[9px]`}`,children:[a?(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`h-1.5 w-1.5 animate-pulse rounded-full bg-gold/80`}):null,(0,X.jsx)(`span`,{children:s})]})}var Hr=`argus.locale`,Ur={"language.english":`English`,"handshake.connecting":`Getting Argus ready`,"handshake.service":`Service`,"handshake.project":`Project`,"handshake.ready":`Ready`,"handshake.title":`Getting Argus ready`,"handshake.detail":`Reopening your workspace…`,"splash.starting":`Argus starting`,"rail.workbench":`Workbench`,"rail.sessionsShortcut":`Sessions · Ctrl/⌘ P`,"panel.backlog":`Backlog`,"panel.activity":`Activity`,"panel.journal":`Journal`,"panel.roles":`Roles`,"panel.project":`Project`,"panel.liveView":`Manager live project view`,"stream.jumpToLatest":`Jump to latest`,"stream.toggleReasoning":`Show or hide agent reasoning (⌘T)`,"stream.reasoning":`Reasoning`,"stream.noLogs":`No activity yet`,"stream.system":`Argus updates`,"stream.autonomous":`Background activity`,"stream.backgroundWork":`Argus is working in the background`,"stream.ready":`Argus is ready. Ask a question or assign work.`,"newDaemon.workdirPlaceholder":`Blank → ~/.argus-skill/workspaces/`,"operations.resetManager":`Reset Manager context`,"language.chinese":`中文`,"language.switchTo":`Switch to {language}`,"common.loading":`Loading…`,"common.retry":`Retry`,"common.save":`Save`,"common.cancel":`Cancel`,"common.close":`Close`,"common.settings":`Settings`,"common.ready":`Ready`,"common.live":`Live`,"common.reconnecting":`Reconnecting`,"common.stale":`Snapshot stale`,"common.degraded":`Snapshot degraded`,"common.external":`External`,"common.pause":`Pause`,"common.run":`Run`,"common.local":`Local`,"common.all":`All`,"common.unassigned":`Unassigned`,"common.closeSessions":`Close sessions`,"common.resizeSessions":`Resize sessions`,"common.resizePreview":`Resize preview`,"common.expandPreview":`Expand preview`,"time.justNow":`just now`,"time.minutesAgo":`{count}m ago`,"time.hoursAgo":`{count}h ago`,"time.yesterdayAt":`Yesterday at {time}`,"connection.pairingTitle":`This browser is not paired with Argus`,"connection.pairingDetail":`Close this tab and reopen the workbench from Argus Desktop, or open a fresh pairing link.`,"connection.pairAgain":`Pair again`,"connection.pairingInput":`Pairing link or token`,"connection.pairingPlaceholder":`Paste a fresh pairing link or token`,"connection.pairingInvalid":`Enter a valid pairing link or token.`,"connection.connect":`Connect`,"connection.unreachableTitle":`The local Argus service is unavailable`,"connection.unreachableDetail":`Keep Argus Desktop running, wait for the local service to become ready, then retry.`,"sidebar.collapse":`Collapse sessions`,"sidebar.expand":`Expand sessions`,"sidebar.create":`Create session`,"sidebar.find":`Find a session`,"sidebar.clearSearch":`Clear search`,"sidebar.refreshFailed":`Refresh failed · retry`,"sidebar.noSessions":`No sessions`,"sidebar.noMatches":`No sessions matching "{query}"`,"sidebar.unnamedSession":`Unnamed session`,"sidebar.daemonAlive":`Argus running`,"sidebar.updateRequired":`Update required`,"sidebar.updateAvailable":`Update available`,"sidebar.updateAvailableHint":`The executor is still running with a different release from this page.`,"sidebar.stopped":`stopped`,"sidebar.runningFor":`running · {uptime}`,"sidebar.manage":`Manage {name}`,"sidebar.manageHint":`Rename, pause, or delete`,"sidebar.resume":`Resume`,"sidebar.resumeHint":`Resume work in {workdir}`,"sidebar.resumeSuccess":`Session resumed.`,"sidebar.resumeFailed":`Could not resume session: {error}`,"sidebar.modelLoading":`Loading backend and model…`,"sidebar.modelUnavailable":`Backend and model unavailable`,"sidebar.defaultModel":`default model`,"sidebar.openSettings":`Open settings`,"sidebar.theme":`{current} theme; switch to {next}`,"landing.selectOrCreate":`Select a session from the sidebar, or create a new one.`,"landing.noSessions":`No sessions yet. Create one to begin.`,"landing.select":`Select session`,"landing.new":`New session`,"topbar.openSessions":`Open sessions`,"topbar.externallyManaged":`Externally managed`,"topbar.pauseDaemon":`Pause Argus`,"topbar.runDaemon":`Run Argus`,"topbar.roleActive":`{role} is active`,"topbar.roleIdle":`{role} is idle`,"topbar.externalDaemonHint":`Argus is managed outside this app and must be controlled there.`,"topbar.manageSession":`Manage session`,"topbar.showPreview":`Show preview`,"topbar.showActivity":`Show activity`,"mobile.views":`Views`,"mobile.sessions":`Sessions`,"mobile.mission":`Mission`,"mobile.activity":`Activity`,"mobile.workbench":`Workbench`,"mobile.map":`Map`,"mobile.preview":`Preview`,"chat.working":`Argus is working on your message`,"chat.workingQuiet":`Argus is working on your message · Still working; no new update for {quiet}s`,"chat.stopWaitingHint":`Esc stop waiting`,"chat.messageArgus":`message Argus`,"chat.selectSession":`Select a session…`,"chat.placeholder":`Ask a question or assign work`,"chat.routeLabel":`message category`,"chat.routeHint":`Task skips category classification but still uses Manager → Planner → Engineer → Reviewer`,"chat.routeTask":`Task`,"chat.routeAuto":`Auto`,"chat.routeChat":`Chat`,"chat.attach":`attach files`,"chat.attachHint":`PNG, JPEG, WebP, PDF, Markdown/text, JSON, CSV · up to {count} files, {perFile} each, {total} total`,"chat.attachDrop":`Drop files to attach`,"chat.attachRemove":`remove attachment {name}`,"chat.attachUnsupported":`{name} is not supported. Use PNG, JPEG, WebP, PDF, Markdown/text, JSON, or CSV.`,"chat.attachTooLarge":`{name} exceeds the {size} per-file limit.`,"chat.attachTooMany":`You can attach up to {count} files per message.`,"chat.attachTotalTooLarge":`Attachments exceed the {size} total limit.`,"chat.attachmentUploadFailed":`Attachment upload failed: {error}`,"chat.uploadingAttachments":`Uploading attachments`,"chat.rewriteHint":`Let the Manager rewrite this prompt into a brief the team can act on. Nothing is sent — the rewrite lands back in this box for you to edit.`,"chat.rewriteLabel":`rewrite prompt with the Manager`,"chat.rewriting":`rewriting`,"chat.rewrite":`✦ Rewrite`,"chat.stopWaiting":`stop waiting`,"chat.stopWaitingTitle":`stop waiting for this reply; server-side work may continue`,"chat.send":`send message`,"copy.message":`Copy`,"copy.code":`Copy code`,"copy.copied":`Copied`,"help.title":`Keyboard shortcuts`,"help.commands":`Commands`,"help.palette":`command palette`,"help.sessions":`toggle sessions`,"help.managerChat":`focus Manager chat`,"help.rewrite":`rewrite the current prompt before sending`,"help.reasoning":`toggle agent reasoning`,"help.kiosk":`toggle kiosk (read-only) mode`,"help.composer":`focus the composer`,"help.send":`send message`,"help.newline":`insert newline`,"help.thisHelp":`this help`,"help.escape":`close overlay / stop waiting in composer`,"palette.placeholder":`Type a command or search…`,"palette.noMatches":`no matching commands`,"palette.navigate":`↑↓ navigate`,"palette.run":`↵ run`,"palette.close":`esc close`,"palette.view":`View`,"palette.action":`Action`,"palette.project":`Project`,"palette.newDaemon":`New session`,"palette.openTranscript":`Open Transcript`,"palette.openProject":`Open Project`,"palette.projectHint":`work · memory · agents`,"palette.openOperations":`Open Operations`,"palette.operationsHint":`session controls`,"palette.hideReasoning":`Hide reasoning`,"palette.showReasoning":`Show reasoning`,"palette.exitKiosk":`Exit kiosk mode`,"palette.enterKiosk":`Enter kiosk mode`,"palette.messageArgus":`Message Argus…`,"palette.stopWaiting":`Stop waiting for Manager reply`,"palette.stopContinuous":`Stop continuous campaign`,"palette.startContinuous":`Start continuous campaign`,"palette.stopDaemon":`Pause Argus`,"palette.startDaemon":`Run Argus`,"slash.suggestions":`Slash command suggestions`,"mission.roleActive":`{role} active`,"mission.overview":`mission overview`,"mission.operations":`Operations`,"role.manager":`Manager`,"role.planner":`Planner`,"role.engineer":`Engineer`,"role.reviewer":`Reviewer`,"role.critic":`Critic`,"role.system":`Argus`,"role.operator":`You`,"doctor.title":`Doctor`,"doctor.subtitle":`Argus status checks + recommended root-cause fix`,"doctor.recommended":`recommended fix`,"doctor.loadError":`Couldn’t load diagnostics.`,"doctor.empty":`No diagnostic data available`,"doctor.daemonLog":`Daemon log`,"settings.subtitle":`effective roles, budgets, and essential controls`,"settings.loadError":`Couldn’t load configuration.`,"settings.empty":`No configuration found`,"settings.quickConfig":`Quick Config`,"settings.appearance":`Appearance`,"settings.appearanceHint":`Choose the interface colour treatment. Logos and icons always remain monochrome.`,"settings.themeStyle":`Theme colour`,"settings.themeStyle.standard":`Standard`,"settings.themeStyle.standardHint":`Quiet black, white, grey, and blue.`,"settings.themeStyle.gradient":`Gradient`,"settings.themeStyle.gradientHint":`The classic Argus blue-to-gold background.`,"settings.backend":`Backend`,"settings.backendLabel.copilot":`GitHub Copilot`,"settings.backendLabel.codex":`Codex`,"settings.backendLabel.claude":`Claude`,"settings.backendLabel.cursor":`Cursor`,"settings.backendLabel.opencode":`OpenCode`,"settings.backendLabel.pi":`Pi`,"settings.backendLabel.grok":`Grok`,"settings.backendLabel.qoder":`Qoder`,"settings.backendLabel.dsh":`DSH`,"settings.backendSwitched":`Backend saved as {backend}. Restart Argus to apply.`,"settings.backendUnsupported":`Unsupported backend ({backend})`,"settings.backendUnavailable":`Backend unavailable`,"settings.model":`Model`,"settings.applyModel":`Apply`,"settings.modelPlaceholder":`auto (backend default)`,"settings.connection":`Connection`,"settings.webApi":`Web + REST API`,"settings.eventStream":`Live updates`,"settings.taskDaemon":`Background work`,"settings.taskDaemonValue":`Local process · events.jsonl · no TCP port`,"settings.budgetTitle":`Budget and quota limits`,"settings.budgetHint":`Set 0 for an uncapped provider-call limit where supported.`,"settings.saveBudgets":`Save budget limits`,"settings.budget.global":`Host-global daily`,"settings.budget.codex":`Codex calls / day`,"settings.budget.copilot":`Copilot calls / day`,"settings.budget.premium":`Copilot premium / day`,"settings.required":`{field} is required`,"settings.budgetSaved":`Budget limits saved. Restart active sessions to apply their limits.`,"settings.unit.usd":`USD`,"settings.unit.calls":`calls`,"settings.unit.requests":`requests`,"settings.advanced":`Advanced`,"settings.advancedHint":`Connection details, environment overrides, and effective raw configuration`,"settings.overrideTitle":`Environment override`,"settings.overrideHint":`Set a specific config alias or environment-variable key.`,"settings.namePlaceholder":`name or alias, e.g. manager_model`,"settings.valuePlaceholder":`value`,"settings.applyAdvanced":`Apply environment override`,"settings.applied":`Applied. Restart affected sessions to use the new settings.`,"settings.rolesTitle":`Effective roles`,"settings.rawConfig":`Raw configuration`,"settings.group.limits":`Limits`,"settings.group.safety":`Safety`,"settings.group.interface":`Interface`,"settings.knob.activeDaemons":`Active session limit`,"settings.knob.activeDaemonsDoc":`Maximum background sessions running on this host.`,"settings.knob.unpricedCalls":`Calls without pricing`,"settings.knob.unpricedCallsDoc":`Whether calls with unresolved pricing are blocked or allowed.`,"settings.knob.safeMode":`Safe mode`,"settings.knob.safeModeDoc":`Enable extra-conservative runtime guardrails.`,"settings.knob.telegram":`Telegram`,"settings.knob.telegramDoc":`Enable the Telegram notification bridge.`,"settings.knob.showReasoning":`Show reasoning`,"settings.knob.showReasoningDoc":`Stream role reasoning into the activity view.`,"settings.source.notApplicable":`Not applicable for this model`,"settings.source.vaultDefault":`Capability vault / default`,"settings.source.default":`Default`,"settings.source.saved":`Saved override`,"settings.source.environment":`Environment variable`,"settings.source.hostConfig":`Host configuration`,"settings.source.other":`Resolved configuration`,"settings.value.block":`Block calls`,"settings.value.allow":`Allow calls`,"settings.value.enabled":`Enabled`,"settings.value.disabled":`Disabled`,"settings.effort.low":`Low effort`,"settings.effort.medium":`Medium effort`,"settings.effort.high":`High effort`,"settings.effort.xhigh":`Extra-high effort`,"settings.role.curator":`Curator`,"settings.role.managerDoc":`Routes conversations and tasks, and approves reusable skills.`,"settings.role.plannerDoc":`Queues new work and decides when the project is ready to finish.`,"settings.role.engineerDoc":`Writes code and runs commands.`,"settings.role.reviewerDoc":`Reads completed work and decides whether it holds.`,"settings.role.curatorDoc":`Maintains and distills the reusable skill pool.`,"settings.footer":`Human-readable labels are shown with raw keys. The full registry remains available via`,"identity.title":`Identity`,"identity.subtitle":`who argus is working for on this project`,"identity.placeholder":`Describe who Argus is working for and durable preferences…`,"identity.save":`Save identity`,"identity.saved":`Identity saved.`,"transcript.title":`Transcript`,"transcript.subtitle":`recent operator ↔ argus turns · reply from the composer`,"transcript.empty":`no conversation turns yet`,"transcript.operator":`operator`,"new.createDaemon":`Create session`,"new.subtitle":`Creates an isolated timeline and Manager context.`,"new.close":`close create session`,"new.name":`Name`,"new.optional":`(optional)`,"new.namePlaceholder":`e.g. AAAI embodiment paper`,"new.workdir":`Output workdir`,"new.workdirHint":`Agents write code, papers, reports, and experiment outputs here. Internal memory stays under the session state directory.`,"new.objective":`Objective`,"new.objectivePlaceholder":`Leave blank to start with a conversation, or describe a campaign to start immediately.`,"new.startsAfterCreate":`Campaign starts after session creation`,"new.idleUntilMessage":`Idle until the first message`,"new.startsHint":`The session opens immediately while Argus prepares the work in the background.`,"new.idleHint":`Background work starts after your first message, when needed.`,"new.shortcut":`Ctrl/⌘+Enter to create`,"new.creating":`Creating…`,"new.createAndStart":`Create and start`,"manage.daemon":`Manage session`,"manage.displayName":`Display name`,"manage.executor":`Background work`,"manage.running":`Running`,"manage.runningExternally":`Running externally`,"manage.paused":`Stopped`,"manage.pauseHint":`Interrupt the current operation and keep progress resumable.`,"manage.stopNow":`Stop now`,"manage.stopNowHint":`Immediately interrupt this verified daemon so the session can be deleted.`,"manage.externalHint":`This session is managed outside this app.`,"manage.resumeHint":`Resume queued research work.`,"manage.working":`Working…`,"manage.resume":`Resume`,"manage.deleteSession":`Delete session`,"manage.deleteHint":`Deleted sessions move to the trash and remain recoverable. Stop background work first.`,"manage.delete":`Delete…`,"manage.confirmQuestion":`Move this session to trash?`,"manage.confirmDelete":`Confirm delete`,"decision.operator":`Operator decision`,"decision.required":`Decision required`,"decision.whyBlocked":`Why work is blocked`,"decision.evidence":`Evidence`,"decision.notePlaceholder":`Add the guidance the Manager should apply…`,"decision.resumeHint":`The Manager applies your choice before work resumes.`,"decision.later":`Later`,"decision.applying":`Applying…`,"decision.stopCampaign":`Stop campaign`,"decision.useOption":`Use this option`,"decision.sendAnswer":`Send answer`,"decision.noteRequired":`Add the required details before sending this choice.`,"artifact.preview":`Result preview`,"artifact.title":`Result`,"artifact.approvedEvidence":`evidence the Reviewer has checked`,"artifact.downloading":`Downloading…`,"artifact.download":`Download`,"artifact.open":`Open`,"artifact.close":`close result preview`,"artifact.unavailable":`preview unavailable`,"artifact.empty":`(empty file)`,"artifact.truncated":`preview truncated · download to inspect the complete file`,"artifact.htmlTooLarge":`HTML preview is too large to render safely. Download the complete file.`,"artifact.pdfDisabled":`Inline PDF preview is disabled by this browser.`,"artifact.openPdf":`Open PDF`,"artifact.noPreview":`This file type has no safe inline preview.`,"artifact.downloadHint":`Download it to inspect with a local application.`,"task.details":`Task details`,"task.stopLoop":`stop loop`,"task.done":`done`,"task.skip":`skip`,"task.close":`close task details`,"task.waitingOnYou":`Waiting on you`,"task.objective":`Objective`,"task.noObjective":`(no objective recorded)`,"task.untitled":`Untitled task`,"task.priority":`priority`,"task.started":`started`,"task.finished":`finished`,"task.outcome":`Outcome`,"task.iteration":`Iteration`,"task.mode":`mode`,"task.autoIterate":`auto-iterate`,"task.singlePass":`single pass`,"task.cycles":`cycles`,"task.cost":`cost`,"task.lastError":`Last error`,"task.notes":`Notes`,"task.dependsOn":`depends on`,"task.dependsOnCount":`Depends on {count} earlier tasks`,"pending.reviewRespond":`Review and respond`,"pending.showOnMap":`Show on map`,"backlog.active":`Active · {count}`,"backlog.history":`History · {count}`,"backlog.noHistory":`No completed work yet`,"backlog.empty":`Nothing queued. Argus is ready for new work.`,"backlog.viewDetails":`View full task details`,"backlog.iterating":`Repeating`,"backlog.stopIterating":`Stop repeating`,"backlog.stop":`Stop`,"backlog.markDone":`Mark done`,"backlog.remove":`Remove`,"mission.achievement":`Argus achievement`,"mission.elapsed":`Elapsed`,"mission.rejectedAttempts":`{count} rejected attempts`,"mission.skillsLearned":`{count} skills learned`,"mission.artifacts":`{count} files produced`,"mission.waiting":`Waiting for a mission`,"mission.statusActive":`{role} — {work}`,"mission.statusWaiting":`Ready when you are — assign a mission to begin.`,"mission.statusDone":`{outcome} — finished in {elapsed}.`,"mission.continuousDone":`Continuous run finished`,"mission.resumeContinuous":`Resume`,"mission.control":`Mission control`,"mission.attentionHealth":`System error — health is degraded.`,"mission.attentionFailed":`Mission failed — check the task below.`,"mission.deliveryFailed":`Task failed at delivery — execution could not start or finish.`,"mission.attentionStepFailed":`A step failed — check the task below.`,"mission.attentionPaused":`Mission is paused — waiting for your input.`,"mission.showObjective":`Show full objective`,"mission.showFullOutput":`View full output`,"mission.stage":`Stage`,"mission.campaign":`Campaign`,"mission.totalElapsed":`Total elapsed`,"mission.round":`Round`,"mission.mode":`Mode`,"mission.summary":`Mission summary`,"mission.deliveryCertified":`Delivery approved`,"mission.taskCompleted":`Task completed`,"mission.openResult":`Open result`,"mission.viewTask":`View task`,"mission.taskPlan":`Task plan`,"mission.team":`AI research team`,"mission.waitingShort":`Waiting`,"mission.roleWork":`Role work`,"mission.showMore":`Show more`,"mission.showLess":`Show less`,"mission.done":`Done`,"mission.inProgress":`In progress`,"mission.failed":`Failed`,"mission.bannerPaused":`Mission is paused — waiting for your input.`,"mission.bannerError":`System error — health is degraded.`,"mission.bannerStepFailed":`A step failed: {step}`,"mission.elapsedAgo":`{elapsed} ago`,"mission.filteredBy":`filtered by {task} · clear`,"mission.allVisible":`all visible missions`,"mission.roundNumber":`round {count}`,"mission.noRoleWork":`No persisted {role} work for this selection yet.`,"mission.researchDag":`Task route`,"mission.active":`active`,"mission.noDag":`The Planner has not added tasks to the route yet.`,"mission.workingHypothesis":`Working hypothesis · can be revised`,"mission.goalContribution":`How this supports the goal`,"mission.temporaryRegressions":`Expected temporary tradeoffs`,"mission.decisionRule":`When to revise, split, or stop`,"mission.acceptance":`What counts as done`,"mission.nonGoals":`Non-goals`,"mission.capabilities":`Capabilities`,"mission.capabilitiesUnlocked":`Capabilities unlocked`,"mission.learnedCapability":`Learned capability`,"mission.learnedDuring":`Learned during {mission}`,"mission.skillUnavailable":`Skill content is not available in this snapshot.`,"mission.contentTruncated":`Content preview truncated`,"mission.knowledgeRetained":`Knowledge retained`,"mission.selfEvolution":`Saved project knowledge`,"mission.knowledgeSaved":`Argus saved these capabilities and notes for future work on this project.`,"mission.noCapabilities":`No capabilities learned yet.`,"mission.replay":`Mission replay`,"mission.replayTimeline":`Replay mission timeline`,"mission.roleFailed":`{role} failed`,"mission.showingLatestEvent":`Showing latest event`,"mission.showingLastEvents":`Showing last {count} events`,"mission.waitingEvents":`Waiting for structured research events.`,"mission.startsAfter":`Starts after {count} earlier tasks`,"mission.hiddenTasks":`{count} earlier tasks hidden · {failed} blocked or failed · {skipped} skipped`,"mission.projectFilesChanged":`Project files changed`,"mission.reviewInIde":`Open the IDE to review the diff`,"research.currentWork":`Current work`,"research.dagProgress":`Task route progress`,"research.verifiedOutputs":`Verified outputs`,"research.recentMilestones":`Recent milestones`,"research.liveProgress":`Live progress`,"research.artifact":`Research result`,"research.canvas":`Manager live research canvas`,"research.previewArtifact":`Preview the result`,"research.openLarge":`Open large preview`,"research.collapse":`Collapse preview`,"research.unavailable":`Manager live view is temporarily unavailable.`,"research.noPreview":`No preview`,"research.waiting":`Waiting…`,"research.updating":`Updating…`,"research.fileUnavailable":`Preview unavailable for this file.`,"research.eventSourced":`event-sourced mission state`,"research.downloadFailed":`download failed`,"operations.title":`Operations`,"operations.work":`Work`,"operations.runtime":`Runtime`,"operations.system":`System`,"operations.recovery":`Recovery`,"operations.workInput":`Work input`,"operations.workHint":`Queue work, guide the active task, save a note, or preview a plan without dispatching it.`,"operations.action.task":`Task`,"operations.action.nudge":`Guide`,"operations.action.note":`Note`,"operations.action.plan":`Plan`,"operations.planPlaceholder":`Objective to preview; preview never queues work`,"operations.actionPlaceholder":`{action} text`,"operations.previewPlan":`Preview plan`,"operations.submitAction":`Submit {action}`,"operations.runtimeHint":`Change where this session runs, reset Manager context, or safely restart the session.`,"operations.workdir":`Working directory`,"operations.workdirUpdated":`Working directory updated.`,"operations.applyWorkdir":`Apply working directory`,"operations.replaceSlot":`Replace an active session`,"operations.sourceUpdate":`Argus source version`,"operations.pullLatest":`Pull latest version`,"operations.updateChecking":`Checking published branch…`,"operations.updateRunning":`Updating…`,"operations.updateAvailable":`Update available`,"operations.updateCurrent":`Up to date`,"operations.updateUnavailable":`This checkout cannot be updated safely.`,"operations.currentRevision":`Current`,"operations.latestRevision":`Latest`,"operations.updatePhase":`Phase`,"operations.updateRestart":`Source updated. Restart the cockpit, then use the reload button to move active daemons to the new release at a safe task boundary.`,"operations.skills":`Skills`,"operations.runSkill":`Run skill command`,"operations.metrics":`System metrics`,"operations.trash":`Recoverable trash`,"operations.searchTrash":`Search trash`,"operations.trashEmpty":`Trash is empty.`,"resource.title":`Resources`,"resource.loading":`Loading resource status…`,"resource.devices":`Devices: {count}`,"resource.inUse":`In use · {count}`,"resource.queue":`Queue · {count}`,"resource.none":`None`,"resource.timeLeft":`{ttl} left`,"resource.noIntent":`No purpose recorded`,"resource.yieldRequest":`Resource release requested · {reason}`,"resource.queuePosition":`Queue position {position}`,"label.status.inProgress":`In progress`,"label.status.waiting":`Waiting`,"label.status.completed":`Completed`,"label.status.blocked":`Blocked`,"label.status.failed":`Failed`,"label.status.needsChanges":`Needs changes`,"label.status.skipped":`Skipped`,"label.status.paused":`Paused`,"label.status.available":`Available`,"label.status.unavailable":`Unavailable`,"label.status.inaccessible":`Not accessible`,"label.status.limited":`Limited`,"label.status.healthy":`Healthy`,"label.status.updated":`Status updated`,"label.role.manager":`Manager`,"label.role.planner":`Planner`,"label.role.engineer":`Engineer`,"label.role.reviewer":`Reviewer`,"label.role.argus":`Argus`,"label.role.you":`You`,"label.work.task":`Task`,"label.work.action":`Work step`,"label.work.handoff":`Notes for the next step`,"label.work.review":`Review`,"label.work.planning":`Planning`,"label.work.update":`Update`,"label.stage.scope":`Scope`,"label.stage.research":`Research`,"label.stage.implementation":`Implementation`,"label.stage.experiment":`Experiments`,"label.stage.analysis":`Analysis`,"label.stage.writing":`Writing`,"label.stage.review":`Final review`,"label.stage.delivery":`Delivery`,"label.stage.unstaged":`Unstaged`,"label.frontier.reopened":`An earlier task was reopened`,"label.frontier.added":`A new task was added`,"label.frontier.completed":`A task path was completed`,"label.frontier.revised":`The task plan was revised`,"label.frontier.narrowed":`The task scope was narrowed`,"label.frontier.expanded":`The task scope was expanded`,"label.frontier.updated":`The task plan was updated`,"label.priority":`Priority {priority}`,"label.outcome.workCompleted":`Work completed`,"label.outcome.workPaused":`Work paused`,"label.outcome.workBlocked":`Work blocked`,"label.outcome.workFailed":`Work failed`,"label.outcome.workEnded":`Work ended`,"label.outcome.workIncomplete":`Work incomplete`,"label.outcome.workStalled":`Work stalled`,"label.outcome.workUpdated":`Work status updated`,"label.outcome.reviewPassed":`Review passed`,"label.outcome.reviewNeedsChanges":`Review requested changes`,"label.outcome.reviewBlocked":`Review blocked`,"label.outcome.reviewOutdated":`Review is out of date`,"label.outcome.reviewPending":`Review pending`,"label.outcome.stageApproved":`Stage approved`,"label.outcome.stageNotApproved":`Stage not approved`,"label.outcome.stageRevoked":`Stage approval revoked`,"label.outcome.stageNotNeeded":`Stage decision not needed`,"label.outcome.stagePending":`Stage decision pending`,"label.outcome.budgetPaused":`Paused by budget limit`,"label.outcome.waitingForYou":`Waiting for your response`,"label.outcome.stoppedByYou":`Stopped by you`,"label.outcome.pausedByYou":`Paused by you`,"label.outcome.sessionPaused":`Session paused`,"label.outcome.serviceUnavailable":`Service unavailable`,"label.outcome.serviceCoolingDown":`Service temporarily paused`,"label.outcome.temporaryIssue":`Paused by a temporary issue`,"label.outcome.serviceError":`Stopped by a service error`,"label.outcome.needsPlan":`A new plan is needed`,"label.outcome.canResume":`Can resume`,"label.routing.team":`Team workflow`,"label.routing.individual":`Individual workflow`,"label.routing.research":`Research`,"label.routing.software":`Software work`,"label.routing.staged":`Step by step`,"label.routing.flexible":`Flexible workflow`,"label.routing.ongoing":`Ongoing`,"label.routing.defined":`Defined scope`,"label.resource.nvidiaGpu":`NVIDIA GPU`,"label.resource.amdGpu":`AMD GPU`,"label.resource.appleGpu":`Apple GPU`,"label.resource.cpu":`CPU`,"label.resource.accelerator":`Accelerator`,"label.resource.enforced":`Limits enforced`,"label.resource.advisory":`Recommendations only`,"label.resource.released":`Resources released`,"label.resource.kept":`Resources kept`},Wr={"language.english":`English`,"handshake.connecting":`正在准备 Argus`,"handshake.service":`服务`,"handshake.project":`项目`,"handshake.ready":`就绪`,"handshake.title":`正在准备 Argus`,"handshake.detail":`正在恢复你的工作区…`,"splash.starting":`Argus 启动中`,"rail.workbench":`工作台`,"rail.sessionsShortcut":`会话 · Ctrl/⌘ P`,"panel.backlog":`待办`,"panel.activity":`动态`,"panel.journal":`日志`,"panel.roles":`角色`,"panel.project":`项目`,"panel.liveView":`Manager 实时项目视图`,"stream.jumpToLatest":`跳到最新`,"stream.toggleReasoning":`显示或隐藏 Agent 推理(⌘T)`,"stream.reasoning":`推理`,"stream.noLogs":`暂无活动`,"stream.system":`Argus 动态`,"stream.autonomous":`后台活动`,"stream.backgroundWork":`Argus 正在后台工作`,"stream.ready":`Argus 已就绪。你可以提问或安排下一项工作。`,"newDaemon.workdirPlaceholder":`留空 → ~/.argus-skill/workspaces/`,"operations.resetManager":`重置 Manager 上下文`,"language.chinese":`中文`,"language.switchTo":`切换到{language}`,"common.loading":`加载中…`,"common.retry":`重试`,"common.save":`保存`,"common.cancel":`取消`,"common.close":`关闭`,"common.settings":`设置`,"common.ready":`就绪`,"common.live":`实时`,"common.reconnecting":`正在重连`,"common.stale":`快照已过期`,"common.degraded":`快照异常`,"common.external":`外部`,"common.pause":`暂停`,"common.run":`运行`,"common.local":`本地`,"common.all":`全部`,"common.unassigned":`未分配`,"common.closeSessions":`关闭会话列表`,"common.resizeSessions":`调整会话列表宽度`,"common.resizePreview":`调整预览区域宽度`,"common.expandPreview":`展开预览`,"time.justNow":`刚刚`,"time.minutesAgo":`{count}分钟前`,"time.hoursAgo":`{count}小时前`,"time.yesterdayAt":`昨天 {time}`,"connection.pairingTitle":`此浏览器尚未与 Argus 配对`,"connection.pairingDetail":`请关闭此标签页,然后从 Argus Desktop 重新打开工作台,或使用新的配对链接。`,"connection.pairAgain":`重新配对`,"connection.pairingInput":`配对链接或令牌`,"connection.pairingPlaceholder":`粘贴新的配对链接或令牌`,"connection.pairingInvalid":`请输入有效的配对链接或令牌。`,"connection.connect":`连接`,"connection.unreachableTitle":`Argus 本地服务当前不可达`,"connection.unreachableDetail":`请保持 Argus Desktop 运行,等待本地服务就绪后再重试。`,"sidebar.collapse":`收起会话`,"sidebar.expand":`展开会话`,"sidebar.create":`创建会话`,"sidebar.find":`查找会话`,"sidebar.clearSearch":`清除搜索`,"sidebar.refreshFailed":`刷新失败 · 重试`,"sidebar.noSessions":`暂无会话`,"sidebar.noMatches":`没有匹配"{query}"的会话`,"sidebar.unnamedSession":`未命名会话`,"sidebar.daemonAlive":`Argus 运行中`,"sidebar.updateRequired":`需要更新`,"sidebar.updateAvailable":`可更新`,"sidebar.updateAvailableHint":`后台仍在运行,执行器与网页版本不同。`,"sidebar.stopped":`已停止`,"sidebar.runningFor":`运行中 · {uptime}`,"sidebar.manage":`管理 {name}`,"sidebar.manageHint":`重命名、暂停或删除`,"sidebar.resume":`继续`,"sidebar.resumeHint":`在 {workdir} 中继续工作`,"sidebar.resumeSuccess":`会话已恢复。`,"sidebar.resumeFailed":`无法恢复会话:{error}`,"sidebar.modelLoading":`正在加载后端和模型…`,"sidebar.modelUnavailable":`后端和模型信息不可用`,"sidebar.defaultModel":`默认模型`,"sidebar.openSettings":`打开设置`,"sidebar.theme":`{current}主题;切换到{next}主题`,"landing.selectOrCreate":`从侧边栏选择一个会话,或创建新会话。`,"landing.noSessions":`还没有会话。创建一个即可开始。`,"landing.select":`选择会话`,"landing.new":`新建会话`,"topbar.openSessions":`打开会话列表`,"topbar.externallyManaged":`由外部管理`,"topbar.pauseDaemon":`暂停 Argus`,"topbar.runDaemon":`运行 Argus`,"topbar.roleActive":`{role} 活跃中`,"topbar.roleIdle":`{role} 空闲`,"topbar.externalDaemonHint":`Argus 由此应用之外的服务管理,请前往相应位置控制。`,"topbar.manageSession":`管理会话`,"topbar.showPreview":`显示预览`,"topbar.showActivity":`显示动态`,"mobile.views":`视图`,"mobile.sessions":`会话`,"mobile.mission":`任务`,"mobile.activity":`动态`,"mobile.workbench":`工作台`,"mobile.map":`地图`,"mobile.preview":`预览`,"chat.working":`Argus 正在处理你的消息`,"chat.workingQuiet":`Argus 正在处理你的消息 · 仍在处理中,{quiet} 秒暂无新进展`,"chat.stopWaitingHint":`按 Esc 停止等待`,"chat.messageArgus":`向 Argus 发送消息`,"chat.selectSession":`请选择会话…`,"chat.placeholder":`提问或安排工作`,"chat.routeLabel":`消息类型`,"chat.routeHint":`任务模式跳过消息分类,但仍严格经过 Manager → Planner → Engineer → Reviewer`,"chat.routeTask":`任务`,"chat.routeAuto":`自动`,"chat.routeChat":`对话`,"chat.attach":`添加文件`,"chat.attachHint":`支持 PNG、JPEG、WebP、PDF、Markdown/文本、JSON、CSV · 每条消息最多 {count} 个文件,单个 {perFile},总计 {total}`,"chat.attachDrop":`拖放文件以添加附件`,"chat.attachRemove":`移除附件 {name}`,"chat.attachUnsupported":`{name} 不受支持。请使用 PNG、JPEG、WebP、PDF、Markdown/文本、JSON 或 CSV。`,"chat.attachTooLarge":`{name} 超过单文件大小限制 {size}。`,"chat.attachTooMany":`每条消息最多只能附带 {count} 个文件。`,"chat.attachTotalTooLarge":`附件总大小超过 {size} 限制。`,"chat.attachmentUploadFailed":`附件上传失败:{error}`,"chat.uploadingAttachments":`正在上传附件`,"chat.rewriteHint":`让 Manager 将提示词改写为团队可执行的任务说明。不会直接发送,改写结果会回到输入框供你编辑。`,"chat.rewriteLabel":`使用 Manager 改写提示词`,"chat.rewriting":`正在改写`,"chat.rewrite":`✦ 改写`,"chat.stopWaiting":`停止等待`,"chat.stopWaitingTitle":`停止等待此回复;服务端工作可能仍会继续`,"chat.send":`发送消息`,"copy.message":`复制`,"copy.code":`复制代码`,"copy.copied":`已复制`,"help.title":`键盘快捷键`,"help.commands":`命令`,"help.palette":`打开命令面板`,"help.sessions":`展开或收起会话`,"help.managerChat":`聚焦 Manager 对话框`,"help.rewrite":`发送前改写当前提示词`,"help.reasoning":`显示或隐藏 Agent 推理`,"help.kiosk":`切换只读展示模式`,"help.composer":`聚焦输入框`,"help.send":`发送消息`,"help.newline":`插入换行`,"help.thisHelp":`打开此帮助`,"help.escape":`关闭浮层或停止等待`,"palette.placeholder":`输入命令或搜索…`,"palette.noMatches":`没有匹配的命令`,"palette.navigate":`↑↓ 导航`,"palette.run":`↵ 执行`,"palette.close":`Esc 关闭`,"palette.view":`视图`,"palette.action":`操作`,"palette.project":`项目`,"palette.newDaemon":`新建会话`,"palette.openTranscript":`打开对话记录`,"palette.openProject":`打开项目`,"palette.projectHint":`工作 · 记忆 · Agent`,"palette.openOperations":`打开运行控制`,"palette.operationsHint":`会话控制`,"palette.hideReasoning":`隐藏推理`,"palette.showReasoning":`显示推理`,"palette.exitKiosk":`退出展示模式`,"palette.enterKiosk":`进入展示模式`,"palette.messageArgus":`向 Argus 发送消息…`,"palette.stopWaiting":`停止等待 Manager 回复`,"palette.stopContinuous":`停止持续任务`,"palette.startContinuous":`启动持续任务`,"palette.stopDaemon":`暂停 Argus`,"palette.startDaemon":`运行 Argus`,"slash.suggestions":`Slash 命令建议`,"mission.roleActive":`{role} 正在工作`,"mission.overview":`任务概览`,"mission.operations":`运行控制`,"role.manager":`Manager`,"role.planner":`Planner`,"role.engineer":`Engineer`,"role.reviewer":`Reviewer`,"role.critic":`Critic`,"role.system":`Argus`,"role.operator":`你`,"doctor.title":`诊断`,"doctor.subtitle":`Argus 状态检查与推荐的根因修复方案`,"doctor.recommended":`推荐修复`,"doctor.loadError":`无法加载诊断数据。`,"doctor.empty":`诊断暂无数据`,"doctor.daemonLog":`后台进程日志`,"settings.subtitle":`生效中的角色、预算和关键控制项`,"settings.loadError":`无法加载配置。`,"settings.empty":`未找到配置`,"settings.quickConfig":`快速配置`,"settings.appearance":`外观`,"settings.appearanceHint":`选择界面主题色。Logo 与图标始终保持黑白,不参与渐变。`,"settings.themeStyle":`主题色`,"settings.themeStyle.standard":`标准`,"settings.themeStyle.standardHint":`克制的黑、白、灰与蓝色。`,"settings.themeStyle.gradient":`渐变`,"settings.themeStyle.gradientHint":`经典 Argus 蓝金渐变背景。`,"settings.backend":`后端`,"settings.backendLabel.copilot":`GitHub Copilot`,"settings.backendLabel.codex":`Codex`,"settings.backendLabel.claude":`Claude`,"settings.backendLabel.cursor":`Cursor`,"settings.backendLabel.opencode":`OpenCode`,"settings.backendLabel.pi":`Pi`,"settings.backendLabel.grok":`Grok`,"settings.backendLabel.qoder":`Qoder`,"settings.backendLabel.dsh":`DSH`,"settings.backendSwitched":`后端已保存为{backend}。重启 Argus 后生效。`,"settings.backendUnsupported":`不支持的后端({backend})`,"settings.backendUnavailable":`后端信息不可用`,"settings.model":`模型`,"settings.applyModel":`应用`,"settings.modelPlaceholder":`auto(后端默认模型)`,"settings.connection":`连接`,"settings.webApi":`Web + REST API`,"settings.eventStream":`实时动态`,"settings.taskDaemon":`后台工作`,"settings.taskDaemonValue":`本地进程 · events.jsonl · 无 TCP 端口`,"settings.budgetTitle":`预算和配额限制`,"settings.budgetHint":`支持时,将调用限制设为 0 表示不设上限。`,"settings.saveBudgets":`保存预算限制`,"settings.budget.global":`主机全局每日预算`,"settings.budget.codex":`Codex 每日调用`,"settings.budget.copilot":`Copilot 每日调用`,"settings.budget.premium":`Copilot 每日 Premium 请求`,"settings.required":`必须填写{field}`,"settings.budgetSaved":`预算限制已保存。请重启活动会话以应用限制。`,"settings.unit.usd":`美元`,"settings.unit.calls":`次调用`,"settings.unit.requests":`次请求`,"settings.advanced":`高级设置`,"settings.advancedHint":`连接详情、环境变量覆盖和生效中的原始配置`,"settings.overrideTitle":`环境变量覆盖`,"settings.overrideHint":`设置特定的配置别名或环境变量键。`,"settings.namePlaceholder":`名称或别名,例如 manager_model`,"settings.valuePlaceholder":`值`,"settings.applyAdvanced":`应用环境变量覆盖`,"settings.applied":`设置已应用。请重启受影响的会话以使用新设置。`,"settings.rolesTitle":`生效中的角色`,"settings.rawConfig":`原始配置`,"settings.group.limits":`限制`,"settings.group.safety":`安全`,"settings.group.interface":`界面`,"settings.knob.activeDaemons":`活动会话上限`,"settings.knob.activeDaemonsDoc":`此主机上可同时运行的后台会话数量上限。`,"settings.knob.unpricedCalls":`未定价调用`,"settings.knob.unpricedCallsDoc":`未能确定价格的调用是阻止还是允许。`,"settings.knob.safeMode":`安全模式`,"settings.knob.safeModeDoc":`启用更保守的运行时保护措施。`,"settings.knob.telegram":`Telegram`,"settings.knob.telegramDoc":`启用 Telegram 通知桥接。`,"settings.knob.showReasoning":`显示推理`,"settings.knob.showReasoningDoc":`在活动视图中显示角色推理过程。`,"settings.source.notApplicable":`不适用于此模型`,"settings.source.vaultDefault":`能力库 / 默认值`,"settings.source.default":`默认值`,"settings.source.saved":`已保存的覆盖值`,"settings.source.environment":`环境变量`,"settings.source.hostConfig":`主机配置`,"settings.source.other":`解析后的配置`,"settings.value.block":`阻止调用`,"settings.value.allow":`允许调用`,"settings.value.enabled":`已启用`,"settings.value.disabled":`已停用`,"settings.effort.low":`低推理强度`,"settings.effort.medium":`中等推理强度`,"settings.effort.high":`高推理强度`,"settings.effort.xhigh":`超高推理强度`,"settings.role.curator":`知识维护`,"settings.role.managerDoc":`分流对话和任务,并批准可复用技能。`,"settings.role.plannerDoc":`安排后续工作,并判断项目何时可以收尾。`,"settings.role.engineerDoc":`编写代码并运行命令。`,"settings.role.reviewerDoc":`审读已完成的工作,判断其是否成立。`,"settings.role.curatorDoc":`维护并提炼可复用技能库。`,"settings.footer":`配置项同时显示易读标签和原始键。完整配置仍可通过以下命令查看:`,"identity.title":`身份`,"identity.subtitle":`本项目中 Argus 服务的对象`,"identity.placeholder":`描述 Argus 正在为谁工作,以及需要长期遵循的偏好…`,"identity.save":`保存身份`,"identity.saved":`身份已保存。`,"transcript.title":`对话记录`,"transcript.subtitle":`近期操作者 ↔ Argus 对话 · 请从输入框继续回复`,"transcript.empty":`暂无对话记录`,"transcript.operator":`操作者`,"new.createDaemon":`创建会话`,"new.subtitle":`创建隔离的时间线和 Manager 上下文。`,"new.close":`关闭创建会话窗口`,"new.name":`名称`,"new.optional":`(可选)`,"new.namePlaceholder":`例如:AAAI 具身智能论文`,"new.workdir":`输出工作目录`,"new.workdirHint":`Agent 会在这里写入代码、论文、报告和实验结果。内部记忆仍保存在会话状态目录中。`,"new.objective":`目标`,"new.objectivePlaceholder":`留空则从对话开始,也可以填写一个立即启动的持续任务。`,"new.startsAfterCreate":`创建会话后立即启动任务`,"new.idleUntilMessage":`收到第一条消息前保持空闲`,"new.startsHint":`会话会立即打开,Argus 将在后台准备相关工作。`,"new.idleHint":`收到第一条消息后,Argus 会按需启动后台工作。`,"new.shortcut":`按 Ctrl/⌘+Enter 创建`,"new.creating":`正在创建…`,"new.createAndStart":`创建并启动`,"manage.daemon":`管理会话`,"manage.displayName":`显示名称`,"manage.executor":`后台工作`,"manage.running":`运行中`,"manage.runningExternally":`由外部运行`,"manage.paused":`未运行`,"manage.pauseHint":`中断当前操作并保留可恢复的进度。`,"manage.stopNow":`立即停止`,"manage.stopNowHint":`立即中断这个已验证的 daemon,停止后即可删除会话。`,"manage.externalHint":`此会话由此应用之外的服务管理。`,"manage.resumeHint":`继续执行队列中的研究工作。`,"manage.working":`处理中…`,"manage.resume":`继续`,"manage.deleteSession":`删除会话`,"manage.deleteHint":`删除的会话会移入回收站,之后仍可恢复。请先停止后台工作。`,"manage.delete":`删除…`,"manage.confirmQuestion":`将此会话移入回收站?`,"manage.confirmDelete":`确认删除`,"decision.operator":`操作者决策`,"decision.required":`需要你的决策`,"decision.whyBlocked":`工作被阻塞的原因`,"decision.evidence":`证据`,"decision.notePlaceholder":`添加 Manager 应采用的指导…`,"decision.resumeHint":`Manager 会在恢复工作前应用你的选择。`,"decision.later":`稍后处理`,"decision.applying":`正在应用…`,"decision.stopCampaign":`停止持续任务`,"decision.useOption":`使用此选项`,"decision.sendAnswer":`发送回答`,"decision.noteRequired":`这个选项需要补充说明后才能提交。`,"artifact.preview":`结果预览`,"artifact.title":`结果`,"artifact.approvedEvidence":`Reviewer 已核实的证据`,"artifact.downloading":`正在下载…`,"artifact.download":`下载`,"artifact.open":`打开`,"artifact.close":`关闭结果预览`,"artifact.unavailable":`无法预览`,"artifact.empty":`(空文件)`,"artifact.truncated":`预览已截断 · 请下载完整文件查看`,"artifact.htmlTooLarge":`HTML 文件过大,无法安全预览。请下载完整文件。`,"artifact.pdfDisabled":`此浏览器已禁用内嵌 PDF 预览。`,"artifact.openPdf":`打开 PDF`,"artifact.noPreview":`此文件类型无法安全地在线预览。`,"artifact.downloadHint":`请下载后使用本地应用查看。`,"task.details":`任务详情`,"task.stopLoop":`停止循环`,"task.done":`完成`,"task.skip":`跳过`,"task.close":`关闭任务详情`,"task.waitingOnYou":`等待你的回复`,"task.objective":`目标`,"task.noObjective":`(未记录目标)`,"task.untitled":`未命名任务`,"task.priority":`优先级`,"task.started":`开始时间`,"task.finished":`完成时间`,"task.outcome":`结果`,"task.iteration":`迭代`,"task.mode":`模式`,"task.autoIterate":`自动迭代`,"task.singlePass":`单次执行`,"task.cycles":`轮次`,"task.cost":`成本`,"task.lastError":`最近错误`,"task.notes":`备注`,"task.dependsOn":`依赖`,"task.dependsOnCount":`依赖前置任务 {count} 项`,"pending.reviewRespond":`查看并回复`,"pending.showOnMap":`在地图上查看`,"backlog.active":`进行中 · {count}`,"backlog.history":`历史记录 · {count}`,"backlog.noHistory":`暂无已完成工作`,"backlog.empty":`队列中没有工作。Argus 已准备好接收新任务。`,"backlog.viewDetails":`查看完整任务详情`,"backlog.iterating":`重复执行中`,"backlog.stopIterating":`停止重复执行`,"backlog.stop":`停止`,"backlog.markDone":`标记为完成`,"backlog.remove":`移除`,"mission.achievement":`Argus 成果`,"mission.elapsed":`耗时`,"mission.rejectedAttempts":`{count} 次方案被拒绝`,"mission.skillsLearned":`学习了 {count} 个 Skill`,"mission.artifacts":`产出 {count} 个文件`,"mission.waiting":`等待任务`,"mission.statusActive":`{role} — {work}`,"mission.statusWaiting":`已准备就绪,请分配一个任务开始工作。`,"mission.statusDone":`{outcome} — 用时 {elapsed}。`,"mission.continuousDone":`连续运行已完成`,"mission.resumeContinuous":`恢复`,"mission.control":`任务控制`,"mission.attentionHealth":`系统出错——运行状态异常。`,"mission.attentionFailed":`任务失败——请查看下方详情。`,"mission.deliveryFailed":`任务在交付阶段失败——执行未能启动或完成。`,"mission.attentionStepFailed":`有一个步骤失败——请查看下方任务。`,"mission.attentionPaused":`任务已暂停——正在等待你的输入。`,"mission.showObjective":`显示完整目标`,"mission.showFullOutput":`查看完整输出`,"mission.stage":`阶段`,"mission.campaign":`持续任务`,"mission.totalElapsed":`总耗时`,"mission.round":`轮次`,"mission.mode":`模式`,"mission.summary":`本次完成`,"mission.deliveryCertified":`交付成果已通过审核`,"mission.taskCompleted":`任务已完成`,"mission.openResult":`打开成果`,"mission.viewTask":`查看任务`,"mission.taskPlan":`任务计划`,"mission.team":`AI 研究团队`,"mission.waitingShort":`等待中`,"mission.roleWork":`角色工作`,"mission.showMore":`显示更多`,"mission.showLess":`收起`,"mission.done":`已完成`,"mission.inProgress":`进行中`,"mission.failed":`失败`,"mission.bannerPaused":`任务已暂停 — 等待你的操作。`,"mission.bannerError":`系统异常 — 健康状态已降级。`,"mission.bannerStepFailed":`某步骤失败:{step}`,"mission.elapsedAgo":`{elapsed} 前`,"mission.filteredBy":`按 {task} 筛选 · 清除`,"mission.allVisible":`全部可见任务`,"mission.roundNumber":`第 {count} 轮`,"mission.noRoleWork":`当前筛选下还没有持久化的 {role} 工作记录。`,"mission.researchDag":`任务路线`,"mission.active":`进行中`,"mission.noDag":`Planner 尚未向路线中添加任务。`,"mission.workingHypothesis":`当前假设 · 可随证据调整`,"mission.goalContribution":`对目标的作用`,"mission.temporaryRegressions":`预期的暂时取舍`,"mission.decisionRule":`何时调整、拆分或停止`,"mission.acceptance":`完成的标准`,"mission.nonGoals":`非目标`,"mission.capabilities":`能力`,"mission.capabilitiesUnlocked":`已解锁能力`,"mission.learnedCapability":`已学习能力`,"mission.learnedDuring":`在“{mission}”期间学习`,"mission.skillUnavailable":`当前快照中没有此 Skill 的内容。`,"mission.contentTruncated":`内容预览已截断`,"mission.knowledgeRetained":`已保留知识`,"mission.selfEvolution":`已保存的项目知识`,"mission.knowledgeSaved":`Argus 已保存这些能力和笔记,供本项目后续工作使用。`,"mission.noCapabilities":`尚未学习新能力。`,"mission.replay":`任务回放`,"mission.replayTimeline":`回放任务时间线`,"mission.roleFailed":`{role} 执行失败`,"mission.showingLatestEvent":`显示最近一条事件`,"mission.showingLastEvents":`显示最近 {count} 条事件`,"mission.waitingEvents":`等待结构化研究事件。`,"mission.startsAfter":`需等待前置任务 {count} 项`,"mission.hiddenTasks":`已隐藏前序任务 {count} 项 · 阻塞或失败 {failed} 项 · 已跳过 {skipped} 项`,"mission.projectFilesChanged":`项目文件有变更`,"mission.reviewInIde":`可打开 IDE 查看差异`,"research.currentWork":`当前工作`,"research.dagProgress":`任务路线进度`,"research.verifiedOutputs":`已验证输出`,"research.recentMilestones":`近期里程碑`,"research.liveProgress":`实时进度`,"research.artifact":`研究成果`,"research.canvas":`Manager 实时研究面板`,"research.previewArtifact":`预览成果`,"research.openLarge":`打开大尺寸预览`,"research.collapse":`收起预览`,"research.unavailable":`Manager 实时视图暂时不可用。`,"research.noPreview":`暂无预览`,"research.waiting":`等待中…`,"research.updating":`正在更新…`,"research.fileUnavailable":`此文件无法预览。`,"research.eventSourced":`基于事件的任务状态`,"research.downloadFailed":`下载失败`,"operations.title":`运行控制`,"operations.work":`工作`,"operations.runtime":`运行时`,"operations.system":`系统`,"operations.recovery":`恢复`,"operations.workInput":`工作输入`,"operations.workHint":`加入工作、指导当前任务、保存备注,或仅预览计划而不分派。`,"operations.action.task":`任务`,"operations.action.nudge":`指导`,"operations.action.note":`备注`,"operations.action.plan":`计划`,"operations.planPlaceholder":`要预览的目标;预览不会加入任务队列`,"operations.actionPlaceholder":`输入 {action} 内容`,"operations.previewPlan":`预览计划`,"operations.submitAction":`提交 {action}`,"operations.runtimeHint":`更改会话运行位置、重置 Manager 上下文,或安全重启会话。`,"operations.workdir":`工作目录`,"operations.workdirUpdated":`工作目录已更新。`,"operations.applyWorkdir":`应用工作目录`,"operations.replaceSlot":`替换活动会话`,"operations.sourceUpdate":`Argus 源码版本`,"operations.pullLatest":`拉取最新版本`,"operations.updateChecking":`正在检查已发布分支…`,"operations.updateRunning":`正在更新…`,"operations.updateAvailable":`有可用更新`,"operations.updateCurrent":`已是最新`,"operations.updateUnavailable":`当前工作树无法安全更新。`,"operations.currentRevision":`当前`,"operations.latestRevision":`最新`,"operations.updatePhase":`阶段`,"operations.updateRestart":`源码已更新。请重启工作台,再使用重载按钮让活动 daemon 在安全任务边界切换到新版本。`,"operations.skills":`Skills`,"operations.runSkill":`运行 Skill 命令`,"operations.metrics":`系统指标`,"operations.trash":`可恢复的回收站`,"operations.searchTrash":`搜索回收站`,"operations.trashEmpty":`回收站为空。`,"resource.title":`资源`,"resource.loading":`正在加载资源状态…`,"resource.devices":`设备:{count}`,"resource.inUse":`使用中 · {count}`,"resource.queue":`等待队列 · {count}`,"resource.none":`无`,"resource.timeLeft":`剩余 {ttl}`,"resource.noIntent":`未记录用途`,"resource.yieldRequest":`收到释放资源请求 · {reason}`,"resource.queuePosition":`队列第 {position} 位`,"label.status.inProgress":`进行中`,"label.status.waiting":`等待中`,"label.status.completed":`已完成`,"label.status.blocked":`已阻塞`,"label.status.failed":`失败`,"label.status.needsChanges":`需要修改`,"label.status.skipped":`已跳过`,"label.status.paused":`已暂停`,"label.status.available":`可用`,"label.status.unavailable":`不可用`,"label.status.inaccessible":`无法访问`,"label.status.limited":`部分受限`,"label.status.healthy":`状态正常`,"label.status.updated":`状态已更新`,"label.role.manager":`Manager`,"label.role.planner":`Planner`,"label.role.engineer":`Engineer`,"label.role.reviewer":`Reviewer`,"label.role.argus":`Argus`,"label.role.you":`你`,"label.work.task":`任务`,"label.work.action":`工作步骤`,"label.work.handoff":`给下一步的说明`,"label.work.review":`审核`,"label.work.planning":`规划`,"label.work.update":`动态`,"label.stage.scope":`范围定义`,"label.stage.research":`研究`,"label.stage.implementation":`方法实现`,"label.stage.experiment":`实验验证`,"label.stage.analysis":`结果分析`,"label.stage.writing":`论文写作`,"label.stage.review":`最终审核`,"label.stage.delivery":`成果交付`,"label.stage.unstaged":`未分阶段`,"label.frontier.reopened":`已重新开启一项前序任务`,"label.frontier.added":`已添加一项新任务`,"label.frontier.completed":`已完成一条任务路径`,"label.frontier.revised":`已调整任务计划`,"label.frontier.narrowed":`已缩小任务范围`,"label.frontier.expanded":`已扩大任务范围`,"label.frontier.updated":`任务计划已更新`,"label.priority":`优先级 {priority}`,"label.outcome.workCompleted":`工作已完成`,"label.outcome.workPaused":`工作已暂停`,"label.outcome.workBlocked":`工作被阻塞`,"label.outcome.workFailed":`工作失败`,"label.outcome.workEnded":`工作已结束`,"label.outcome.workIncomplete":`工作尚未完成`,"label.outcome.workStalled":`工作停滞`,"label.outcome.workUpdated":`工作状态已更新`,"label.outcome.reviewPassed":`审核通过`,"label.outcome.reviewNeedsChanges":`审核要求修改`,"label.outcome.reviewBlocked":`审核被阻塞`,"label.outcome.reviewOutdated":`审核结果已过期`,"label.outcome.reviewPending":`等待审核`,"label.outcome.stageApproved":`阶段已通过`,"label.outcome.stageNotApproved":`阶段未通过`,"label.outcome.stageRevoked":`阶段批准已撤回`,"label.outcome.stageNotNeeded":`无需阶段审核`,"label.outcome.stagePending":`阶段审核待定`,"label.outcome.budgetPaused":`因预算上限暂停`,"label.outcome.waitingForYou":`正在等待你的回复`,"label.outcome.stoppedByYou":`已由你停止`,"label.outcome.pausedByYou":`已由你暂停`,"label.outcome.sessionPaused":`会话已暂停`,"label.outcome.serviceUnavailable":`服务暂不可用`,"label.outcome.serviceCoolingDown":`服务暂时暂停`,"label.outcome.temporaryIssue":`因临时问题暂停`,"label.outcome.serviceError":`因服务错误停止`,"label.outcome.needsPlan":`需要制定新计划`,"label.outcome.canResume":`可以继续`,"label.routing.team":`团队协作`,"label.routing.individual":`单独执行`,"label.routing.research":`研究任务`,"label.routing.software":`软件工作`,"label.routing.staged":`分步执行`,"label.routing.flexible":`灵活流程`,"label.routing.ongoing":`持续进行`,"label.routing.defined":`范围明确`,"label.resource.nvidiaGpu":`NVIDIA GPU`,"label.resource.amdGpu":`AMD GPU`,"label.resource.appleGpu":`Apple GPU`,"label.resource.cpu":`CPU`,"label.resource.accelerator":`加速设备`,"label.resource.enforced":`强制执行限制`,"label.resource.advisory":`仅提供建议`,"label.resource.released":`已释放资源`,"label.resource.kept":`继续占用资源`};function Gr(){try{let e=localStorage.getItem(Hr);if(e===`en`||e===`zh-CN`)return e}catch{}return navigator.language.toLowerCase().startsWith(`zh`)?`zh-CN`:`en`}function Kr(e,t={},n=Gr()){return((n===`zh-CN`?Wr[e]:Ur[e])??e).replace(/\{(\w+)\}/g,(e,n)=>String(t[n]??`{${n}}`))}var qr=(0,I.createContext)({locale:`en`,setLocale:()=>void 0,t:(e,t)=>Kr(e,t,`en`)});function Jr({children:e}){let[t,n]=(0,I.useState)(Gr),r=e=>{try{localStorage.setItem(Hr,e)}catch{}n(e)};(0,I.useEffect)(()=>{document.documentElement.lang=t},[t]);let i=(0,I.useMemo)(()=>({locale:t,setLocale:r,t:(e,n)=>Kr(e,n,t)}),[t]);return(0,X.jsx)(qr.Provider,{value:i,children:e})}function Z(){return(0,I.useContext)(qr)}var Yr=new Set([`running`,`in_progress`,`claimed`]);function Xr(e){return e.find(e=>e.active)??e.find(e=>e.role===`manager`)}function Zr({snap:e,streamOk:t,onStart:n,onStop:i,onManage:a,onOpenSessions:c,mobileView:l,onToggleMobileView:u,busy:d,snapshotStale:f=!1,readOnly:p=!1,missionView:m}){let{t:h}=Z(),g=Xr(e.roles),_=[`complete`,`completed`,`done`,`success`].includes(String(m?.mission.status||``).toLowerCase()),v=e.daemon.alive&&!_?m?.roles.find(e=>e.role===m.active_role):void 0,y=v?.role||g?.role||`manager`,b=e.daemon.alive&&(v?v.status===`active`:!!g?.active),x=e.backlog.find(e=>Yr.has(e.status)),S=v?.label||x?.title||x?.objective||(_?m?.mission.summary||m?.mission.title:``)||e.session.objective||h(`common.ready`),C=!!(e.partial||e.observability?.slo.status===`degraded`),w=e.daemon.alive&&e.daemon.control_available===!1,T=w?h(`topbar.externallyManaged`):e.daemon.alive?h(`topbar.pauseDaemon`):h(`topbar.runDaemon`),E=C?[...(e.diagnostics??[]).map(e=>`${e.section}: ${e.message}`),...e.observability?.slo.violations??[]].join(` +`)||h(`common.degraded`):h(f?`common.stale`:t?`common.live`:`common.reconnecting`);return(0,X.jsxs)(`header`,{className:`chrome-seam-surface glass-panel glass-panel--raised flex h-12 min-w-0 shrink-0 items-center gap-2 border-b px-3 sm:gap-3 sm:px-4`,children:[c?(0,X.jsx)(`button`,{type:`button`,onClick:c,"aria-label":h(`topbar.openSessions`),className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-md text-ink-faint hover:bg-bg hover:text-ink lg:hidden`,children:(0,X.jsx)(`svg`,{viewBox:`0 0 16 16`,"aria-hidden":`true`,className:`h-4 w-4`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.25`,children:(0,X.jsx)(`path`,{d:`M2.5 4h11M2.5 8h11M2.5 12h11`})})}):null,(0,X.jsx)(`div`,{className:`hidden min-w-0 max-w-28 truncate text-sm font-semibold text-ink sm:block`,children:e.session.display_name||e.session.id}),(0,X.jsx)(`span`,{className:`hidden h-4 w-px shrink-0 bg-line/40 sm:block`}),(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[(0,X.jsx)(`span`,{"data-role-dot":y,"aria-label":h(b?`topbar.roleActive`:`topbar.roleIdle`,{role:y}),className:`h-2 w-2 shrink-0 rounded-full ${b?`animate-pulse motion-reduce:animate-none`:``}`,style:{background:W.role[y]||`rgb(var(--ink-faint))`}}),(0,X.jsx)(`span`,{className:`hidden shrink-0 text-xs font-semibold capitalize text-ink-dim sm:inline`,children:y}),(0,X.jsx)(`span`,{className:`truncate text-xs text-ink-faint`,children:S})]}),(0,X.jsx)(`span`,{title:E,className:`h-2 w-2 shrink-0 rounded-full transition-shadow duration-150 ${C||f?`bg-err ring-1 ring-err/30 ring-offset-1 ring-offset-panel`:t?`bg-ok ring-1 ring-ok/30 ring-offset-1 ring-offset-panel`:`bg-ink-faint/50`}`,children:(0,X.jsx)(`span`,{className:`sr-only`,children:E})}),(0,X.jsx)(Vr,{settledUsd:e.spend_usd,knownUsd:e.usage_summary?.known_cost_usd,status:e.spend_status,calls:e.usage_summary?.call_count,premiumRequests:e.usage_summary?.premium_requests,live:e.daemon.alive,compact:!0}),u?(0,X.jsx)(`button`,{type:`button`,onClick:u,"aria-label":h(l===`activity`?`topbar.showPreview`:`topbar.showActivity`),title:h(l===`activity`?`topbar.showPreview`:`topbar.showActivity`),className:`icon-control flex h-8 w-8 shrink-0 items-center justify-center lg:hidden`,children:(0,X.jsx)(`svg`,{viewBox:`0 0 16 16`,"aria-hidden":`true`,className:`h-4 w-4`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.25`,children:l===`activity`?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`rect`,{x:`2`,y:`2.5`,width:`12`,height:`11`,rx:`1.5`}),(0,X.jsx)(`path`,{d:`M9.5 2.75v10.5`})]}):(0,X.jsx)(`path`,{d:`M3 4h10M3 8h10M3 12h7`})})}):null,p?null:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`button`,{type:`button`,disabled:d||w,onClick:e.daemon.alive?i:n,"aria-label":T,title:w?h(`topbar.externalDaemonHint`):T,className:`compact-control flex h-8 shrink-0 items-center gap-1 px-2 disabled:opacity-40`,children:[(0,X.jsx)(o,{icon:e.daemon.alive?s:r,className:`h-3 w-3`}),(0,X.jsx)(`span`,{className:`hidden sm:inline`,children:w?h(`common.external`):e.daemon.alive?h(`common.pause`):h(`common.run`)})]}),(0,X.jsx)(`button`,{type:`button`,"aria-label":h(`topbar.manageSession`),title:h(`topbar.manageSession`),onClick:a,className:`icon-control flex h-8 w-8 shrink-0 items-center justify-center text-sm tracking-widest`,children:`···`})]})]})}function Qr(e){let t=new Set;return[e.primary_target,...e.targets].filter(e=>!e?.path||t.has(e.path)?!1:(t.add(e.path),!0))}function $r(e,t){if(t===`research`)for(let t of e){let e=Qr(t).find(e=>/(?:^|\/)paper\/main\.pdf$/i.test(e.path.replace(/\\/g,`/`)));if(e)return{receipt:t,path:e.path}}let n=e[0];return n?{receipt:n,path:Qr(n)[0]?.path||null}:null}function ei(e){return e.replace(/\s*\bRESULT\s*=\s*/g,` + +`).replace(/\s*\b(?:STATUS|REVIEW_STATUS)\s*=\s*\S+/g,``).trim()}function ti(e,t,n){let r=n.reduce((e,t)=>t.type===`ui.operator`?Math.max(e,Number(t.ts)||0):e,0),i=t&&(e===void 0||t.delivered_at>r)?t:null;return e?i&&i.delivered_at>e.delivered_at?i:e:i}function ni(e,t){if(!t)return!1;let n=new Set([t]),r=[t];for(let t=0;te.id!==t&&n.has(e.id)&&[`pending`,`running`,`in_progress`,`claimed`].includes(e.status))}var ri=`modulepreload`,ii=function(e){return`/`+e},ai={},oi=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?import.meta.resolve(e):new URL(e,import.meta.url).href}r=o(t.map(t=>{if(t=ii(t,n),t=s(t),t in ai)return;ai[t]=!0;let r=t.endsWith(`.css`);for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}let i=document.createElement(`link`);if(i.rel=r?`stylesheet`:ri,r||(i.as=`script`),i.crossOrigin=``,i.href=t,a&&i.setAttribute(`nonce`,a),document.head.appendChild(i),r)return new Promise((e,n)=>{i.addEventListener(`load`,e),i.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},si={all:`(min-width: 0px)`,reduceMotion:`(prefers-reduced-motion: reduce)`};function ci(e,t,n=[]){let r=(0,I.useRef)(t);r.current=t,(0,I.useEffect)(()=>{let t=!1,n=null;return oi(()=>import(`./motion-sqs9Ax-g.js`).then(e=>e.t).then(i=>{if(t||!e.current)return;let a=i.gsap;n=a.matchMedia(),n.add(si,e=>r.current(a,!!e.conditions?.reduceMotion),e.current)}),__vite__mapDeps([0,1])),()=>{t=!0,n?.revert()}},n)}function li(e){if(!e)return`—`;let t=Date.now()/1e3,n=Math.max(0,t-e);return n<5?`just now`:n<60?`${Math.floor(n)}s ago`:n<3600?`${Math.floor(n/60)}m ago`:n<86400?`${Math.floor(n/3600)}h ago`:`${Math.floor(n/86400)}d ago`}function ui(e){if(e==null||e<0)return`—`;let t=Math.floor(e/86400),n=Math.floor(e%86400/3600),r=Math.floor(e%3600/60);return t?`${t}d ${n}h`:n?`${n}h ${r}m`:r?`${r}m`:`${Math.floor(e)}s`}function di(e,t=2){return e==null||!isFinite(e)?`$0.00`:`$${e.toFixed(t)}`}function fi(e){if(!Number.isFinite(e)||e<=0)return`0 B`;let t=[`B`,`KB`,`MB`,`GB`],n=Math.min(Math.floor(Math.log(e)/Math.log(1024)),t.length-1),r=e/1024**n;return`${r>=10||n===0?r.toFixed(0):r.toFixed(1)} ${t[n]}`}function pi(e){let t=e.ts??e.time,n=null;if(typeof t==`number`)n=t>0xe8d4a51000?t:t*1e3;else if(typeof t==`string`){let e=Date.parse(t);isNaN(e)||(n=e)}if(n==null)return``;let r=new Date(n),i=e=>String(e).padStart(2,`0`);return`${i(r.getHours())}:${i(r.getMinutes())}:${i(r.getSeconds())}`}function mi(e){return e instanceof Error?e.message:String(e||`Unknown error`)}function hi(e,t){let n=mi(e);return t?`Reply interrupted after a partial response: ${n}`:`Message failed before a response was received: ${n}`}function gi({ok:e,pulse:t=!1,title:n}){return(0,X.jsx)(`span`,{title:n,className:`inline-block h-1.5 w-1.5 rounded-full transition-shadow duration-150 ${e?`bg-ok ring-1 ring-ok/30 ring-offset-1 ring-offset-panel`:`bg-ink-faint/50`}`,"data-live":e&&t?`true`:void 0})}function _i({children:e,color:t,className:n=``}){return(0,X.jsx)(`span`,{className:`chip text-ink-dim ${n}`,style:t?{color:t,borderColor:`${t}44`}:void 0,children:e})}function vi({children:e,onClick:t,variant:n=`ghost`,disabled:r,title:i,className:a=``}){return(0,X.jsx)(`button`,{type:`button`,title:i,disabled:r,onClick:t,className:`brand-button ${{ghost:`brand-button-ghost`,primary:`brand-button-primary`,danger:`brand-button-danger`}[n]} ${a}`,children:e})}function yi({title:e,right:t}){return(0,X.jsxs)(`div`,{className:`panel-header flex min-h-11 items-center justify-between border-b px-4`,children:[(0,X.jsx)(`span`,{className:`text-sm font-medium text-ink-dim`,children:e}),t]})}function bi(){return(0,X.jsx)(`span`,{className:`inline-block h-3 w-3 animate-spin rounded-full border-2 border-line border-t-blue`})}function xi({children:e}){return(0,X.jsx)(`div`,{className:`px-3 py-6 text-center text-xs text-ink-faint`,children:e})}async function Si(e){try{if(navigator.clipboard?.writeText)return await navigator.clipboard.writeText(e),!0}catch{}try{let t=document.createElement(`textarea`);t.value=e,t.setAttribute(`readonly`,``),t.style.position=`fixed`,t.style.opacity=`0`,document.body.appendChild(t),t.select();let n=document.execCommand(`copy`);return t.remove(),n}catch{return!1}}function Ci({text:e,label:t,copiedLabel:n,className:r=``}){let[i,a]=(0,I.useState)(!1),o=(0,I.useRef)();(0,I.useEffect)(()=>()=>{o.current&&clearTimeout(o.current)},[]);let s=async()=>{await Si(e)&&(a(!0),o.current&&clearTimeout(o.current),o.current=setTimeout(()=>a(!1),1600))};return(0,X.jsxs)(`button`,{type:`button`,onClick:()=>void s(),"aria-label":i?n:t,title:i?n:t,className:`inline-flex h-7 items-center gap-1 rounded-md border border-line/60 bg-panel/85 px-2 text-[10px] text-ink-faint shadow-sm backdrop-blur transition hover:border-blue/45 hover:text-blue focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue/50 ${r}`,children:[i?(0,X.jsx)(`svg`,{viewBox:`0 0 16 16`,"aria-hidden":`true`,className:`h-3.5 w-3.5`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.7`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,X.jsx)(`path`,{d:`m3.5 8.5 2.7 2.7 6.3-6.4`})}):(0,X.jsxs)(`svg`,{viewBox:`0 0 16 16`,"aria-hidden":`true`,className:`h-3.5 w-3.5`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.4`,children:[(0,X.jsx)(`rect`,{x:`5.2`,y:`5.2`,width:`7.2`,height:`7.2`,rx:`1.2`}),(0,X.jsx)(`path`,{d:`M10.8 5.2V3.8a1.2 1.2 0 0 0-1.2-1.2H3.8a1.2 1.2 0 0 0-1.2 1.2v5.8a1.2 1.2 0 0 0 1.2 1.2h1.4`})]}),(0,X.jsx)(`span`,{children:i?n:t})]})}function wi(e){return typeof e==`string`||typeof e==`number`?String(e):Array.isArray(e)?e.map(wi).join(``):(0,I.isValidElement)(e)?wi(e.props.children):``}function Ti(e){let t=String(e||``).trim();try{t=decodeURIComponent(t)}catch{}if(/^file:/i.test(t))try{let e=new URL(t);if(e.hostname&&e.hostname!==`localhost`)return``;t=e.pathname}catch{return``}else if(/^[a-z][a-z0-9+.-]*:/i.test(t)&&!/^[a-z]:[\\/]/i.test(t))return``;for(t=t.split(`#`,1)[0].split(`?`,1)[0].replaceAll(`\\`,`/`),/^\/[a-z]:\//i.test(t)&&(t=t.slice(1));t.startsWith(`./`);)t=t.slice(2);return t.replace(/\/{2,}/g,`/`)}function Ei(e,t){return!e||!t?!1:/^[a-z]:\//i.test(e)||/^[a-z]:\//i.test(t)?e.toLowerCase()===t.toLowerCase():e===t}function Di(e,t=[]){let n=Ti(e||``);if(!n)return null;for(let e of t){let t=Ti(e.path),r=Ti(e.storage_path||``);if(Ei(n,t)||Ei(n.replace(/^\//,``),t)||Ei(n,r))return e.path}return null}function Oi({src:e,alt:t}){let[n,r]=(0,I.useState)(!1);return n||!e?(0,X.jsxs)(`span`,{className:`text-xs text-ink-faint`,children:[`Image unavailable`,t?` · ${t}`:``]}):(0,X.jsx)(`img`,{src:e,alt:t||``,loading:`lazy`,decoding:`async`,onError:()=>r(!0),className:`my-2 h-auto max-w-full rounded-lg`})}function ki({children:e,artifacts:t=[],onOpenArtifact:n}){let{t:r}=Z();return(0,X.jsx)(he,{remarkPlugins:[_e,[ge,{backslashDelimiters:!0,singleDollarTextMath:!1}]],rehypePlugins:[ve],components:{h1:({children:e})=>(0,X.jsx)(`h1`,{className:`mb-2 mt-3 text-base font-semibold text-ink first:mt-0`,children:e}),h2:({children:e})=>(0,X.jsx)(`h2`,{className:`mb-1.5 mt-3 text-sm font-semibold text-ink first:mt-0`,children:e}),h3:({children:e})=>(0,X.jsx)(`h3`,{className:`mb-1 mt-2 text-sm font-medium text-ink first:mt-0`,children:e}),p:({children:e})=>(0,X.jsx)(`p`,{className:`my-1.5 whitespace-pre-wrap break-words leading-[1.625] first:mt-0 last:mb-0`,children:e}),ul:({children:e})=>(0,X.jsx)(`ul`,{className:`my-2 list-disc space-y-1 pl-5`,children:e}),ol:({children:e})=>(0,X.jsx)(`ol`,{className:`my-2 list-decimal space-y-1 pl-5`,children:e}),li:({children:e})=>(0,X.jsx)(`li`,{className:`pl-0.5`,children:e}),blockquote:({children:e})=>(0,X.jsx)(`blockquote`,{className:`my-2 border-l border-blue/50 pl-3 text-ink-dim`,children:e}),hr:()=>(0,X.jsx)(`hr`,{className:`my-3 border-line/60`}),a:({href:e,title:r,children:i})=>{let a=Di(e,t),o=a?t.find(e=>e.path===a):void 0;return a&&n?(0,X.jsx)(`a`,{href:e,"data-artifact-path":a,title:o?.storage_path||a,onClick:e=>{e.preventDefault(),n(a)},className:`cursor-pointer text-blue underline decoration-blue/35 underline-offset-2 hover:decoration-blue`,children:i}):(0,X.jsx)(`a`,{href:e,title:r,target:`_blank`,rel:`noreferrer`,className:`text-blue underline decoration-blue/35 underline-offset-2 hover:decoration-blue`,children:i})},code:({className:e,children:t,...n})=>{let r=!!e||String(t).includes(` +`);return(0,X.jsx)(`code`,{...n,className:r?`block min-w-0 whitespace-pre-wrap break-words font-mono text-xs text-ink ${e??``}`:`break-all rounded bg-bg px-1.5 py-0.5 font-mono text-xs text-ink`,children:t})},pre:({children:e})=>(0,X.jsxs)(`pre`,{className:`group/code relative my-2 max-w-full overflow-x-hidden whitespace-pre-wrap break-words rounded-lg border border-line/50 bg-bg px-3 pb-3 pt-10`,children:[(0,X.jsx)(Ci,{text:I.Children.toArray(e).map(wi).join(``),label:r(`copy.code`),copiedLabel:r(`copy.copied`),className:`absolute right-2 top-2`}),e]}),table:({children:e})=>(0,X.jsx)(`table`,{className:`my-2 w-full table-fixed border-collapse text-left text-xs`,children:e}),th:({children:e})=>(0,X.jsx)(`th`,{className:`break-words border border-line/60 bg-bg px-2 py-1.5 font-semibold text-ink`,children:e}),td:({children:e})=>(0,X.jsx)(`td`,{className:`break-words border border-line/60 px-2 py-1.5 align-top`,children:e}),strong:({children:e})=>(0,X.jsx)(`strong`,{className:`font-semibold text-ink`,children:e}),img:({src:e,alt:t})=>(0,X.jsx)(Oi,{src:e,alt:t})},children:e})}function Ai({size:e,className:t=`text-ink`}){return(0,X.jsxs)(`svg`,{"data-logo":`rounded-mark`,viewBox:`0 0 512 512`,role:`img`,"aria-label":`Argus`,style:{width:e,height:e},className:`argus-brand-mark shrink-0 ${t}`,children:[(0,X.jsx)(`path`,{d:`M352 112q0-30 30-30h28q30 0 30 30v320h-88v-52q-46 62-129 62Q66 442 66 266T228 88q80 0 124 56v-32ZM140 266q46-80 102-80t110 80q-54 80-110 80t-102-80Z`,fill:`rgb(var(--brand-body))`,fillRule:`evenodd`}),(0,X.jsx)(`path`,{d:`M140 266q46-80 102-80t110 80q-54 80-110 80t-102-80Z`,fill:`rgb(var(--brand-eye))`}),(0,X.jsxs)(`g`,{className:`argus-mark-eye`,children:[(0,X.jsx)(`circle`,{cx:`244`,cy:`266`,r:`42`,fill:`rgb(var(--brand-pupil))`}),(0,X.jsx)(`circle`,{cx:`262`,cy:`248`,r:`12`,fill:`rgb(var(--brand-highlight))`})]})]})}function ji({size:e}){return(0,X.jsxs)(`svg`,{"data-logo":`rounded-horizontal`,viewBox:`150 40 1160 390`,role:`img`,"aria-label":`Argus`,style:{width:e*2.75,height:e},className:`shrink-0 text-ink`,children:[(0,X.jsxs)(`g`,{className:`argus-brand-mark`,transform:`translate(180 92) scale(.54)`,children:[(0,X.jsx)(`path`,{d:`M352 112q0-30 30-30h28q30 0 30 30v320h-88v-52q-46 62-129 62Q66 442 66 266T228 88q80 0 124 56v-32ZM140 266q46-80 102-80t110 80q-54 80-110 80t-102-80Z`,fill:`rgb(var(--brand-body))`,fillRule:`evenodd`}),(0,X.jsx)(`path`,{d:`M140 266q46-80 102-80t110 80q-54 80-110 80t-102-80Z`,fill:`rgb(var(--brand-eye))`}),(0,X.jsx)(`circle`,{cx:`244`,cy:`266`,r:`42`,fill:`rgb(var(--brand-pupil))`}),(0,X.jsx)(`circle`,{cx:`262`,cy:`248`,r:`12`,fill:`rgb(var(--brand-highlight))`})]}),(0,X.jsxs)(`g`,{fill:`rgb(var(--brand-body))`,children:[(0,X.jsx)(`path`,{d:`M383 556Q394 556 409 555Q424 554 433 552L422 412Q415 414 401.5 415.5Q388 417 378 417Q340 417 305 403.5Q270 390 248.5 360Q227 330 227 278V0H78V546H191L213 454H220Q244 496 286 526Q328 556 383 556Z`,transform:`translate(444 334) scale(.36 -.36)`}),(0,X.jsx)(`path`,{d:`M255 556Q356 556 413 476H417L429 546H555V-1Q555-118 486-179Q417-240 282-240Q224-240 174.5-233Q125-226 78-208V-89Q179-131 291-131Q406-131 406-7V4Q406 21 407.5 39Q409 57 410 71H406Q378 28 339 9Q300-10 251-10Q154-10 99.5 64.5Q45 139 45 272Q45 406 101 481Q157 556 255 556ZM302 435Q197 435 197 270Q197 107 304 107Q361 107 388.5 139.5Q416 172 416 253V271Q416 359 389 397Q362 435 302 435Z`,transform:`translate(617.52 334) scale(.36 -.36)`}),(0,X.jsx)(`path`,{d:`M579 546V0H465L445 70H437Q411 28 365.5 9Q320-10 269-10Q181-10 128 37.5Q75 85 75 190V546H224V227Q224 169 245 139Q266 109 312 109Q380 109 405 155.5Q430 202 430 289V546Z`,transform:`translate(855.48 334) scale(.36 -.36)`}),(0,X.jsx)(`path`,{d:`M459 162Q459 79 400.5 34.5Q342-10 226-10Q169-10 128-2.5Q87 5 46 22V145Q90 125 141 112Q192 99 231 99Q275 99 293.5 112Q312 125 312 146Q312 160 304.5 171Q297 182 272 196Q247 210 194 232Q143 254 110 275.5Q77 297 61 327.5Q45 358 45 404Q45 480 104 518Q163 556 261 556Q312 556 358 546Q404 536 453 513L408 406Q368 423 332 434.5Q296 446 259 446Q193 446 193 410Q193 397 201.5 386.5Q210 376 234.5 364Q259 352 307 332Q354 313 388 292.5Q422 272 440.5 241.5Q459 211 459 162Z`,transform:`translate(1102.08 334) scale(.36 -.36)`})]})]})}function Mi({size:e=20,tag:t,compact:n=!1}){return(0,X.jsxs)(`span`,{className:`inline-flex select-none items-center gap-2.5`,children:[n?(0,X.jsx)(Ai,{size:e}):(0,X.jsx)(ji,{size:e}),t&&!n?(0,X.jsx)(`span`,{className:`text-xs font-medium uppercase tracking-[0.08em] text-ink-faint`,children:t}):null]})}var Ni={active:`label.status.inProgress`,claimed:`label.status.inProgress`,in_progress:`label.status.inProgress`,running:`label.status.inProgress`,working:`label.status.inProgress`,pending:`label.status.waiting`,queued:`label.status.waiting`,waiting:`label.status.waiting`,idle:`label.status.waiting`,accepted:`label.status.completed`,complete:`label.status.completed`,completed:`label.status.completed`,done:`label.status.completed`,success:`label.status.completed`,blocked:`label.status.blocked`,failed:`label.status.failed`,error:`label.status.failed`,rejected:`label.status.needsChanges`,continue:`label.status.needsChanges`,skipped:`label.status.skipped`,paused:`label.status.paused`,stopped:`label.status.paused`,cancelled:`label.status.paused`,aborted:`label.status.paused`,not_started:`label.status.waiting`,available:`label.status.available`,absent:`label.status.unavailable`,inaccessible:`label.status.inaccessible`,degraded:`label.status.limited`,healthy:`label.status.healthy`},Pi={manager:`label.role.manager`,planner:`label.role.planner`,engineer:`label.role.engineer`,reviewer:`label.role.reviewer`,system:`label.role.argus`,operator:`label.role.you`},Fi={completed:`label.outcome.workCompleted`,done:`label.outcome.workCompleted`,success:`label.outcome.workCompleted`,paused:`label.outcome.workPaused`,blocked:`label.outcome.workBlocked`,failed:`label.outcome.workFailed`,error:`label.outcome.workFailed`,aborted:`label.outcome.workEnded`,ended:`label.outcome.workEnded`,incomplete:`label.outcome.workIncomplete`,research_incomplete:`label.outcome.workIncomplete`,paused_no_breakthrough:`label.outcome.workIncomplete`,exhausted_current_methods:`label.outcome.workIncomplete`,stalled:`label.outcome.workStalled`,no_progress:`label.outcome.workStalled`,max_rounds:`label.outcome.workStalled`,infra_blocked:`label.outcome.workBlocked`,supervisor_error:`label.outcome.workFailed`},Ii={accepted:`label.outcome.reviewPassed`,done:`label.outcome.reviewPassed`,passed:`label.outcome.reviewPassed`,continue:`label.outcome.reviewNeedsChanges`,rejected:`label.outcome.reviewNeedsChanges`,blocked:`label.outcome.reviewBlocked`,stale:`label.outcome.reviewOutdated`,pending:`label.outcome.reviewPending`,pending_review:`label.outcome.reviewPending`},Li={certified:`label.outcome.stageApproved`,not_certified:`label.outcome.stageNotApproved`,revoked:`label.outcome.stageRevoked`,intentionally_skipped:`label.outcome.stageNotNeeded`,deferred:`label.outcome.stagePending`},Ri={budget_exhausted:`label.outcome.budgetPaused`,budget_pause:`label.outcome.budgetPaused`,operator_input_required:`label.outcome.waitingForYou`,operator_abort:`label.outcome.stoppedByYou`,operator_pause:`label.outcome.pausedByYou`,daemon_shutdown:`label.outcome.sessionPaused`,backend_unavailable:`label.outcome.serviceUnavailable`,provider_cooldown:`label.outcome.serviceCoolingDown`,provider_fence:`label.outcome.serviceUnavailable`,transient_error:`label.outcome.temporaryIssue`,permanent_error:`label.outcome.serviceError`,planner_empty_plan:`label.outcome.needsPlan`},zi={cuda:`label.resource.nvidiaGpu`,rocm:`label.resource.amdGpu`,mps:`label.resource.appleGpu`,cpu:`label.resource.cpu`};function Bi(e,t){return t(Ni[String(e??``).toLowerCase()]??`label.status.updated`)}function Vi(e,t){return t(Pi[String(e??``).toLowerCase()]??`label.role.argus`)}function Hi(e,t){return t(`label.priority`,{priority:e})}function Ui(e,t){if(!e?.execution_status)return[];let n=[t(Fi[e.execution_status.toLowerCase()]??`label.outcome.workUpdated`)],r=Ii[String(e.review_status??``).toLowerCase()],i=Li[String(e.stage_certification??``).toLowerCase()],a=Ri[String(e.interruption_kind??``).toLowerCase()];return r&&n.push(t(r)),i&&n.push(t(i)),a&&n.push(t(a)),e.resumable&&n.push(t(`label.outcome.canResume`)),n}function Wi(e,t){return t(zi[e.toLowerCase()]??`label.resource.accelerator`)}function Gi(e,t){return t(e===`strict`?`label.resource.enforced`:`label.resource.advisory`)}function Ki(e,t){return t(e===`yield`?`label.resource.released`:`label.resource.kept`)}var qi=[`manager`,`planner`,`engineer`,`reviewer`],Ji=/Info: (?:Operation cancelled by user|Response was interrupted due to a server error\. Retrying\.\.\.)/gi;function Yi(e){let t=new Map;return e.forEach(e=>{let n=String(e.type??``);if(n===`life.mission.completed`||n===`mission.completed`){t.clear();return}let r=String(e.call_id??``);r&&(n===`provider.request.started`?t.set(r,e):(n===`provider.request.completed`||n===`provider.request.denied`)&&t.delete(r))}),Array.from(t.values()).at(-1)??null}function Xi({ev:e,r:t,first:n,last:r}){let i=W.role[t.role]??W.inkFaint,a=rr(t.tone);return(0,X.jsxs)(`div`,{className:`event-activity-row group relative grid grid-cols-[16px_minmax(0,1fr)] gap-3 px-4 py-3 transition-colors hover:bg-bg/70 ${r?`animate-appear`:``} ${t.reasoning?`opacity-60`:``}`,style:t.rule?{marginTop:4}:void 0,children:[(0,X.jsxs)(`div`,{className:`relative flex justify-center`,children:[n?null:(0,X.jsx)(`span`,{className:`absolute -top-2.5 h-4 w-px bg-line/60`}),r?null:(0,X.jsx)(`span`,{className:`absolute -bottom-2.5 top-2 w-px bg-line/60`}),(0,X.jsx)(`span`,{className:`relative z-10 mt-1.5 h-2 w-2 rounded-full border-2 border-panel`,style:{backgroundColor:i,boxShadow:`0 0 0 1px ${i}55`}})]}),(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(`span`,{className:`truncate text-xs font-semibold uppercase tracking-[0.06em]`,style:{color:i},title:t.label,children:t.label}),(0,X.jsx)(`span`,{className:`text-xs`,style:{color:a},children:t.glyph}),(0,X.jsx)(`time`,{className:`ml-auto font-mono text-xs tabular-nums text-ink-faint opacity-0 transition-opacity group-hover:opacity-100`,children:pi(e)})]}),(0,X.jsx)(`div`,{className:`mt-0.5 whitespace-pre-wrap break-words text-sm leading-5 ${t.reasoning?`italic`:``}`,style:{color:a},children:t.text})]})]})}function Zi({ev:e,r:t,artifacts:n,onOpenArtifact:r}){let{t:i}=Z(),a=String(e.type)===`ui.operator`,o=Number(e.response_latency_ms??0),s=!a&&o>=100?` · ${(o/1e3).toFixed(1)}s`:``,c=(0,I.useRef)(null);return ci(c,(e,t)=>{c.current&&(t||e.fromTo(c.current,{autoAlpha:0,x:a?12:0,y:a?0:8},{autoAlpha:1,x:0,y:0,duration:.28,ease:`power2.out`,clearProps:`transform,opacity,visibility`}))}),(0,X.jsx)(`article`,{ref:c,className:`conversation-row group mx-auto w-full max-w-full px-4 py-3 sm:px-6 lg:max-w-[61.8vw]`,children:a?(0,X.jsxs)(`div`,{className:`flex items-end justify-end gap-2`,children:[(0,X.jsx)(Ci,{text:t.text,label:i(`copy.message`),copiedLabel:i(`copy.copied`),className:`opacity-60 sm:opacity-0 sm:group-hover:opacity-100`}),(0,X.jsx)(`time`,{className:`shrink-0 pb-1 font-mono text-[10px] tabular-nums text-ink-faint`,children:pi(e)}),(0,X.jsx)(`div`,{className:`max-w-[calc(100%_-_3rem)] rounded-[18px] bg-conversation-user px-4 py-2.5 text-[15px] leading-relaxed text-ink ring-1 ring-line/35 sm:max-w-[82%]`,children:(0,X.jsx)(ki,{artifacts:n,onOpenArtifact:r,children:t.text})})]}):(0,X.jsxs)(`div`,{className:`flex gap-3`,children:[(0,X.jsx)(`span`,{className:`mt-0.5 flex h-7 w-7 shrink-0 items-center justify-center`,children:(0,X.jsx)(Ai,{size:26,className:`text-ink`})}),(0,X.jsxs)(`div`,{className:`relative min-w-0 flex-1 text-[15px] leading-relaxed text-ink`,children:[(0,X.jsxs)(`div`,{className:`mb-1 flex items-center gap-2`,children:[(0,X.jsx)(`span`,{className:`text-xs font-semibold text-blue`,children:`Argus`}),(0,X.jsx)(Ci,{text:t.text,label:i(`copy.message`),copiedLabel:i(`copy.copied`),className:`ml-auto opacity-60 sm:opacity-0 sm:group-hover:opacity-100`}),(0,X.jsxs)(`time`,{className:`font-mono text-[10px] tabular-nums text-ink-faint`,children:[pi(e),s]})]}),(0,X.jsx)(ki,{artifacts:n,onOpenArtifact:r,children:t.text})]})]})})}function Qi({role:e,rows:t,open:n,active:r,onToggle:i}){let{t:a}=Z(),o=W.role[e],s=(0,I.useRef)(null),c=t[t.length-1]?.r.text.length??0;return(0,I.useEffect)(()=>{if(!n)return;let e=window.requestAnimationFrame(()=>{s.current&&s.current.scrollHeight>s.current.clientHeight&&(s.current.scrollTop=s.current.scrollHeight)});return()=>window.cancelAnimationFrame(e)},[n,t.length,c]),(0,X.jsxs)(`section`,{className:`role-log-group border-b border-line/50`,"data-role":e,"data-open":n?`true`:`false`,"data-active":r?`true`:`false`,children:[(0,X.jsxs)(`button`,{type:`button`,onClick:i,"aria-expanded":n,className:`group flex h-11 w-full items-center gap-2 px-4 text-left transition-colors hover:bg-bg/60`,children:[(0,X.jsx)(`span`,{"data-role-dot":e,"aria-hidden":`true`,className:`h-2 w-2 shrink-0 rounded-full ${r?`animate-pulse motion-reduce:animate-none`:``}`,style:{background:o}}),(0,X.jsx)(`span`,{className:`text-xs font-semibold text-ink-dim`,children:Vi(e,a)}),(0,X.jsx)(`span`,{className:`font-mono text-xs text-ink-faint`,children:t.length}),t.length>0?(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-ink-faint`,children:t[t.length-1].r.text}):(0,X.jsx)(`span`,{className:`flex-1`}),(0,X.jsx)(`svg`,{viewBox:`0 0 16 16`,"aria-hidden":`true`,className:`h-4 w-4 shrink-0 text-ink-faint transition-transform duration-panel ease-panel ${n?`rotate-90`:``}`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,children:(0,X.jsx)(`path`,{d:`m6 3.5 4.5 4.5L6 12.5`})})]}),n?(0,X.jsx)(`div`,{className:`grid grid-rows-[1fr]`,children:(0,X.jsx)(`div`,{className:`min-h-0 overflow-hidden`,children:(0,X.jsx)(`div`,{ref:s,className:`max-h-72 overflow-x-hidden overflow-y-auto border-t border-line/40 scroll-thin`,children:t.length>0?t.map(({ev:e,r:n,key:r},i)=>(0,X.jsx)(Xi,{ev:e,r:n,first:i===0,last:i===t.length-1},r)):(0,X.jsx)(`div`,{className:`px-4 py-3 text-xs text-ink-faint`,children:a(`stream.noLogs`)})})})}):null]})}function $i(e){let t={manager:[],planner:[],engineer:[],reviewer:[]},n=[];return e.forEach(e=>{qi.includes(e.r.role)?t[e.r.role].push(e):n.push(e)}),{roleRows:t,systemRows:n,lastRole:[...e].reverse().find(e=>qi.includes(e.r.role))?.r.role??``}}function ea({rows:e}){let{t}=Z(),[n,r]=(0,I.useState)(!1);return(0,X.jsxs)(`section`,{className:`border-b border-line/50`,"data-system-open":n?`true`:`false`,children:[(0,X.jsxs)(`button`,{type:`button`,"aria-expanded":n,onClick:()=>r(e=>!e),className:`flex h-10 w-full items-center gap-2 px-4 text-left text-xs text-ink-faint hover:bg-bg/60`,children:[(0,X.jsx)(`span`,{children:t(`stream.system`)}),(0,X.jsx)(`span`,{className:`font-mono`,children:e.length}),(0,X.jsx)(`span`,{className:`flex-1`}),(0,X.jsx)(`svg`,{viewBox:`0 0 16 16`,"aria-hidden":`true`,className:`h-4 w-4 shrink-0 transition-transform duration-panel ease-panel ${n?`rotate-90`:``}`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,children:(0,X.jsx)(`path`,{d:`m6 3.5 4.5 4.5L6 12.5`})})]}),n?(0,X.jsx)(`div`,{className:`border-t border-line/40`,children:e.map(({ev:t,r:n,key:r},i)=>(0,X.jsx)(Xi,{ev:t,r:n,first:i===0,last:i===e.length-1},r))}):null]})}function ta({rows:e,live:t}){let{roleRows:n,systemRows:r,lastRole:i}=(0,I.useMemo)(()=>$i(e),[e]),[a,o]=(0,I.useState)(()=>new Set(t&&i?[i]:[])),s=(0,I.useRef)(!1);return(0,I.useEffect)(()=>{!t||!i||s.current||o(new Set([i]))},[i,t]),(0,X.jsxs)(`div`,{className:`bg-bg/25`,children:[qi.map(e=>(0,X.jsx)(Qi,{role:e,rows:n[e],open:a.has(e),active:i===e,onToggle:()=>{s.current=!0,o(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}},e)),r.length>0?(0,X.jsx)(ea,{rows:r}):null]})}function na(e){let t=e.delivery;if(!t||typeof t!=`object`||Array.isArray(t))return null;let n=t;return typeof n.delivery_id!=`string`||!n.delivery_id.trim()?null:n}function ra(e){for(let t=e.length-1;t>=0;--t){let n=e[t];if(n.type===`ui.operator`)return null;let r=na(n);if(r)return r}}function ia({delivery:e,onOpen:t}){let{t:n}=Z(),r=e.kind===`submission_certified`;return(0,X.jsxs)(`aside`,{className:`mx-auto my-3 flex w-full max-w-full gap-3 rounded-lg border border-ok/35 bg-ok/5 px-4 py-3 lg:max-w-[61.8vw]`,children:[(0,X.jsx)(`span`,{className:`flex h-7 w-7 shrink-0 items-center justify-center rounded-full bg-ok/15 font-semibold text-ok`,children:`✓`}),(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-[0.14em] text-ok`,children:n(r?`mission.deliveryCertified`:`mission.taskCompleted`)}),(0,X.jsx)(`div`,{className:`mt-1 truncate text-sm font-semibold text-ink`,title:e.title,children:e.title}),e.summary?(0,X.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-ink-dim`,children:ei(e.summary)}):null,t?(0,X.jsx)(`button`,{type:`button`,onClick:()=>t(e),className:`mt-2 rounded border border-ok/40 px-2 py-1 font-mono text-[10px] text-ok hover:border-ok hover:bg-ok/10`,children:n(e.primary_target?`mission.openResult`:`mission.viewTask`)}):null]})]})}function aa({group:e,latest:t,artifacts:n,onOpenArtifact:r,onOpenDelivery:i}){let a=e=>e.ev.type===`ui.argus`&&/^(info:|operation cancelled|cancelled\b)/i.test(e.r.text.trim()),o=e.rows.filter(e=>e.ev.type===`ui.argus`).map(e=>{let t=e.r.text.match(Ji)??[],n=e.r.text.replace(Ji,``).trim();return{reply:n&&!a(e)?{...e,r:{...e.r,text:n}}:null,messages:a(e)&&t.length===0?[e.r.text]:t}}),s=o.flatMap(e=>e.reply?[e.reply]:[]),c=o.flatMap(e=>e.messages),l=e.rows.filter(({ev:e})=>e.type!==`ui.argus`),u=(()=>{let t=new Set;return e.rows.flatMap(e=>{let n=na(e.ev);return!n||t.has(n.delivery_id)?[]:(t.add(n.delivery_id),[n])})})();return(0,X.jsxs)(`section`,{className:`conversation-thread border-b border-line/60`,children:[(0,X.jsx)(Zi,{ev:e.operator.ev,r:e.operator.r,artifacts:n,onOpenArtifact:r}),s.map(e=>(0,X.jsx)(Zi,{ev:e.ev,r:e.r,artifacts:n,onOpenArtifact:r},e.key)),c.map((t,n)=>(0,X.jsx)(`div`,{className:`mx-auto w-full max-w-full px-6 py-1.5 text-center text-xs text-ink-faint lg:max-w-[61.8vw]`,children:t},`${e.key}-system-${n}`)),u.map(e=>(0,X.jsx)(ia,{delivery:e,onOpen:i},e.delivery_id)),l.length>0?(0,X.jsx)(`div`,{className:`mx-auto w-full max-w-full border-t border-line/40 lg:max-w-[61.8vw]`,children:(0,X.jsx)(ta,{rows:l,live:t})}):null]})}function oa({events:e,connected:t,showReasoning:n,onToggleReasoning:r,embedded:i=!1,showHeader:a=!0,filter:o=`all`,query:s=``,skipFirst:c=0,artifacts:l,onOpenArtifact:u,onOpenDelivery:d}){let{locale:f,t:p}=Z(),[m,h]=(0,I.useState)(!0),[g,_]=(0,I.useState)(()=>Date.now()),v=(0,I.useRef)(null),y=(0,I.useDeferredValue)(e),b=(0,I.useMemo)(()=>Yi(y),[y]);(0,I.useEffect)(()=>{if(!b)return;_(Date.now());let e=window.setInterval(()=>_(Date.now()),1e3);return()=>window.clearInterval(e)},[b]);let x=b?Math.max(0,Math.floor((g-Number(b.ts??0)*1e3)/1e3)):0,S=(0,I.useMemo)(()=>{let e=[],t=new Map,r=0;return(c>0?y.slice(c):y).forEach((i,a)=>{let c=ir(i,f);if(!c)return;if(c.reasoning&&!n){r++;return}if(!Mt(i,c,o,s))return;let l=i,u=String(l.message_id??``),d=!!u&&String(l.type)===`engineer.progress`&&[`assistant_message`,`agent_message`,`message`].includes(String(l.kind));if(d&&t.has(u)){let n=t.get(u);e[n]={...e[n],ev:{...e[n].ev,...i},r:{...e[n].r,...c,text:kt(e[n].r.text,c.text,Dt(i))}};return}let p={ev:i,r:c,key:ar(i,a)};d&&t.set(u,e.length),e.push(p)}),{list:e,hiddenReasoning:r}},[y,n,o,s,c,f]),C=(0,I.useMemo)(()=>{let e=[],t=[],n=null;return S.list.forEach(r=>{r.ev.type===`ui.operator`?(n={key:r.key,operator:r,rows:[]},e.push(n)):n?n.rows.push(r):t.push(r)}),{groups:e,earlier:t}},[S.list]),w=(0,I.useMemo)(()=>y.filter(Ct).length,[y]),T=(0,I.useMemo)(()=>S.list.slice(-20).reduce((e,t)=>e+t.r.text.length,0),[S.list]);return(0,I.useEffect)(()=>{if(!m)return;let e=window.requestAnimationFrame(()=>{v.current&&(v.current.scrollTop=v.current.scrollHeight)});return()=>window.cancelAnimationFrame(e)},[S.list.length,T,m]),(0,I.useEffect)(()=>{let e=v.current;if(!e)return;let t=()=>h(e.scrollHeight-e.scrollTop-e.clientHeight<40);return e.addEventListener(`scroll`,t,{passive:!0}),()=>e.removeEventListener(`scroll`,t)},[]),(0,X.jsxs)(`section`,{className:`relative flex min-h-0 flex-1 flex-col overflow-hidden bg-panel ${i?``:`rounded-lg border border-line/80`}`,children:[a&&(0,X.jsx)(yi,{title:p(`panel.activity`),right:(0,X.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,X.jsxs)(`button`,{onClick:r,className:`rounded px-1.5 py-0.5 text-xs transition-colors ${n?`text-blue-sky`:`text-ink-faint hover:text-ink-dim`}`,title:p(`stream.toggleReasoning`),children:[p(`stream.reasoning`),w?` ·${w}`:``]}),(0,X.jsx)(`span`,{className:`text-xs ${t?`text-ok`:`text-ink-faint`}`,children:t?`● ${p(`common.live`)}`:`○ ${p(`common.reconnecting`)}`})]})}),b?(0,X.jsxs)(`div`,{className:`flex h-9 shrink-0 items-center gap-2 border-b border-line/60 bg-blue-deep/5 px-4 text-xs text-ink-dim`,children:[(0,X.jsx)(`span`,{className:`h-2 w-2 animate-pulse rounded-full bg-blue-sky`}),(0,X.jsx)(`span`,{className:`truncate`,children:p(`stream.backgroundWork`)}),(0,X.jsxs)(`span`,{className:`ml-auto shrink-0 font-mono tabular-nums text-ink-faint`,children:[x,`s`]})]}):null,(0,X.jsx)(`div`,{ref:v,className:`min-h-0 flex-1 overflow-x-hidden overflow-y-auto pb-6 pt-1.5 scroll-thin`,children:S.list.length===0?(0,X.jsx)(xi,{children:p(`stream.ready`)}):(0,X.jsxs)(X.Fragment,{children:[C.earlier.length>0?(0,X.jsxs)(`section`,{className:`mx-auto w-full max-w-full border-b border-line/60 lg:max-w-[61.8vw]`,children:[(0,X.jsxs)(`div`,{className:`flex h-10 items-center gap-2 border-b border-line/40 px-4 text-[10px] font-semibold uppercase tracking-[0.12em] text-ink-faint`,children:[p(`stream.autonomous`),(0,X.jsx)(`span`,{className:`font-mono font-normal tracking-normal`,children:C.earlier.length})]}),(0,X.jsx)(ta,{rows:C.earlier,live:C.groups.length===0})]}):null,C.groups.map((e,t)=>(0,X.jsx)(aa,{group:e,latest:t===C.groups.length-1,artifacts:l,onOpenArtifact:u,onOpenDelivery:d},e.key))]})}),!m&&(0,X.jsx)(`button`,{onClick:()=>{h(!0),v.current?.scrollTo({top:v.current.scrollHeight,behavior:`smooth`})},"aria-label":p(`stream.jumpToLatest`),title:p(`stream.jumpToLatest`),className:`absolute bottom-4 left-1/2 flex h-8 w-8 -translate-x-1/2 items-center justify-center rounded-full border border-line/60 bg-panel text-sm text-ink-dim shadow-glow transition-all duration-200 hover:border-ink-faint hover:text-ink`,children:`↓`})]})}function sa(e){return e.nativeEvent.isComposing||e.keyCode===229}var ca=`operator console`,la={Everyday:`常用`,"Task management":`任务管理`,"Sessions & diagnostics":`会话与诊断`,Configuration:`配置`,Other:`其他`},ua={crystalpilot:`在当前 Argus 会话启用晶体学工具,保持原生界面`,status:`查看角色、队列、日志和健康状态`,roles:`查看各角色的后端、模型、推理强度和实时活动`,journal:`查看近期日志(默认 10 条)`,backlog:`查看待处理任务(all 包含已完成和已跳过)`,artifacts:`查看 Reviewer 批准的结果文件(按 Enter 预览)`,artifact:`预览一个已批准的结果文件`,events:`搜索动态:all / watch / milestones / messages`,find:`搜索当前事件缓冲区`,cancel:`停止等待当前 Manager 回复`,ask:`直接回答,不排任务、不走 Planner/Engineer/Reviewer`,task:`直接加入任务队列`,plan:`预览 Planner 编写的执行计划`,rewrite:`让 Manager 在发送前改写提示词`,nudge:`向正在运行的任务注入指导`,abort:`立即终止正在运行的任务`,note:`向时间线添加手动备注`,done:`将任务标记为完成`,skip:`跳过任务`,stop:`停止任务的自动迭代`,item:`查看完整任务契约`,run:`返回持续更新的任务动态`,new:`检查、创建并切换到新会话`,daemons:`查找全部会话并切换或创建`,resume:`切换到其他项目或会话`,attach:`跟随其他项目并读取其动态`,rename:`重命名当前会话`,doctor:`诊断为什么没有任务运行`,backend:`查看或更改共享 Runner 后端`,config:`查看或更改运行时设置`,identity:`查看或替换操作者身份卡`,reset:`清除 Manager 的热会话上下文`,skills:`查看或提升运行时 Skill`,clear:`清空事件动态视图`,reconnect:`重新连接实时动态`,help:`查看快捷键和完整命令参考`,quit:`离开控制台(后台工作继续运行)`};function da(e,t){return t===`zh-CN`?ua[e.id]:e.id===`reconnect`?`reconnect live activity`:e.desc}function fa(e,t){return t===`zh-CN`?la[e.group]:e.group}function pa(e,t){let n=new Map;for(let r of e){let e=fa(r,t),i=r.aliases?.length?` (= ${r.aliases.join(`, `)})`:``,a=`${r.name}${r.arg?` ${r.arg}`:``}${i}`;n.has(e)||n.set(e,[]),n.get(e).push({label:a,desc:da(r,t)})}return[...n.entries()].map(([e,t])=>({group:e,rows:t}))}var ma=`slash-completion-listbox`;function ha(e,t){return t<=0?0:Math.max(0,Math.min(e,t-1))}function ga(e){return`slash-completion-option-${e}`}function _a({query:e,selected:t,onSelect:n}){let{locale:r,t:i}=Z(),a=Rt(e);if(a.length===0)return null;let o=a.slice(0,8),s=ha(t,o.length);return(0,X.jsx)(`div`,{id:ma,role:`listbox`,"aria-label":i(`slash.suggestions`),className:`slash-completion-menu scroll-thin border-b border-line/40`,children:o.map((e,t)=>(0,X.jsxs)(`button`,{id:ga(e.id),type:`button`,role:`option`,"aria-selected":t===s,onPointerDown:e=>{e.preventDefault(),n(t)},className:`flex w-full items-baseline gap-2 px-3 py-1.5 text-left text-sm transition-colors ${t===s?`bg-blue/10 text-ink`:`text-ink-dim hover:bg-line/20`}`,children:[(0,X.jsx)(`span`,{className:`shrink-0 font-mono text-blue`,children:e.name}),e.arg?(0,X.jsx)(`span`,{className:`shrink-0 font-mono text-xs text-ink-faint`,children:e.arg}):null,(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-ink-faint`,children:da(e,r)})]},e.id))})}var va=10485760,ya=26214400,ba=[`.png`,`.jpg`,`.jpeg`,`.webp`,`.pdf`,`.md`,`.markdown`,`.txt`,`.json`,`.csv`].join(`,`),xa={".png":`image/png`,".jpg":`image/jpeg`,".jpeg":`image/jpeg`,".webp":`image/webp`,".pdf":`application/pdf`,".md":`text/markdown`,".markdown":`text/markdown`,".txt":`text/plain`,".json":`application/json`,".csv":`text/csv`};function Sa(e){let t=String(e||``).trim().toLowerCase(),n=t.lastIndexOf(`.`);return n>=0?t.slice(n):``}function Ca(e){return xa[Sa(e.name)]||String(e.type||``).split(`;`,1)[0].trim()||`application/octet-stream`}function wa(e){return Object.hasOwn(xa,Sa(e.name))}function Ta(e){return Ca(e).startsWith(`image/`)}function Ea(e){return[e.name,String(e.size),Ca(e),String(e.lastModified??``)].join(`::`)}function Da(e,t){let n=[],r=[],i=new Set(e.map(Ea)),a=e.reduce((e,t)=>e+Math.max(0,t.size||0),0),o=e.length;for(let e of t){let t=Ea(e);if(!i.has(t)){if(i.add(t),!wa(e)){r.push({code:`unsupported`,fileName:e.name});continue}if(o>=5){r.push({code:`too-many`,limitCount:5});continue}if(e.size>10485760){r.push({code:`too-large`,fileName:e.name,limitBytes:va});continue}if(a+e.size>26214400){r.push({code:`too-large-total`,limitBytes:ya});continue}n.push(e),a+=e.size,o+=1}}return{accepted:n,issues:r}}function Oa(e){return e?Array.from(e):[]}function ka(e){return Oa(e?.types).map(e=>String(e)).includes(`Files`)||Aa(e).length>0}function Aa(e){let t=Oa(e?.files).filter(e=>e instanceof File);if(t.length)return t;let n=[];for(let t of Oa(e?.items)){if(String(t?.kind||``)!==`file`||typeof t?.getAsFile!=`function`)continue;let e=t.getAsFile();e instanceof File&&n.push(e)}return n}function ja({file:e,removeLabel:t,onRemove:n,disabled:r=!1}){let[i,a]=(0,I.useState)(``);return(0,I.useEffect)(()=>{if(!Ta(e)||typeof URL>`u`||typeof URL.createObjectURL!=`function`){a(``);return}let t=URL.createObjectURL(e);return a(t),()=>URL.revokeObjectURL(t)},[e]),(0,X.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 rounded-2xl border border-line/50 bg-panel/80 px-2.5 py-2 text-xs shadow-[0_10px_24px_-20px_rgb(0_0_0/0.2)]`,children:[i?(0,X.jsx)(`img`,{src:i,alt:``,className:`h-10 w-10 shrink-0 rounded-xl border border-line/40 object-cover`}):null,(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`div`,{className:`truncate font-medium text-ink`,title:e.name,children:e.name}),(0,X.jsxs)(`div`,{className:`truncate text-ink-faint`,children:[fi(e.size),` · `,Ca(e)]})]}),(0,X.jsx)(`button`,{type:`button`,onClick:n,disabled:r,"aria-label":t,title:t,className:`send-control h-8 w-8 shrink-0 rounded-full border-line/60 text-ink-faint hover:border-err/50 hover:bg-err/10 hover:text-err`,children:`×`})]})}var Ma=e=>e.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase(),Na=(...e)=>e.filter((e,t,n)=>!!e&&e.trim()!==``&&n.indexOf(e)===t).join(` `).trim(),Pa={xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`},Fa=(0,I.forwardRef)(({color:e=`currentColor`,size:t=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:i=``,children:a,iconNode:o,...s},c)=>(0,I.createElement)(`svg`,{ref:c,...Pa,width:t,height:t,stroke:e,strokeWidth:r?Number(n)*24/Number(t):n,className:Na(`lucide`,i),...s},[...o.map(([e,t])=>(0,I.createElement)(e,t)),...Array.isArray(a)?a:[a]])),Ia=(e,t)=>{let n=(0,I.forwardRef)(({className:n,...r},i)=>(0,I.createElement)(Fa,{ref:i,iconNode:t,className:Na(`lucide-${Ma(e)}`,n),...r}));return n.displayName=`${e}`,n},La=Ia(`Activity`,[[`path`,{d:`M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2`,key:`169zse`}]]),Ra=Ia(`ArrowUpRight`,[[`path`,{d:`M7 7h10v10`,key:`1tivn9`}],[`path`,{d:`M7 17 17 7`,key:`1vkiza`}]]),za=Ia(`ArrowUp`,[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]),Ba=Ia(`Boxes`,[[`path`,{d:`M2.97 12.92A2 2 0 0 0 2 14.63v3.24a2 2 0 0 0 .97 1.71l3 1.8a2 2 0 0 0 2.06 0L12 19v-5.5l-5-3-4.03 2.42Z`,key:`lc1i9w`}],[`path`,{d:`m7 16.5-4.74-2.85`,key:`1o9zyk`}],[`path`,{d:`m7 16.5 5-3`,key:`va8pkn`}],[`path`,{d:`M7 16.5v5.17`,key:`jnp8gn`}],[`path`,{d:`M12 13.5V19l3.97 2.38a2 2 0 0 0 2.06 0l3-1.8a2 2 0 0 0 .97-1.71v-3.24a2 2 0 0 0-.97-1.71L17 10.5l-5 3Z`,key:`8zsnat`}],[`path`,{d:`m17 16.5-5-3`,key:`8arw3v`}],[`path`,{d:`m17 16.5 4.74-2.85`,key:`8rfmw`}],[`path`,{d:`M17 16.5v5.17`,key:`k6z78m`}],[`path`,{d:`M7.97 4.42A2 2 0 0 0 7 6.13v4.37l5 3 5-3V6.13a2 2 0 0 0-.97-1.71l-3-1.8a2 2 0 0 0-2.06 0l-3 1.8Z`,key:`1xygjf`}],[`path`,{d:`M12 8 7.26 5.15`,key:`1vbdud`}],[`path`,{d:`m12 8 4.74-2.85`,key:`3rx089`}],[`path`,{d:`M12 13.5V8`,key:`1io7kd`}]]),Va=Ia(`Check`,[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]),Ha=Ia(`ChevronDown`,[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]),Ua=Ia(`CircleCheck`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),Wa=Ia(`CircleHelp`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`,key:`1u773s`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),Ga=Ia(`Clock3`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`polyline`,{points:`12 6 12 12 16.5 12`,key:`1aq6pp`}]]),Ka=Ia(`Diamond`,[[`path`,{d:`M2.7 10.3a2.41 2.41 0 0 0 0 3.41l7.59 7.59a2.41 2.41 0 0 0 3.41 0l7.59-7.59a2.41 2.41 0 0 0 0-3.41l-7.59-7.59a2.41 2.41 0 0 0-3.41 0Z`,key:`1f1r0c`}]]),qa=Ia(`Download`,[[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}],[`polyline`,{points:`7 10 12 15 17 10`,key:`2ggqvy`}],[`line`,{x1:`12`,x2:`12`,y1:`15`,y2:`3`,key:`1vk2je`}]]),Ja=Ia(`ExternalLink`,[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`M10 14 21 3`,key:`gplh6r`}],[`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`,key:`a6xqqp`}]]),Ya=Ia(`FileText`,[[`path`,{d:`M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z`,key:`1rqfz7`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`path`,{d:`M10 9H8`,key:`b1mrlr`}],[`path`,{d:`M16 13H8`,key:`t4e002`}],[`path`,{d:`M16 17H8`,key:`z1uh3a`}]]),Xa=Ia(`KeyRound`,[[`path`,{d:`M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z`,key:`1s6t7t`}],[`circle`,{cx:`16.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`w0ekpg`}]]),Za=Ia(`LoaderCircle`,[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`,key:`13zald`}]]),Qa=Ia(`Maximize2`,[[`polyline`,{points:`15 3 21 3 21 9`,key:`mznyad`}],[`polyline`,{points:`9 21 3 21 3 15`,key:`1avn1i`}],[`line`,{x1:`21`,x2:`14`,y1:`3`,y2:`10`,key:`ota7mn`}],[`line`,{x1:`3`,x2:`10`,y1:`21`,y2:`14`,key:`1atl0r`}]]),$a=Ia(`Minimize2`,[[`polyline`,{points:`4 14 10 14 10 20`,key:`11kfnr`}],[`polyline`,{points:`20 10 14 10 14 4`,key:`rlmsce`}],[`line`,{x1:`14`,x2:`21`,y1:`10`,y2:`3`,key:`o5lafz`}],[`line`,{x1:`3`,x2:`10`,y1:`21`,y2:`14`,key:`1atl0r`}]]),eo=Ia(`PackageCheck`,[[`path`,{d:`m16 16 2 2 4-4`,key:`gfu2re`}],[`path`,{d:`M21 10V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l2-1.14`,key:`e7tb2h`}],[`path`,{d:`m7.5 4.27 9 5.15`,key:`1c824w`}],[`polyline`,{points:`3.29 7 12 12 20.71 7`,key:`ousv84`}],[`line`,{x1:`12`,x2:`12`,y1:`22`,y2:`12`,key:`a4e8g8`}]]),to=Ia(`Pause`,[[`rect`,{x:`14`,y:`4`,width:`4`,height:`16`,rx:`1`,key:`zuxfzm`}],[`rect`,{x:`6`,y:`4`,width:`4`,height:`16`,rx:`1`,key:`1okwgv`}]]),no=Ia(`RefreshCw`,[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`,key:`v9h5vc`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`,key:`3uifl3`}],[`path`,{d:`M8 16H3v5`,key:`1cv678`}]]),ro=Ia(`ShieldCheck`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),io=Ia(`Square`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]),ao=Ia(`Terminal`,[[`polyline`,{points:`4 17 10 11 4 5`,key:`akl6gq`}],[`line`,{x1:`12`,x2:`20`,y1:`19`,y2:`19`,key:`q2wloq`}]]),oo=Ia(`X`,[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]);function so(e,t,n){let r=e?.model_revision&&e.model_revision!==n,i={...e?.cards};for(let[n,a]of Object.entries(t.cards)){if(r&&i[n]?.model_revision===e.model_revision)continue;let t=i[n];(!t||(a.copy_revision??0)>(t.copy_revision??0)||(a.copy_revision??0)===(t.copy_revision??0)&&(a.generated_at>t.generated_at||a.generated_at===t.generated_at&&!t.input_revision))&&(i[n]=a)}let a=(t.cache_revision??0)<(e?.cache_revision??0);return{...e,...t,cards:i,cache_revision:Math.max(t.cache_revision??0,e?.cache_revision??0),relations:(r||a)&&e?e.relations:t.relations,available:t.available??!0,...r?{model_revision:e.model_revision,available:e.available}:{}}}function co(e,t,n){let r=n?.cards[e.key],i=t.tasks.find(t=>t.id===e.task_id);if(!r||!i)return!0;let a=[i.id,i.id+`:active`,i.id+`:outcome`].includes(e.key);if(a||!r.task_content_revision||!i.content_revision){if(i.revision&&r.task_revision!==i.revision||a&&r.task_status!==i.status)return!0}else if(r.task_content_revision!==i.content_revision)return!0;let o=r.event_ids||[];return e.event_ids.some(e=>{let n=o.indexOf(e),i=t.events.find(t=>t.id===e);return n<0||r.event_revisions&&i?.revision&&r.event_revisions[n]!==i.revision})||!a&&JSON.stringify(e.event_ids)!==JSON.stringify(o)}var lo=e=>`[[Argus引用 ${JSON.stringify(e)}]]\n`;function uo(e){let t=[];return{refs:t,text:e.split(` +`).filter(e=>{if(e.startsWith(`[[Argus引用 `)&&e.endsWith(`]]`))try{let n=JSON.parse(e.slice(10,-2));if(typeof n.task_id==`string`&&typeof n.source==`string`&&typeof n.task_title==`string`&&(n.part===void 0||Number.isInteger(n.part)&&n.part>0)&&(n.step_title===void 0||typeof n.step_title==`string`)&&(n.step_id===void 0||typeof n.step_id==`string`)&&(n.team_id===void 0||typeof n.team_id==`string`)&&(n.team_task_id===void 0||typeof n.team_task_id==`string`)&&(n.lang===void 0||typeof n.lang==`string`)&&Array.isArray(n.event_ids)&&n.event_ids.every(e=>typeof e==`string`))return t.push(n),!1}catch{}return!0}).join(` +`).replace(/^\n+/,``)}}function fo(e,t,n){let r=e.tasks.find(e=>e.id===n),i=r?[r,...e.tasks.filter(e=>e.id!==n)]:e.tasks,a=(t,n=1/0)=>{let r=Math.max(-1/0,...e.events.filter(e=>e.item_id===t&&e.type===`life.mission.started`&&e.ts<=n).map(e=>e.ts));return e.events.filter(e=>e.item_id===t&&e.ts>=r&&e.ts<=n&&[`round.main.completed`,`round.review.completed`].includes(e.type)).slice(-2).map(e=>e.id)},o=i.map(t=>({key:t.id,task_id:t.id,kind:`task`,event_ids:[...new Set([...a(t.id),...e.events.filter(e=>e.item_id===t.id).slice(-2).map(e=>e.id)])]})),s=r?t.map(e=>({key:e.id,task_id:r.id,kind:e.kind,event_ids:[...new Set([...e.kind===`result`?a(r.id,e.ts):[],...e.eventIds])].slice(-16)})):[];return[...o.slice(0,1),...s,...o.slice(1)]}function po({value:e,onChange:t,inputRef:n,fileInputRef:r,onFiles:i,inputProps:a,onSend:o,onCancel:s,pending:c,disabled:l=!1,controls:u}){let{t:d,locale:f}=Z(),p=f===`zh-CN`,{refs:m,text:h}=uo(e);return(0,I.useEffect)(()=>{let e=n.current;if(!e)return;let t=()=>{e.getClientRects().length&&(e.style.height=`0px`,e.style.height=`${Math.min(132,Math.max(28,e.scrollHeight))}px`)};t();let r=e.clientWidth,i=new ResizeObserver(()=>{e.clientWidth!==r&&(r=e.clientWidth,t())});return i.observe(e),()=>i.disconnect()},[n,h]),(0,X.jsxs)(`div`,{className:`composer-surface`,"data-pending":c,children:[m.length>0&&(0,X.jsx)(`div`,{className:`map-reference-chips`,children:m.map((e,n)=>(0,X.jsxs)(`span`,{children:[(0,X.jsxs)(`span`,{children:[p?`引用`:`Reference`,` · `,e.step_title||e.task_title]}),(0,X.jsx)(`button`,{type:`button`,"aria-label":p?`移除引用`:`Remove reference`,onClick:()=>t(m.filter((e,t)=>t!==n).map(lo).join(``)+h),children:(0,X.jsx)(oo,{size:12})})]},`${e.task_id}:${e.step_id}:${n}`))}),(0,X.jsxs)(`form`,{className:`map-composer`,onSubmit:e=>{e.preventDefault(),!c&&!l&&o()},children:[(0,X.jsx)(`input`,{ref:r,type:`file`,multiple:!0,accept:ba,hidden:!0,disabled:l||c,onChange:i}),(0,X.jsx)(`button`,{type:`button`,className:`map-composer-brand map-attach`,"aria-label":d(`chat.attach`),title:d(`chat.attach`),disabled:l||c,onClick:()=>r.current?.click(),children:(0,X.jsx)(Ai,{size:24})}),(0,X.jsx)(`textarea`,{...a,ref:n,rows:1,value:h,disabled:l,onChange:e=>t(m.map(lo).join(``)+e.target.value),onKeyDown:e=>{a.onKeyDown?.(e),!(e.defaultPrevented||sa(e))&&e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),!c&&!l&&o())}}),(0,X.jsx)(`button`,{type:c?`button`:`submit`,onClick:c?s:void 0,disabled:l||!c&&!h.trim(),"aria-label":c?p?`停止等待`:`Stop waiting`:p?`发送消息`:`Send message`,className:`map-send ${c?`is-pending`:``}`,children:c?(0,X.jsx)(io,{size:15}):(0,X.jsx)(za,{size:20})})]}),u?(0,X.jsx)(`div`,{className:`composer-controls`,children:u}):null]})}function mo(e,t){if(!t.onRewrite||!Zn(e.key,e.ctrlKey,e.metaKey))return!1;e.preventDefault();let n=t.value.trim();return n&&!t.disabled&&!t.pending&&!t.rewriting&&t.onRewrite(n),!0}function ho({value:e,onChange:t,onSend:n,onCancel:r,disabled:i,pending:a,focusSignal:o,attachments:s,onAttachmentsChange:c,steps:l=[],onRewrite:u,rewriting:d=!1,slashSelection:f,onSlashSelectionChange:p,routeOverride:m=`auto`,onRouteOverrideChange:h}){let{t:g}=Z(),_=(0,I.useRef)(null),v=(0,I.useRef)(null),y=(0,I.useRef)(!1),[b,x]=(0,I.useState)(0),[S,C]=(0,I.useState)(!1),[w,T]=(0,I.useState)(``),[E,D]=(0,I.useState)(0),[ee,O]=(0,I.useState)(!1);(0,I.useEffect)(()=>{if(!a&&!d)return;let e=setInterval(()=>x(e=>e+1),1e3);return()=>clearInterval(e)},[a,d]),(0,I.useEffect)(()=>{o&&!i&&_.current?.focus()},[o,i]);let te=Jn(l),ne=Date.now()/1e3,k=Rt(e).slice(0,8),re=k.length>0&&!S,A=re?ha(f,k.length):0,j=re?k[A]:void 0,ie=e=>{let n=k[e];n&&(t(Bt(n)),n.argument===`none`&&C(!0),p(0),_.current?.focus())},ae=async()=>{if(!(!e.trim()||a||i||d||y.current)){y.current=!0;try{await n(e.trim(),s)&&(p(0),C(!1),T(``))}finally{y.current=!1}}},M=e=>{if(!e.length||i||a||y.current)return;let{accepted:t,issues:n}=Da(s,e);t.length&&c([...s,...t]),T(n.map(e=>e.code===`unsupported`?g(`chat.attachUnsupported`,{name:e.fileName}):e.code===`too-large`?g(`chat.attachTooLarge`,{name:e.fileName,size:fi(e.limitBytes)}):e.code===`too-many`?g(`chat.attachTooMany`,{count:e.limitCount}):g(`chat.attachTotalTooLarge`,{size:fi(e.limitBytes)})).join(` `))},oe=(e,t)=>{ka(e.dataTransfer)&&(e.preventDefault(),D(e=>Math.max(0,e+t)))};return(0,X.jsxs)(`div`,{className:`conversation-composer flex flex-col ${E>0?`rounded-3xl ring-2 ring-manager/60`:``}`,"data-compact":!ee&&!e.trim()&&!s.length&&!a&&!d&&!w&&!E,onFocusCapture:()=>O(!0),onBlurCapture:e=>O(e.currentTarget.contains(e.relatedTarget)),onDragEnter:e=>oe(e,1),onDragOver:e=>oe(e,0),onDragLeave:e=>oe(e,-1),onDrop:e=>{ka(e.dataTransfer)&&(e.preventDefault(),D(0),M(Aa(e.dataTransfer)))},children:[a?(0,X.jsxs)(`div`,{className:`px-3 py-2`,children:[te.length?(0,X.jsx)(`ol`,{className:`mt-1.5 space-y-0.5`,children:te.map((e,t)=>{let n=t===te.length-1&&!e.endedTs,r=Xn(Yn(e,ne));return(0,X.jsxs)(`li`,{className:`flex min-w-0 items-baseline gap-2 text-xs`,children:[(0,X.jsx)(`span`,{className:`shrink-0 font-mono ${n?`text-manager`:`text-ok`}`,children:n?Un(b):`✓`}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono ${n?`text-ink`:`text-ink-faint`}`,title:e.detail||e.label,children:e.label}),r?(0,X.jsx)(`span`,{className:`shrink-0 font-mono tabular-nums text-ink-faint`,children:r}):null]},e.id)})}):null,(0,X.jsx)(`div`,{className:`mt-1 text-xs text-ink-faint`,children:g(`chat.stopWaitingHint`)})]}):null,re?(0,X.jsx)(_a,{query:e,selected:A,onSelect:ie}):null,s.length||w||E>0?(0,X.jsxs)(`div`,{className:`px-3 py-2`,children:[E>0?(0,X.jsx)(`div`,{className:`mb-2 text-xs text-manager`,children:g(`chat.attachDrop`)}):null,(0,X.jsx)(`div`,{className:`map-attachment-tray`,children:s.map((e,t)=>(0,X.jsx)(ja,{file:e,removeLabel:g(`chat.attachRemove`,{name:e.name}),onRemove:()=>{c(s.filter(t=>t!==e)),T(``)}},`${e.name}:${e.lastModified}:${t}`))}),(0,X.jsx)(`div`,{className:`text-xs ${w?`text-err`:`text-ink-faint`}`,children:w||g(`chat.attachHint`,{count:5,perFile:fi(10485760),total:fi(26214400)})})]}):null,(0,X.jsx)(po,{value:e,onChange:e=>{t(e),p(0),C(!1)},inputRef:_,fileInputRef:v,onFiles:e=>{M(Array.from(e.target.files??[])),e.target.value=``},onSend:()=>void ae(),onCancel:r,pending:a,disabled:i,inputProps:{onPaste:e=>{let t=Aa(e.clipboardData);t.length&&(e.preventDefault(),M(t))},onKeyDown:t=>{sa(t)||mo(t,{value:e,disabled:i,pending:a,rewriting:d,onRewrite:u})||(re?t.key===`ArrowDown`||t.key===`ArrowUp`?(t.preventDefault(),p(ha(A+(t.key===`ArrowDown`?1:-1),k.length))):t.key===`Tab`||t.key===`Enter`&&!t.shiftKey?(t.preventDefault(),ie(A)):t.key===`Escape`&&(t.preventDefault(),C(!0)):t.key===`Escape`&&a?(t.preventDefault(),r()):t.key===`Enter`&&!t.shiftKey&&(t.preventDefault(),ae()))},"aria-label":g(`chat.messageArgus`),"aria-keyshortcuts":`Control+R Meta+R`,"aria-controls":re?ma:void 0,"aria-expanded":re,"aria-activedescendant":j?ga(j.id):void 0,placeholder:g(i?`chat.selectSession`:`chat.placeholder`)},controls:(0,X.jsxs)(X.Fragment,{children:[h?(0,X.jsxs)(`select`,{value:m,onChange:e=>h(e.target.value),disabled:i||a,title:g(`chat.routeHint`),"aria-label":g(`chat.routeLabel`),children:[(0,X.jsx)(`option`,{value:`task`,children:g(`chat.routeTask`)}),(0,X.jsx)(`option`,{value:`auto`,children:g(`chat.routeAuto`)}),(0,X.jsx)(`option`,{value:`chat`,children:g(`chat.routeChat`)})]}):null,u?(0,X.jsx)(`button`,{type:`button`,onClick:()=>u(e.trim()),disabled:i||a||d||!e.trim(),title:`Ctrl/⌘+R · ${g(`chat.rewriteHint`)}`,"aria-label":g(`chat.rewriteLabel`),"aria-keyshortcuts":`Control+R Meta+R`,children:d?`${Un(b)} ${g(`chat.rewriting`)}`:g(`chat.rewrite`)}):null]})})]})}function go({open:e,onClose:t,children:n,label:r,width:i=`max-w-2xl`,align:a=`center`,viewport:o=!1,showClose:s=!0,style:c}){let{t:l}=Z(),u=(0,I.useRef)(null),d=(0,I.useRef)(null),f=(0,I.useRef)(t);return f.current=t,ci(u,(t,n)=>{if(!(!e||!u.current||!d.current)){if(n){t.set([d.current,u.current],{clearProps:`all`});return}t.timeline({defaults:{overwrite:`auto`}}).fromTo(d.current,{autoAlpha:0},{autoAlpha:1,duration:.14,ease:`power1.out`},0).fromTo(u.current,{autoAlpha:0,y:a===`top`?-6:8,scale:.992},{autoAlpha:1,y:0,scale:1,duration:.2,ease:`power3.out`,clearProps:`transform,opacity,visibility`},.03)}},[e,a]),(0,I.useEffect)(()=>{if(!e)return;let t=document.activeElement instanceof HTMLElement?document.activeElement:null,n=window.requestAnimationFrame(()=>{(u.current?.querySelector(`[data-autofocus]`)??u.current?.querySelector(`input:not([disabled]), textarea:not([disabled]), select:not([disabled]), button:not([disabled]), [href], [tabindex]:not([tabindex="-1"])`)??u.current)?.focus()}),r=e=>{if(e.key===`Escape`){e.preventDefault(),f.current();return}if(e.key!==`Tab`||!u.current)return;let t=Array.from(u.current.querySelectorAll(`input:not([disabled]), textarea:not([disabled]), select:not([disabled]), button:not([disabled]), [href], [tabindex]:not([tabindex="-1"])`)).filter(e=>e.getAttribute(`aria-hidden`)!==`true`);if(t.length===0){e.preventDefault(),u.current.focus();return}let n=t[0],r=t[t.length-1];e.shiftKey&&(document.activeElement===n||!u.current.contains(document.activeElement))?(e.preventDefault(),r.focus()):!e.shiftKey&&document.activeElement===r&&(e.preventDefault(),n.focus())};return window.addEventListener(`keydown`,r),()=>{window.cancelAnimationFrame(n),window.removeEventListener(`keydown`,r),t?.isConnected&&t.focus()}},[e]),e?(0,X.jsxs)(`div`,{className:`fixed inset-0 z-50 flex ${a===`top`?`items-start pt-3 sm:pt-14`:`items-center`} justify-center ${o?`p-0`:`p-3 sm:p-4`}`,onPointerDown:t,children:[(0,X.jsx)(`div`,{ref:d,className:`modal-scrim absolute inset-0`}),(0,X.jsxs)(`div`,{ref:u,role:`dialog`,"aria-modal":`true`,"aria-label":r,tabIndex:-1,style:c,className:`brand-modal glass-panel glass-panel--raised relative z-10 w-full overscroll-contain ${i} scroll-thin ${o?`flex h-[100dvh] max-h-[100dvh] flex-col overflow-hidden rounded-none`:`max-h-[calc(100dvh-1.5rem)] overflow-x-hidden overflow-y-auto rounded-2xl sm:max-h-[88dvh]`}`,onPointerDown:e=>e.stopPropagation(),children:[!o&&s?(0,X.jsx)(`button`,{type:`button`,"data-modal-close":!0,onClick:t,"aria-label":l(`common.close`),className:`modal-close`,children:(0,X.jsx)(`svg`,{viewBox:`0 0 16 16`,"aria-hidden":`true`,children:(0,X.jsx)(`path`,{d:`m4 4 8 8m0-8-8 8`})})}):null,n]})]}):null}function _o({title:e,sub:t}){return(0,X.jsxs)(`div`,{className:`px-6 pb-3 pr-14 pt-5`,children:[(0,X.jsx)(`h2`,{className:`text-base font-semibold tracking-[-0.01em] text-ink`,children:e}),t&&(0,X.jsx)(`p`,{className:`mt-1 text-sm text-ink-faint`,children:t})]})}function vo(e,t,n,r=`en`){return e.map(e=>({id:`command-${e.id}`,label:da(e,r),hint:`${e.name}${e.arg?` ${e.arg}`:``}`,group:fa(e,r),keywords:[e.name,...e.aliases??[]].join(` `),run:()=>Ft(e)?n(`${e.name} `):t(e.name)}))}function yo(e,t){let n=t.trim().toLowerCase().split(/\s+/).filter(Boolean);return n.length?e.filter(e=>{let t=`${e.label} ${e.group} ${e.hint??``} ${e.keywords??``}`.toLowerCase();return n.every(e=>t.includes(e))}):e}function bo({open:e,onClose:t,items:n}){let{t:r}=Z(),[i,a]=(0,I.useState)(``),[o,s]=(0,I.useState)(0),c=(0,I.useRef)(null),l=(0,I.useRef)(null);(0,I.useEffect)(()=>{e&&(a(``),s(0),setTimeout(()=>c.current?.focus(),0))},[e]);let u=(0,I.useMemo)(()=>yo(n,i),[i,n]);(0,I.useEffect)(()=>{o>=u.length&&s(Math.max(0,u.length-1))},[u.length,o]),(0,I.useEffect)(()=>{l.current?.scrollIntoView({block:`nearest`})},[e,i,o]);let d=e=>{e&&(t(),e.run())},f=e=>{sa(e)||(e.key===`ArrowDown`?(e.preventDefault(),u.length&&s(e=>Math.min(u.length-1,e+1))):e.key===`ArrowUp`?(e.preventDefault(),s(e=>Math.max(0,e-1))):e.key===`Enter`&&(e.preventDefault(),d(u[o])))},p=[];for(let e of u){let t=p.find(t=>t.name===e.group);t||(t={name:e.group,items:[]},p.push(t)),t.items.push(e)}let m=-1;return(0,X.jsxs)(go,{open:e,onClose:t,label:r(`help.palette`),width:`max-w-xl`,align:`top`,children:[(0,X.jsx)(`div`,{className:`border-b border-line px-4 py-3`,children:(0,X.jsx)(`input`,{ref:c,value:i,onChange:e=>a(e.target.value),onKeyDown:f,placeholder:r(`palette.placeholder`),role:`combobox`,"aria-expanded":e,"aria-autocomplete":`list`,"aria-controls":`command-palette-results`,"aria-activedescendant":u[o]?`palette-${u[o].id}`:void 0,className:`w-full bg-transparent font-mono text-sm text-ink outline-none placeholder:text-ink-faint`})}),(0,X.jsxs)(`div`,{id:`command-palette-results`,role:`listbox`,className:`max-h-[52vh] overflow-y-auto scroll-thin py-1.5`,children:[u.length===0&&(0,X.jsx)(`div`,{className:`px-4 py-6 text-center text-xs text-ink-faint`,children:r(`palette.noMatches`)}),p.map(e=>(0,X.jsxs)(`div`,{className:`mb-1`,children:[(0,X.jsx)(`div`,{className:`px-4 py-1 text-[10px] font-semibold uppercase tracking-wider text-ink-faint`,children:e.name}),e.items.map(e=>{m++;let t=m===o;return(0,X.jsxs)(`button`,{id:`palette-${e.id}`,ref:t?l:void 0,role:`option`,"aria-selected":t,onMouseEnter:()=>s(u.indexOf(e)),onClick:()=>d(e),className:`flex w-full items-center justify-between px-4 py-1.5 text-left text-sm transition-colors ${t?`bg-blue-deep/20 text-ink`:`text-ink-dim hover:bg-panel/60`}`,children:[(0,X.jsx)(`span`,{children:e.label}),e.hint&&(0,X.jsx)(`span`,{className:`font-mono text-[11px] text-ink-faint`,children:e.hint})]},e.id)})]},e.name))]}),(0,X.jsxs)(`div`,{className:`flex items-center gap-3 border-t border-line px-4 py-1.5 text-[10px] text-ink-faint`,children:[(0,X.jsx)(`span`,{children:r(`palette.navigate`)}),(0,X.jsx)(`span`,{children:r(`palette.run`)}),(0,X.jsx)(`span`,{children:r(`palette.close`)})]})]})}var xo=[{keys:`⌘K / Ctrl+K`,desc:`help.palette`},{keys:`⌘B / Ctrl+B`,desc:`help.sessions`},{keys:`⌘J / Ctrl+J`,desc:`help.managerChat`},{keys:`⌘R / Ctrl+R`,desc:`help.rewrite`},{keys:`⌘T / Ctrl+T`,desc:`help.reasoning`},{keys:`⌘. / Ctrl+.`,desc:`help.kiosk`},{keys:`/`,desc:`help.composer`},{keys:`↵ Enter`,desc:`help.send`},{keys:`Shift+Enter`,desc:`help.newline`},{keys:`?`,desc:`help.thisHelp`},{keys:`Esc`,desc:`help.escape`}];function So({open:e,onClose:t}){let{locale:n,t:r}=Z(),i=pa(Nt,n);return(0,X.jsxs)(go,{open:e,onClose:t,label:r(`help.title`),width:`max-w-2xl`,children:[(0,X.jsx)(_o,{title:r(`help.title`)}),(0,X.jsxs)(`div`,{className:`max-h-[70dvh] overflow-y-auto scroll-thin`,children:[(0,X.jsx)(`div`,{className:`p-4`,children:xo.map(e=>(0,X.jsxs)(`div`,{className:`flex items-center justify-between py-1.5`,children:[(0,X.jsx)(`span`,{className:`text-sm text-ink-dim`,children:r(e.desc)}),(0,X.jsx)(`kbd`,{className:`rounded border border-line bg-surface px-2 py-0.5 font-mono text-[11px] text-ink`,children:e.keys})]},e.keys))}),(0,X.jsxs)(`div`,{className:`border-t border-line px-4 pb-4 pt-3`,children:[(0,X.jsx)(`p`,{className:`mb-3 text-xs font-semibold uppercase tracking-wider text-ink-faint`,children:r(`help.commands`)}),i.map(e=>(0,X.jsxs)(`div`,{className:`mb-4`,children:[(0,X.jsx)(`p`,{className:`mb-1 text-[10px] font-semibold uppercase tracking-wider text-ink-faint`,children:e.group}),e.rows.map(e=>(0,X.jsxs)(`div`,{className:`flex items-start justify-between gap-4 py-1`,children:[(0,X.jsx)(`code`,{className:`shrink-0 font-mono text-xs text-ink`,children:e.label}),(0,X.jsx)(`span`,{className:`text-right text-xs text-ink-dim`,children:e.desc})]},e.label))]},e.group))]})]})]})}function Co({sid:e,config:t,onSaved:n}){let{locale:r}=Z(),i=r===`zh-CN`,a=t.roles.find(e=>e.role===`engineer`),o=new Map(t.operator_knobs.map(e=>[e.name,e.value])),s=o.get(`ARGUS_SKILL_MAP_MODEL`)||`auto`,c=o.get(`ARGUS_SKILL_MAP_REASONING_EFFORT`)||`auto`,[l,u]=(0,I.useState)(s===`auto`?``:s),[d,f]=(0,I.useState)(!1),[p,m]=(0,I.useState)(``);(0,I.useEffect)(()=>u(s===`auto`?``:s),[s]);let h=async(t,r)=>{if(!d){f(!0),m(``);try{await U.setConfig(e,t,r),await n()}catch(e){m(e instanceof Error?e.message:String(e))}finally{f(!1)}}},g=i?`跟随科研设置`:`Follow research settings`;return(0,X.jsxs)(`section`,{className:`map-model-settings rounded-lg border border-line glass-card p-3`,"aria-label":i?`地图模型`:`Map model`,children:[(0,X.jsx)(`div`,{className:`text-xs font-semibold text-ink`,children:i?`地图模型`:`Map model`}),(0,X.jsx)(`p`,{className:`mt-1 text-xs text-ink-dim`,children:i?`沿用科研 Engineer 的接入与账号。留空即可跟随 Engineer 模型。`:`Uses the research Engineer's runner and account. Leave the model blank to follow Engineer settings.`}),(0,X.jsxs)(`p`,{className:`mt-1 text-xs text-ink-faint`,children:[a?.backend_label,` · `,a?.model||(i?`接入默认模型`:`Runner default model`)]}),(0,X.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-end gap-2`,children:[(0,X.jsxs)(`label`,{className:`min-w-0 flex-1 text-xs text-ink-dim`,children:[i?`摘要模型`:`Summary model`,(0,X.jsx)(`input`,{value:l,onChange:e=>u(e.target.value),disabled:d,placeholder:g,className:`mt-1 h-9 w-full rounded border border-line bg-bg px-2 text-xs text-ink outline-none focus:border-blue`})]}),(0,X.jsx)(`button`,{type:`button`,disabled:d,onClick:()=>void h(`ARGUS_SKILL_MAP_MODEL`,l.trim()||`auto`),className:`h-9 rounded border border-line px-3 text-xs text-ink-dim hover:border-blue disabled:opacity-40`,children:i?`应用`:`Apply`}),s!==`auto`&&(0,X.jsx)(`button`,{type:`button`,disabled:d,onClick:()=>void h(`ARGUS_SKILL_MAP_MODEL`,`auto`),className:`h-9 rounded border border-line px-3 text-xs text-ink-dim hover:border-blue disabled:opacity-40`,children:g})]}),(0,X.jsxs)(`label`,{className:`mt-3 flex items-center gap-3 text-xs text-ink-dim`,children:[i?`思考强度`:`Reasoning effort`,(0,X.jsxs)(`select`,{value:c,disabled:d,onChange:e=>void h(`ARGUS_SKILL_MAP_REASONING_EFFORT`,e.target.value),className:`h-9 rounded border border-line bg-bg px-2 text-xs text-ink outline-none focus:border-blue`,children:[(0,X.jsx)(`option`,{value:`auto`,children:g}),[[`low`,`低`],[`medium`,`中`],[`high`,`高`],[`xhigh`,`很高`],[`max`,`最高`]].map(([e,t])=>(0,X.jsx)(`option`,{value:e,children:i?t:e},e))]})]}),p&&(0,X.jsx)(`p`,{role:`alert`,className:`mt-2 text-xs text-err`,children:p})]})}var wo=[{name:`ARGUS_SKILL_MAX_ACTIVE_DAEMONS`,group:`Limits`,label:`Active daemon limit`,description:`Maximum background sessions running on this host.`},{name:`ARGUS_SKILL_UNPRICED_COST_POLICY`,group:`Safety`,label:`Unpriced calls`,description:`Whether calls with unresolved pricing are blocked or allowed.`},{name:`ARGUS_SKILL_SAFE_MODE`,group:`Safety`,label:`Safe mode`,description:`Enable extra-conservative runtime guardrails.`},{name:`ARGUS_SKILL_ENABLE_TELEGRAM`,group:`Interface`,label:`Telegram`,description:`Enable the Telegram notification bridge.`},{name:`ARGUS_SKILL_SHOW_REASONING`,group:`Interface`,label:`Show reasoning`,description:`Stream role reasoning into the cockpit activity view.`}];function To(e){let t=new Map(e.map(e=>[e.name,e]));return wo.flatMap(e=>{let n=t.get(e.name);return n?[{...n,group:e.group,label:e.label,doc:e.description}]:[]})}function Eo(e,t){let n=new URL(e),r=n.protocol===`https:`?`wss:`:`ws:`,i=encodeURIComponent(t);return{webApi:`${n.origin}/api`,eventStream:`${r}//${n.host}/api/projects/${i}/stream`,daemon:`local process · events.jsonl · no TCP port`}}var Do=[{value:`copilot`,label:`settings.backendLabel.copilot`},{value:`codex`,label:`settings.backendLabel.codex`},{value:`claude`,label:`settings.backendLabel.claude`},{value:`cursor`,label:`settings.backendLabel.cursor`},{value:`opencode`,label:`settings.backendLabel.opencode`},{value:`pi`,label:`settings.backendLabel.pi`},{value:`grok`,label:`settings.backendLabel.grok`},{value:`qoder`,label:`settings.backendLabel.qoder`},{value:`dsh`,label:`settings.backendLabel.dsh`}],Oo={copilot:`copilot`,codex:`codex`,claude:`claude`,cursor:`cursor`,opencode:`opencode`,pi:`pi`,grok:`grok`,qoder:`qoder`,dsh:`dsh`};function ko(e){return Oo[e]??``}function Ao(e,t){let n=ko(e);return n?t(`settings.backendLabel.${n}`):e}function jo(e){return e?.operator_knobs.find(e=>e.name===`ARGUS_SKILL_RUNNER_BACKEND`)?.value??e?.roles[0]?.backend??``}var Mo=[{alias:`global_daily_cap`,env:`ARGUS_SKILL_GLOBAL_DAILY_CAP_USD`,label:`settings.budget.global`,unit:`settings.unit.usd`,step:`0.1`},{alias:`codex_daily_requests`,env:`ARGUS_SKILL_CODEX_DAILY_CALL_CAP`,label:`settings.budget.codex`,unit:`settings.unit.calls`,step:`1`},{alias:`copilot_daily_requests`,env:`ARGUS_SKILL_COPILOT_DAILY_CALL_CAP`,label:`settings.budget.copilot`,unit:`settings.unit.calls`,step:`1`},{alias:`copilot_daily_premium`,env:`ARGUS_SKILL_COPILOT_DAILY_PREMIUM_CAP`,label:`settings.budget.premium`,unit:`settings.unit.requests`,step:`1`}],No={ARGUS_SKILL_MAX_ACTIVE_DAEMONS:{label:`settings.knob.activeDaemons`,doc:`settings.knob.activeDaemonsDoc`},ARGUS_SKILL_UNPRICED_COST_POLICY:{label:`settings.knob.unpricedCalls`,doc:`settings.knob.unpricedCallsDoc`},ARGUS_SKILL_SAFE_MODE:{label:`settings.knob.safeMode`,doc:`settings.knob.safeModeDoc`},ARGUS_SKILL_ENABLE_TELEGRAM:{label:`settings.knob.telegram`,doc:`settings.knob.telegramDoc`},ARGUS_SKILL_SHOW_REASONING:{label:`settings.knob.showReasoning`,doc:`settings.knob.showReasoningDoc`}},Po={Limits:`settings.group.limits`,Safety:`settings.group.safety`,Interface:`settings.group.interface`},Fo={manager:`settings.role.managerDoc`,planner:`settings.role.plannerDoc`,engineer:`settings.role.engineerDoc`,reviewer:`settings.role.reviewerDoc`,curator:`settings.role.curatorDoc`};function Io(e,t){let n=e.trim();return n===`not applicable for this model`?t(`settings.source.notApplicable`):n.startsWith(`capability vault`)?t(`settings.source.vaultDefault`):n.startsWith(`default`)?t(`settings.source.default`):n.startsWith(`persisted:`)||n===`persisted`?t(`settings.source.saved`):n.startsWith(`ARGUS_SKILL_`)||n===`env`?t(`settings.source.environment`):n.startsWith(`global:`)?t(`settings.source.hostConfig`):t(`settings.source.other`)}function Lo(e,t){let n=e.value.trim().toLowerCase();if(e.name===`ARGUS_SKILL_UNPRICED_COST_POLICY`){if(n===`block`)return t(`settings.value.block`);if(n===`allow`)return t(`settings.value.allow`)}return[`ARGUS_SKILL_SAFE_MODE`,`ARGUS_SKILL_ENABLE_TELEGRAM`,`ARGUS_SKILL_SHOW_REASONING`].includes(e.name)?t([`1`,`true`,`on`,`yes`].includes(n)?`settings.value.enabled`:`settings.value.disabled`):e.value}function Ro(e,t){let n={low:`low`,medium:`medium`,high:`high`,xhigh:`xhigh`}[e.toLowerCase()];return n?t(`settings.effort.${n}`):e}function zo({message:e,retrying:t,onRetry:n,t:r}){return(0,X.jsxs)(`div`,{role:`alert`,className:`flex flex-col items-center gap-3 px-4 py-8 text-center`,children:[(0,X.jsx)(`p`,{className:`text-sm text-err`,children:e}),(0,X.jsx)(`button`,{type:`button`,onClick:n,disabled:t,className:`rounded-md border border-err/40 px-3 py-1.5 text-xs font-medium text-err hover:bg-err/10 disabled:opacity-40`,children:r(t?`common.loading`:`common.retry`)})]})}function Bo({sid:e,open:t,onClose:n}){let{t:r}=Z(),{data:i,isLoading:a,isError:o,isFetching:s,refetch:c}=xr(e,t),l=!!(i&&(i.recommended||i.checks.length||i.log_tail.trim()));return(0,X.jsxs)(go,{open:t,onClose:n,label:r(`doctor.title`),width:`max-w-3xl`,children:[(0,X.jsx)(_o,{title:r(`doctor.title`),sub:r(`doctor.subtitle`)}),(0,X.jsxs)(`div`,{className:`p-4`,children:[a&&(0,X.jsx)(`div`,{className:`flex justify-center py-8`,children:(0,X.jsx)(bi,{})}),!a&&o&&(0,X.jsx)(zo,{message:r(`doctor.loadError`),retrying:s,onRetry:()=>void c(),t:r}),!a&&!o&&!l&&(0,X.jsx)(xi,{children:r(`doctor.empty`)}),!a&&!o&&i?.recommended&&(0,X.jsxs)(`div`,{className:`mb-4 rounded-lg border border-gold/40 bg-gold/5 p-3`,children:[(0,X.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-wide text-gold`,children:r(`doctor.recommended`)}),(0,X.jsx)(`div`,{className:`mt-1 text-sm text-ink`,children:i.recommended.name}),(0,X.jsx)(`div`,{className:`mt-0.5 text-xs text-ink-dim`,children:i.recommended.detail}),i.recommended.fix&&(0,X.jsx)(`pre`,{className:`mt-2 whitespace-pre-wrap break-words rounded bg-bg p-2 font-mono text-xs text-blue-sky`,children:i.recommended.fix})]}),!a&&!o&&(0,X.jsx)(`div`,{className:`space-y-1.5`,children:(i?.checks??[]).map((e,t)=>(0,X.jsxs)(`div`,{className:`flex items-start gap-2 rounded-md border border-line/60 px-3 py-2`,children:[(0,X.jsx)(`span`,{className:e.ok?`text-ok`:`text-err`,children:e.ok?`✓`:`✗`}),(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsx)(`div`,{className:`text-xs font-medium text-ink`,children:e.name}),e.detail&&(0,X.jsx)(`div`,{className:`mt-0.5 text-[11px] text-ink-dim`,children:e.detail}),!e.ok&&e.fix&&(0,X.jsx)(`pre`,{className:`mt-1 whitespace-pre-wrap break-words rounded bg-bg p-1.5 font-mono text-xs text-ink-dim`,children:e.fix})]})]},t))}),!a&&!o&&i?.log_tail&&(0,X.jsxs)(`div`,{className:`mt-4`,children:[(0,X.jsx)(`div`,{className:`mb-1 text-[10px] font-semibold uppercase tracking-wide text-ink-faint`,children:r(`doctor.daemonLog`)}),(0,X.jsx)(`pre`,{className:`max-h-48 overflow-x-hidden overflow-y-auto whitespace-pre-wrap break-words rounded-lg bg-bg p-3 font-mono text-xs leading-relaxed text-ink-dim scroll-thin`,children:i.log_tail})]})]})]})}function Vo({sid:e,open:t,onClose:n}){let{t:r}=Z(),i=oe(),{data:a,isLoading:s,isError:c,isFetching:l,refetch:u}=Sr(e,t),[d,f]=(0,I.useState)(!1),[p,h]=(0,I.useState)(``),[g,_]=(0,I.useState)(!1),[v,y]=(0,I.useState)(``),[b,x]=(0,I.useState)(!1),[C,w]=(0,I.useState)(``),[E,D]=(0,I.useState)(``),[ee,O]=(0,I.useState)(!1),[te,ne]=(0,I.useState)(``),[k,re]=(0,I.useState)(!1),[A,j]=(0,I.useState)(``),[ie,ae]=(0,I.useState)({});(0,I.useEffect)(()=>{t||f(!1)},[t]),(0,I.useEffect)(()=>{if(!t||!a)return;h(a.operator_knobs.find(e=>e.name===`ARGUS_SKILL_MODEL`)?.value??``);let e=new Map(a.operator_knobs.map(e=>[e.name,e.value]));ae(Object.fromEntries(Mo.map(t=>[t.alias,e.get(t.env)??``])))},[a,t]);let M=async()=>{await u(),await i.invalidateQueries({queryKey:[`map-copy`]})},se=jo(a),N=async t=>{if(!g){_(!0),y(``),x(!1);try{await U.setConfig(e,`ARGUS_SKILL_RUNNER_BACKEND`,t),await M(),y(r(`settings.backendSwitched`,{backend:Ao(t,r)}))}catch(e){x(!0),y(e instanceof Error?e.message:String(e))}finally{_(!1)}}},ce=async()=>{if(!g){_(!0),y(``),x(!1);try{await U.setConfig(e,`ARGUS_SKILL_MODEL`,p.trim()||`auto`),await M(),y(r(`settings.applied`))}catch(e){x(!0),y(e instanceof Error?e.message:String(e))}finally{_(!1)}}},le=async()=>{if(!k){re(!0),j(``);try{let t=Object.fromEntries(Mo.map(e=>{let t=String(ie[e.alias]??``).trim();if(!t)throw Error(r(`settings.required`,{field:r(e.label)}));return[e.alias,t]}));await U.setBudgets(e,t),await M(),j(r(`settings.budgetSaved`))}catch(e){j(e instanceof Error?e.message:String(e))}finally{re(!1)}}},ue=async t=>{if(t.preventDefault(),!(!C.trim()||!E.trim()||ee)){O(!0),ne(``);try{await U.setConfig(e,C.trim(),E.trim()),await M(),ne(r(`settings.applied`))}catch(e){ne(e instanceof Error?e.message:String(e))}finally{O(!1)}}},de=To(a?.operator_knobs??[]).reduce((e,t)=>((e[t.group]??=[]).push(t),e),{}),fe=Eo(window.location.origin,e),P=!!(a&&(a.roles.length||a.operator_knobs.length));return(0,X.jsxs)(go,{open:t,onClose:n,label:r(`common.settings`),width:`max-w-4xl`,children:[(0,X.jsx)(_o,{title:r(`common.settings`),sub:r(`settings.subtitle`)}),(0,X.jsxs)(`div`,{className:`p-4`,children:[s&&(0,X.jsx)(`div`,{className:`flex justify-center py-8`,children:(0,X.jsx)(bi,{})}),!s&&c&&(0,X.jsx)(zo,{message:r(`settings.loadError`),retrying:l,onRetry:()=>void u(),t:r}),!s&&!c&&!P&&(0,X.jsx)(xi,{children:r(`settings.empty`)}),!s&&!c&&P&&a&&(0,X.jsxs)(`div`,{className:`space-y-4`,children:[(0,X.jsxs)(`section`,{className:`rounded-lg border border-line glass-card p-3`,children:[(0,X.jsx)(`div`,{className:`mb-2 text-[10px] font-semibold uppercase tracking-wide text-ink-faint`,children:r(`settings.quickConfig`)}),(0,X.jsxs)(`label`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(`span`,{className:`w-12 shrink-0 text-[10px] text-ink-faint`,children:r(`settings.backend`)}),(0,X.jsxs)(`select`,{value:ko(se),disabled:g,onChange:e=>void N(e.target.value),className:`h-8 min-w-44 rounded border border-line bg-bg px-2 text-xs text-ink outline-none focus:border-blue disabled:opacity-40`,children:[ko(se)?null:(0,X.jsx)(`option`,{value:``,disabled:!0,children:se?r(`settings.backendUnsupported`,{backend:se}):r(`settings.backendUnavailable`)}),Do.map(e=>(0,X.jsx)(`option`,{value:e.value,children:r(e.label)},e.value))]})]}),(0,X.jsxs)(`div`,{className:`mt-2 flex items-center gap-2`,children:[(0,X.jsx)(`span`,{className:`w-12 shrink-0 text-[10px] text-ink-faint`,children:r(`settings.model`)}),(0,X.jsx)(`input`,{value:p,onChange:e=>h(e.target.value),placeholder:r(`settings.modelPlaceholder`),className:`h-8 min-w-0 flex-1 rounded border border-line bg-bg px-2 font-mono text-xs text-ink outline-none focus:border-blue`}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>void ce(),disabled:g,className:`h-8 shrink-0 rounded border border-line/70 px-2.5 text-xs font-medium text-ink-dim hover:border-blue/50 disabled:opacity-40`,children:r(`settings.applyModel`)})]}),v&&(0,X.jsx)(`div`,{role:b?`alert`:`status`,className:`mt-1.5 text-[10px] ${b?`text-err`:`text-ink-dim`}`,children:v})]}),(0,X.jsx)(Co,{sid:e,config:a,onSaved:M}),(0,X.jsxs)(`section`,{className:`rounded-lg border border-gold/40 bg-gold/5 p-3`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-wide text-gold`,children:r(`settings.budgetTitle`)}),(0,X.jsx)(`p`,{className:`mt-0.5 text-[10px] text-ink-faint`,children:r(`settings.budgetHint`)})]}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>void le(),disabled:k,title:r(`settings.saveBudgets`),"aria-label":r(`settings.saveBudgets`),className:`flex h-9 w-9 items-center justify-center rounded border border-blue/35 bg-blue/8 text-xs font-semibold text-blue hover:border-blue-deep hover:bg-blue-deep hover:text-white disabled:opacity-40`,children:k?`…`:(0,X.jsx)(o,{icon:m})})]}),(0,X.jsx)(`div`,{className:`mt-3 grid gap-2 sm:grid-cols-2 lg:grid-cols-3`,children:Mo.map(e=>(0,X.jsxs)(`label`,{className:`rounded border border-line/70 bg-bg/60 p-2`,children:[(0,X.jsx)(`span`,{className:`block text-[10px] text-ink-faint`,children:r(e.label)}),(0,X.jsxs)(`div`,{className:`mt-1 flex items-center gap-2`,children:[(0,X.jsx)(`input`,{type:`number`,min:`0`,step:e.step,value:ie[e.alias]??``,onChange:t=>ae(n=>({...n,[e.alias]:t.target.value})),className:`h-8 min-w-0 flex-1 bg-transparent font-mono text-sm text-ink outline-none`}),(0,X.jsx)(`span`,{className:`text-[9px] text-ink-faint`,children:r(e.unit)})]})]},e.alias))}),A?(0,X.jsx)(`div`,{className:`mt-2 text-xs text-ink-dim`,children:A}):null]}),(0,X.jsxs)(`section`,{className:`overflow-hidden rounded-lg border border-line bg-surface/50`,children:[(0,X.jsxs)(`button`,{type:`button`,"aria-expanded":d,"aria-controls":`config-advanced-settings`,onClick:()=>f(e=>!e),className:`flex w-full items-center justify-between gap-3 px-3 py-3 text-left hover:bg-bg/30`,children:[(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`span`,{className:`block text-xs font-semibold text-ink`,children:r(`settings.advanced`)}),(0,X.jsx)(`span`,{className:`mt-0.5 block text-[10px] text-ink-faint`,children:r(`settings.advancedHint`)})]}),(0,X.jsx)(o,{icon:T,className:`text-xs text-ink-faint transition-transform ${d?`rotate-180`:``}`})]}),d&&(0,X.jsxs)(`div`,{id:`config-advanced-settings`,className:`space-y-4 border-t border-line/70 p-3`,children:[(0,X.jsxs)(`section`,{className:`rounded-lg border border-line bg-surface p-3`,children:[(0,X.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-wide text-ink-faint`,children:r(`settings.connection`)}),(0,X.jsxs)(`div`,{className:`mt-2 grid gap-2 text-[10px] sm:grid-cols-[100px_minmax(0,1fr)]`,children:[(0,X.jsx)(`span`,{className:`text-ink-faint`,children:r(`settings.webApi`)}),(0,X.jsx)(`code`,{className:`min-w-0 break-all text-ink-dim`,children:fe.webApi}),(0,X.jsx)(`span`,{className:`text-ink-faint`,children:r(`settings.eventStream`)}),(0,X.jsx)(`code`,{className:`min-w-0 break-all text-ink-dim`,children:fe.eventStream}),(0,X.jsx)(`span`,{className:`text-ink-faint`,children:r(`settings.taskDaemon`)}),(0,X.jsx)(`span`,{className:`text-ink-dim`,children:r(`settings.taskDaemonValue`)})]})]}),(0,X.jsxs)(`form`,{onSubmit:e=>void ue(e),className:`rounded-lg border border-blue/30 bg-blue/5 p-3`,children:[(0,X.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-wide text-blue`,children:r(`settings.overrideTitle`)}),(0,X.jsx)(`p`,{className:`mt-0.5 text-[10px] text-ink-faint`,children:r(`settings.overrideHint`)}),(0,X.jsxs)(`div`,{className:`mt-2 grid gap-2 sm:grid-cols-[minmax(0,1fr)_minmax(0,1fr)_auto]`,children:[(0,X.jsx)(`input`,{value:C,onChange:e=>w(e.target.value),placeholder:r(`settings.namePlaceholder`),className:`h-9 rounded border border-line bg-bg px-2 font-mono text-xs text-ink outline-none focus:border-blue`}),(0,X.jsx)(`input`,{value:E,onChange:e=>D(e.target.value),placeholder:r(`settings.valuePlaceholder`),className:`h-9 rounded border border-line bg-bg px-2 font-mono text-xs text-ink outline-none focus:border-blue`}),(0,X.jsx)(`button`,{disabled:ee||!C.trim()||!E.trim(),title:r(`settings.applyAdvanced`),"aria-label":r(`settings.applyAdvanced`),className:`flex h-9 w-9 items-center justify-center rounded border border-blue/35 bg-blue/8 text-xs font-medium text-blue hover:border-blue-deep hover:bg-blue-deep hover:text-white disabled:opacity-40`,children:ee?`…`:(0,X.jsx)(o,{icon:S})})]}),te?(0,X.jsx)(`div`,{className:`mt-2 text-xs text-ink-dim`,children:te}):null]}),a.roles.length>0&&(0,X.jsxs)(`section`,{children:[(0,X.jsx)(`div`,{className:`mb-2 text-[10px] font-semibold uppercase tracking-[0.14em] text-ink-faint`,children:r(`settings.rolesTitle`)}),(0,X.jsx)(`div`,{className:`grid gap-2 sm:grid-cols-2`,children:a.roles.map(e=>(0,X.jsxs)(`div`,{className:`rounded-lg border border-line bg-surface p-3`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,X.jsx)(`div`,{className:`text-xs font-semibold text-ink`,children:e.role===`curator`?r(`settings.role.curator`):Vi(e.role,r)}),(0,X.jsx)(`span`,{className:`text-[10px] text-ink-faint`,children:e.backend_label})]}),(0,X.jsx)(`div`,{className:`mt-2 truncate font-mono text-[11px] text-ink-dim`,title:e.model,children:e.model}),(0,X.jsxs)(`div`,{className:`mt-1 flex items-center gap-2 text-[10px] text-ink-faint`,children:[(0,X.jsx)(`span`,{className:`truncate`,children:Io(e.model_source,r)}),e.reasoning_effort&&(0,X.jsx)(`span`,{className:`ml-auto shrink-0`,style:{color:ft(e.reasoning_effort)},children:Ro(e.reasoning_effort,r)})]}),Fo[e.role]&&(0,X.jsx)(`p`,{className:`mt-2 text-[10px] leading-relaxed text-ink-faint`,children:r(Fo[e.role])})]},e.role))})]}),Object.keys(de).length>0&&(0,X.jsxs)(`section`,{children:[(0,X.jsx)(`div`,{className:`mb-2 text-[10px] font-semibold uppercase tracking-[0.14em] text-ink-faint`,children:r(`settings.rawConfig`)}),Object.entries(de).map(([e,t])=>(0,X.jsxs)(`div`,{className:`mt-3 first:mt-0`,children:[(0,X.jsx)(`div`,{className:`mb-1.5 text-[10px] font-semibold uppercase tracking-[0.14em] text-ink-faint`,children:r(Po[e])}),(0,X.jsx)(`div`,{className:`overflow-hidden rounded-lg border border-line`,children:t.map((e,t)=>{let n=No[e.name],i=Lo(e,r);return(0,X.jsxs)(`div`,{className:`grid gap-1 px-3 py-2.5 sm:grid-cols-[minmax(0,1fr)_auto] ${t?`border-t border-line/60`:``}`,children:[(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsx)(`div`,{className:`text-xs font-medium text-ink-dim`,children:r(n.label)}),(0,X.jsx)(`code`,{className:`mt-0.5 block break-all text-[9px] text-ink-faint`,children:e.name}),(0,X.jsx)(`div`,{className:`mt-1 text-[10px] leading-relaxed text-ink-faint`,children:r(n.doc)})]}),(0,X.jsxs)(`div`,{className:`text-left sm:text-right`,children:[(0,X.jsxs)(`div`,{className:`text-[11px] text-ink`,children:[i,i!==e.value&&(0,X.jsxs)(`code`,{className:`ml-1 text-[9px] text-ink-faint`,children:[`(`,e.value,`)`]})]}),(0,X.jsx)(`div`,{className:`mt-0.5 text-[9px] text-ink-faint`,children:Io(e.source,r)})]})]},e.name)})})]},e))]}),(0,X.jsxs)(`p`,{className:`text-[10px] text-ink-faint`,children:[r(`settings.footer`),` `,(0,X.jsx)(`code`,{children:`argus-skill --config-help`}),`.`]})]})]})]})]})]})}function Ho({sid:e,open:t,onClose:n}){let{t:r}=Z(),{data:i,isLoading:a,refetch:s}=Cr(e,t),[c,l]=(0,I.useState)(``),[u,d]=(0,I.useState)(!1),[f,p]=(0,I.useState)(``);(0,I.useEffect)(()=>{t&&i!=null&&l(i)},[i,t]);let h=async()=>{if(!u){d(!0),p(``);try{await U.setIdentity(e,c),await s(),p(r(`identity.saved`))}catch(e){p(e instanceof Error?e.message:String(e))}finally{d(!1)}}};return(0,X.jsxs)(go,{open:t,onClose:n,label:r(`identity.title`),width:`max-w-2xl`,children:[(0,X.jsx)(_o,{title:r(`identity.title`),sub:r(`identity.subtitle`)}),(0,X.jsxs)(`div`,{className:`max-h-[64vh] overflow-y-auto scroll-thin p-5`,children:[a&&(0,X.jsx)(`div`,{className:`flex justify-center py-8`,children:(0,X.jsx)(bi,{})}),a?null:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`textarea`,{value:c,onChange:e=>l(e.target.value),rows:12,className:`w-full resize-y rounded-lg border border-line bg-bg p-3 font-sans text-sm leading-relaxed text-ink outline-none focus:border-blue`,placeholder:r(`identity.placeholder`)}),(0,X.jsxs)(`div`,{className:`mt-3 flex items-center justify-between`,children:[(0,X.jsx)(`span`,{className:`text-xs text-ink-faint`,children:f}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>void h(),disabled:u||c===(i??``),title:r(`identity.save`),"aria-label":r(`identity.save`),className:`flex h-9 w-9 items-center justify-center rounded border border-blue/35 bg-blue/8 text-xs font-medium text-blue hover:border-blue-deep hover:bg-blue-deep hover:text-white disabled:opacity-40`,children:u?`…`:(0,X.jsx)(o,{icon:m})})]})]})]})]})}function Uo({sid:e,open:t,onClose:n}){let{t:r}=Z(),{data:i,isLoading:a}=wr(e,t),o=i??[];return(0,X.jsxs)(go,{open:t,onClose:n,label:r(`transcript.title`),width:`max-w-2xl`,children:[(0,X.jsx)(_o,{title:r(`transcript.title`),sub:r(`transcript.subtitle`)}),(0,X.jsxs)(`div`,{className:`max-h-[64vh] overflow-y-auto scroll-thin p-4`,children:[a&&(0,X.jsx)(`div`,{className:`flex justify-center py-8`,children:(0,X.jsx)(bi,{})}),!a&&o.length===0&&(0,X.jsx)(xi,{children:r(`transcript.empty`)}),o.map((e,t)=>{let n=e.role===`operator`;return(0,X.jsxs)(`div`,{className:`grid grid-cols-[72px_minmax(0,1fr)] border-b border-line/50 py-2.5 last:border-b-0`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`div`,{className:`font-mono text-[10px] font-semibold uppercase tracking-wide ${n?`text-ink-faint`:`text-blue-sky`}`,children:n?r(`transcript.operator`):`argus`}),(0,X.jsx)(`div`,{className:`mt-0.5 text-[9px] text-ink-faint`,children:li(e.ts)})]}),(0,X.jsx)(`div`,{className:`whitespace-pre-wrap text-sm leading-relaxed text-ink-dim`,children:e.text})]},t)})]})]})}function Wo({questions:e,backlog:t,onAnswer:n,onLocate:r}){let{t:i}=Z(),a=_t(e,t);if(!a.length)return null;let o=a[0];return(0,X.jsxs)(`div`,{className:`mb-2 flex min-h-11 items-center gap-3 rounded-md border border-gold/40 bg-gold/5 px-3 py-2`,children:[(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`div`,{className:`truncate text-xs font-medium text-gold`,children:o.title}),(0,X.jsx)(`div`,{className:`truncate text-xs text-ink-dim`,title:o.reason||o.question,children:o.reason||o.question})]}),a.length>1?(0,X.jsxs)(`span`,{className:`font-mono text-xs text-ink-faint`,children:[`+`,a.length-1]}):null,r?(0,X.jsx)(`button`,{onClick:r,className:`shrink-0 text-xs text-ink-dim hover:text-gold`,children:i(`pending.showOnMap`)}):null,(0,X.jsx)(`button`,{onClick:n,className:`shrink-0 text-xs font-medium text-gold hover:text-gold-soft`,children:i(`pending.reviewRespond`)})]})}function Go({reply:e,open:t,busy:n,onClose:r,onSubmit:i}){let{t:a}=Z(),o=(0,I.useMemo)(()=>e?.options[0]?.id??`custom`,[e]),[s,c]=(0,I.useState)(o),[l,u]=(0,I.useState)(``),[d,f]=(0,I.useState)(``);if((0,I.useEffect)(()=>{t&&(c(o),u(``),f(``))},[o,t,e?.id]),!e)return null;let p=e.options.length===0,m=e.options.find(e=>e.id===s),h=p?!!l.trim():!!(m&&(!m.requires_note||l.trim())),g=()=>{if(!n){if(!h){f(a(`decision.noteRequired`));return}f(``),i(p?`custom`:s,l.trim())}};return(0,X.jsxs)(go,{open:t,onClose:n?()=>void 0:r,label:a(`decision.operator`),width:`max-w-2xl`,children:[(0,X.jsx)(_o,{title:a(`decision.required`),sub:e.title}),(0,X.jsxs)(`div`,{className:`space-y-4 px-5 py-4`,children:[e.reason?(0,X.jsxs)(`section`,{className:`rounded-md border border-gold/30 bg-gold/5 p-3`,children:[(0,X.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-wider text-gold`,children:a(`decision.whyBlocked`)}),(0,X.jsx)(`p`,{className:`mt-1 whitespace-pre-wrap text-sm leading-relaxed text-ink`,children:e.reason})]}):null,e.evidence.length?(0,X.jsxs)(`section`,{children:[(0,X.jsx)(`div`,{className:`mb-2 text-[10px] font-semibold uppercase tracking-wider text-ink-faint`,children:a(`decision.evidence`)}),(0,X.jsx)(`div`,{className:`space-y-2`,children:e.evidence.map((e,t)=>(0,X.jsxs)(`div`,{className:`rounded border border-line/70 bg-bg/40 p-2.5`,children:[(0,X.jsx)(`div`,{className:`text-xs font-medium text-ink`,children:e.label}),e.summary?(0,X.jsx)(`div`,{className:`mt-1 text-xs text-ink-dim`,children:e.summary}):null,e.path?(0,X.jsx)(`div`,{className:`mt-1 break-all font-mono text-[10px] text-blue-sky`,children:e.path}):null]},`${e.path}:${t}`))})]}):null,(0,X.jsx)(`p`,{className:`whitespace-pre-wrap text-sm leading-relaxed text-ink`,children:e.question}),e.options.length?(0,X.jsx)(`div`,{className:`space-y-2`,children:e.options.map(e=>(0,X.jsxs)(`button`,{type:`button`,onClick:()=>{c(e.id),f(``)},disabled:n,className:`w-full rounded-md border p-3 text-left ${s===e.id?`border-blue bg-blue/5`:`border-line bg-bg/30`}`,children:[(0,X.jsx)(`div`,{className:`text-sm font-medium text-ink`,children:e.label}),(0,X.jsx)(`div`,{className:`mt-1 text-xs leading-relaxed text-ink-dim`,children:e.description})]},e.id))}):null,p||m?.requires_note||l?(0,X.jsx)(`textarea`,{"data-autofocus":!0,value:l,onChange:e=>{u(e.target.value),f(``)},onKeyDown:e=>{sa(e)||e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),g())},rows:3,disabled:n,placeholder:a(`decision.notePlaceholder`),className:`w-full resize-y rounded-lg border border-line bg-bg px-3 py-2 text-sm leading-relaxed text-ink outline-none focus:border-blue disabled:opacity-60`}):null,d?(0,X.jsx)(`p`,{role:`alert`,className:`text-xs text-err`,children:d}):null,(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,X.jsx)(`span`,{className:`text-xs text-ink-faint`,children:a(`decision.resumeHint`)}),(0,X.jsxs)(`div`,{className:`flex gap-2`,children:[(0,X.jsx)(`button`,{type:`button`,onClick:r,disabled:n,className:`rounded-md px-3 py-2 text-xs text-ink-dim hover:bg-bg disabled:opacity-50`,children:a(`decision.later`)}),(0,X.jsx)(`button`,{type:`button`,onClick:g,disabled:n,className:`rounded-md border border-blue/35 bg-blue/8 px-3 py-2 text-xs font-medium text-blue hover:border-blue-deep hover:bg-blue-deep hover:text-white disabled:opacity-50`,children:a(n?`decision.applying`:p||s===`custom`?`decision.sendAnswer`:s===`stop`?`decision.stopCampaign`:`decision.useOption`)})]})]})]})]})}function Ko({alert:e}){if(!e)return null;let t=e.tone===`block`,n=e.kind===`budget`;return(0,X.jsxs)(`div`,{className:`mx-3 mt-3 flex items-center gap-2.5 rounded-lg border px-3.5 py-2 text-[13px] ${t?`border-err/50 bg-err/10 text-err`:`border-warn/50 bg-warn/10 text-warn`}`,role:t?`alert`:`status`,children:[(0,X.jsx)(`span`,{className:`shrink-0 font-mono text-xs font-bold leading-none`,children:n?`$`:t?`!`:`i`}),(0,X.jsx)(`span`,{className:`shrink-0 text-[10px] font-semibold uppercase tracking-wide`,children:n?`budget alarm`:t?`action required`:`notice`}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,title:e.text,children:e.text})]})}function qo({html:e,title:t,className:n=``,sid:r,path:i}){return r&&i?(0,X.jsx)(Jo,{sid:r,path:i,html:e,title:t,className:n}):(0,X.jsx)(`iframe`,{title:t,srcDoc:e,sandbox:`allow-scripts`,referrerPolicy:`no-referrer`,className:`min-h-0 w-full flex-1 border-0 bg-white ${n}`})}function Jo({html:e,title:t,className:n,sid:r,path:i}){let{locale:a}=Z(),o=a===`zh-CN`,s=ce({queryKey:[`artifact-html`,r,i,e],queryFn:({signal:e})=>U.artifactPreview(r,i,e),enabled:!!(r&&i),staleTime:3e4,retry:1});return r&&i&&s.isPending?(0,X.jsx)(`div`,{className:`m-auto p-6 text-sm text-ink-dim`,role:`status`,children:o?`正在加载网页和配套资源…`:`Loading the website and its assets…`}):r&&i&&s.isError?(0,X.jsxs)(`div`,{className:`m-auto p-6 text-sm text-err`,role:`alert`,children:[o?`网页预览加载失败,请重试或下载文件。`:`Preview could not load. Retry or download the file.`,(0,X.jsx)(`button`,{type:`button`,className:`ml-3 underline`,onClick:()=>void s.refetch(),children:o?`重试`:`Retry`})]}):(0,X.jsxs)(`div`,{className:`flex min-h-0 w-full flex-1 flex-col ${n}`,children:[!!s.data?.warnings.length&&(0,X.jsx)(`p`,{className:`shrink-0 bg-warn/10 px-3 py-2 text-xs text-warn`,role:`status`,children:o?`部分配套资源无法加载,页面可能不完整。`:`Some linked assets are unavailable; the preview may be incomplete.`}),(0,X.jsx)(`iframe`,{title:t,srcDoc:s.data?.html??e,sandbox:`allow-scripts allow-downloads`,referrerPolicy:`no-referrer`,className:`min-h-0 w-full flex-1 border-0 bg-white`})]})}function Yo(e){let t=e.trim();if(!t)return``;try{return JSON.stringify(JSON.parse(t),null,2)}catch{try{return t.split(/\r?\n/).filter(Boolean).map(e=>JSON.parse(e)).map(e=>JSON.stringify(e,null,2)).join(` +`)}catch{return e}}}function Xo(e,t){let n=[],r=[],i=``,a=!1;for(let o=0;oe.some(e=>e.length>0))}function Zo({value:e}){return(0,X.jsx)(`pre`,{className:`min-h-0 flex-1 overflow-auto whitespace-pre-wrap break-words p-5 font-mono text-xs leading-6 text-ink-dim scroll-thin`,children:Yo(e)||`(empty data)`})}function Qo({value:e,delimiter:t}){let n=Xo(e,t).slice(0,200),r=n[0]??[];return(0,X.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto p-4 scroll-thin`,children:n.length?(0,X.jsxs)(`table`,{className:`w-full border-collapse text-left text-xs`,children:[(0,X.jsx)(`thead`,{children:(0,X.jsx)(`tr`,{children:r.slice(0,40).map((e,t)=>(0,X.jsx)(`th`,{className:`border border-line/60 bg-surface px-2 py-1.5 font-semibold text-ink`,children:e},t))})}),(0,X.jsx)(`tbody`,{children:n.slice(1).map((e,t)=>(0,X.jsx)(`tr`,{children:r.slice(0,40).map((t,n)=>(0,X.jsx)(`td`,{className:`border border-line/50 px-2 py-1.5 align-top text-ink-dim`,children:e[n]??``},n))},t))})]}):(0,X.jsx)(`div`,{className:`text-sm text-ink-faint`,children:`(empty table)`})})}var $o=`/assets/pdf.min-Bbvtrhlt.mjs`,es=`/assets/pdf.worker.min-CLrFZWeq.mjs`,ts=null,ns=0;function rs(){ts=null,ns+=1}function is(){if(ts)return ts;let e=new URL($o,import.meta.url),t=new URL(es,import.meta.url);ns&&(e.searchParams.set(`retry`,String(ns)),t.searchParams.set(`retry`,String(ns)));let n=oi(()=>import(e.href).then(e=>(e.GlobalWorkerOptions.workerSrc=t.href,e)),[]).catch(e=>{throw ts===n&&rs(),e});return ts=n,n}function as(e,t,n,r){let i=Math.max(1,n-32)/Math.max(1,e),a=Math.max(1,r-32)/Math.max(1,t);return Math.min(2.5,i,a)}function os({src:e,name:t,className:n=``,onPageOrientation:r,onRetry:i}){let{locale:a}=Z(),o=a===`zh-CN`,s=(0,I.useRef)(null),c=(0,I.useRef)(null),l=(0,I.useRef)(null),[u,d]=(0,I.useState)(null),[f,p]=(0,I.useState)(1),[m,h]=(0,I.useState)(1),[g,_]=(0,I.useState)({width:0,height:0}),[v,y]=(0,I.useState)(!0),[b,x]=(0,I.useState)(!1),[S,C]=(0,I.useState)(``),[w,T]=(0,I.useState)(0);(0,I.useEffect)(()=>{let e=c.current;if(!e)return;let t=()=>_({width:e.clientWidth,height:e.clientHeight});t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[]),(0,I.useEffect)(()=>{let t=!0,n=new AbortController,r=null;return d(null),p(1),h(1),l.current=null,c.current?.scrollTo(0,0),C(``),y(!0),Promise.all([fetch(e,{signal:n.signal}).then(e=>{if(!e.ok)throw Error(`PDF request failed (${e.status})`);return e.arrayBuffer()}),is()]).then(async([e,n])=>{if(!t)return;r=n.getDocument({data:new Uint8Array(e)});let i=await r.promise;t&&(d(i),y(!1))}).catch(e=>{t&&(y(!1),C(e instanceof Error?e.message:String(e)))}),()=>{t=!1,n.abort(),r?.destroy().catch(()=>{})}},[e,w]),(0,I.useEffect)(()=>{let e=s.current;if(!u||!e||g.width<=0||g.height<=0)return;let t=!1,n=null;return x(!0),C(``),u.getPage(f).then(e=>{if(t||!s.current)return;let i=e.getViewport({scale:1});r?.(i.width>i.height?`landscape`:`portrait`);let a=as(i.width,i.height,g.width,g.height),o=e.getViewport({scale:a*m}),u=document.createElement(`canvas`),d=u.getContext(`2d`,{alpha:!1});if(!d)throw Error(`Canvas rendering is unavailable`);let f=Math.min(window.devicePixelRatio||1,2);return u.width=Math.max(1,Math.floor(o.width*f)),u.height=Math.max(1,Math.floor(o.height*f)),n=e.render({canvas:u,canvasContext:d,viewport:o,transform:f===1?void 0:[f,0,0,f,0,0]}),n.promise.then(()=>{if(t||!s.current)return;let e=s.current,n=e.getContext(`2d`,{alpha:!1});if(!n)throw Error(`Canvas rendering is unavailable`);e.width=u.width,e.height=u.height,e.style.width=`${o.width}px`,e.style.height=`${o.height}px`,n.drawImage(u,0,0);let r=c.current,i=l.current;if(r&&i){let t=r.getBoundingClientRect(),n=e.getBoundingClientRect();r.scrollLeft+=n.left+i.x*n.width-t.left-r.clientWidth/2,r.scrollTop+=n.top+i.y*n.height-t.top-r.clientHeight/2,l.current=null}})}).then(()=>{t||x(!1)}).catch(e=>{t||e instanceof Error&&e.name===`RenderingCancelledException`||(x(!1),C(e instanceof Error?e.message:String(e)))}),()=>{t=!0,n?.cancel()}},[r,f,u,g.height,g.width,m]);let E=e=>{let t=c.current,n=s.current;if(t&&n&&n.clientWidth&&n.clientHeight){let e=t.getBoundingClientRect(),r=n.getBoundingClientRect();l.current={x:Math.max(0,Math.min(1,(e.left+t.clientWidth/2-r.left)/r.width)),y:Math.max(0,Math.min(1,(e.top+t.clientHeight/2-r.top)/r.height))}}h(t=>Math.max(.6,Math.min(2.2,Math.round((t+e)*100)/100)))},D=()=>{l.current=null,c.current?.scrollTo(0,0),h(1)},ee=u?.numPages??0;return(0,X.jsxs)(`div`,{className:`pdf-viewer flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden bg-bg ${n}`,"aria-busy":v||b,children:[(0,X.jsxs)(`div`,{className:`flex min-h-10 shrink-0 flex-wrap items-center gap-2 border-b border-line/70 bg-panel px-3 py-1.5 text-[11px] text-ink-dim`,children:[(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-ink`,title:t,children:t}),(0,X.jsxs)(`span`,{className:`shrink-0 font-mono tabular-nums`,children:[o?`第`:`Page`,` `,f,` / `,ee||`…`]}),(0,X.jsx)(`button`,{type:`button`,disabled:!u||f<=1,onClick:()=>{c.current?.scrollTo(0,0),l.current=null,p(e=>Math.max(1,e-1))},className:`rounded border border-line px-2 py-1 hover:border-blue/50 hover:text-ink disabled:opacity-35`,children:o?`上一页`:`Previous`}),(0,X.jsx)(`button`,{type:`button`,disabled:!u||f>=ee,onClick:()=>{c.current?.scrollTo(0,0),l.current=null,p(e=>Math.min(ee,e+1))},className:`rounded border border-line px-2 py-1 hover:border-blue/50 hover:text-ink disabled:opacity-35`,children:o?`下一页`:`Next`}),(0,X.jsx)(`button`,{type:`button`,"aria-label":o?`缩小`:`Zoom out`,disabled:!u||m<=.6,onClick:()=>E(-.15),className:`flex h-7 w-7 items-center justify-center rounded border border-line hover:border-blue/50 hover:text-ink`,children:`−`}),(0,X.jsxs)(`span`,{className:`w-10 text-center font-mono tabular-nums`,children:[Math.round(m*100),`%`]}),(0,X.jsx)(`button`,{type:`button`,"aria-label":o?`放大`:`Zoom in`,disabled:!u||m>=2.2,onClick:()=>E(.15),className:`flex h-7 w-7 items-center justify-center rounded border border-line hover:border-blue/50 hover:text-ink`,children:`+`}),(0,X.jsx)(`button`,{type:`button`,disabled:!u,onClick:D,className:`rounded border border-line px-2 py-1 hover:border-blue/50 hover:text-ink disabled:opacity-35`,children:o?`适合页面`:`Fit page`})]}),(0,X.jsxs)(`div`,{ref:c,className:`pdf-scroll-viewport relative min-h-0 min-w-0 flex-1 overflow-auto bg-surface/60 p-4 scroll-thin`,tabIndex:0,"aria-label":o?`PDF 页面滚动区域`:`PDF page scroll area`,children:[v?(0,X.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center`,children:(0,X.jsx)(bi,{})}):null,S?(0,X.jsxs)(`div`,{role:`alert`,className:`m-auto max-w-sm rounded border border-err/35 bg-err/5 p-4 text-center text-sm text-err`,children:[(0,X.jsx)(`p`,{children:o?`PDF 暂时无法预览`:`PDF preview is temporarily unavailable`}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>{rs(),i?i():T(e=>e+1)},className:`mt-3 rounded border border-line bg-panel px-3 py-1.5 text-ink hover:border-blue/50`,children:o?`重试预览`:`Retry preview`}),(0,X.jsxs)(`details`,{className:`mt-3 break-words text-xs text-ink-dim`,children:[(0,X.jsx)(`summary`,{children:o?`错误详情`:`Error details`}),S]})]}):null,S?null:(0,X.jsx)(`div`,{className:`pdf-page-stage flex min-h-full min-w-full w-max items-center justify-center`,children:(0,X.jsx)(`canvas`,{ref:s,role:`img`,"aria-label":`${t} · ${o?`第`:`page`} ${f}`,className:`block max-w-none shrink-0 bg-white shadow-xl`})})]})]})}function ss(e,t){return typeof e==`string`?e.trim().slice(0,t):``}function cs(e,t){return ss(e,t*2).replace(/!?(?:\[([^\]]+)\])\([^)]+\)/g,`$1`).replace(/[*_`#]/g,``).replace(/\s+/g,` `).trim().slice(0,t)}function ls(e){let t=ss(e.completionId,300);if(!t)return null;let n=ss(e.path,1e3);return{deliveryId:t,title:cs(e.title,240)||`已完成的任务`,summary:cs(e.summary,500),...n?{path:n}:{}}}function us(){return typeof window>`u`||window.parent===window?null:window.parent}function ds(e){if(!e||typeof e!=`object`||Array.isArray(e))return null;let t=e,n=ss(t.deliveryId,300);if(!n)return null;let r=ss(t.path,1e3);return{deliveryId:n,title:ss(t.title,240)||`Argus`,summary:ss(t.summary,1e3),...r?{path:r}:{}}}function fs(e){let t=ds(e),n=us();return!t||!n?Promise.resolve(!1):(n.postMessage({type:`argus:notify-completion`,payload:t},`*`),Promise.resolve(!0))}function ps(e){let t=us();t&&t.postMessage({type:`argus:large-preview`,payload:e},`*`)}function ms(e){let t=us();if(!t)return()=>void 0;let n=n=>{if(n.source!==t||n.data?.type!==`argus:open-delivery`)return;let r=ds(n.data.payload);r&&e(r)};return window.addEventListener(`message`,n),()=>window.removeEventListener(`message`,n)}function hs(e){let t=us();if(!t)return()=>void 0;let n=n=>{n.source===t&&n.data?.type===`argus:new-chat`&&e()};return window.addEventListener(`message`,n),()=>window.removeEventListener(`message`,n)}function gs(){if(typeof document>`u`)return()=>void 0;let e=us();if(!e)return()=>void 0;let t=t=>{if(t.defaultPrevented||t.button!==0&&t.button!==1)return;let n=t.target instanceof Element?t.target.closest(`a[href]`):null;if(!n)return;let r;try{r=new URL(n.href,window.location.href)}catch{return}r.origin===window.location.origin||![`http:`,`https:`].includes(r.protocol)||(t.preventDefault(),e.postMessage({type:`argus:open-external`,payload:r.toString()},`*`))},n=t=>{if(t.defaultPrevented||t.isComposing||t.altKey||t.shiftKey||!(t.ctrlKey||t.metaKey))return;let n=t.key===`,`?`argus:show-setup`:t.key.toLowerCase()===`n`?`argus:request-new-chat`:null;n&&(t.preventDefault(),e.postMessage({type:n},`*`))},r=()=>e.postMessage({type:`argus:cockpit-interaction`},`*`);return document.addEventListener(`click`,t,!0),document.addEventListener(`auxclick`,t,!0),window.addEventListener(`keydown`,n),document.addEventListener(`pointerdown`,r,{passive:!0}),()=>{document.removeEventListener(`click`,t,!0),document.removeEventListener(`auxclick`,t,!0),window.removeEventListener(`keydown`,n),document.removeEventListener(`pointerdown`,r)}}function _s(e){return e.kind===`markdown`||e.mime?.split(`;`,1)[0].trim().toLowerCase()===`text/markdown`||/\.(?:md|markdown)$/i.test(e.name||e.path||``)}function vs({sid:e,path:t,onClose:n,delivery:r,deliveries:i=[],onSelectDelivery:a,onSelectPath:o,reviewActivity:s}){let{t:c,locale:l}=Z(),u=l===`zh-CN`,d=r?Qr(r):[],f=Er(e,t),p=f.data,m=p?_s(p):!1,[h,g]=(0,I.useState)(null),[_,v]=(0,I.useState)(``),[y,b]=(0,I.useState)(0),[x,S]=(0,I.useState)(!1),[C,w]=(0,I.useState)(!1),[T,E]=(0,I.useState)(`portrait`),D=p?.kind===`pdf`||t?.toLowerCase().endsWith(`.pdf`)===!0,ee=!!(t&&/(?:^|[\\/])REVIEW\.md$/i.test(t));(0,I.useEffect)(()=>{if(!(!t||!D))return ps(!0),()=>ps(!1)},[t,D]),(0,I.useEffect)(()=>{if(E(`portrait`),g(null),v(``),!e||!t||!p||![`image`,`pdf`,`audio`,`video`].includes(p.kind))return;let n=!0,r=``,i=new AbortController;return U.artifactBlob(e,t,!1,i.signal).then(e=>{n&&(r=URL.createObjectURL(e),g(r))},e=>n&&v(e.message)),()=>{n=!1,i.abort(),r&&URL.revokeObjectURL(r)}},[e,t,p?.kind,y]);let O=async(n=!1)=>{if(!(!e||!t||!p)){S(!0),v(``);try{let r=n?await U.artifactBundle(e,t):await U.artifactBlob(e,t,!0),i=URL.createObjectURL(r),a=document.createElement(`a`);a.href=i,a.download=n?`${p.name.replace(/\.html?$/i,``)}-website.zip`:p.name,document.body.appendChild(a),a.click(),a.remove(),window.setTimeout(()=>URL.revokeObjectURL(i),0)}catch(e){v(e.message)}finally{S(!1)}}};return(0,X.jsxs)(go,{open:!!(t||r),onClose:n,label:r?u?`交付成果`:`Delivery`:c(`artifact.preview`),width:r?C?`max-w-none`:`max-w-6xl`:D?`max-w-none`:`max-w-5xl`,viewport:r?C:D,showClose:!1,style:r?{height:C?`100dvh`:`min(92dvh, 960px)`,display:`flex`,flexDirection:`column`,overflow:`hidden`}:D?{maxWidth:T===`portrait`?`min(96vw, 76dvh)`:`min(96vw, 145dvh)`}:void 0,children:[r&&!C&&(0,X.jsxs)(`header`,{className:`delivery-header`,children:[(0,X.jsxs)(`div`,{className:`delivery-heading`,children:[(0,X.jsx)(`span`,{className:`delivery-mark`,children:(0,X.jsx)(eo,{size:22})}),(0,X.jsxs)(`div`,{children:[(0,X.jsxs)(`p`,{children:[`DELIVERY · `,u?`交付成果`:`Your results`]}),(0,X.jsx)(`h2`,{children:u?`成果文件`:`Result files`})]}),(0,X.jsxs)(`button`,{type:`button`,onClick:n,className:`delivery-return`,"aria-label":u?`关闭交付弹窗`:`Close delivery`,children:[u?`返回地图`:`Back to map`,` ×`]})]}),i.length>1?(0,X.jsx)(`select`,{"aria-label":u?`选择交付任务`:`Choose delivery`,className:`delivery-task-select`,value:r.delivery_id,onChange:e=>{let t=i.find(t=>t.delivery_id===e.target.value);t&&a?.(t)},children:i.map(e=>(0,X.jsx)(`option`,{value:e.delivery_id,children:e.title},e.delivery_id))}):(0,X.jsx)(`p`,{className:`delivery-task-title`,title:r.title,children:r.title}),(0,X.jsxs)(`div`,{className:`delivery-facts`,children:[(0,X.jsxs)(`span`,{children:[(0,X.jsx)(Ua,{size:13}),[`done`,`passed`,`approved`,`accepted`].includes(r.review_status)?u?`任务已完成`:`Task completed`:u?`可查看`:`Available`]}),(0,X.jsxs)(`span`,{children:[d.length,` `,u?`个文件`:`files`]})]}),r.summary&&(0,X.jsxs)(`details`,{className:`delivery-summary`,children:[(0,X.jsx)(`summary`,{children:u?`查看成果说明`:`Result summary`}),(0,X.jsx)(`p`,{children:ei(r.summary)})]})]}),!C&&!!d.length&&(0,X.jsx)(`nav`,{className:`delivery-files`,"aria-label":u?`交付文件`:`Delivery files`,children:d.map(e=>(0,X.jsxs)(`button`,{type:`button`,"aria-pressed":t===e.path,onClick:()=>o?.(e.path),title:e.path,children:[(0,X.jsx)(`span`,{children:e.path.split(`/`).at(-1)}),r?.primary_target?.path===e.path&&(0,X.jsx)(`small`,{children:u?`主要成果`:`Main result`})]},e.path))}),(0,X.jsxs)(`div`,{className:`flex shrink-0 items-start gap-2 border-b border-line px-4 py-3 sm:px-5 ${t?``:`hidden`}`,children:[(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`h2`,{className:`truncate font-mono text-sm font-semibold text-ink`,title:p?.storage_path??p?.path??t??``,children:p?.name??t??c(`artifact.title`)}),(0,X.jsx)(`p`,{className:`mt-0.5 truncate text-[11px] text-ink-faint`,children:p?`${p.kind} · ${fi(p.size)} · ${p.mime}`:c(`artifact.approvedEvidence`)})]}),r&&(0,X.jsx)(`button`,{type:`button`,onClick:()=>w(e=>!e),"aria-label":C?u?`收起预览`:`Exit full screen`:u?`全屏预览`:`Full screen preview`,title:u?`切换全屏预览`:`Toggle full screen preview`,className:`shrink-0 rounded-md border border-line p-2 text-ink-dim`,children:C?(0,X.jsx)($a,{size:16}):(0,X.jsx)(Qa,{size:16})}),p?.kind===`html`&&(0,X.jsx)(`button`,{type:`button`,disabled:x,onClick:()=>void O(!0),className:`shrink-0 rounded-md border border-blue-deep/60 bg-blue-deep/10 px-3 py-2 text-xs text-blue-sky disabled:opacity-50`,children:u?`下载完整网页`:`Download website`}),(0,X.jsx)(`button`,{type:`button`,disabled:!p||x,onClick:()=>void O(),className:`rounded-md border border-blue-deep/60 bg-blue-deep/10 px-3 py-1.5 text-xs text-blue-sky transition-colors hover:bg-blue-deep/20 disabled:cursor-wait disabled:opacity-50`,children:c(x?`artifact.downloading`:`artifact.download`)}),(!r||C)&&(0,X.jsx)(`button`,{type:`button`,"aria-label":c(`artifact.close`),onClick:n,className:`rounded-md px-2 py-1 text-lg leading-none text-ink-faint hover:bg-surface hover:text-ink`,children:`×`})]}),(0,X.jsxs)(`div`,{className:r?`flex min-h-0 flex-1 flex-col overflow-auto bg-bg/40 p-2 sm:p-3`:D?`flex min-h-0 flex-1 flex-col overflow-hidden bg-bg/40`:`flex min-h-64 max-h-[72vh] flex-col overflow-x-hidden overflow-y-auto bg-bg/40 p-3 scroll-thin sm:p-4`,children:[!t&&r&&(0,X.jsx)(`p`,{className:`m-auto p-6 text-sm text-ink-dim`,children:ei(r.summary)}),f.isLoading?(0,X.jsx)(`div`,{className:`m-auto`,children:(0,X.jsx)(bi,{})}):null,f.isError?(0,X.jsxs)(`div`,{className:`m-auto text-sm text-err`,children:[c(`artifact.unavailable`),` · `,f.error.message]}):null,p?.why&&!D&&!r?(0,X.jsxs)(`div`,{className:`mb-3 rounded-md border border-line bg-surface px-3 py-2 text-xs text-ink-dim`,children:[(0,X.jsx)(`span`,{className:`mr-1 text-ink-faint`,children:`Reviewer:`}),p.why]}):null,p?.kind===`text`&&!m?(0,X.jsxs)(`pre`,{className:`min-h-52 overflow-x-hidden overflow-y-auto whitespace-pre-wrap break-words rounded-lg border border-line bg-bg p-4 font-mono text-xs leading-relaxed text-ink-dim scroll-thin`,children:[p.preview||c(`artifact.empty`),p.truncated?`\n\n… ${c(`artifact.truncated`)}`:``]}):null,p&&m?(0,X.jsxs)(`div`,{className:`min-h-52 overflow-auto rounded-lg border border-line bg-bg p-4 text-sm text-ink-dim scroll-thin`,children:[ee&&(0,X.jsxs)(`div`,{className:`mb-4 border-b border-line pb-3 text-xs leading-5 text-ink-faint`,role:`status`,children:[s===`revising`?u?`正在根据这份意见修改论文,修改后的版本尚待复审。`:`The paper is being revised against this opinion; the revised version awaits review.`:s===`reviewing`?u?`Reviewer 正在更新本轮审稿意见,内容会自动刷新。`:`The Reviewer is updating this round’s opinion. This file refreshes automatically.`:u?`这是最近保存的审稿意见,文件更新后会自动刷新。`:`This is the latest saved review. Changes to this file appear automatically.`,p.mtime!=null&&(0,X.jsxs)(`div`,{children:[u?`最近更新:`:`Last updated: `,new Date(p.mtime*1e3).toLocaleString(l)]})]}),(0,X.jsx)(ki,{artifacts:d.map(e=>({path:e.path})),onOpenArtifact:o,children:p.preview||c(`artifact.empty`)})]}):null,p?.kind===`json`?(0,X.jsx)(Zo,{value:p.preview||``}):null,p?.kind===`table`?(0,X.jsx)(Qo,{value:p.preview||``,delimiter:p.name.endsWith(`.tsv`)?` `:`,`}):null,p?.kind===`html`?(0,X.jsx)(`div`,{className:`flex flex-1 overflow-hidden rounded-lg border border-line ${r?`min-h-0`:`min-h-[60vh]`}`,children:(0,X.jsx)(qo,{sid:e,path:t,html:p.preview||``,title:`HTML preview: ${p.name}`})}):null,p?.kind===`image`&&h?(0,X.jsx)(`div`,{className:`flex min-h-64 flex-1 items-center justify-center rounded border border-line bg-bg/50`,children:(0,X.jsx)(`img`,{src:h,alt:p.why||p.name,className:`max-h-[62vh] max-w-full object-contain`})}):null,p?.kind===`pdf`&&h?(0,X.jsx)(os,{src:h,name:p.name,className:`min-h-0 overflow-hidden`,onPageOrientation:E,onRetry:()=>b(e=>e+1)}):null,p?.kind===`audio`&&h?(0,X.jsx)(`div`,{className:`m-auto w-full max-w-xl`,children:(0,X.jsx)(`audio`,{controls:!0,preload:`metadata`,src:h,className:`w-full`})}):null,p?.kind===`video`&&h?(0,X.jsx)(`div`,{className:`flex min-h-64 flex-1 items-center justify-center rounded border border-line bg-black`,children:(0,X.jsx)(`video`,{controls:!0,playsInline:!0,preload:`metadata`,src:h,className:`max-h-[62vh] max-w-full`})}):null,p&&[`image`,`pdf`,`audio`,`video`].includes(p.kind)&&!h&&!_?(0,X.jsx)(`div`,{className:`m-auto`,children:(0,X.jsx)(bi,{})}):null,p?.kind===`binary`?(0,X.jsxs)(`div`,{className:`m-auto max-w-md text-center`,children:[(0,X.jsx)(`div`,{className:`text-3xl text-ink-faint`,children:`◇`}),(0,X.jsx)(`p`,{className:`mt-2 text-sm text-ink-dim`,children:c(`artifact.noPreview`)}),(0,X.jsx)(`p`,{className:`mt-1 text-xs text-ink-faint`,children:c(`artifact.downloadHint`)})]}):null,_?(0,X.jsx)(`div`,{className:`mt-3 text-center text-xs text-err`,children:_}):null]})]})}var ys=`__argus_live_progress__`,bs=new Set([`framed`,`grounding`,`queued`,`running`,`in_progress`,`working`]),xs=new Set([`complete`,`completed`,`done`,`success`]);function Ss(e){return xs.has(String(e?.mission.status||``).toLowerCase())}function Cs(e){return(e??[]).filter(e=>e.source===`manager_live`)}function ws(e){return Cs(e).filter(e=>e.exists)[0]??null}function Ts(e){let t=e??[],n={markdown:0,pdf:1,html:2,text:3,table:4,json:5,image:6,video:7,audio:8,binary:9},r=t.filter(e=>e.exists&&e.source===`delivery`),i=t.filter(e=>e.exists&&e.source===`manager_live`),a=t.filter(e=>e.exists&&e.source!==`manager_live`&&e.source!==`delivery`);return a.length||r.length?[...r,...[...a].sort((e,t)=>(n[e.kind]??99)-(n[t.kind]??99)),...i]:i}function Es(e){return Ts(e).find(e=>e.exists)??null}function Ds(e){let t=Ts(e);return t.find(e=>e.source===`delivery`)??t.find(e=>e.source!==`manager_live`)??t[0]??null}function Os(e){let t=e.path.split(`/`);return t[t.length-1]||e.path}function ks(e,t){if(e){let n=String(e.mission.status||``).toLowerCase();if(bs.has(n))return ys;let r=e.delivery?.primary_target?.path;if(r)return r;if(Ss(e))return Ds(t)?.path??`__argus_live_progress__`;let i=ws(t);return i?i.path:ys}return Es(t)?.path??``}var As={manager:`Manager`,planner:`Planner`,engineer:`Engineer`,reviewer:`Reviewer`};function js(e){let t=String(e.agent_layer??e.actor??``);if(t===`main`)return`engineer`;if(t)return t;let n=String(e.type??``);return n.startsWith(`round.review`)||n.startsWith(`reviewer`)?`reviewer`:n.startsWith(`life.planner`)?`planner`:n.startsWith(`life.manager`)||n.startsWith(`manager`)?`manager`:n.startsWith(`engineer`)||n.startsWith(`round.`)?`engineer`:``}function Ms(e,t=[]){if(Ss(e))return null;let n=String(e?.active_role??``);if(!n)return null;let r=e?.roles.find(e=>e.role===n),i=``;for(let e=t.length-1;e>=0;--e){let r=t[e];if(js(r)!==n||String(r.kind??``)===`reasoning`)continue;let a=String(r.text??r.action_summary??``).trim();if(!(!a||a.startsWith(`{`))){i=a.split(` +`)[0].slice(0,240);break}}return{role:n,roleLabel:As[n]??n,label:r?.label||`Working`,detail:i}}function Ns(e){let t=e.dag.find(e=>[`running`,`in_progress`,`claimed`].includes(e.status)),n=e.dag.filter(e=>[`done`,`completed`].includes(e.status)).length,r=e.dag.length,i=`Awaiting Planner`;return e.mission.status===`idle`?i=`Ready for a new mission`:e.mission.status===`complete`&&(i=`Mission complete`),{title:Cn(t?.title||e.mission.title||i),dagProgress:r>0?`${n} / ${r} complete`:`Not planned`}}function Ps({view:e,liveStatus:t,artifacts:n=[],onOpenArtifact:r}){let{t:i}=Z(),a=Ns(e),o=[...n].filter(e=>e.exists&&e.source!==`manager_live`).sort((e,t)=>Number(t.mtime??0)-Number(e.mtime??0)).slice(0,4),s=e.timeline.slice(-6).reverse(),c=e.delivery,l=e=>e===`done`?`text-ok`:[`running`,`in_progress`,`claimed`].includes(e)?`text-blue-sky`:[`failed`,`blocked`,`rejected`].includes(e)?`text-err`:`text-ink-faint`;return(0,X.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-5 text-sm text-ink-dim scroll-thin`,children:[c?(0,X.jsxs)(`section`,{className:`mb-4 rounded-lg border border-ok/35 bg-ok/10 p-4`,children:[(0,X.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-[0.14em] text-ok`,children:c.kind===`submission_certified`?`交付已认证`:`已完成`}),(0,X.jsx)(`h3`,{className:`mt-2 text-base font-semibold leading-snug text-ink`,children:c.title}),c.summary?(0,X.jsx)(`p`,{className:`mt-2 text-xs leading-5 text-ink-dim`,children:c.summary}):null,c.primary_target?(0,X.jsxs)(`button`,{type:`button`,onClick:()=>r(c.primary_target.path),title:n.find(e=>e.path===c.primary_target.path)?.storage_path||c.primary_target.path,className:`mt-3 rounded border border-ok/40 bg-panel px-2.5 py-1.5 font-mono text-[10px] text-ok hover:border-ok`,children:[`打开成果 · `,c.primary_target.label||c.primary_target.path]}):null]}):null,(0,X.jsxs)(`section`,{className:`rounded-lg border border-blue-deep/30 bg-blue-deep/10 p-4`,children:[(0,X.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-[0.14em] text-blue-sky`,children:i(`research.currentWork`)}),(0,X.jsx)(`h3`,{className:`mt-2 text-base font-semibold leading-snug text-ink`,children:a.title}),t?.detail?(0,X.jsx)(`p`,{className:`mt-2 leading-6 text-ink-dim`,children:t.detail}):null,(0,X.jsxs)(`div`,{className:`mt-3 grid grid-cols-2 gap-3 text-xs`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`span`,{className:`text-ink-faint`,children:i(`mission.stage`)}),(0,X.jsx)(`div`,{className:`mt-1 font-medium capitalize text-blue-sky`,children:e.stage.label||e.stage.id||`—`})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`span`,{className:`text-ink-faint`,children:i(`mission.campaign`)}),(0,X.jsx)(`div`,{className:`mt-1 font-mono text-ink`,children:wn(e.mission.campaign_elapsed_seconds)})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`span`,{className:`text-ink-faint`,children:i(`mission.round`)}),(0,X.jsxs)(`div`,{className:`mt-1 font-mono text-ink`,children:[e.round.current||`—`,e.round.max?` / ${e.round.max}`:``]})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`span`,{className:`text-ink-faint`,children:i(`research.dagProgress`)}),(0,X.jsx)(`div`,{className:`mt-1 font-mono text-ink`,children:a.dagProgress})]})]})]}),(0,X.jsxs)(`section`,{className:`mt-5`,children:[(0,X.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-[0.14em] text-ink-faint`,children:i(`mission.researchDag`)}),(0,X.jsx)(`div`,{className:`mt-2 space-y-2`,children:e.dag.map(e=>(0,X.jsx)(`div`,{className:`rounded-md border border-line/60 bg-panel px-3 py-2.5`,children:(0,X.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,X.jsx)(`span`,{className:`mt-0.5 shrink-0 font-mono text-xs ${l(e.status)}`,children:e.status===`done`?`✓`:[`running`,`in_progress`,`claimed`].includes(e.status)?`●`:`○`}),(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`div`,{className:`text-xs font-medium leading-5 text-ink`,children:e.title}),(0,X.jsx)(`div`,{className:`mt-0.5 font-mono text-[10px] ${l(e.status)}`,children:e.status})]})]})},e.id))})]}),o.length?(0,X.jsxs)(`section`,{className:`mt-5`,children:[(0,X.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-[0.14em] text-ink-faint`,children:i(`research.verifiedOutputs`)}),(0,X.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:o.map(e=>(0,X.jsxs)(`button`,{type:`button`,onClick:()=>r(e.path),title:e.storage_path||e.path,className:`rounded border border-line/70 bg-panel px-2.5 py-1.5 font-mono text-[10px] text-blue-sky hover:border-blue/60`,children:[Os(e),` ↗`]},e.path))})]}):null,s.length?(0,X.jsxs)(`section`,{className:`mt-5`,children:[(0,X.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-[0.14em] text-ink-faint`,children:i(`research.recentMilestones`)}),(0,X.jsx)(`div`,{className:`mt-2 space-y-2 border-l border-line/70 pl-3`,children:s.map(e=>(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`div`,{className:`text-xs font-medium text-ink`,children:e.title}),e.detail?(0,X.jsx)(`div`,{className:`mt-0.5 line-clamp-2 text-xs leading-5 text-ink-faint`,children:e.detail}):null]},e.id))})]}):null]})}function Fs({sid:e,artifacts:t,error:n=!1,onExpand:r,onOpenFile:i,className:a=``,embedded:s=!1,onCollapse:c,missionView:l,activityEvents:u=[],requestedPath:d,requestedPathToken:f}){let{t:p,locale:m}=Z(),h=(0,I.useMemo)(()=>Ts(t),[t]),g=(0,I.useMemo)(()=>Es(t),[t]),_=Ss(l),v=(0,I.useMemo)(()=>{if(!_)return null;let e=l?.delivery?.primary_target?.path;return h.find(t=>t.path===e&&t.exists)??Ds(t)},[t,_,l?.delivery?.primary_target?.path,h]),[y,b]=(0,I.useState)(null);(0,I.useEffect)(()=>{b(_&&v?v.path:null)},[_,v?.path,l?.mission.id,e]),(0,I.useEffect)(()=>{if(!d)return;let e=h.find(e=>e.path===d&&e.exists);e&&b(e.path)},[h,d,f]);let S=e=>{b(e),e!==`__argus_live_progress__`&&i?.()},C=y??ks(l,t),w=C===ys,T=w?null:h.find(e=>e.path===C)??(_?v:g),E=Er(e,T?.exists?T.path:null,T?.mtime??null),D=E.data,ee=D?_s(D):!1,[O,te]=(0,I.useState)(null),[ne,k]=(0,I.useState)(``),[re,A]=(0,I.useState)(!1),[j,ie]=(0,I.useState)(``),ae=(0,I.useMemo)(()=>Ms(l,u),[u,l]);(0,I.useEffect)(()=>{if(te(null),k(``),!e||!T||!D||![`image`,`pdf`,`audio`,`video`].includes(D.kind))return;let t=!0,n=``,r=new AbortController;return U.artifactBlob(e,T.path,!1,r.signal).then(e=>{t&&(n=URL.createObjectURL(e),te(n))},e=>t&&k(e.message)),()=>{t=!1,r.abort(),n&&URL.revokeObjectURL(n)}},[e,T?.path,D?.kind,D?.mtime]);let M=l?.delivery??null,oe=M?.primary_target?.path??``,se=!!(_&&!w&&T&&(T.source===`delivery`||T.path===oe)),N=m===`zh-CN`?M?.kind===`submission_certified`?`交付已认证`:`已完成`:M?.kind===`submission_certified`?`Certified delivery`:`Delivered result`,ce=se?N:w?p(`research.liveProgress`):h[0]?.group_title||p(`research.artifact`),le=async()=>{if(!(!e||!T)){A(!0),ie(``);try{let t=await U.artifactBlob(e,T.path,!0),n=URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=T.name,document.body.appendChild(r),r.click(),r.remove(),window.setTimeout(()=>URL.revokeObjectURL(n),0)}catch(e){ie(e.message)}finally{A(!1)}}};return(0,X.jsxs)(`section`,{className:`glass-panel glass-panel--side flex min-h-0 flex-col overflow-hidden ${s?``:`rounded-lg border`} ${a}`,"aria-label":p(`research.canvas`),children:[(0,X.jsxs)(`header`,{className:`flex h-12 shrink-0 items-center gap-3 border-b border-line/50 bg-panel px-4`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 shrink-0 items-center gap-2`,children:[(0,X.jsx)(`span`,{className:`h-2 w-2 rounded-full ${se?`bg-ok`:`animate-pulse bg-blue`}`}),(0,X.jsx)(`h2`,{className:`max-w-24 truncate text-sm font-semibold text-ink sm:max-w-48`,children:ce})]}),l||h.length>0?(0,X.jsxs)(`label`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`span`,{className:`sr-only`,children:p(`research.previewArtifact`)}),(0,X.jsxs)(`select`,{value:w?ys:T?.path??``,onChange:e=>S(e.target.value),title:w?p(`research.liveProgress`):T?.storage_path||T?.path,className:`h-8 w-full min-w-0 max-w-64 truncate rounded-md border border-line/50 bg-bg px-2 font-mono text-xs text-ink-dim outline-none focus:border-blue/60`,children:[l?(0,X.jsx)(`option`,{value:ys,children:p(`research.liveProgress`)}):null,h.map(e=>(0,X.jsxs)(`option`,{value:e.path,disabled:!e.exists,title:e.storage_path||e.path,children:[e.source===`delivery`?`交付 · `:e.source===`manager_live`?`Checkpoint · `:``,Os(e),e.exists?``:` · pending`]},e.path))]})]}):(0,X.jsx)(`div`,{className:`flex-1`}),(0,X.jsx)(`div`,{className:`shrink-0`,children:T?(0,X.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,X.jsx)(`button`,{type:`button`,onClick:()=>void le(),disabled:re||!T.exists,title:p(`artifact.download`),"aria-label":p(`artifact.download`),className:`flex h-7 w-7 items-center justify-center rounded-md text-ink-faint hover:bg-surface hover:text-ink disabled:opacity-40`,children:(0,X.jsx)(`svg`,{viewBox:`0 0 16 16`,"aria-hidden":`true`,className:`h-4 w-4`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.25`,children:(0,X.jsx)(`path`,{d:`M8 2.25v7.5M5.25 7.5 8 10.25 10.75 7.5M3 13.25h10`})})}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>r(T.path),title:p(`research.openLarge`),"aria-label":p(`research.openLarge`),className:`flex h-7 w-7 items-center justify-center rounded-md text-ink-faint hover:bg-surface hover:text-ink`,children:(0,X.jsx)(`svg`,{viewBox:`0 0 16 16`,"aria-hidden":`true`,className:`h-4 w-4`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.25`,children:(0,X.jsx)(`path`,{d:`M6 3H3v3M10 3h3v3M6 13H3v-3M10 13h3v-3`})})})]}):null}),c?(0,X.jsx)(`button`,{type:`button`,onClick:c,"aria-label":p(`research.collapse`),title:p(`research.collapse`),className:`hidden h-8 w-8 shrink-0 items-center justify-center rounded-md border border-line/50 bg-bg/40 text-ink-faint hover:border-blue/50 hover:text-ink lg:flex`,children:(0,X.jsx)(o,{icon:x,className:`h-3.5 w-3.5`})}):null]}),ae?(0,X.jsxs)(`div`,{className:`shrink-0 border-b border-line/50 bg-blue-deep/10 px-4 py-3`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2 text-xs`,children:[(0,X.jsx)(`span`,{"data-role-dot":ae.role,className:`h-2 w-2 shrink-0 animate-pulse rounded-full motion-reduce:animate-none`,style:{background:W.role[ae.role]??W.inkFaint},"aria-hidden":`true`}),(0,X.jsx)(`span`,{className:`font-semibold text-ink`,children:ae.roleLabel}),(0,X.jsx)(`span`,{className:`text-blue-sky`,children:p(`mission.active`)}),(0,X.jsxs)(`span`,{className:`truncate text-ink-faint`,children:[`· `,ae.label]})]}),ae.detail?(0,X.jsx)(`p`,{className:`mt-1 line-clamp-2 text-xs leading-5 text-ink-dim`,children:ae.detail}):null]}):null,(0,X.jsxs)(`div`,{className:`relative flex min-h-0 flex-1 flex-col bg-bg`,children:[w&&l?(0,X.jsx)(Ps,{view:l,liveStatus:ae,artifacts:t,onOpenArtifact:S}):null,!w&&n?(0,X.jsx)(`div`,{className:`m-auto max-w-sm px-6 text-center text-sm text-warn`,children:p(`research.unavailable`)}):null,!w&&!n&&h.length===0?(0,X.jsxs)(`div`,{className:`m-auto max-w-sm px-8 text-center`,children:[(0,X.jsx)(`div`,{className:`text-3xl text-ink-faint`,children:`◇`}),(0,X.jsx)(`h3`,{className:`mt-3 text-xs text-ink-faint`,children:p(`research.noPreview`)})]}):null,!w&&!n&&h.length>0&&!T?(0,X.jsxs)(`div`,{className:`m-auto max-w-sm px-8 text-center`,children:[(0,X.jsx)(bi,{}),(0,X.jsx)(`p`,{className:`mt-3 text-xs text-ink-faint`,children:p(`research.waiting`)})]}):null,T&&!T.exists?(0,X.jsxs)(`div`,{className:`m-auto max-w-sm px-8 text-center`,children:[(0,X.jsx)(bi,{}),(0,X.jsx)(`p`,{className:`mt-3 text-xs text-ink-faint`,children:p(`research.updating`)})]}):null,T?.exists&&E.isLoading?(0,X.jsx)(`div`,{className:`m-auto`,children:(0,X.jsx)(bi,{})}):null,T?.exists&&E.isError?(0,X.jsxs)(`div`,{className:`m-auto px-6 text-center text-sm text-err`,children:[p(`artifact.unavailable`),` · `,E.error.message]}):null,D?.kind===`text`&&!ee?(0,X.jsxs)(`pre`,{className:`min-h-0 flex-1 overflow-x-hidden overflow-y-auto whitespace-pre-wrap break-words p-5 font-mono text-xs leading-6 text-ink-dim scroll-thin`,children:[D.preview||`(empty file)`,D.truncated?` + +… live preview truncated · expand to inspect the complete file`:``]}):null,D&&ee?(0,X.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto p-5 text-sm text-ink-dim scroll-thin`,children:(0,X.jsx)(ki,{artifacts:t,onOpenArtifact:S,children:D.preview||`(empty file)`})}):null,D?.kind===`json`?(0,X.jsx)(Zo,{value:D.preview||``}):null,D?.kind===`table`?(0,X.jsx)(Qo,{value:D.preview||``,delimiter:D.name.endsWith(`.tsv`)?` `:`,`}):null,D?.kind===`html`&&!D.truncated?(0,X.jsx)(qo,{sid:e,path:D.path,html:D.preview||``,title:`Live HTML preview: ${D.name}`}):null,D?.kind===`html`&&D.truncated?(0,X.jsx)(`div`,{className:`m-auto max-w-sm px-8 text-center text-sm text-warn`,children:p(`artifact.htmlTooLarge`)}):null,D?.kind===`image`&&O?(0,X.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center overflow-hidden p-4`,children:(0,X.jsx)(`img`,{src:O,alt:D.why||D.name,className:`max-h-full max-w-full object-contain`})}):null,D?.kind===`pdf`&&O?(0,X.jsx)(os,{src:O,name:D.name}):null,D?.kind===`audio`&&O?(0,X.jsx)(`div`,{className:`m-auto w-full max-w-xl px-6`,children:(0,X.jsx)(`audio`,{controls:!0,preload:`metadata`,src:O,className:`w-full`})}):null,D?.kind===`video`&&O?(0,X.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center overflow-hidden bg-black p-2`,children:(0,X.jsx)(`video`,{controls:!0,playsInline:!0,preload:`metadata`,src:O,className:`max-h-full max-w-full`})}):null,D?.kind===`binary`?(0,X.jsx)(`div`,{className:`m-auto max-w-sm px-8 text-center text-sm text-ink-dim`,children:p(`research.fileUnavailable`)}):null,D&&[`image`,`pdf`,`audio`,`video`].includes(D.kind)&&!O&&!ne?(0,X.jsx)(`div`,{className:`m-auto`,children:(0,X.jsx)(bi,{})}):null,ne?(0,X.jsx)(`div`,{className:`m-auto px-6 text-center text-sm text-err`,children:ne}):null]}),w?(0,X.jsxs)(`footer`,{className:`flex h-9 items-center gap-2 border-t border-line px-4 font-mono text-xs text-ink-faint`,children:[(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:p(`research.eventSourced`)}),(0,X.jsx)(`span`,{className:`shrink-0 text-ok`,children:se?N:p(`common.live`)})]}):D?(0,X.jsxs)(`footer`,{className:`flex h-9 items-center gap-2 border-t border-line px-4 font-mono text-xs text-ink-faint`,children:[(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,title:D.storage_path||D.path,children:D.storage_path||D.path}),j?(0,X.jsx)(`span`,{className:`ml-auto truncate text-err`,title:j,children:p(`research.downloadFailed`)}):null,(0,X.jsxs)(`span`,{className:`shrink-0`,children:[D.kind,` · `,fi(D.size)]}),(0,X.jsx)(`span`,{className:`shrink-0 text-ok`,children:se?N:p(`common.live`)})]}):null]})}function Is({notice:e,onClose:t}){if((0,I.useEffect)(()=>{if(!e)return;let n=window.setTimeout(t,e.tone===`error`?8e3:4e3);return()=>window.clearTimeout(n)},[e,t]),!e)return null;let n=e.tone===`error`?`border-err/60 bg-err/10 text-err`:e.tone===`success`?`border-ok/60 bg-ok/10 text-ok`:`border-blue-deep/60 bg-panel text-blue-sky`;return(0,X.jsxs)(`div`,{role:e.tone===`error`?`alert`:`status`,"aria-live":e.tone===`error`?`assertive`:`polite`,className:`fixed bottom-4 left-4 right-4 z-[70] flex items-start gap-2 rounded-md border px-3 py-2.5 shadow-glow sm:left-auto sm:max-w-md ${n}`,children:[(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`mt-px shrink-0`,children:e.tone===`error`?`!`:e.tone===`success`?`✓`:`i`}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 break-words text-xs leading-relaxed text-ink-dim`,children:e.message}),(0,X.jsx)(`button`,{type:`button`,"aria-label":`dismiss notification`,onClick:t,className:`shrink-0 rounded px-1 text-base leading-none opacity-70 hover:bg-white/5 hover:opacity-100`,children:`×`})]})}function Ls({open:e,busy:t,onClose:n,onCreate:r}){let{t:i}=Z(),[a,o]=(0,I.useState)(``),[s,c]=(0,I.useState)(``),[l,u]=(0,I.useState)(``),d=(0,I.useRef)(null);(0,I.useEffect)(()=>{e&&(o(``),c(``),u(``))},[e]);let f=()=>{t||n()},p=async e=>{e.preventDefault(),!t&&await r(a.trim(),s.trim(),l.trim())&&n()},m=e=>{sa(e)||e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),d.current?.requestSubmit())},h=!!s.trim();return(0,X.jsx)(go,{open:e,onClose:f,label:i(`new.createDaemon`),width:`max-w-xl`,showClose:!1,children:(0,X.jsxs)(`form`,{ref:d,onSubmit:e=>void p(e),children:[(0,X.jsxs)(`div`,{className:`flex items-start gap-3 border-b border-line px-5 py-4`,children:[(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`h2`,{className:`text-base font-semibold text-ink`,children:i(`landing.new`)}),(0,X.jsx)(`p`,{className:`mt-0.5 text-xs text-ink-faint`,children:i(`new.subtitle`)})]}),(0,X.jsx)(`button`,{type:`button`,"aria-label":i(`new.close`),onClick:f,disabled:t,className:`rounded px-2 py-1 text-lg leading-none text-ink-faint hover:bg-surface hover:text-ink disabled:opacity-40`,children:`×`})]}),(0,X.jsxs)(`div`,{className:`space-y-4 p-5`,children:[(0,X.jsxs)(`label`,{className:`block`,children:[(0,X.jsxs)(`span`,{className:`mb-1 block text-[10px] font-semibold uppercase tracking-wider text-ink-faint`,children:[i(`new.name`),` `,(0,X.jsx)(`span`,{className:`normal-case tracking-normal`,children:i(`new.optional`)})]}),(0,X.jsx)(`input`,{"data-autofocus":!0,value:a,onChange:e=>o(e.target.value),maxLength:80,disabled:t,placeholder:i(`new.namePlaceholder`),className:`h-10 w-full rounded border border-line bg-bg/50 px-3 text-sm text-ink outline-none placeholder:text-ink-faint focus:border-blue-deep disabled:opacity-50`})]}),(0,X.jsxs)(`label`,{className:`block`,children:[(0,X.jsxs)(`span`,{className:`mb-1 block text-[10px] font-semibold uppercase tracking-wider text-ink-faint`,children:[i(`new.workdir`),` `,(0,X.jsx)(`span`,{className:`normal-case tracking-normal`,children:i(`new.optional`)})]}),(0,X.jsx)(`input`,{value:l,onChange:e=>u(e.target.value),disabled:t,placeholder:i(`newDaemon.workdirPlaceholder`),className:`h-10 w-full rounded border border-line bg-bg/50 px-3 font-mono text-xs text-ink outline-none placeholder:text-ink-faint focus:border-blue-deep disabled:opacity-50`}),(0,X.jsx)(`span`,{className:`mt-1 block text-[10px] leading-relaxed text-ink-faint`,children:i(`new.workdirHint`)})]}),(0,X.jsxs)(`label`,{className:`block`,children:[(0,X.jsxs)(`span`,{className:`mb-1 block text-[10px] font-semibold uppercase tracking-wider text-ink-faint`,children:[i(`new.objective`),` `,(0,X.jsx)(`span`,{className:`normal-case tracking-normal`,children:i(`new.optional`)})]}),(0,X.jsx)(`textarea`,{value:s,onChange:e=>c(e.target.value),onKeyDown:m,maxLength:4e3,disabled:t,rows:4,placeholder:i(`new.objectivePlaceholder`),className:`w-full resize-y rounded border border-line bg-bg/50 px-3 py-2.5 text-sm leading-relaxed text-ink outline-none placeholder:text-ink-faint focus:border-blue-deep disabled:opacity-50`})]}),(0,X.jsxs)(`div`,{className:`rounded border p-3 ${h?`border-gold/40 bg-gold/5`:`border-line bg-bg/30`}`,children:[(0,X.jsx)(`div`,{className:`text-xs font-medium ${h?`text-gold`:`text-blue-sky`}`,children:i(h?`new.startsAfterCreate`:`new.idleUntilMessage`)}),(0,X.jsx)(`p`,{className:`mt-1 text-[11px] leading-relaxed text-ink-faint`,children:i(h?`new.startsHint`:`new.idleHint`)})]})]}),(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-t border-line px-5 py-3`,children:[(0,X.jsx)(`span`,{className:`text-[10px] text-ink-faint`,children:i(`new.shortcut`)}),(0,X.jsxs)(`div`,{className:`flex gap-2`,children:[(0,X.jsx)(`button`,{type:`button`,onClick:f,disabled:t,className:`rounded border border-line px-3 py-1.5 text-xs text-ink-dim hover:bg-surface disabled:opacity-40`,children:i(`common.cancel`)}),(0,X.jsx)(`button`,{type:`submit`,disabled:t,className:`rounded border border-blue/35 bg-blue/8 px-3 py-1.5 text-xs font-medium text-blue hover:border-blue-deep hover:bg-blue-deep hover:text-white disabled:cursor-wait disabled:opacity-50`,children:i(t?`new.creating`:h?`new.createAndStart`:`sidebar.create`)})]})]})]})})}function Rs({open:e,sid:t,name:n,alive:r,controlAvailable:i=!0,busy:a,onClose:o,onRename:s,onStart:c,onStop:l,onDelete:u}){let{t:d}=Z(),[f,p]=(0,I.useState)(n),[m,h]=(0,I.useState)(!1),[g,_]=(0,I.useState)(!1);(0,I.useEffect)(()=>{e&&(p(n),h(!1),_(!1))},[e,n,t]);let v=async e=>{e.preventDefault(),await s(f.trim())},y=r&&!g,b=async()=>{if(y){await l()&&_(!0);return}await c()&&_(!1)};return(0,X.jsxs)(go,{open:e,onClose:()=>!a&&o(),label:d(`manage.daemon`),width:`max-w-lg`,children:[(0,X.jsxs)(`div`,{className:`border-b border-line px-5 py-4`,children:[(0,X.jsx)(`h2`,{className:`text-base font-semibold text-ink`,children:d(`topbar.manageSession`)}),(0,X.jsx)(`p`,{className:`mt-0.5 font-mono text-[10px] text-ink-faint`,children:t})]}),(0,X.jsx)(`form`,{onSubmit:e=>void v(e),className:`border-b border-line p-5`,children:(0,X.jsxs)(`label`,{className:`block`,children:[(0,X.jsx)(`span`,{className:`mb-1 block text-[10px] font-semibold uppercase tracking-wider text-ink-faint`,children:d(`manage.displayName`)}),(0,X.jsxs)(`div`,{className:`flex gap-2`,children:[(0,X.jsx)(`input`,{value:f,onChange:e=>p(e.target.value),maxLength:80,disabled:a,className:`h-9 min-w-0 flex-1 rounded border border-line bg-bg/50 px-3 text-sm text-ink outline-none focus:border-blue-deep disabled:opacity-50`}),(0,X.jsx)(`button`,{type:`submit`,disabled:a||f.trim()===n,className:`rounded border border-line px-3 text-xs text-ink-dim hover:bg-surface disabled:opacity-40`,children:d(`common.save`)})]})]})}),(0,X.jsxs)(`div`,{className:`border-b border-line p-5`,children:[(0,X.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-wider text-ink-faint`,children:d(`manage.executor`)}),(0,X.jsxs)(`div`,{className:`mt-2 flex items-center justify-between rounded border border-line bg-bg/30 p-3`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`div`,{className:`text-sm text-ink`,children:d(y?i?`manage.running`:`manage.runningExternally`:`manage.paused`)}),(0,X.jsx)(`p`,{className:`mt-0.5 text-[11px] text-ink-faint`,children:d(y?i?`manage.stopNowHint`:`manage.externalHint`:`manage.resumeHint`)})]}),(0,X.jsx)(`button`,{type:`button`,disabled:a||!i,onClick:()=>void b(),className:`rounded border px-3 py-1.5 text-xs disabled:cursor-wait disabled:opacity-50 ${y?`border-warn/50 text-warn hover:bg-warn/10`:`border-blue-deep bg-blue-deep text-white hover:bg-blue-deep/80`}`,children:d(a?`manage.working`:i?y?`manage.stopNow`:`manage.resume`:`common.external`)})]})]}),(0,X.jsxs)(`div`,{className:`p-5`,children:[(0,X.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-wider text-err`,children:d(`manage.deleteSession`)}),(0,X.jsx)(`p`,{className:`mt-1 text-[11px] leading-relaxed text-ink-faint`,children:d(`manage.deleteHint`)}),m?(0,X.jsxs)(`div`,{className:`mt-3 flex items-center justify-between gap-3 rounded border border-err/40 bg-err/5 p-3`,children:[(0,X.jsx)(`span`,{className:`text-xs text-ink-dim`,children:d(`manage.confirmQuestion`)}),(0,X.jsxs)(`div`,{className:`flex gap-2`,children:[(0,X.jsx)(`button`,{type:`button`,onClick:()=>h(!1),className:`rounded px-2 py-1 text-xs text-ink-faint hover:bg-surface`,children:d(`common.cancel`)}),(0,X.jsx)(`button`,{type:`button`,disabled:a,onClick:()=>void u(),className:`rounded bg-err px-3 py-1 text-xs font-medium text-bg disabled:opacity-50`,children:d(`manage.confirmDelete`)})]})]}):(0,X.jsx)(`button`,{type:`button`,disabled:a||y,onClick:()=>h(!0),className:`mt-3 rounded border border-err/40 px-3 py-1.5 text-xs text-err hover:bg-err/10 disabled:cursor-not-allowed disabled:opacity-40`,children:d(`manage.delete`)})]})]})}var zs={科学环境已就绪:`Scientific environment ready`,"科学环境 · ⟦0⟧ 项待配置":`Scientific environment · ⟦0⟧ item(s) to configure`,科学环境:`Scientific environment`,检查环境:`Check environment`,"免费科学组件自动配置;SHELX 需要你在官网取得学术授权后输入下载凭据。":`Free scientific components are configured automatically; SHELX requires academic authorization from the official website before entering download credentials.`,修复依赖:`Repair dependencies`,"配置 SHELX":`Configure SHELX`,"SHELX 授权安装":`SHELX authorized installation`,学术授权:`Academic authorization`,前往官网申请:`Apply on official website`,"填写授权邮件中的 username 和 password,即可自动下载安装。凭据仅用于本次官方下载,不保存,也不发送给模型。":`Enter the username and password from the authorization email to download and install automatically. Credentials are used only for this official download, are not saved, and are not sent to the model.`,用户名:`Username`,"SHELX 用户名":`SHELX username`,密码:`Password`,"SHELX 密码":`SHELX password`,"查看许可 ↗":`View license ↗`,"下载并安装 SHELX":`Download and install SHELX`,取消:`Cancel`,科学软件健康检查:`Scientific software health check`,"点击“检查环境”可验证科学内核与外部程序。":`Click “Check environment” to verify the scientific kernel and external programs.`,可用:`Available`,待授权安装:`Authorization required`,待修复:`Needs repair`,查看检查详情:`View check details`,查看原因与安装方式:`View cause and installation method`,"官方安装说明 ↗":`Official installation instructions ↗`,使用已有安装:`Use existing installation`,"DIALS 环境目录":`DIALS environment directory`,"Systre JAR 路径(需要已有 Java)":`Systre JAR path (existing Java required)`,"⟦0⟧ 可执行文件路径":`⟦0⟧ executable path`,"填写运行 Argus 的电脑上的路径,验证成功后生效。":`Enter the path on the computer running Argus. It takes effect after successful verification.`,验证并使用:`Verify and use`,最近检查:`Last checked`,"· 检查不调用模型":`· Check does not call the model`,无法读取插件列表:`Unable to read plugin list`,插件操作未完成:`Plugin operation incomplete`,插件:`Plugins`,关闭插件列表:`Close plugin list`,"按需安装研究工具,沿用 Argus 的模型与执行后端。":`Install research tools as needed, using Argus's model and execution backend.`,"正在读取插件…":`Reading plugins…`,暂无可用插件:`No plugins available`,已启用:`Enabled`,已停用:`Disabled`,未安装:`Not installed`,"· 当前后端":`· Current backend`,安装:`Install`,打开工作台:`Open workbench`,启用:`Enable`,更新至:`Update to`,停用:`Disable`,卸载:`Uninstall`,"原生会话输入 ⟦0⟧ 可启用后台工具。卸载保留会话、研究数据和科学软件。":`Native session input ⟦0⟧ can enable background tools. Uninstalling preserves sessions, research data, and scientific software.`,"首次安装自动配置独立 Python、DIALS、Systre / Java 和 PLATON 学术免费组件。SHELX 稍后输入授权信息即可安装。":`First installation automatically configures standalone Python, DIALS, Systre / Java, and free academic PLATON components. SHELX can be installed later by entering authorization details.`,"暂不支持,敬请期待。当前插件支持 Codex、Copilot 和 Pi。":`Not supported yet. Stay tuned. Current plugins support Codex, Copilot, and Pi.`,"安装科学环境需要 Python 3.11–3.13。请安装 Python 后重试,或设置 ARGUS_PLUGIN_PYTHON。":`Installing the scientific environment requires Python 3.11–3.13. Install Python and try again, or set ARGUS_PLUGIN_PYTHON.`,准备安装:`Prepare installation`,获取并校验插件包:`Download and verify plugin package`,"安装独立运行环境(首次可能需要几分钟)":`Install standalone environment (may take several minutes the first time)`,"插件仍有任务运行,请等任务结束或先暂停,再进行此操作。":`This plugin still has running tasks. Wait for them to finish or pause them before continuing.`,"此插件版本尚未提供可校验的发行包。":`No verifiable release package is available for this plugin version.`,"插件包校验失败,未安装。":`Plugin package verification failed. Not installed.`,正在准备:`Preparing`,"当前系统或 Argus 插件接口版本暂不支持此插件。":`This plugin is not currently supported by the system or Argus plugin API version.`,"插件发行包尚未发布。":`The plugin release package has not been published.`,安装完成:`Installation complete`,环境检查完成:`Environment check complete`,"此插件已有安装或更新操作正在进行。":`An installation or update operation for this plugin is already in progress.`,插件尚未安装:`Plugin not installed`,"安装进程已中断;已有可用版本保持不变,可重试。":`Installation was interrupted. The existing available version is unchanged; you can retry.`,"安装未完成,已有版本保持不变":`Installation incomplete; existing version unchanged`,"此版本已安装,可启用插件。":`This version is installed. You can enable the plugin.`,请先安装插件:`Install the plugin first`,请先更新插件以使用环境管理功能:`Update the plugin first to use environment management`,"插件包超过允许大小。":`The plugin package exceeds the allowed size.`,科学计算内核:`Scientific computing kernel`,"cctbx · Gemmi · RDKit · 科学服务":`cctbx · Gemmi · RDKit · scientific services`,衍射帧处理与探测器格式支持:`Diffraction frame processing and detector format support`,周期网络与拓扑识别:`Periodic networks and topology identification`,"本地 checkCIF 结构校验 · 学术免费":`Local checkCIF structure validation · free for academic use`,"结构精修 · 需要学术授权":`Structure refinement · academic authorization required`,"结构求解 · 需要学术授权":`Structure solution · academic authorization required`,全部组件可用:`All components available`,部分组件需要配置或修复:`Some components require configuration or repair`,"PLATON 官网中间证书已更换,请更新插件安装器":`The PLATON official-site intermediate certificate has changed. Update the plugin installer.`,"PLATON Mac 发行包架构不符":`PLATON Mac release package architecture mismatch`,"请输入授权邮件中的用户名和密码。":`Enter the username and password from the authorization email.`,请选择有效的科学软件路径:`Select a valid scientific software path`,检查科学软件与运行环境:`Check scientific software and runtime environment`,"正在修复科学 Python 依赖":`Repairing scientific Python dependencies`,"(首次下载可能需要几分钟)":`(The initial download may take several minutes)`,"from cctbx.array_family import flex; import gemmi,rdkit; from argus_crystalpilot import worker; from argus_crystalpilot.resources import bundle_root; assert (bundle_root()/'ui/dist/index.html').is_file(); import crystalpilot; from pathlib import Path; assert (Path(crystalpilot.__file__).parent/'io/dxtbx_plugin/pyproject.toml').is_file(); assert flex.double([1,2]).size()==2; print('科学内核及工作台资源可用')":`from cctbx.array_family import flex; import gemmi,rdkit; from argus_crystalpilot import worker; from argus_crystalpilot.resources import bundle_root; assert (bundle_root()/'ui/dist/index.html').is_file(); import crystalpilot; from pathlib import Path; assert (Path(crystalpilot.__file__).parent/'io/dxtbx_plugin/pyproject.toml').is_file(); assert flex.double([1,2]).size()==2; print('Scientific kernel and workbench resources available')`,"; from importlib.metadata import entry_points; assert {'FormatCBFMiniRigaku:FormatCBF','FormatBrukerSfrmGeom:FormatBruker','FormatRODLegacy:FormatROD'} <= {e.name for e in entry_points(group='dxtbx.format')}; from dials.util.version import dials_version; assert flex.reflection_table() is not None; print(dials_version()+' · 探测器格式插件可用')":`; from importlib.metadata import entry_points; assert {'FormatCBFMiniRigaku:FormatCBF','FormatBrukerSfrmGeom:FormatBruker','FormatRODLegacy:FormatROD'} <= {e.name for e in entry_points(group='dxtbx.format')}; from dials.util.version import dials_version; assert flex.reflection_table() is not None; print(dials_version()+' · detector format plugins available')`,"Systre 19.6.0 · pcu 拓扑计算通过":`Systre 19.6.0 · pcu topology calculation passed`,"正在安装 Apple Rosetta 2 兼容组件":`Installing Apple Rosetta 2 compatibility components`,"从 SHELX 官方站点下载":`Downloading from the official SHELX site`,"SHELX 下载内容不是支持的可执行程序":`SHELX download is not a supported executable`,"已可用,保留当前安装":`Already available; keeping current installation`,正在安装:`Installing`,"尚未安装 DIALS":`DIALS is not installed`,"PLATON 编译需要 Apple 命令行工具;请运行 xcode-select --install,然后点击修复依赖。":`PLATON compilation requires Apple Command Line Tools; run xcode-select --install, then click Repair dependencies.`,"SHELX 官方 Mac 版需要 Rosetta 2,请先同意安装兼容组件。":`The official Mac version of SHELX requires Rosetta 2. Agree to install the compatibility components first.`,"暂未完成;可在健康检查中重试":`Not completed; retry from the health check`,"SHELX 下载或启动失败;请核对授权、网络及系统平台后重试。":`SHELX download or launch failed; check authorization, network, and system platform, then retry.`,"尚未安装 Systre":`Systre is not installed`,"尚未安装 Java":`Java is not installed`,"Systre 未能识别内置 pcu 网络":`Systre could not identify the built-in pcu network`,"尚未安装 PLATON":`PLATON is not installed`,"PLATON 安装配方已更新,点击修复依赖即可使用当前版本。":`The PLATON installation recipe has been updated. Click Repair dependencies to use the current version.`,"PLATON 未生成校验规则;请检查运行库":`PLATON did not generate verification rules; check the runtime`,"请输入 SHELX 授权信息以安装":`Enter SHELX authorization details to install`,"无法启动,请核对平台与运行库":`Unable to start; check the platform and runtime`,"衍射数据处理、结构求解、精修与三维晶体研究工作台":`Diffraction data processing, structure solution, refinement and a 3D crystallography workbench`},Bs=e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),Vs=/⟦\d+⟧/g,Hs=Object.entries(zs).filter(([e])=>e.includes(`⟦`)).sort((e,t)=>t[0].length-e[0].length).map(([e,t])=>({regex:RegExp(`^`+e.split(Vs).map(Bs).join(`([\\s\\S]*?)`)+`$`),slots:e.match(Vs)??[],target:t})),Us=new RegExp(Object.keys(zs).filter(e=>e.length>1&&!e.includes(`⟦`)).sort((e,t)=>t.length-e.length).map(Bs).join(`|`),`g`);function Ws(e,t){if(t===`zh-CN`||!/[\u3400-\u9fff]/.test(e))return e;if(zs[e.trim()])return e.replace(e.trim(),zs[e.trim()]);for(let t of Hs){let n=t.regex.exec(e.trim());if(n){let e=new Map(t.slots.map((e,t)=>[e,n[t+1]]));return t.target.replace(Vs,t=>e.get(t)??t)}}return e.replace(Us,e=>zs[e])}function Gs(){let{locale:e}=Z();return t=>typeof t==`string`?Ws(t,e):t}var Ks=Se(),qs=`inline-flex items-center justify-center gap-1.5 rounded-lg border border-line px-3 py-1.5 text-sm transition-colors hover:bg-bg disabled:cursor-not-allowed disabled:opacity-45`;function Js({health:e,setup:t,running:n,act:r,platform:i,machine:a}){let o=Gs(),[s,c]=(0,I.useState)(!1),[l,u]=(0,I.useState)(!1),[d,f]=(0,I.useState)(``),[p,m]=(0,I.useState)(``),[h,g]=(0,I.useState)(null),[_,v]=(0,I.useState)(``),[y,b]=(0,I.useState)(!1),x=t.license?.platform_consent,S=x?.platform===i&&x?.machines.includes(a||``),C=e?.components||[],w=C.filter(e=>e.status!==`ready`),T=w.some(e=>e.license_required),E=w.some(e=>e.automatic);async function D(e){e.preventDefault();let n=await r(t.license.action,{username:d,password:p,accept_platform_license:y});m(``),n&&(u(!1),f(``),c(!0))}return(0,X.jsxs)(`div`,{className:`mt-5 border-t border-line/60 pt-4`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,X.jsxs)(`button`,{type:`button`,"aria-expanded":s,onClick:()=>c(!s),className:`inline-flex items-center gap-2 text-sm text-ink-dim hover:text-ink`,children:[(0,X.jsx)(ro,{size:16,strokeWidth:1.5}),(0,X.jsx)(`span`,{children:o(e?.checked?e.ready?o(`科学环境已就绪`):o(`科学环境 · ${w.length} 项待配置`):o(`科学环境`))}),(0,X.jsx)(Ha,{size:13,className:`transition-transform duration-200 ${s?`rotate-180`:``}`})]}),(0,X.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 text-xs text-ink-faint hover:text-ink disabled:opacity-45`,disabled:n,onClick:()=>{c(!0),r(`health`)},children:[(0,X.jsx)(no,{size:12}),o(`检查环境`)]})]}),o((T||E||!e?.checked)&&(0,X.jsx)(`p`,{className:`mt-2 text-xs leading-relaxed text-ink-faint`,children:o(` 免费科学组件自动配置;SHELX 需要你在官网取得学术授权后输入下载凭据。 `)})),(0,X.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[o((E||!e?.checked)&&(0,X.jsxs)(`button`,{className:qs,disabled:n,onClick:()=>{c(!0),r(`repair`)},children:[(0,X.jsx)(qa,{size:14}),o(`修复依赖`)]})),o(t.license&&(0,X.jsxs)(`button`,{className:qs,disabled:n,onClick:()=>{u(!l),m(``),f(``)},children:[(0,X.jsx)(Xa,{size:14}),o(o(T?`配置 SHELX`:`SHELX 授权安装`))]}))]}),o(l&&t.license&&(0,X.jsxs)(`form`,{onSubmit:D,className:`mt-4 rounded-lg bg-bg/70 p-3`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-2 text-sm`,children:[(0,X.jsxs)(`span`,{className:`font-medium`,children:[o(t.license.name),o(` 学术授权`)]}),(0,X.jsxs)(`a`,{href:t.license.url,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-xs text-blue`,children:[o(`前往官网申请`),(0,X.jsx)(Ja,{size:11})]})]}),(0,X.jsx)(`p`,{className:`mb-3 mt-1.5 text-xs leading-relaxed text-ink-faint`,children:o(`填写授权邮件中的 username 和 password,即可自动下载安装。凭据仅用于本次官方下载,不保存,也不发送给模型。`)}),(0,X.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,X.jsxs)(`label`,{className:`text-xs text-ink-dim`,children:[o(`用户名`),(0,X.jsx)(`input`,{"aria-label":o(`SHELX 用户名`),value:d,onChange:e=>f(e.target.value),required:!0,maxLength:200,autoComplete:`off`,autoCapitalize:`none`,spellCheck:!1,className:`mt-1.5 w-full rounded-md border border-line bg-panel px-2.5 py-2 text-sm text-ink outline-none focus:border-blue/60`})]}),(0,X.jsxs)(`label`,{className:`text-xs text-ink-dim`,children:[o(`密码`),(0,X.jsx)(`input`,{"aria-label":o(`SHELX 密码`),type:`password`,value:p,onChange:e=>m(e.target.value),required:!0,maxLength:500,autoComplete:`new-password`,className:`mt-1.5 w-full rounded-md border border-line bg-panel px-2.5 py-2 text-sm text-ink outline-none focus:border-blue/60`})]})]}),o(S&&x&&(0,X.jsxs)(`label`,{className:`mt-3 flex items-start gap-2 text-xs leading-relaxed text-ink-faint`,children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:y,onChange:e=>b(e.target.checked),className:`mt-0.5`}),(0,X.jsxs)(`span`,{children:[o(x.text),` `,(0,X.jsx)(`a`,{href:x.url,target:`_blank`,rel:`noreferrer`,className:`text-blue`,children:o(`查看许可 ↗`)})]})]})),(0,X.jsxs)(`div`,{className:`mt-3 flex gap-2`,children:[(0,X.jsxs)(`button`,{type:`submit`,className:qs,disabled:n||!d.trim()||!p.trim(),children:[(0,X.jsx)(qa,{size:14}),o(`下载并安装 SHELX`)]}),(0,X.jsx)(`button`,{type:`button`,className:`px-2 text-xs text-ink-faint`,onClick:()=>{u(!1),f(``),m(``)},children:o(`取消`)})]})]})),s&&(0,X.jsxs)(`div`,{className:`mt-3`,"aria-label":o(`科学软件健康检查`),children:[o(!C.length&&(0,X.jsx)(`p`,{className:`py-2 text-xs text-ink-faint`,children:o(`点击“检查环境”可验证科学内核与外部程序。`)})),C.map(e=>(0,X.jsx)(`div`,{className:`border-b border-line/40 py-2.5 last:border-0`,children:(0,X.jsxs)(`div`,{className:`flex items-start gap-2.5`,children:[o(e.status===`ready`?(0,X.jsx)(Va,{size:15,strokeWidth:1.7,className:`mt-0.5 shrink-0 text-blue/75`}):(0,X.jsx)(Wa,{size:15,strokeWidth:1.5,className:`mt-0.5 shrink-0 text-ink-faint`})),(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-3 text-sm`,children:[(0,X.jsx)(`span`,{children:o(e.name)}),(0,X.jsx)(`span`,{className:`shrink-0 text-xs text-ink-faint`,children:o(e.status===`ready`?o(`可用`):e.license_required?o(`待授权安装`):o(`待修复`))})]}),(0,X.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-ink-faint`,children:o(e.description)}),(0,X.jsxs)(`details`,{className:`mt-1.5 text-xs text-ink-faint`,children:[(0,X.jsx)(`summary`,{className:`cursor-pointer hover:text-ink-dim`,children:o(e.status===`ready`?o(`查看检查详情`):o(`查看原因与安装方式`))}),(0,X.jsx)(`p`,{className:`mt-2 whitespace-pre-wrap break-words leading-relaxed`,children:o(e.detail)}),e.path&&(0,X.jsx)(`p`,{className:`mt-1 break-all leading-relaxed`,children:e.path}),(0,X.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-3`,children:[(0,X.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,className:`text-blue`,children:o(`官方安装说明 ↗`)}),o(e.id!==`python`&&t.actions.includes(`configure`)&&(0,X.jsx)(`button`,{type:`button`,disabled:n,onClick:()=>{g(e.id),v(``)},className:`text-blue`,children:o(`使用已有安装`)}))]})]})]})]})},e.id)),o(h&&(0,X.jsxs)(`form`,{onSubmit:async e=>{e.preventDefault(),await r(`configure`,{paths:{[h]:_}})&&(g(null),v(``))},className:`mt-3 rounded-lg bg-bg/70 p-3`,children:[(0,X.jsxs)(`label`,{className:`text-xs text-ink-dim`,children:[o(o(h===`dials`?`DIALS 环境目录`:h===`systre`?`Systre JAR 路径(需要已有 Java)`:`${h.toUpperCase()} 可执行文件路径`)),(0,X.jsx)(`input`,{required:!0,value:_,onChange:e=>v(e.target.value),className:`mt-2 w-full rounded-md border border-line bg-panel px-2 py-2 text-sm text-ink`})]}),(0,X.jsx)(`p`,{className:`mt-1.5 text-xs text-ink-faint`,children:o(`填写运行 Argus 的电脑上的路径,验证成功后生效。`)}),(0,X.jsxs)(`div`,{className:`mt-3 flex gap-3`,children:[(0,X.jsx)(`button`,{className:qs,disabled:n,children:o(`验证并使用`)}),(0,X.jsx)(`button`,{type:`button`,className:`text-xs text-ink-faint`,onClick:()=>g(null),children:o(`取消`)})]})]})),o(e?.checked&&(0,X.jsxs)(`p`,{className:`mt-2 text-[11px] text-ink-faint`,children:[o(`最近检查 `),o(new Date(e.checked*1e3).toLocaleString()),o(` · 检查不调用模型`)]}))]})]})}function Ys({compact:e=!1}){let t=Gs(),{locale:n}=Z(),[r,i]=(0,I.useState)(!1),[a,o]=(0,I.useState)([]),[s,c]=(0,I.useState)(``),[l,u]=(0,I.useState)(!1),[d,f]=(0,I.useState)(null),p=(0,I.useRef)(null);async function m(e){let n=await fetch(`/api/plugins`,{headers:Ke(),signal:e});if(!n.ok)throw Error(t(`无法读取插件列表`));o((await n.json()).plugins)}(0,I.useEffect)(()=>{if(!r)return;let e=new AbortController;p.current?.focus(),c(``),u(!0),m(e.signal).catch(t=>{e.signal.aborted||c(t.message)}).finally(()=>u(!1));let t=window.setInterval(()=>void m(e.signal).catch(()=>{}),1500),n=e=>{e.key===`Escape`&&i(!1)};return window.addEventListener(`keydown`,n),()=>{e.abort(),window.clearInterval(t),window.removeEventListener(`keydown`,n)}},[r]);async function h(e,n,r){f(e.id),c(``);try{let i=await fetch(`/api/plugins/${e.id}/${n===`launch`?`launch`:`manage/${n}`}`,{method:`POST`,headers:{...Ke(),"Content-Type":`application/json`},body:r?JSON.stringify(r):void 0}),a=await i.json();if(!i.ok)throw Error(a.detail||t(`插件操作未完成`));return n===`launch`?window.location.assign(a.url):await m(),!0}catch(e){return c(e instanceof Error?e.message:String(e)),!1}finally{f(null)}}return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`button`,{type:`button`,onClick:()=>i(!0),title:t(`插件`),"aria-label":t(`插件`),className:`mx-2 my-1 flex h-9 shrink-0 items-center rounded-md text-sm text-ink-dim transition-colors hover:bg-bg hover:text-ink ${e?`justify-center`:`gap-2 px-3`}`,children:[(0,X.jsx)(Ba,{size:17,strokeWidth:1.5}),t(!e&&(0,X.jsx)(`span`,{children:t(`插件`)}))]}),r&&(0,Ks.createPortal)((0,X.jsx)(`div`,{className:`fixed inset-0 z-[100] flex items-center justify-center bg-black/20 p-5 backdrop-blur-sm`,onClick:()=>i(!1),children:(0,X.jsxs)(`section`,{role:`dialog`,"aria-modal":`true`,"aria-labelledby":`plugin-title`,onClick:e=>e.stopPropagation(),className:`max-h-[85vh] w-full max-w-xl overflow-y-auto rounded-2xl border border-line bg-panel p-6 text-ink shadow-xl`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,X.jsx)(`h2`,{id:`plugin-title`,className:`text-lg font-semibold`,children:t(`插件`)}),(0,X.jsx)(`button`,{ref:p,type:`button`,"aria-label":t(`关闭插件列表`),className:`icon-control p-1.5`,onClick:()=>i(!1),children:(0,X.jsx)(oo,{size:18})})]}),(0,X.jsx)(`p`,{className:`mb-6 mt-2 text-sm text-ink-faint`,children:t(`按需安装研究工具,沿用 Argus 的模型与执行后端。`)}),t(s&&(0,X.jsx)(`p`,{role:`alert`,className:`mb-4 text-sm text-ink-dim`,children:t(s)})),t(l&&(0,X.jsx)(`p`,{className:`text-sm text-ink-faint`,children:t(`正在读取插件…`)})),t(!l&&!a.length&&(0,X.jsx)(`p`,{className:`text-sm text-ink-faint`,children:t(`暂无可用插件`)})),t(a.map(e=>{let r=e.operation?.status===`running`||d===e.id,i=r||!e.supported,a=`inline-flex items-center justify-center gap-1.5 rounded-lg border border-line px-3 py-1.5 text-sm transition-colors hover:bg-bg disabled:cursor-not-allowed disabled:opacity-45`;return(0,X.jsxs)(`article`,{className:`rounded-xl border border-line/70 p-4`,"data-testid":`plugin-${e.id}`,children:[(0,X.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,X.jsx)(Ka,{size:24,strokeWidth:1.25,className:`mt-0.5 shrink-0 text-blue`}),(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,X.jsx)(`h3`,{className:`font-medium`,children:t(e.name)}),(0,X.jsx)(`span`,{className:`text-xs text-ink-faint`,children:t(e.installed_version||e.version)})]}),(0,X.jsx)(`p`,{className:`mt-1 text-sm leading-relaxed text-ink-faint`,children:t(e.description)})]})]}),(0,X.jsxs)(`div`,{className:`mt-4 text-xs text-ink-faint`,children:[t(e.installed?e.enabled?t(`已启用`):t(`已停用`):t(`未安装`)),t(` · 当前后端 `),t(Array.from(new Set(Object.values(e.backends))).join(` / `))]}),t(!e.supported&&(0,X.jsx)(`p`,{className:`mt-3 text-sm text-ink-dim`,children:t(e.reason)})),t(e.operation?.status===`running`&&(0,X.jsxs)(`p`,{role:`status`,className:`mt-3 flex items-center gap-2 text-sm text-ink-dim`,children:[(0,X.jsx)(Za,{size:14,className:`animate-spin`}),t(e.operation.progress)]})),t(e.operation?.status===`failed`&&(0,X.jsx)(`p`,{role:`status`,className:`mt-3 break-words text-sm text-ink-dim`,children:t(e.operation.error)})),(0,X.jsxs)(`div`,{className:`mt-4 flex flex-wrap items-center gap-2`,children:[t(!e.installed&&(0,X.jsxs)(`button`,{className:a,disabled:i,onClick:()=>void h(e,`install`),children:[(0,X.jsx)(qa,{size:14}),t(`安装`)]})),t(e.installed&&e.enabled&&(0,X.jsxs)(`button`,{className:a,disabled:i,onClick:()=>void h(e,`launch`),children:[t(`打开工作台`),(0,X.jsx)(Ra,{size:14})]})),t(e.installed&&!e.enabled&&(0,X.jsx)(`button`,{className:a,disabled:i,onClick:()=>void h(e,`enable`),children:t(`启用`)})),t(e.update_available&&(0,X.jsxs)(`button`,{className:a,disabled:i,onClick:()=>void h(e,`update`),children:[(0,X.jsx)(no,{size:14}),t(`更新至 `),t(e.version)]})),t(e.installed&&e.enabled&&(0,X.jsx)(`button`,{className:a,disabled:r,onClick:()=>void h(e,`disable`),children:t(`停用`)})),t(e.installed&&(0,X.jsx)(`button`,{className:a,disabled:r,onClick:()=>void h(e,`uninstall`),children:t(`卸载`)}))]}),(0,X.jsx)(`p`,{className:`mt-4 text-xs leading-relaxed text-ink-faint`,children:t(e.installed?t(`原生会话输入 ${e.command||``} 可启用后台工具。卸载保留会话、研究数据和科学软件。`):t(`首次安装自动配置独立 Python、DIALS、Systre / Java 和 PLATON 学术免费组件。SHELX 稍后输入授权信息即可安装。`))}),t(e.rights_notice&&(0,X.jsx)(`p`,{className:`mt-3 text-[10px] leading-relaxed text-ink-faint`,"data-testid":`plugin-rights-notice`,children:t(n===`zh-CN`&&e.rights_notice_zh||e.rights_notice)})),t(e.installed&&e.setup&&(0,X.jsx)(Js,{health:e.health,setup:e.setup,running:r,platform:e.platform,machine:e.machine,act:(t,n)=>h(e,t,n)}))]},e.id)}))]})}),document.body)]})}function Xs(e){return e.replace(/[\\/]+$/,``).split(/[\\/]/).at(-1)||e}function Zs(e,t,n){if(e.length===0)return`local`;let r=n.trim(),i=r?e.filter(e=>e.launch_cwd?.trim()===r):[];return i.length===0||t&&!i.some(e=>e.id===t)?`all`:`local`}function Qs({projects:e,activeId:t,localCwd:n,onSelect:i,onPrefetch:a,onManage:s,onResume:l,resumingId:u,onOpenPanel:d,onNew:f,loading:p,creating:m=!1,error:h,onRetry:_,mobileOpen:v=!1,collapsed:y=!1,onToggleCollapse:S,themeMode:w,onCycleTheme:ee}){let{locale:O,setLocale:te,t:k}=Z(),[re,A]=(0,I.useState)(`local`),j=(0,I.useRef)(!1),[ie,ae]=(0,I.useState)(``),[M,oe]=(0,I.useState)(()=>new Set),se=y&&!v,N=n.trim(),ce=(0,I.useMemo)(()=>N?e.filter(e=>e.launch_cwd?.trim()===N):[],[N,e]);(0,I.useEffect)(()=>{j.current||p||e.length===0||(j.current=!0,A(Zs(e,t,N)))},[t,p,N,e]);let le=re===`local`?ce:e,ue=ie.trim()?Mn(le,ie):le,de=(0,I.useMemo)(()=>{if(re===`local`)return ue.length>0?[[N||`Local`,ue]]:[];let e=new Map;return ue.forEach(t=>{let n=t.launch_cwd?.trim()||k(`common.unassigned`),r=e.get(n)??[];r.push(t),e.set(n,r)}),[...e.entries()]},[N,re,ue]),fe=w===`light`?c:ne,P=w===`light`?`dark`:`light`,F=e=>M.has(e)&&!ie.trim();return(0,X.jsxs)(`aside`,{"data-state":se?`collapsed`:`expanded`,"data-resizable-panel":`left`,className:`glass-panel glass-panel--side fixed inset-y-0 left-0 z-50 flex h-full shrink-0 flex-col border-r transition-[width,transform,visibility] duration-panel ease-panel lg:visible lg:static lg:z-auto lg:translate-x-0 ${se?`w-14`:`w-64 lg:w-[var(--sidebar-width)]`} ${v?`visible translate-x-0`:`invisible -translate-x-full`}`,children:[(0,X.jsx)(`div`,{className:`chrome-seam-surface flex h-12 shrink-0 items-center border-b border-line/50 ${se?`justify-center`:`justify-between px-4`}`,children:se?(0,X.jsx)(Mi,{size:22,compact:!0}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Mi,{size:24}),(0,X.jsx)(`button`,{type:`button`,onClick:S,"aria-label":k(`sidebar.collapse`),title:`${k(`sidebar.collapse`)} · Ctrl/⌘ B`,className:`icon-control flex h-8 w-8 shrink-0 items-center justify-center`,children:(0,X.jsx)(o,{icon:E,className:`h-3.5 w-3.5`})})]})}),se?(0,X.jsx)(`div`,{className:`flex h-12 shrink-0 items-center justify-center`,children:(0,X.jsx)(`button`,{type:`button`,onClick:S,"aria-label":k(`sidebar.expand`),title:`${k(`sidebar.expand`)} · Ctrl/⌘ B`,className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-md border border-line/50 bg-bg/40 text-ink-faint hover:border-blue/50 hover:text-ink`,children:(0,X.jsx)(o,{icon:x,className:`h-3.5 w-3.5`})})}):null,(0,X.jsx)(Ys,{compact:se}),se?null:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`flex h-12 shrink-0 items-center gap-1 border-b border-line/50 px-3`,children:[[`local`,`all`].map(t=>(0,X.jsxs)(`button`,{type:`button`,onClick:()=>A(t),className:`h-8 rounded-md px-3 text-xs font-medium capitalize transition-colors ${re===t?`bg-bg text-ink`:`text-ink-faint hover:text-ink-dim`}`,children:[k(`common.${t}`),(0,X.jsx)(`span`,{className:`ml-1.5 font-mono text-ink-faint`,children:t===`local`?ce.length:e.length})]},t)),(0,X.jsx)(`button`,{type:`button`,onClick:f,disabled:m,"aria-label":k(`sidebar.create`),title:k(`sidebar.create`),className:`ml-auto flex h-8 w-8 items-center justify-center rounded-md text-lg text-blue hover:bg-bg disabled:opacity-40`,children:m?`…`:`+`})]}),(0,X.jsxs)(`div`,{className:`px-3 py-2`,children:[(0,X.jsx)(`label`,{className:`sr-only`,htmlFor:`daemon-search`,children:k(`sidebar.find`)}),(0,X.jsxs)(`div`,{className:`flex items-center rounded-md border border-line/60 bg-bg/60 px-2 focus-within:border-blue/60`,children:[(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`mr-1.5 text-xs text-ink-faint`,children:`/`}),(0,X.jsx)(`input`,{id:`daemon-search`,value:ie,onChange:e=>ae(e.target.value),placeholder:k(`sidebar.find`),className:`h-8 min-w-0 flex-1 bg-transparent text-xs text-ink outline-none placeholder:text-ink-faint`}),ie?(0,X.jsx)(`button`,{type:`button`,"aria-label":k(`sidebar.clearSearch`),onClick:()=>ae(``),className:`px-1 text-sm text-ink-faint hover:text-ink`,children:`×`}):null]})]}),(0,X.jsxs)(`div`,{className:`mobile-scroll-region min-h-0 flex-1 overflow-x-hidden overflow-y-auto px-3 pb-3 scroll-thin`,children:[p&&e.length===0?(0,X.jsx)(`div`,{className:`px-1 py-3 text-xs text-ink-faint`,children:k(`common.loading`)}):null,h?(0,X.jsx)(`button`,{type:`button`,onClick:_,className:`mb-2 w-full rounded-md bg-err/5 px-3 py-2 text-left text-xs text-err`,children:k(`sidebar.refreshFailed`)}):null,!p&&!h&&ue.length===0?(0,X.jsxs)(`div`,{className:`px-1 py-4 text-xs text-ink-faint`,children:[(0,X.jsx)(`div`,{children:ie.trim()?k(`sidebar.noMatches`,{query:ie.trim()}):k(`sidebar.noSessions`)}),ie.trim()?(0,X.jsx)(`button`,{type:`button`,onClick:()=>ae(``),className:`mt-2 text-xs text-ink-dim underline underline-offset-2 hover:text-ink`,children:k(`sidebar.clearSearch`)}):null]}):null,de.map(([e,n])=>(0,X.jsxs)(`section`,{className:`mb-4 last:mb-0`,children:[(0,X.jsxs)(`button`,{type:`button`,"aria-expanded":!F(e),title:e,onClick:()=>oe(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),className:`mb-1 flex h-7 w-full items-center gap-2 rounded-md px-1.5 text-left text-[11px] font-medium text-ink-faint hover:bg-bg/70 hover:text-ink-dim`,children:[(0,X.jsx)(o,{icon:T,className:`h-2.5 w-2.5 transition-transform ${F(e)?`-rotate-90`:``}`}),(0,X.jsx)(o,{icon:C,className:`h-3 w-3`}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:Xs(e)}),(0,X.jsx)(`span`,{className:`font-mono text-[10px]`,children:n.length})]}),F(e)?null:n.map(e=>{let n=e.id===t,c=En(e),d=c?(e.label||e.display_name||``).trim():e.objective.trim()||e.id||k(`sidebar.unnamedSession`),f=e.daemon_alive&&e.daemon_protocol_compatible===!1,p=f&&e.daemon_protocol_error===`daemon release is incompatible with WebAPI release`,m=f&&!p,h=!e.daemon_alive&&e.last_active>0&&!!e.workdir?.trim();return(0,X.jsxs)(`div`,{"data-active":n?`true`:`false`,onPointerEnter:()=>{n||a?.(e.id)},className:`session-card group relative mb-0.5 h-14 w-full rounded-md transition-colors duration-150 ease-panel ${n?`text-ink`:`text-ink-dim hover:text-ink`}`,children:[(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`absolute left-0 transition-colors ${n?`inset-y-1 w-px bg-blue`:`inset-y-2 w-px bg-transparent group-hover:bg-ink-faint/30`}`}),(0,X.jsxs)(`button`,{type:`button`,onClick:()=>i(e.id),onFocus:()=>{n||a?.(e.id)},"aria-current":n?`page`:void 0,title:`${d}${!c&&d!==e.id?` · ${e.id}`:``}${e.objective&&e.objective!==d?` — ${e.objective}`:``}`,className:`flex h-14 w-full min-w-0 flex-col justify-center px-2.5 text-left ${h?`pr-[4.75rem]`:`pr-10`}`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,X.jsx)(gi,{ok:e.daemon_alive&&!m,title:m?k(`sidebar.updateRequired`):e.daemon_alive?k(`sidebar.daemonAlive`):k(`sidebar.stopped`)}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm font-medium`,children:d})]}),(0,X.jsxs)(`div`,{className:`mt-1 flex min-w-0 items-center gap-1.5 pl-3.5 text-[11px] text-ink-faint`,children:[(0,X.jsx)(`span`,{className:`min-w-0 truncate ${m?`text-warn`:``}`,children:m?k(`sidebar.updateRequired`):e.daemon_alive?k(`sidebar.runningFor`,{uptime:ui(e.uptime_seconds)}):li(e.last_active)}),p&&(0,X.jsx)(`span`,{title:k(`sidebar.updateAvailableHint`),className:`shrink-0 rounded border border-line px-1 text-[10px] leading-4`,children:k(`sidebar.updateAvailable`)})]})]}),h&&l?(0,X.jsx)(`button`,{type:`button`,disabled:u!=null,onClick:t=>{t.stopPropagation(),l(e.id)},"aria-label":k(`sidebar.resume`),title:k(`sidebar.resumeHint`,{workdir:e.workdir??``}),className:`absolute right-9 top-3 flex h-8 w-8 items-center justify-center rounded-md text-blue opacity-100 hover:bg-blue/10 disabled:opacity-40 sm:opacity-0 sm:group-hover:opacity-100 sm:group-focus-within:opacity-100`,children:u===e.id?`…`:(0,X.jsx)(o,{icon:r,className:`h-3 w-3`})}):null,(0,X.jsx)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),s(e.id)},"aria-label":k(`sidebar.manage`,{name:d}),title:k(`sidebar.manageHint`),className:`absolute right-1 top-3 flex h-8 w-8 items-center justify-center rounded-md text-ink-faint opacity-100 transition-opacity hover:bg-panel-raised hover:text-ink sm:opacity-0 sm:group-hover:opacity-100 sm:group-focus-within:opacity-100`,children:(0,X.jsx)(o,{icon:D,className:`h-4 w-4`})})]},e.id)})]},e))]}),(0,X.jsxs)(`div`,{className:`flex min-h-14 items-center justify-between border-t border-line/50 px-4 py-2`,children:[(0,X.jsx)(`button`,{type:`button`,onClick:()=>d(`config`),className:`icon-control flex h-8 w-8 items-center justify-center`,"aria-label":k(`sidebar.openSettings`),title:k(`common.settings`),children:(0,X.jsx)(o,{icon:b,className:`h-3.5 w-3.5`})}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>te(O===`zh-CN`?`en`:`zh-CN`),title:k(`language.switchTo`,{language:k(O===`zh-CN`?`language.english`:`language.chinese`)}),"aria-label":k(`language.switchTo`,{language:k(O===`zh-CN`?`language.english`:`language.chinese`)}),className:`icon-control flex h-8 w-8 items-center justify-center`,children:(0,X.jsx)(o,{icon:g,className:`h-3.5 w-3.5`})}),(0,X.jsx)(`button`,{type:`button`,onClick:ee,title:k(`sidebar.theme`,{current:w,next:P}),"aria-label":k(`sidebar.theme`,{current:w,next:P}),className:`icon-control flex h-8 w-8 items-center justify-center`,children:(0,X.jsx)(o,{icon:fe,className:`h-3.5 w-3.5`})})]})]})]})}var $s={in_progress:`rgb(var(--blue))`,running:`rgb(var(--blue))`,pending:`rgb(var(--ink-faint))`,queued:`rgb(var(--ink-faint))`,done:`rgb(var(--blue))`,completed:`rgb(var(--blue))`,blocked:`rgb(var(--err))`,failed:`rgb(var(--err))`};function ec({items:e,onDispose:t,onStop:n,onInspect:r,busy:i,readOnly:a=!1}){let{t:o}=Z(),[s,c]=(0,I.useState)(!1),l=Vn(e,!1),u=Vn(e,!0),d=s?u:l;return(0,X.jsxs)(`section`,{className:`card flex flex-col ${d.length>0?`min-h-0 flex-1`:`shrink-0`}`,children:[(0,X.jsx)(yi,{title:o(`panel.backlog`),right:(0,X.jsx)(`button`,{className:`text-[10px] text-ink-faint transition-colors hover:text-ink`,onClick:()=>c(e=>!e),children:o(s?`backlog.active`:`backlog.history`,{count:s?l.length:u.length})})}),(0,X.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto scroll-thin`,children:[d.length===0&&(0,X.jsx)(xi,{children:o(s?`backlog.noHistory`:`backlog.empty`)}),d.map(e=>{let s=$s[e.status]??`rgb(var(--ink-faint))`,c=e.iterate;return(0,X.jsx)(`div`,{className:`group border-b border-line/60 px-3 py-2 last:border-0`,children:(0,X.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsx)(`button`,{type:`button`,onClick:()=>r?.(e.id),disabled:!r,className:`block max-w-full truncate text-left text-xs font-medium text-ink enabled:hover:text-blue-sky enabled:focus-visible:outline-none enabled:focus-visible:underline`,title:r?o(`backlog.viewDetails`):void 0,children:e.title||e.objective}),(0,X.jsxs)(`div`,{className:`mt-0.5 flex items-center gap-1.5`,children:[(0,X.jsx)(_i,{color:s,children:Bi(e.status,o)}),typeof e.priority==`number`&&(0,X.jsx)(`span`,{className:`text-[10px] text-ink-faint`,children:Hi(e.priority,o)}),c&&(0,X.jsxs)(`span`,{className:`text-[10px] text-blue-sky`,children:[`↻ `,o(`backlog.iterating`)]})]})]}),(0,X.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1 opacity-0 transition-opacity group-focus-within:opacity-100 group-hover:opacity-100`,children:[!a&&c&&(0,X.jsx)(vi,{variant:`ghost`,onClick:()=>n(e.id),disabled:i,title:o(`backlog.stopIterating`),children:o(`backlog.stop`)}),!a&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(vi,{variant:`ghost`,onClick:()=>t(e.id,`done`),disabled:i,title:o(`backlog.markDone`),children:`✓`}),(0,X.jsx)(vi,{variant:`ghost`,onClick:()=>t(e.id,`rm`),disabled:i,title:o(`backlog.remove`),children:`✕`})]})]})]})},e.id)})]})]})}var tc={win:`rgb(var(--blue))`,milestone:`rgb(var(--blue))`,insight:`rgb(var(--ink-dim))`,decision:`rgb(var(--ink-dim))`,failure:`rgb(var(--err))`,note:`rgb(var(--ink-faint))`};function nc({entries:e}){let{t}=Z(),n=[...e].reverse();return(0,X.jsxs)(`section`,{className:`card flex min-h-0 flex-1 flex-col`,children:[(0,X.jsx)(yi,{title:t(`panel.journal`),right:(0,X.jsx)(`span`,{className:`text-[10px] text-ink-faint`,children:e.length})}),(0,X.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto scroll-thin`,children:[e.length===0&&(0,X.jsx)(xi,{children:`no journal entries yet`}),n.map(e=>{let t=tc[e.kind]??`rgb(var(--ink-faint))`,n=String(e.extra?.pricing_status??``),r=e.extra&&Object.prototype.hasOwnProperty.call(e.extra,`cost_usd`)?e.extra.cost_usd:e.cost_usd,i=typeof r==`number`&&r>0?`${di(r)}${n===`partial`||n===`unpriced`?`+`:``}`:n===`partial`||n===`unpriced`?n:``;return(0,X.jsxs)(`div`,{className:`border-b border-line/60 px-3 py-2 last:border-0`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,X.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full`,style:{background:t}}),(0,X.jsx)(`span`,{className:`text-[10px] uppercase tracking-wide`,style:{color:t},children:e.kind}),(0,X.jsx)(`span`,{className:`ml-auto text-[10px] text-ink-faint`,children:li(e.ts)})]}),(0,X.jsx)(`div`,{className:`mt-1 text-xs font-medium text-ink`,children:e.title}),e.summary&&(0,X.jsx)(`div`,{className:`mt-0.5 text-[11px] leading-snug text-ink-dim`,children:e.summary}),(0,X.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-1`,children:[(e.tags??[]).slice(0,4).map(e=>(0,X.jsx)(`span`,{className:`rounded bg-line/60 px-1 text-[9px] text-ink-faint`,children:e},e)),i?(0,X.jsx)(`span`,{className:`ml-auto text-[10px] text-ink-faint`,children:i}):null]})]},e.id)})]})]})}var rc=[`manager`,`planner`,`engineer`,`reviewer`];function ic(e){return e==null?``:e<3?`now`:e<60?`${Math.floor(e)}s`:e<3600?`${Math.floor(e/60)}m`:`${Math.floor(e/3600)}h`}function ac({roles:e}){let{t}=Z(),n=new Map(e.map(e=>[e.role,e])),r=rc.map(e=>n.get(e)).filter(Boolean),i=e.filter(e=>!rc.includes(e.role)),a=[...r,...i];return(0,X.jsxs)(`section`,{className:`card`,children:[(0,X.jsx)(yi,{title:t(`panel.roles`)}),(0,X.jsx)(`div`,{children:a.map(e=>{let t=W.role[e.role]??W.info;return(0,X.jsxs)(`div`,{className:`grid grid-cols-[84px_minmax(0,1fr)_auto] items-center gap-2 border-b border-line/60 px-3 py-2 last:border-b-0`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,X.jsx)(`span`,{"data-role-dot":e.role,"aria-hidden":`true`,className:`inline-block h-1.5 w-1.5 shrink-0 rounded-full`,style:{background:t}}),(0,X.jsx)(`span`,{className:`text-[11px] font-medium capitalize`,style:{color:e.active?t:W.inkDim},children:e.role})]}),(0,X.jsx)(`div`,{className:`min-w-0 truncate font-mono text-[10px] text-ink-faint`,title:e.model,children:e.model||`—`}),(0,X.jsxs)(`div`,{className:`flex items-center gap-1 text-right`,children:[(0,X.jsx)(`span`,{className:`text-[10px]`,style:{color:e.active?W.ink:W.inkFaint},children:e.active?e.status||`active`:`idle`}),e.active&&ic(e.age_s)&&(0,X.jsxs)(`span`,{className:`text-[10px] tabular-nums text-ink-faint`,children:[`· `,ic(e.age_s)]}),e.effort&&(0,X.jsxs)(`span`,{className:`text-[10px]`,style:{color:ft(e.effort)},children:[`· `,e.effort]})]})]},e.role)})})]})}function oc({open:e,snap:t,journal:n,busy:r,onClose:i,onDispose:a,onStop:o,onInspect:s}){let{t:c}=Z();return(0,X.jsxs)(go,{open:e,onClose:i,label:`Project inspector`,width:`max-w-6xl`,children:[(0,X.jsx)(_o,{title:c(`panel.project`),sub:t.session.display_name||t.session.id}),(0,X.jsxs)(`div`,{className:`h-[68vh] min-h-0 space-y-3 overflow-y-auto bg-bg p-3 scroll-thin lg:grid lg:grid-cols-[minmax(0,1.4fr)_minmax(300px,0.8fr)] lg:gap-3 lg:space-y-0 lg:overflow-hidden`,children:[(0,X.jsx)(ec,{items:t.backlog,onDispose:a,onStop:o,onInspect:s,busy:r}),(0,X.jsxs)(`div`,{className:`flex min-h-0 flex-col gap-3`,children:[(0,X.jsx)(ac,{roles:t.roles}),(0,X.jsx)(nc,{entries:n})]})]})]})}var sc=e=>e?new Date(e*1e3).toLocaleString():`—`;function cc({label:e,value:t}){return(0,X.jsxs)(`div`,{className:`rounded-md border border-line/70 bg-bg/40 px-3 py-2`,children:[(0,X.jsx)(`div`,{className:`text-[9px] font-semibold uppercase tracking-wider text-ink-faint`,children:e}),(0,X.jsx)(`div`,{className:`mt-0.5 text-xs text-ink-dim`,children:t})]})}function lc({sid:e,itemId:t,onClose:n,onDone:r,onSkip:i,onStop:a,busy:o,readOnly:s=!1}){let{t:c}=Z(),l=Or(e,t),u=l.data,d=u?Bn(u):!1,f=Ui(u?.outcome,c);return(0,X.jsxs)(go,{open:!!t,onClose:n,label:c(`task.details`),width:`max-w-3xl`,showClose:!1,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-start gap-3 border-b border-line px-4 py-3 sm:flex-nowrap sm:px-5`,children:[(0,X.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(`h2`,{className:`truncate text-sm font-semibold text-ink`,children:u?.title||c(`task.details`)}),u?(0,X.jsx)(_i,{children:Bi(u.status,c)}):null]})}),!s&&u&&!d?(0,X.jsxs)(`div`,{className:`order-3 flex w-full shrink-0 items-center justify-end gap-1 sm:order-none sm:w-auto`,children:[u.iterate?(0,X.jsx)(vi,{onClick:()=>a(u.id),disabled:o,children:c(`task.stopLoop`)}):null,(0,X.jsx)(vi,{onClick:()=>r(u.id),disabled:o,children:c(`task.done`)}),(0,X.jsx)(vi,{variant:`danger`,onClick:()=>i(u.id),disabled:o,children:c(`task.skip`)})]}):null,(0,X.jsx)(`button`,{type:`button`,"aria-label":c(`task.close`),onClick:n,className:`order-2 rounded-md px-2 py-1 text-lg leading-none text-ink-faint hover:bg-surface hover:text-ink sm:order-none`,children:`×`})]}),(0,X.jsxs)(`div`,{className:`max-h-[70vh] overflow-y-auto p-4 scroll-thin sm:p-5`,children:[l.isLoading?(0,X.jsx)(`div`,{className:`flex justify-center py-12`,children:(0,X.jsx)(bi,{})}):null,l.isError?(0,X.jsx)(`div`,{className:`rounded-md border border-err/40 bg-err/5 p-3 text-xs text-err`,children:l.error.message}):null,u?(0,X.jsxs)(`div`,{className:`space-y-4`,children:[u.pending_question?(0,X.jsxs)(`div`,{className:`rounded-lg border border-warn/40 bg-warn/5 p-3`,children:[(0,X.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-wider text-warn`,children:c(`task.waitingOnYou`)}),(0,X.jsx)(`p`,{className:`mt-1 whitespace-pre-wrap text-sm leading-relaxed text-ink`,children:u.pending_question})]}):null,(0,X.jsxs)(`section`,{children:[(0,X.jsx)(`div`,{className:`mb-1 text-[10px] font-semibold uppercase tracking-wider text-ink-faint`,children:c(`task.objective`)}),(0,X.jsx)(`div`,{className:`whitespace-pre-wrap rounded-lg border border-line bg-bg/50 p-3 text-sm leading-relaxed text-ink-dim`,children:u.objective||u.original_objective||c(`task.noObjective`)})]}),(0,X.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 sm:grid-cols-4`,children:[(0,X.jsx)(cc,{label:c(`task.priority`),value:Hi(u.priority,c)}),(0,X.jsx)(cc,{label:c(`task.started`),value:sc(u.started_ts)}),(0,X.jsx)(cc,{label:c(`task.finished`),value:sc(u.finished_ts)})]}),f.length?(0,X.jsxs)(`section`,{children:[(0,X.jsx)(`div`,{className:`mb-1 text-[10px] font-semibold uppercase tracking-wider text-ink-faint`,children:c(`task.outcome`)}),(0,X.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:f.map(e=>(0,X.jsx)(_i,{children:e},e))})]}):null,u.iterate||u.iteration_cycles_done||u.iteration_cost_usd?(0,X.jsxs)(`section`,{children:[(0,X.jsx)(`div`,{className:`mb-1 text-[10px] font-semibold uppercase tracking-wider text-ink-faint`,children:c(`task.iteration`)}),(0,X.jsxs)(`div`,{className:`grid grid-cols-3 gap-2`,children:[(0,X.jsx)(cc,{label:c(`task.mode`),value:u.iterate?c(`task.autoIterate`):c(`task.singlePass`)}),(0,X.jsx)(cc,{label:c(`task.cycles`),value:`${u.iteration_cycles_done??0}/${u.iteration_max_cycles??`—`}`}),(0,X.jsx)(cc,{label:c(`task.cost`),value:`$${(u.iteration_cost_usd??0).toFixed(2)}`})]})]}):null,u.last_error?(0,X.jsxs)(`section`,{className:`rounded-lg border border-err/30 bg-err/5 p-3`,children:[(0,X.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-wider text-err`,children:c(`task.lastError`)}),(0,X.jsx)(`p`,{className:`mt-1 whitespace-pre-wrap font-mono text-xs leading-relaxed text-ink-dim`,children:u.last_error})]}):null,u.notes?(0,X.jsxs)(`section`,{children:[(0,X.jsx)(`div`,{className:`mb-1 text-[10px] font-semibold uppercase tracking-wider text-ink-faint`,children:c(`task.notes`)}),(0,X.jsx)(`p`,{className:`whitespace-pre-wrap text-xs leading-relaxed text-ink-dim`,children:u.notes})]}):null,u.tags?.length||u.deps?.length?(0,X.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[(u.tags??[]).map(e=>(0,X.jsxs)(_i,{children:[`#`,e]},`tag-${e}`)),u.deps?.length?(0,X.jsx)(_i,{children:c(`task.dependsOnCount`,{count:u.deps.length})}):null]}):null]}):null]})]})}function uc({onPointerDown:e,onReset:t,onNudge:n,value:r,min:i=240,max:a=600,label:o=`Resize panel`}){return(0,X.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":o,"aria-valuenow":r,"aria-valuemin":i,"aria-valuemax":a,tabIndex:0,onPointerDown:e,onDoubleClick:t,onKeyDown:e=>{e.key===`ArrowLeft`?(e.preventDefault(),n(-16)):e.key===`ArrowRight`?(e.preventDefault(),n(16)):e.key===`Home`&&(e.preventDefault(),t())},className:`group relative hidden w-2 shrink-0 cursor-col-resize items-center justify-center outline-none lg:flex`,children:(0,X.jsx)(`span`,{className:`h-full w-px bg-line/30 transition-colors duration-150 group-hover:bg-blue/70 group-focus:bg-blue/70`})})}var dc=[`manager`,`planner`,`engineer`,`reviewer`],Q=new Set([`grounding`,`task`,`decision`,`agent_message`,`assistant_message`,`command_execution`,`tool_use`,`handoff`,`review`,`verdict`,`completion`,`plan`,`file_change`,`result`]),fc=/^(using a tool|running project command|inspecting project state|working|reporting progress|暂无详细记录)$/i;function pc(e){let t=Et(e).replace(/^\s*(?:RESULT|SUMMARY)\s*=\s*/gim,``).trim();return fc.test(t)||t.startsWith(`{`)?``:t}function mc(e,t,n=``){if(n){if(/^(?:rg|grep|glob|search)$/.test(n))return t?`检索项目文件`:`Searching project files`;if(/^(?:view|read|read_file)$/.test(n))return t?`读取文件`:`Reading a file`;if(/apply_patch|edit|write/.test(n))return t?`编辑文件`:`Editing a file`;if(/bash|shell|exec|terminal/.test(n))return t?`运行终端命令`:`Running a command`;if(/playwright|browser/.test(n))return t?`检查浏览器交互`:`Checking browser interactions`}return({grounding:[`理解任务与检查项目`,`Understanding the task`],task:[`安排任务`,`Task assignment`],decision:[`确定执行方案`,`Execution decision`],plan:[`制定执行计划`,`Planning the work`],agent_message:[`更新执行进度`,`Progress update`],assistant_message:[`更新执行进度`,`Progress update`],command_execution:[`运行项目命令`,`Running a project command`],tool_use:[`使用工具`,`Using a tool`],file_change:[`更新项目文件`,`Updating project files`],handoff:[`提交结果与交接`,`Results and handoff`],review:[`复核实现与结果`,`Reviewing implementation and results`],verdict:[`给出审查结论`,`Review verdict`],completion:[`完成任务`,`Task completed`],result:[`产出结果`,`Result`]}[e]??[e,e])[+!t]}function hc(e,t,n){let r=new Map;for(let i of e?.role_work??[]){if(i.role!==t||!Q.has(i.kind))continue;let e=i.item_id||i.mission_id;n&&e!==n||r.set(i.id,{...i,detail:pc(i.detail)})}return[...r.values()].sort((e,t)=>t.ts-e.ts)}function gc(e,t,n){return[...e].reverse().find(e=>e.type===`engineer.progress`&&[`tool_use`,`command_execution`,`file_change`].includes(String(e.kind))&&String(e.agent_layer||e.actor||e.role)===t&&(!n||String(e.item_id||e.mission_id)===n))}function _c(e,t,n,r,i){return r||[`done`,`completed`,`failed`,`aborted`,`stopped`].includes(e?.mission.status??``)||i&&e?.mission.id!==i?!1:t.length?t.some(e=>e.role===n&&e.active):e?.active_role===n&&[`working`,`grounding`,`framed`,`running`].includes(e?.mission.status??``)}var vc={manager:[`统筹`,`Manager`],planner:[`规划`,`Planner`],engineer:[`执行`,`Engineer`],reviewer:[`审查`,`Reviewer`]};function yc({view:e,roles:t=[],events:n=[],taskId:r,paused:i=!1,selectedRole:a,onSelectRole:o,onClose:s,showTabs:c=!0}){let{locale:l}=Z(),u=l===`zh-CN`,[d,f]=(0,I.useState)(null),[p,m]=(0,I.useState)(Date.now),h=a||d||t.find(e=>e.active)?.role||e?.active_role||`manager`,g=_c(e,t,h,i,r),_=hc(e,h,r),v=_[0],y=_.find(e=>e.detail&&[`agent_message`,`assistant_message`,`decision`,`verdict`,`handoff`,`review`,`completion`].includes(e.kind)),b=gc(n,h,r),x=b&&Number(b.ts||0)>=(v?.ts??0),S=!x&&v&&[`agent_message`,`assistant_message`].includes(v.kind)&&v.detail?v.detail.split(/[。\n]/)[0].slice(0,70):mc(x?String(b.kind):v?.kind||`task`,u,x?String(b.tool_name||``):``),C=t.find(e=>e.role===h)?.model||e?.roles.find(e=>e.role===h)?.model,w=v?Math.max(0,Math.floor(p/1e3-v.ts)):0;(0,I.useEffect)(()=>{if(!g)return;let e=setInterval(()=>m(Date.now()),1e3);return()=>clearInterval(e)},[g]);let T=e=>vc[e]?.[+!u]||e;return(0,X.jsxs)(`section`,{className:`agent-activity`,"aria-label":u?`Agent 工作详情`:`Agent work details`,children:[(0,X.jsxs)(`header`,{className:`agent-activity-heading`,children:[(0,X.jsxs)(`span`,{children:[(0,X.jsx)(La,{size:15}),u?`Agent 动态`:`Agent activity`]}),s&&(0,X.jsx)(`button`,{type:`button`,onClick:s,"aria-label":u?`关闭 Agent 详情`:`Close Agent details`,children:(0,X.jsx)(oo,{size:17})})]}),c&&(0,X.jsx)(`div`,{className:`agent-activity-tabs`,role:`group`,"aria-label":u?`筛选 Agent`:`Filter agents`,children:dc.map(n=>(0,X.jsxs)(`button`,{type:`button`,"data-role":n,"aria-pressed":h===n,onClick:()=>{f(n),o?.(n)},children:[(0,X.jsx)(`i`,{"data-active":_c(e,t,n,i,r)}),T(n)]},n))}),(0,X.jsxs)(`div`,{className:`agent-current`,"data-active":g,children:[(0,X.jsxs)(`div`,{className:`agent-current-kicker`,children:[(0,X.jsx)(`span`,{children:g?T(h)+(u?` Agent 正在工作`:` is working`):i?u?`会话已暂停`:`Session paused`:u?`最近进度`:`Latest progress`}),g?(0,X.jsxs)(`span`,{className:`agent-live-indicator`,children:[(0,X.jsx)(`i`,{}),`LIVE`]}):(0,X.jsx)(to,{size:12})]}),(0,X.jsx)(`h3`,{children:v||x?S:u?`等待任务分配`:`Waiting for an assignment`}),y?.detail&&(0,X.jsx)(`div`,{className:`agent-current-summary`,children:(0,X.jsx)(ki,{children:y.detail})}),!y&&v?.detail&&(0,X.jsx)(`p`,{className:`agent-current-summary`,children:v.detail}),v&&(0,X.jsxs)(`div`,{className:`agent-current-meta`,children:[(0,X.jsx)(Ga,{size:12}),(0,X.jsx)(`span`,{children:u?`${w<60?w+` 秒`:Math.floor(w/60)+` 分钟`}前更新`:`Updated ${w<60?w+`s`:Math.floor(w/60)+`m`} ago`}),C&&(0,X.jsx)(`span`,{children:C})]})]}),(0,X.jsxs)(`div`,{className:`agent-records-heading`,children:[(0,X.jsx)(`span`,{children:u?`工作记录`:`Work log`}),(0,X.jsxs)(`span`,{children:[_.length,` `,u?`条`:`records`]})]}),(0,X.jsxs)(`div`,{className:`agent-records`,role:`log`,"aria-live":`off`,children:[_.slice(0,24).map((e,t)=>{let n=g&&t===0,r=[`done`,`completed`].includes(e.status),i=[`failed`,`error`,`rejected`].includes(e.status),a=r?Va:[`tool_use`,`command_execution`].includes(e.kind)?ao:Ya;return(0,X.jsxs)(`article`,{className:`agent-record`,"data-active":n,"data-failed":i,children:[(0,X.jsx)(`span`,{className:`agent-record-icon`,children:(0,X.jsx)(a,{size:13})}),(0,X.jsxs)(`div`,{children:[(0,X.jsxs)(`div`,{className:`agent-record-title`,children:[(0,X.jsx)(`strong`,{children:mc(e.kind,u)}),(0,X.jsx)(`time`,{children:new Date(e.ts*1e3).toLocaleTimeString(u?`zh-CN`:`en-US`,{hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hour12:!1})})]}),(0,X.jsxs)(`small`,{children:[n?u?`进行中`:`In progress`:i?u?`需要处理`:`Needs attention`:r?u?`已完成`:`Completed`:u?`已记录`:`Recorded`,e.round_index==null?``:u?` · 第 ${e.round_index} 轮`:` · Round ${e.round_index}`]}),e.detail&&(0,X.jsxs)(`details`,{open:t===0||e===y,children:[(0,X.jsxs)(`summary`,{children:[(0,X.jsx)(`span`,{children:u?`查看详情`:`Read details`}),(0,X.jsx)(Ha,{size:12})]}),(0,X.jsx)(`div`,{className:`agent-record-detail`,children:(0,X.jsx)(ki,{children:e.detail})})]})]})]},e.id)}),!_.length&&(0,X.jsx)(`p`,{className:`agent-records-empty`,children:u?`${T(h)}尚未留下这个任务的工作记录。`:`No work has been recorded for this task by ${T(h)}.`})]})]})}var bc=[`manager`,`planner`,`engineer`,`reviewer`],xc=[`active`,`running`,`in_progress`,`claimed`],Sc=[`complete`,`completed`,`done`,`success`,`incomplete`,`stalled`,`blocked`,`ended`],Cc=864e5,wc=300;function Tc(e,t){return bc.includes(e)?t(`role.${e}`):Vi(e,t)}function Ec(e){let t=e.type.toLowerCase().split(/[._-]/).at(-1);return[`failed`,`failure`,`error`].includes(t??``)||e.tone===`error`&&/\bfailed\b/i.test(e.title)}function Dc(e,t,n=new Date){let r=new Date(e*1e3),i=r.toLocaleTimeString(t,{hour:`2-digit`,minute:`2-digit`,hourCycle:`h23`}),a=Date.UTC(n.getFullYear(),n.getMonth(),n.getDate()),o=Date.UTC(r.getFullYear(),r.getMonth(),r.getDate());if(o===a)return i;let s=+(t===`zh-CN`);return o>=a-(n.getDay()-s+7)%7*Cc&&ot;(0,I.useEffect)(()=>{if(t!=null||a)return;let e=i.current;if(!e)return;let n=()=>c(e.scrollHeight>e.clientHeight);n();let r=new ResizeObserver(n);return r.observe(e),()=>r.disconnect()},[e,a,t]);let u=!a&&t!=null&&l?`${e.slice(0,t)}…`:e;return(0,X.jsxs)(`div`,{className:`mt-2`,children:[(0,X.jsx)(`p`,{ref:i,className:`${t==null&&!a?`line-clamp-3`:``} whitespace-pre-wrap break-words ${n}`,children:u}),l?(0,X.jsx)(`button`,{type:`button`,onClick:()=>o(e=>!e),"aria-expanded":a,className:`mt-1 text-[11px] text-blue-sky hover:text-ink`,children:r(a?`mission.showLess`:`mission.showMore`)}):null]})}function kc(e){let t=[...e.dag],n=[],r=new Set;for(;t.length;){let i=t.findIndex(t=>t.deps.every(t=>r.has(t)||!e.dag.some(e=>e.id===t))),[a]=t.splice(i>=0?i:0,1);n.push(a),r.add(a.id)}return n}function Ac(e,t=16){let n=kc(e);if(n.length<=t)return{nodes:n,hidden:[]};let r=new Set(n.slice(-t).map(e=>e.id)),i=n.find(e=>[`running`,`in_progress`,`claimed`].includes(e.status)),a=new Map(n.map(e=>[e.id,e])),o=i?[i]:[];for(;o.length;){let e=o.pop();r.has(e.id)||(r.add(e.id),e.deps.forEach(e=>{let t=a.get(e);t&&o.push(t)}))}return{nodes:n.filter(e=>r.has(e.id)),hidden:n.filter(e=>!r.has(e.id))}}function jc({view:e}){let{t}=Z(),n=e.achievement;return n?(0,X.jsxs)(`section`,{className:`border-b border-ok/35 bg-ok/5 px-5 py-4 animate-appear`,children:[(0,X.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-[0.16em] text-ok`,children:t(`mission.achievement`)}),(0,X.jsx)(`div`,{className:`mt-2 text-sm font-semibold text-ink`,children:n.title}),n.summary?(0,X.jsx)(`div`,{className:`mt-1 text-xs text-ink-dim`,children:n.summary}):null,(0,X.jsxs)(`div`,{className:`mt-2 text-xs`,children:[(0,X.jsxs)(`span`,{className:`text-ink-faint`,children:[t(`mission.elapsed`),` `]}),(0,X.jsx)(`span`,{className:`font-mono text-ink`,children:wn(n.elapsed_seconds??0)})]}),(0,X.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-x-5 gap-y-1 text-[11px] text-ink-dim`,children:[(0,X.jsx)(`span`,{children:t(`mission.rejectedAttempts`,{count:n.rejected_attempts??0})}),(0,X.jsx)(`span`,{children:t(`mission.skillsLearned`,{count:n.skills_learned??0})}),(0,X.jsx)(`span`,{children:t(`mission.artifacts`,{count:n.artifacts??0})})]})]}):null}function Mc({view:e,sid:t=``,snapshot:n,artifacts:r=[],onOpenArtifact:i,onOpenDelivery:a,gitDiff:o,onNotify:s}){let{locale:c,t:l}=Z(),u=new Map(e.roles.map(e=>[e.role,e])),d=e.dag.find(e=>[`running`,`in_progress`,`claimed`].includes(e.status)),f=Ac(e),p=f.nodes,m=Cn(e.mission.objective||e.mission.title||l(`mission.waiting`)),h=e.mission.final_output?.trim()||``,g=!!(h&&h!==e.mission.summary.trim()),[_,v]=(0,I.useState)(Math.max(0,e.timeline.length-1)),[y,b]=(0,I.useState)(e.active_role||`planner`),[x,S]=(0,I.useState)(d?.id||``),[C,w]=(0,I.useState)(!1),T=e.delivery,E=new Map(r.map(e=>[e.path,e])),D=e.learned_skills.filter(e=>e.status===`active`),ee=e.learned_wiki_pages.filter(e=>e.status!==`retired`),O=!!(e.storage.project_skill_dir||e.storage.global_skill_dir||e.storage.wiki_paths.length||e.storage.skill_history_compressed||e.storage.wiki_retired_compressed),te=!!(D.length||ee.length||O),ne=e.mission.status.toLowerCase(),k=[`working`,`grounding`,`framed`].includes(ne),re=[`degraded`,`red`,`critical`].includes(e.health?.toLowerCase()??``),A=[`failed`,`error`].includes(e.mission.status.toLowerCase()),j=e.dag.some(t=>t.status.toLowerCase()===`failed`&&(t.id===e.mission.id||!k&&!d)),ie=[`hold`,`paused`].includes(e.stage.id.toLowerCase()),ae=e.outcome.execution_status?.toLowerCase()===`failed`&&e.stage.id.toLowerCase()===`delivery`,M=re||ae||A||j||ie,oe=re?`mission.attentionHealth`:ae?`mission.deliveryFailed`:A?`mission.attentionFailed`:j?`mission.attentionStepFailed`:`mission.attentionPaused`,se=e.role_work.filter(e=>xc.includes(e.status.toLowerCase())).sort((e,t)=>t.ts-e.ts),N=se.find(t=>t.role===e.active_role)??se[0],ce=Sc.includes(ne),le=Ui(e.outcome,l)[0]??Bi(e.mission.status,l),ue=M?l(oe):ce?l(`mission.statusDone`,{outcome:le,elapsed:wn(e.mission.elapsed_seconds)}):k&&N?l(`mission.statusActive`,{role:Vi(e.active_role||N.role,l),work:N.title}):l(`mission.statusWaiting`),de=re||ae||A||j?`error`:ie?`waiting`:ce?`done`:k&&N?`active`:`waiting`;(0,I.useEffect)(()=>v(Math.max(0,e.timeline.length-1)),[e.timeline.length]),(0,I.useEffect)(()=>{d?.id&&S(d.id)},[d?.id]);let fe=async()=>{if(!C){w(!0);try{await U.setContinuous(t,!0,n?.continuous?.objective??``),s?.(`success`,l(`sidebar.resumeSuccess`))}catch(e){s?.(`error`,l(`sidebar.resumeFailed`,{error:mi(e)}))}finally{w(!1)}}},P=e.timeline.slice(0,_+1).slice(-12).reverse(),F=e.dag.find(e=>e.id===x);return(0,X.jsxs)(`section`,{className:`min-h-0 flex-1 overflow-x-hidden overflow-y-auto bg-panel scroll-thin`,"aria-label":l(`mission.control`),children:[(0,X.jsxs)(`header`,{className:`border-b border-line/60 px-5 py-5`,children:[(0,X.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-[0.16em] text-ink-faint`,children:l(`mobile.mission`)}),(0,X.jsx)(`div`,{role:`heading`,"aria-level":1,className:`mt-1 line-clamp-4 max-w-4xl text-lg font-semibold leading-snug text-ink`,title:m,children:(0,X.jsx)(ki,{artifacts:r,onOpenArtifact:i,children:m})}),m.length>600?(0,X.jsxs)(`details`,{className:`mt-2 text-xs text-ink-faint`,children:[(0,X.jsx)(`summary`,{className:`cursor-pointer hover:text-ink`,children:l(`mission.showObjective`)}),(0,X.jsx)(`div`,{className:`mt-2 text-ink-dim`,children:(0,X.jsx)(ki,{artifacts:r,onOpenArtifact:i,children:m})})]}):null,(0,X.jsxs)(`div`,{className:`mission-status-line`,"data-tone":de,role:M?`alert`:`status`,children:[(0,X.jsxs)(`div`,{className:`mission-status-line__signal`,children:[(0,X.jsx)(`span`,{className:`mission-status-line__marker`,"aria-hidden":`true`}),(0,X.jsx)(`span`,{children:ue})]}),e.frontier.change?(0,X.jsx)(`div`,{className:`mission-status-line__subtitle`,children:e.frontier.change}):null]}),e.mission.summary||g?(0,X.jsxs)(`div`,{className:`mt-3 rounded border border-ok/25 bg-ok/5 px-3 py-2`,children:[(0,X.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-[0.12em] text-ok`,children:l(`mission.summary`)}),(0,X.jsx)(`div`,{className:`mt-1 whitespace-pre-wrap text-xs leading-relaxed text-ink-dim`,children:(0,X.jsx)(ki,{artifacts:r,onOpenArtifact:i,children:e.mission.summary})}),g?(0,X.jsxs)(`details`,{className:`mt-2 border-t border-ok/20 pt-2 text-xs text-ink-dim`,children:[(0,X.jsx)(`summary`,{className:`cursor-pointer font-medium text-ok hover:text-ink`,children:l(`mission.showFullOutput`)}),(0,X.jsx)(`div`,{className:`mt-3 break-words text-sm leading-relaxed text-ink`,children:(0,X.jsx)(ki,{artifacts:r,onOpenArtifact:i,children:h})})]}):null]}):null,T?(0,X.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-3 rounded border border-ok/30 bg-ok/5 px-3 py-2`,children:[(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-[0.12em] text-ok`,children:l(T.kind===`submission_certified`?`mission.deliveryCertified`:`mission.taskCompleted`)}),(0,X.jsx)(`div`,{className:`mt-1 truncate text-xs text-ink-dim`,title:T.summary||T.title,children:T.summary||T.title})]}),a?(0,X.jsx)(`button`,{type:`button`,onClick:()=>a(T),title:T.primary_target?E.get(T.primary_target.path)?.storage_path||T.primary_target.path:T.title,className:`shrink-0 rounded border border-ok/40 px-2 py-1 font-mono text-[10px] text-ok hover:border-ok`,children:l(T.primary_target?`mission.openResult`:`mission.viewTask`)}):null]}):null]}),n?.continuous?.done_at&&(0,X.jsxs)(`div`,{className:`mb-3 flex items-center gap-3 rounded-lg border-l-2 border-blue bg-blue/5 px-3 py-2`,children:[(0,X.jsx)(`span`,{className:`text-base`,children:`↩`}),(0,X.jsxs)(`span`,{className:`min-w-0 flex-1 truncate text-sm text-ink-dim`,children:[l(`mission.continuousDone`),n.continuous.objective?` · ${n.continuous.objective}`:``]}),(0,X.jsx)(`button`,{type:`button`,disabled:C,onClick:()=>void fe(),className:`compact-control shrink-0 px-3`,children:C?`…`:l(`mission.resumeContinuous`)})]}),(0,X.jsx)(jc,{view:e}),(0,X.jsxs)(`section`,{className:`border-b border-line/60 px-5 py-4`,"aria-label":l(`mission.team`),children:[(0,X.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-[0.16em] text-ink-faint`,children:l(`mission.team`)}),(0,X.jsx)(`div`,{className:`mt-3 grid gap-2 sm:grid-cols-2 xl:grid-cols-4`,children:bc.map(e=>{let t=u.get(e),n=t?.status===`active`,r=t?.status===`rejected`||t?.status===`error`,i=W.role[e]??W.inkFaint;return(0,X.jsxs)(`button`,{type:`button`,onClick:()=>b(e),"aria-pressed":y===e,className:`min-w-0 rounded-r-md border-l-2 py-2 pl-3 text-left transition-colors hover:bg-bg/60 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue`,style:{borderColor:y===e||n||t?.status===`done`?i:`rgb(var(--line))`,backgroundColor:y===e?`color-mix(in srgb, ${i} 8%, transparent)`:void 0},children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(`span`,{"data-role-dot":e,"aria-hidden":`true`,className:`h-2 w-2 shrink-0 rounded-full ${n?`animate-pulse motion-reduce:animate-none`:``}`,style:{background:i}}),(0,X.jsx)(`span`,{className:`text-xs font-semibold`,style:{color:i},children:Vi(e,l)})]}),(0,X.jsx)(`div`,{className:`mt-1 truncate text-xs ${r?`text-err`:`text-ink-dim`}`,children:t?.label||l(`mission.waitingShort`)})]},e)})})]}),(0,X.jsxs)(`section`,{className:`border-b border-line/60 px-5 py-4`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,X.jsxs)(`div`,{className:`text-[10px] font-semibold uppercase tracking-[0.16em] text-ink-faint`,children:[l(`mission.roleWork`),` · `,(0,X.jsx)(`span`,{style:{color:W.role[y]??W.inkDim},children:Vi(y,l)})]}),F?(0,X.jsx)(`button`,{type:`button`,onClick:()=>S(``),className:`text-[10px] text-ink-faint hover:text-ink`,children:l(`mission.filteredBy`,{task:F.title||F.objective||l(`task.untitled`)})}):(0,X.jsx)(`span`,{className:`text-[10px] text-ink-faint`,children:l(`mission.allVisible`)})]}),(0,X.jsx)(`div`,{className:`mt-3`,children:(0,X.jsx)(yc,{view:e,roles:n?.roles,events:n?.recent_events,taskId:x||void 0,selectedRole:y,showTabs:!1,paused:n?!n.daemon.alive:!1})})]}),(0,X.jsxs)(`div`,{className:`grid min-h-[320px] border-b border-line/60 lg:grid-cols-[minmax(0,1.15fr)_minmax(260px,0.85fr)]`,children:[(0,X.jsxs)(`section`,{className:`min-w-0 border-b border-line/60 px-5 py-4 lg:border-b-0 lg:border-r`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,X.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-[0.16em] text-ink-faint`,children:l(`mission.researchDag`)}),d?(0,X.jsxs)(`span`,{className:`max-w-48 truncate text-[10px] text-blue-sky`,children:[l(`mission.active`),` · `,d.title]}):null]}),(0,X.jsxs)(`div`,{className:`mt-3 space-y-0`,children:[f.hidden.length?(0,X.jsx)(`div`,{className:`mb-3 rounded border border-line/60 bg-bg/50 px-3 py-2 text-[10px] text-ink-faint`,children:l(`mission.hiddenTasks`,{count:f.hidden.length,failed:f.hidden.filter(e=>[`failed`,`blocked`].includes(e.status)).length,skipped:f.hidden.filter(e=>e.status===`skipped`).length})}):null,p.length?p.map((e,t)=>{let n=e.id===d?.id,r=[`done`,`completed`].includes(e.status),i=[`failed`,`blocked`].includes(e.status);return(0,X.jsxs)(`button`,{type:`button`,onClick:()=>S(e.id),className:`relative flex w-full min-w-0 gap-3 pb-3 text-left last:pb-0 ${x===e.id?`bg-white/[0.03]`:``}`,children:[t(0,X.jsx)(`li`,{children:e},e))})]}):null]}):null]}),(0,X.jsxs)(`section`,{className:`min-w-0 px-5 py-4`,children:[(0,X.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-[0.16em] text-ink-faint`,children:l(`mission.capabilities`)}),D.length?(0,X.jsxs)(`div`,{className:`mt-3`,children:[(0,X.jsx)(`div`,{className:`text-[10px] uppercase tracking-[0.12em] text-ok`,children:l(`mission.capabilitiesUnlocked`)}),(0,X.jsx)(`div`,{className:`mt-2 space-y-2`,children:D.slice(-8).map(e=>(0,X.jsxs)(`details`,{className:`rounded border border-ok/35 bg-ok/5 px-2 py-1.5`,children:[(0,X.jsx)(`summary`,{className:`cursor-pointer text-[10px] text-ok`,children:String(e.name||l(`mission.learnedCapability`))}),e.mission_title?(0,X.jsx)(`div`,{className:`mt-2 text-[9px] text-ink-faint`,children:l(`mission.learnedDuring`,{mission:e.mission_title})}):null,e.content?(0,X.jsxs)(`pre`,{className:`mt-2 max-h-64 overflow-auto whitespace-pre-wrap border-t border-ok/20 pt-2 font-mono text-[10px] leading-5 text-ink-dim scroll-thin`,children:[e.content,e.content_truncated?`\n… ${l(`mission.contentTruncated`)}`:``]}):(0,X.jsx)(`div`,{className:`mt-2 text-[10px] text-ink-faint`,children:l(`mission.skillUnavailable`)})]},String(e.id)))})]}):null,ee.length?(0,X.jsxs)(`div`,{className:`mt-4 border-t border-line/50 pt-3`,children:[(0,X.jsx)(`div`,{className:`text-[10px] uppercase tracking-[0.12em] text-blue-sky`,children:l(`mission.knowledgeRetained`)}),(0,X.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:ee.slice(-6).map(e=>(0,X.jsx)(`span`,{className:`rounded border border-blue/35 bg-blue/5 px-2 py-1 text-[10px] text-blue-sky`,children:String(e.title||e.id)},String(e.id)))})]}):null,O?(0,X.jsxs)(`div`,{className:`mt-4 border-t border-line/50 pt-3`,children:[(0,X.jsx)(`div`,{className:`text-[10px] uppercase tracking-[0.12em] text-ink-faint`,children:l(`mission.selfEvolution`)}),(0,X.jsx)(`div`,{className:`mt-2 text-[10px] text-ink-dim`,children:l(`mission.knowledgeSaved`)})]}):null,te?null:(0,X.jsx)(`div`,{className:`py-10 text-center text-xs text-ink-faint`,children:l(`mission.noCapabilities`)})]})]}),(0,X.jsxs)(`section`,{className:`px-5 py-4`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,X.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-[0.16em] text-ink-faint`,children:l(`mission.replay`)}),e.timeline.length>1?(0,X.jsx)(`input`,{type:`range`,min:0,max:e.timeline.length-1,value:_,onChange:e=>v(Number(e.target.value)),"aria-label":l(`mission.replayTimeline`),className:`h-1 min-w-32 flex-1 accent-blue`}):null,P.length?(0,X.jsx)(`span`,{className:`text-[10px] text-ink-faint`,children:l(P.length===1?`mission.showingLatestEvent`:`mission.showingLastEvents`,{count:P.length})}):null]}),(0,X.jsxs)(`div`,{className:`mt-3 space-y-3`,children:[P.map(e=>{let t=new Date(e.ts*1e3),n=W.role[e.role]??W.inkFaint,r=Ec(e)?l(`mission.roleFailed`,{role:Tc(e.role,l)}):e.title;return(0,X.jsxs)(`article`,{className:`rounded border border-line/60 bg-bg/35 px-3 py-2.5 text-xs`,children:[(0,X.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`mt-1.5 h-2 w-2 shrink-0 rounded-full ${e.tone===`error`?`bg-err`:e.tone===`success`||e.tone===`metric`||e.tone===`skill`?`bg-ok`:`bg-blue`}`}),(0,X.jsx)(`span`,{className:`shrink-0 rounded-full border px-2 py-0.5 text-[10px] font-medium`,style:{borderColor:n,color:n},children:Tc(e.role,l)}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 break-words font-medium leading-5 text-ink`,children:r}),(0,X.jsx)(`time`,{dateTime:t.toISOString(),title:t.toLocaleString(c,{dateStyle:`medium`,timeStyle:`short`}),className:`shrink-0 font-mono text-[10px] text-ink-faint`,children:Dc(e.ts,c)})]}),e.detail?(0,X.jsx)(Oc,{detail:e.detail,previewLength:wc,textClassName:`leading-5 text-ink-dim`}):null]},e.id)}),e.timeline.length?null:(0,X.jsx)(`div`,{className:`py-10 text-center text-xs text-ink-faint`,children:l(`mission.waitingEvents`)})]}),e.artifacts.length?(0,X.jsx)(`div`,{className:`mt-5 flex flex-wrap gap-2 border-t border-line/50 pt-4`,children:e.artifacts.slice(-8).map(e=>{let t=String(e.path||``),n=E.get(t);return(0,X.jsx)(`button`,{type:`button`,disabled:!t||!i||n?.exists===!1,onClick:()=>t&&i?.(t),title:n?.storage_path||t,className:`rounded border border-line px-2 py-1 font-mono text-[10px] text-blue-sky hover:border-blue-sky/50 disabled:text-ink-faint`,children:String(e.title||l(`research.artifact`))},String(e.id||t))})}):null,o?.available&&(o.status||o.diff)?(0,X.jsxs)(`div`,{className:`mt-5 border-t border-line/50 pt-4 text-[10px] text-ink-faint`,children:[(0,X.jsx)(`span`,{className:`font-semibold uppercase tracking-[0.14em]`,children:l(`mission.projectFilesChanged`)}),(0,X.jsxs)(`span`,{children:[` · `,l(`mission.reviewInIde`)]})]}):null]})]})}var Nc={available:`bg-ok/10 text-ok`,absent:`bg-bg text-ink-faint`,inaccessible:`bg-warn/10 text-warn`,degraded:`bg-warn/10 text-warn`};function Pc({status:e,error:t}){let{t:n}=Z();return(0,X.jsxs)(`section`,{className:`rounded-lg border border-line bg-panel p-4 lg:col-span-2`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,X.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wide text-ink-dim`,children:n(`resource.title`)}),e?(0,X.jsx)(`span`,{className:`rounded px-2 py-1 text-[10px] font-semibold uppercase ${e.enforcement===`strict`?`bg-ok/10 text-ok`:`bg-warn/10 text-warn`}`,children:Gi(e.enforcement,n)}):null]}),t?(0,X.jsx)(`p`,{className:`mt-3 text-xs text-err`,children:t}):null,!e&&!t?(0,X.jsx)(`p`,{className:`mt-3 text-xs text-ink-faint`,children:n(`resource.loading`)}):null,e?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`mt-3 grid gap-2 sm:grid-cols-2`,children:e.accelerators.map(e=>(0,X.jsxs)(`div`,{className:`rounded border border-line bg-bg p-3`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,X.jsx)(`span`,{className:`text-xs font-semibold text-ink`,children:Wi(e.kind,n)}),(0,X.jsxs)(`span`,{className:`rounded px-2 py-0.5 text-[10px] font-medium ${Nc[e.status]}`,children:[Bi(e.status,n),` · `,n(`resource.devices`,{count:e.device_count})]})]}),e.detail?(0,X.jsx)(`p`,{className:`mt-2 text-xs text-ink-faint`,children:e.detail}):null]},e.kind))}),(0,X.jsxs)(`div`,{className:`mt-4 grid gap-4 md:grid-cols-2`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`h4`,{className:`text-[10px] font-semibold uppercase tracking-wide text-ink-faint`,children:n(`resource.inUse`,{count:e.holders.length})}),(0,X.jsx)(`div`,{className:`mt-2 space-y-2`,children:e.holders.length===0?(0,X.jsx)(`p`,{className:`text-xs text-ink-faint`,children:n(`resource.none`)}):e.holders.map((e,t)=>(0,X.jsxs)(`div`,{className:`rounded border border-line bg-bg p-3 text-xs`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,X.jsx)(`span`,{className:`font-medium text-ink`,children:n(`resource.devices`,{count:e.device_count})}),(0,X.jsx)(`span`,{className:`shrink-0 font-mono text-ink-faint`,children:n(`resource.timeLeft`,{ttl:Tn(e.ttl_seconds)})})]}),(0,X.jsx)(`p`,{className:`mt-1 text-ink-dim`,children:e.intent||n(`resource.noIntent`)}),e.yield_requests.map((e,t)=>(0,X.jsxs)(`div`,{className:`mt-2 border-l-2 border-warn/50 pl-2 text-ink-faint`,children:[(0,X.jsx)(`div`,{children:n(`resource.yieldRequest`,{reason:e.reason})}),e.response?(0,X.jsxs)(`div`,{children:[Ki(e.response.decision,n),` · `,e.response.reason]}):null]},t))]},`${e.project}:${e.task_id}:${t}`))})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`h4`,{className:`text-[10px] font-semibold uppercase tracking-wide text-ink-faint`,children:n(`resource.queue`,{count:e.queue.length})}),(0,X.jsx)(`div`,{className:`mt-2 space-y-2`,children:e.queue.length===0?(0,X.jsx)(`p`,{className:`text-xs text-ink-faint`,children:n(`resource.none`)}):e.queue.map(e=>(0,X.jsxs)(`div`,{className:`rounded border border-line bg-bg p-3 text-xs`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,X.jsx)(`span`,{className:`font-medium text-ink`,children:n(`resource.queuePosition`,{position:e.position})}),(0,X.jsx)(`span`,{className:`shrink-0 font-mono text-ink-faint`,children:n(`resource.timeLeft`,{ttl:Tn(e.ttl_seconds)})})]}),(0,X.jsx)(`p`,{className:`mt-1 text-ink-dim`,children:e.intent||n(`resource.noIntent`)})]},e.position))})]})]})]}):null]})}var Fc=e=>e instanceof Error?e.message:String(e||`Unknown error`);async function Ic(e){let t=await e,n=t&&typeof t==`object`?t:{},r=String(n.command_status??``);if(Number(n.rc??0)!==0||r===`failed`||r===`rejected`)throw Error(String(n.error||`daemon command ${r||`failed`}`));return t}function Lc({open:e,sid:t,snap:n,onClose:i,onChanged:s,onRestored:c}){let{t:l}=Z(),[p,m]=(0,I.useState)(`task`),[g,_]=(0,I.useState)(``),[v,x]=(0,I.useState)(n.session.workdir??n.session.cwd??``),[C,T]=(0,I.useState)(`ls`),[E,D]=(0,I.useState)(``),[ne,k]=(0,I.useState)(``),[re,A]=(0,I.useState)(null),[j,ie]=(0,I.useState)(null),[ae,M]=(0,I.useState)(null),[oe,se]=(0,I.useState)(``),[N,ce]=(0,I.useState)([]),[le,ue]=(0,I.useState)(0),[de,fe]=(0,I.useState)(``),[P,F]=(0,I.useState)(``),[pe,me]=(0,I.useState)(`work`);(0,I.useEffect)(()=>{e&&(x(n.session.workdir??n.session.cwd??``),Promise.all([U.metrics(),U.trash()]).then(([e,t])=>{A(e),ce(t.entries),ue(t.total)},e=>D(Fc(e))))},[e,n.session.cwd,n.session.workdir]),(0,I.useEffect)(()=>{if(!e)return;let t=!1,n=async()=>{try{let e=await U.sourceUpdateStatus();t||ie(e)}catch(e){t||D(Fc(e))}};U.sourceUpdateStatus().then(async e=>{if(!t&&(ie(e),!e.running)){let e=await U.checkSourceUpdate();t||ie(e)}}).catch(e=>{t||D(Fc(e))});let r=window.setInterval(()=>void n(),1500);return()=>{t=!0,window.clearInterval(r)}},[e]),(0,I.useEffect)(()=>{!e||pe!==`system`||(M(null),se(``),U.resources().then(M,e=>se(Fc(e))))},[e,pe]);let he=async(e,t,n)=>{if(!P){F(e),D(``);try{let e=await t();n!==null&&D(n||JSON.stringify(e,null,2)),s()}catch(e){D(Fc(e))}finally{F(``)}}},ge=async()=>{let e=g.trim();if(e){if(p===`plan`){await he(`quick`,async()=>{let n=await U.previewPlan(t,e);return D([...n.steps.map((e,t)=>`${t+1}. ${e.title}${e.detail?` — ${e.detail}`:``}`),...n.notes.map(e=>`Note: ${e}`),...n.error?[`Error: ${n.error}`]:[]].join(` +`)),n},null);return}await he(`quick`,p===`task`?()=>U.addTask(t,e):p===`nudge`?()=>U.nudge(t,e):()=>U.note(t,e),`${p} submitted.`),_(``)}},_e=async e=>{await he(`restore:${e.trash_id}`,async()=>{let t=await U.restoreTrash(e.trash_id);return ce(t=>t.filter(t=>t.trash_id!==e.trash_id)),ue(e=>Math.max(0,e-1)),await c(t.sid),t},`Restored ${e.label}.`)},ve=n.daemon.alive&&n.daemon.protocol_compatible===!1,ye=n.daemon.alive&&n.daemon.control_available===!1,be=n.daemon_admission?.running_daemons??[],xe=p===`task`?h:p===`nudge`?te:p===`note`?d:y,Se=l(`operations.action.${p}`),Ce=async()=>{await he(`trash-search`,async()=>{let e=await U.trash(de);return ce(e.entries),ue(e.total),e},null)};return(0,X.jsxs)(go,{open:e,onClose:()=>!P&&i(),label:l(`operations.title`),width:`max-w-5xl`,children:[(0,X.jsx)(_o,{title:l(`operations.title`),sub:n.session.display_name||t}),(0,X.jsx)(`div`,{className:`flex gap-1 overflow-x-auto border-b border-line bg-panel px-4 py-2 scroll-thin`,children:[[`work`,l(`operations.work`),h],[`runtime`,l(`operations.runtime`),b],[`system`,l(`operations.system`),u],[`recovery`,l(`operations.recovery`),a]].map(([e,t,n])=>(0,X.jsxs)(`button`,{type:`button`,onClick:()=>{me(e),D(``)},"aria-current":pe===e?`page`:void 0,className:`flex h-8 shrink-0 items-center justify-center gap-2 rounded-md px-3 text-xs font-medium ${pe===e?`bg-blue/10 text-blue`:`text-ink-faint hover:bg-bg hover:text-ink`}`,children:[(0,X.jsx)(o,{icon:n}),(0,X.jsx)(`span`,{children:t})]},e))}),(0,X.jsxs)(`div`,{className:`grid max-h-[76vh] gap-3 overflow-y-auto bg-bg p-3 scroll-thin lg:grid-cols-2`,children:[pe===`work`?(0,X.jsxs)(`section`,{className:`rounded-lg border border-line bg-panel p-4 lg:col-span-2`,children:[(0,X.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wide text-ink-dim`,children:l(`operations.workInput`)}),(0,X.jsx)(`p`,{className:`mt-1 text-xs text-ink-faint`,children:l(`operations.workHint`)}),(0,X.jsx)(`div`,{className:`mt-3 grid grid-cols-2 gap-1 sm:grid-cols-4`,children:[[`task`,h],[`nudge`,te],[`note`,d],[`plan`,y]].map(([e,t])=>(0,X.jsxs)(`button`,{type:`button`,onClick:()=>m(e),"aria-pressed":p===e,className:`flex h-9 items-center justify-center gap-2 rounded px-2 text-xs font-medium ${p===e?`bg-blue/10 text-blue`:`bg-bg text-ink-dim hover:text-ink`}`,children:[(0,X.jsx)(o,{icon:t}),(0,X.jsx)(`span`,{children:l(`operations.action.${e}`)})]},e))}),(0,X.jsx)(`textarea`,{value:g,onChange:e=>_(e.target.value),rows:5,placeholder:p===`plan`?l(`operations.planPlaceholder`):l(`operations.actionPlaceholder`,{action:p}),className:`mt-3 w-full resize-y rounded border border-line bg-bg p-3 text-sm text-ink outline-none focus:border-blue`}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>void ge(),disabled:!!P||!g.trim(),className:`mt-2 flex h-9 items-center justify-center gap-2 rounded border border-blue/35 bg-blue/8 px-3 text-xs font-medium text-blue hover:border-blue-deep hover:bg-blue-deep hover:text-white disabled:opacity-40`,children:P===`quick`?`…`:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(o,{icon:xe}),(0,X.jsx)(`span`,{children:p===`plan`?l(`operations.previewPlan`):l(`operations.submitAction`,{action:Se})})]})})]}):null,pe===`runtime`?(0,X.jsxs)(`section`,{className:`rounded-lg border border-line bg-panel p-4 lg:col-span-2`,children:[(0,X.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wide text-ink-dim`,children:l(`operations.runtime`)}),(0,X.jsx)(`p`,{className:`mt-1 text-xs text-ink-faint`,children:l(`operations.runtimeHint`)}),(0,X.jsx)(`label`,{className:`mt-3 block text-[10px] uppercase tracking-wide text-ink-faint`,children:l(`operations.workdir`)}),(0,X.jsxs)(`div`,{className:`mt-1 flex gap-2`,children:[(0,X.jsx)(`input`,{value:v,onChange:e=>x(e.target.value),className:`h-9 min-w-0 flex-1 rounded border border-line bg-bg px-2 font-mono text-xs text-ink outline-none focus:border-blue`}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>void he(`cwd`,()=>U.setWorkdir(t,v),l(`operations.workdirUpdated`)),disabled:!!P||!v.trim(),title:l(`operations.applyWorkdir`),"aria-label":l(`operations.applyWorkdir`),className:`flex h-9 w-9 items-center justify-center rounded border border-blue/50 text-xs text-blue disabled:opacity-40`,children:(0,X.jsx)(o,{icon:S})})]}),(0,X.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-2`,children:[(0,X.jsx)(`button`,{type:`button`,onClick:()=>void he(`reset`,()=>U.resetManager(t),`Manager context reset.`),disabled:!!P,title:l(`operations.resetManager`),"aria-label":l(`operations.resetManager`),className:`flex h-9 w-9 items-center justify-center rounded border border-line text-xs text-ink-dim disabled:opacity-40`,children:(0,X.jsx)(o,{icon:O})}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>void he(`upgrade`,()=>Ic(U.upgradeDaemon(t,n.daemon_commands?.revision)),`Current-release daemon started after safely draining active work.`),disabled:!!P||ye,title:ye?`Externally supervised daemon cannot be restarted from this Web host`:ve?`Upgrade incompatible daemon`:`Restart on current release`,"aria-label":ye?`Externally supervised daemon`:ve?`Upgrade incompatible daemon`:`Restart on current release`,className:`flex h-9 w-9 items-center justify-center rounded border text-xs disabled:opacity-40 ${ve?`border-err/60 bg-err/10 text-err`:`border-line text-ink-dim`}`,children:(0,X.jsx)(o,{icon:w})})]}),(0,X.jsxs)(`div`,{className:`mt-4 rounded-lg border border-line bg-bg p-3`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-start gap-3`,children:[(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(`span`,{className:`text-xs font-semibold text-ink`,children:l(`operations.sourceUpdate`)}),(0,X.jsx)(`span`,{className:`rounded px-1.5 py-0.5 text-[10px] font-semibold ${j?.state===`failed`?`bg-err/10 text-err`:j?.update_available?`bg-warn/10 text-warn`:j?.update_available===!1?`bg-ok/10 text-ok`:`bg-line text-ink-dim`}`,children:j?.running?l(`operations.updateRunning`):j?.update_available?l(`operations.updateAvailable`):j?.update_available===!1?l(`operations.updateCurrent`):l(`operations.updateChecking`)})]}),(0,X.jsx)(`p`,{className:`mt-1 text-xs text-ink-faint`,children:j?.error||j?.message||l(`operations.updateChecking`)}),(0,X.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-x-4 gap-y-1 font-mono text-[10px] text-ink-dim`,children:[(0,X.jsxs)(`span`,{children:[l(`operations.currentRevision`),`: `,j?.current_revision?.slice(0,12)||`—`]}),(0,X.jsxs)(`span`,{children:[l(`operations.latestRevision`),`: `,j?.upstream_revision?.slice(0,12)||`—`]}),j?.phase&&j.phase!==`complete`&&j.phase!==`idle`?(0,X.jsxs)(`span`,{children:[l(`operations.updatePhase`),`: `,j.phase]}):null]}),j?.running?(0,X.jsx)(`div`,{className:`mt-2 h-1 overflow-hidden rounded bg-line`,children:(0,X.jsx)(`div`,{className:`h-full w-1/2 animate-pulse rounded bg-blue`})}):null]}),(0,X.jsxs)(`button`,{type:`button`,onClick:()=>void he(`source-update`,async()=>{let e=await U.applySourceUpdate();return ie(e),e},null),disabled:!!P||!!j?.running||j?.can_update===!1,title:j?.can_update===!1?j.error||l(`operations.updateUnavailable`):l(`operations.pullLatest`),"aria-label":l(`operations.pullLatest`),className:`flex h-9 items-center gap-2 rounded border border-blue/50 px-3 text-xs font-medium text-blue disabled:opacity-40`,children:[(0,X.jsx)(o,{icon:f}),(0,X.jsx)(`span`,{children:j?.running?l(`operations.updateRunning`):l(`operations.pullLatest`)})]})]}),j?.restart_required?(0,X.jsx)(`p`,{className:`mt-2 text-xs text-warn`,children:l(`operations.updateRestart`)}):null]}),n.daemon.protocol_error?(0,X.jsx)(`p`,{className:`mt-2 text-xs text-err`,children:n.daemon.protocol_error}):null,be.length?(0,X.jsxs)(`div`,{className:`mt-4`,children:[(0,X.jsx)(`div`,{className:`text-[10px] uppercase tracking-wide text-ink-faint`,children:l(`operations.replaceSlot`)}),(0,X.jsx)(`div`,{className:`mt-2 space-y-1`,children:be.map(e=>(0,X.jsxs)(`button`,{type:`button`,disabled:!!P,onClick:()=>void he(`replace:${e.id}`,()=>Ic(U.replaceDaemon(t,e.id,!!n.continuous?.enabled,n.daemon_commands?.revision)),`Parked ${e.label||e.id} and started this session.`),title:`Replace ${e.label||e.id}`,"aria-label":`Replace ${e.label||e.id}`,className:`flex w-full items-center justify-between rounded border border-line bg-bg px-2 py-1.5 text-left text-xs text-ink-dim disabled:opacity-40`,children:[(0,X.jsx)(`span`,{className:`truncate`,children:e.label||e.id}),(0,X.jsx)(o,{icon:w,className:`ml-2 text-warn`})]},e.id))})]}):null]}):null,pe===`system`?(0,X.jsxs)(`section`,{className:`rounded-lg border border-line bg-panel p-4`,children:[(0,X.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wide text-ink-dim`,children:l(`operations.skills`)}),(0,X.jsxs)(`div`,{className:`mt-3 flex gap-2`,children:[(0,X.jsx)(`input`,{value:C,onChange:e=>T(e.target.value),className:`h-9 min-w-0 flex-1 rounded border border-line bg-bg px-2 font-mono text-xs text-ink outline-none focus:border-blue`,placeholder:`ls, stats, show NAME…`}),(0,X.jsx)(`button`,{type:`button`,disabled:!!P,onClick:()=>void he(`skills`,async()=>{let e=await U.skills(t,C);return k(e),e},null),title:l(`operations.runSkill`),"aria-label":l(`operations.runSkill`),className:`flex h-9 w-9 items-center justify-center rounded border border-blue/50 text-xs text-blue disabled:opacity-40`,children:(0,X.jsx)(o,{icon:r})})]}),ne?(0,X.jsx)(`pre`,{className:`mt-3 max-h-48 overflow-auto whitespace-pre-wrap rounded bg-bg p-3 font-mono text-xs text-ink-dim scroll-thin`,children:ne}):null]}):null,pe===`system`?(0,X.jsxs)(`section`,{className:`rounded-lg border border-line bg-panel p-4`,children:[(0,X.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wide text-ink-dim`,children:l(`operations.metrics`)}),(0,X.jsxs)(`div`,{className:`mt-3 flex items-center gap-3`,children:[(0,X.jsx)(`span`,{className:`rounded px-2 py-1 text-xs font-semibold ${re?.slo?.status===`healthy`?`bg-ok/10 text-ok`:`bg-warn/10 text-warn`}`,children:re?.slo?.status??`loading`}),(0,X.jsxs)(`span`,{className:`text-xs text-ink-faint`,children:[`event validation failures: `,re?.event_validation_failures??`—`]})]}),re?(0,X.jsx)(`pre`,{className:`mt-3 max-h-48 overflow-auto whitespace-pre-wrap rounded bg-bg p-3 font-mono text-[10px] text-ink-dim scroll-thin`,children:JSON.stringify({web:re.web,provider:re.provider,cost_control:re.cost_control},null,2)}):null]}):null,pe===`system`?(0,X.jsx)(Pc,{status:ae,error:oe}):null,pe===`recovery`?(0,X.jsxs)(`section`,{className:`rounded-lg border border-line bg-panel p-4 lg:col-span-2`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsxs)(`h3`,{className:`mr-auto text-xs font-semibold uppercase tracking-wide text-ink-dim`,children:[l(`operations.trash`),` · `,le]}),(0,X.jsx)(`input`,{value:de,onChange:e=>fe(e.target.value),onKeyDown:e=>{!sa(e)&&e.key===`Enter`&&Ce()},placeholder:l(`operations.searchTrash`),className:`h-8 min-w-52 rounded border border-line bg-bg px-2 text-xs text-ink outline-none focus:border-blue`}),(0,X.jsx)(`button`,{type:`button`,disabled:!!P,onClick:()=>void Ce(),title:l(`operations.searchTrash`),"aria-label":l(`operations.searchTrash`),className:`flex h-8 w-8 items-center justify-center rounded border border-blue/50 text-xs text-blue disabled:opacity-40`,children:(0,X.jsx)(o,{icon:ee})})]}),N.length?(0,X.jsx)(`div`,{className:`mt-3 grid gap-2 sm:grid-cols-2`,children:N.map(e=>(0,X.jsxs)(`div`,{className:`flex items-center gap-3 rounded border border-line bg-bg p-2`,children:[(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`div`,{className:`truncate text-xs text-ink`,children:e.label}),(0,X.jsx)(`div`,{className:`truncate font-mono text-[10px] text-ink-faint`,children:e.trash_path})]}),(0,X.jsx)(`button`,{type:`button`,disabled:!!P,onClick:()=>void _e(e),title:`Restore ${e.label}`,"aria-label":`Restore ${e.label}`,className:`flex h-8 w-8 items-center justify-center rounded border border-blue/50 text-xs text-blue disabled:opacity-40`,children:(0,X.jsx)(o,{icon:a})})]},e.trash_id))}):(0,X.jsx)(`p`,{className:`mt-3 text-xs text-ink-faint`,children:l(`operations.trashEmpty`)}),le>N.length?(0,X.jsxs)(`p`,{className:`mt-2 text-[10px] text-ink-faint`,children:[`Showing the newest `,N.length,` matches. Narrow the search to find older sessions.`]}):null]}):null,E?(0,X.jsx)(`pre`,{className:`rounded-lg border border-line bg-panel p-3 font-mono text-xs whitespace-pre-wrap text-ink-dim lg:col-span-2`,children:E}):null]})]})}var Rc=[`handshake.service`,`handshake.project`,`handshake.ready`];function zc(){let{t:e}=Z(),t=(0,I.useRef)(null);return ci(t,(e,t)=>{if(t){e.set(`[data-handshake-line], [data-handshake-node]`,{opacity:1,scale:1,clearProps:`transform`});return}e.to(`[data-handshake-mark]`,{scale:1.055,duration:.75,ease:`sine.inOut`,repeat:-1,yoyo:!0,transformOrigin:`50% 50%`}),e.timeline({repeat:-1,repeatDelay:.25}).fromTo(`[data-handshake-line]`,{scaleX:0,opacity:.25,transformOrigin:`0% 50%`},{scaleX:1,opacity:.8,duration:.9,ease:`power2.inOut`}).fromTo(`[data-handshake-node]`,{autoAlpha:.25,scale:.72},{autoAlpha:1,scale:1,duration:.28,stagger:.16,ease:`back.out(1.8)`},.12).to(`[data-handshake-node]`,{autoAlpha:.35,duration:.3,stagger:.08},`+=0.35`)}),(0,X.jsxs)(`div`,{ref:t,role:`status`,"aria-label":e(`handshake.connecting`),className:`w-full max-w-xl px-6 text-center`,children:[(0,X.jsx)(`div`,{"data-handshake-mark":!0,className:`handshake-mark glass-card mx-auto flex h-16 w-16 items-center justify-center rounded-3xl text-blue shadow-glow sm:h-20 sm:w-20`,children:(0,X.jsx)(Ai,{size:48,className:`text-ink`})}),(0,X.jsxs)(`div`,{className:`relative mx-auto mt-8 h-10 max-w-sm sm:max-w-md`,children:[(0,X.jsx)(`div`,{className:`absolute left-[10%] right-[10%] top-3 h-px bg-line/80`}),(0,X.jsx)(`div`,{"data-handshake-line":!0,className:`handshake-line absolute left-[10%] right-[10%] top-3 h-px`}),(0,X.jsx)(`div`,{className:`relative flex justify-between`,children:Rc.map(t=>(0,X.jsxs)(`div`,{className:`flex w-20 flex-col items-center gap-2.5`,children:[(0,X.jsx)(`span`,{"data-handshake-node":!0,className:`handshake-node h-6 w-6 rounded-full border ring-4 ring-bg`,children:(0,X.jsx)(`span`,{className:`m-auto mt-[7px] block h-2 w-2 rounded-full bg-blue`})}),(0,X.jsx)(`span`,{className:`text-xs font-medium text-ink-faint`,children:e(t)})]},t))})]}),(0,X.jsx)(`p`,{className:`mt-9 text-base font-medium text-ink-dim`,children:e(`handshake.title`)}),(0,X.jsx)(`p`,{className:`mt-1.5 text-sm text-ink-faint`,children:e(`handshake.detail`)})]})}function Bc({loading:e,hasProjects:t,error:n,onRetry:r,onNew:i,onChoose:a,canCreate:o}){let{t:s}=Z();return(0,X.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-4 text-center`,children:[e?(0,X.jsx)(zc,{}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Mi,{size:32,tag:ca}),(0,X.jsx)(`p`,{className:`max-w-md text-sm leading-relaxed ${n?`text-err`:`text-ink-faint`}`,children:n||s(t?`landing.selectOrCreate`:`landing.noSessions`)})]}),!e&&(0,X.jsxs)(`div`,{className:`flex flex-wrap justify-center gap-2`,children:[n?(0,X.jsx)(vi,{onClick:r,variant:`danger`,children:s(`common.retry`)}):null,t?(0,X.jsx)(vi,{onClick:a,children:s(`landing.select`)}):o?(0,X.jsx)(vi,{onClick:i,variant:`primary`,children:s(`landing.new`)}):null]})]})}function $({active:e,onSelect:t,onOpenSessions:n,sidebarOpen:r=!1}){let{t:a}=Z(),s=[{id:`mission`,label:a(`mobile.mission`),icon:y},{id:`activity`,label:a(`mobile.activity`),icon:l},{id:`workbench`,label:a(`mobile.workbench`),icon:p},{id:`map`,label:a(`mobile.map`),icon:y},{id:`preview`,label:a(`mobile.preview`),icon:i}];return(0,X.jsxs)(`nav`,{"aria-label":a(`mobile.views`),className:`mobile-tabbar glass-panel glass-panel--raised fixed inset-x-0 bottom-0 z-40 items-stretch border-t border-line/60 lg:hidden ${r?`hidden`:`flex`}`,children:[n?(0,X.jsxs)(`button`,{type:`button`,onClick:n,"aria-label":a(`topbar.openSessions`),className:`flex min-h-[3.25rem] flex-1 flex-col items-center justify-center gap-0.5 text-ink-faint active:bg-panel-raised`,children:[(0,X.jsx)(o,{icon:_,className:`h-4 w-4`}),(0,X.jsx)(`span`,{className:`text-[10px] leading-none`,children:a(`mobile.sessions`)})]}):null,s.map(n=>{let r=n.id===e;return(0,X.jsxs)(`button`,{type:`button`,onClick:()=>t(n.id),"aria-current":r?`page`:void 0,className:`flex min-h-[3.25rem] flex-1 flex-col items-center justify-center gap-0.5 active:bg-panel-raised ${r?`text-blue`:`text-ink-faint`}`,children:[(0,X.jsx)(o,{icon:n.icon,className:`h-4 w-4`}),(0,X.jsx)(`span`,{className:`text-[10px] leading-none`,children:n.label})]},n.id)})]})}function Vc(){(0,I.useEffect)(()=>{let e=window.visualViewport,t=document.documentElement;if(!e)return;let n=null,r=()=>{n!=null&&window.cancelAnimationFrame(n),n=window.requestAnimationFrame(()=>{let n=window.innerHeight-e.height-e.offsetTop,r=n>24?Math.round(n):0;t.style.setProperty(`--keyboard-inset`,`${r}px`)})};return r(),e.addEventListener(`resize`,r),e.addEventListener(`scroll`,r),()=>{n!=null&&window.cancelAnimationFrame(n),e.removeEventListener(`resize`,r),e.removeEventListener(`scroll`,r),t.style.removeProperty(`--keyboard-inset`)}},[])}async function Hc(e,t){let n=Ht(e.trim());if(!n)return{kind:`not-command`};if(!n.cmd){let e=Ut(n.name);return{kind:`error`,message:e?`Unknown command ${n.name}. Did you mean ${e}?`:`Unknown command ${n.name}. Use /help for the full list.`}}if(n.cmd.id===`ask`||n.cmd.id===`crystalpilot`)return{kind:`not-command`};if(Ft(n.cmd)&&!n.rest)return{kind:`error`,message:`Usage: ${n.cmd.name}${n.cmd.arg?` ${n.cmd.arg}`:``}`};try{await t[n.cmd.id](n.rest)}catch(e){return{kind:`error`,message:e instanceof Error?e.message:String(e??`Command failed`)}}return{kind:`handled`}}function Uc({activeSid:e,activityEventsRef:t,notify:n,onClearEvents:r,onDispose:i,onOpenConfig:a,onOpenDoctor:o,onOpenHelp:s,onOpenIdentity:c,onOpenInspector:l,onOpenNewDaemon:u,onOpenOperations:d,onOpenSidebar:f,onReconnectEvents:p,onRenameProject:m,onRewriteDraft:h,onSelectProject:g,onSetArtifactPath:_,onSetEventFilter:v,onSetEventQuery:y,onSetTaskItemId:b,onSetWorkspaceView:x,onShowArtifacts:S,onStopIteration:C,onStopWaiting:w,refetchSnapshot:T}){return{status:async()=>l(),roles:async()=>d(),journal:async()=>l(),backlog:async()=>x(`mission`),item:async e=>{e&&b(e)},artifacts:async()=>S(),artifact:async e=>{e&&_(e)},events:async e=>{x(`activity`);let{filter:t,query:n}=Vt(e);v(t),y(n)},find:async e=>{x(`activity`),v(`all`),y(e)},run:async()=>x(`activity`),clear:async()=>{x(`activity`),v(`all`),y(``),r(t.current.length)},cancel:async()=>w(),task:async t=>{e&&(await U.addTask(e,t),T(),n(`success`,`Task queued.`))},rewrite:async e=>{let t=e.trim();if(!t){n(`info`,`Type your prompt in the composer and press Rewrite, or use /rewrite .`);return}h(t)},plan:async t=>{if(!e)return;let r=await U.previewPlan(e,t);r.error?n(`error`,r.error):n(`info`,r.steps.map(e=>e.title).join(` +`)||`Plan preview ready.`)},nudge:async t=>{e&&(await U.nudge(e,t),n(`success`,`Guidance injected.`))},abort:async t=>{e&&(await U.abortMission(e,t||`operator abort`),n(`info`,`Abort requested.`))},note:async t=>{e&&(await U.note(e,t),n(`success`,`Note appended to timeline.`))},done:async e=>{e&&i(e,`done`)},skip:async e=>{e&&i(e,`rm`)},stop:async e=>{e&&C(e)},new:async()=>u(),daemons:async()=>f(),resume:async e=>{e&&e!==`list`?g(e):f()},attach:async e=>{e&&g(e)},rename:async t=>{!e||!t||await m(t)},doctor:async()=>o(),backend:async t=>{if(!e||!t){a();return}await U.setConfig(e,`runner_backend`,t),n(`success`,`Backend set to ${t}.`)},config:async t=>{if(!e||!t){a();return}let r=t.indexOf(`=`);r>0?(await U.setConfig(e,t.slice(0,r).trim(),t.slice(r+1).trim()),n(`success`,`Config updated.`)):a()},identity:async()=>c(),reset:async()=>{e&&(await U.resetManager(e),n(`success`,`Manager context reset.`))},skills:async t=>{e&&n(`info`,(await U.skills(e,t||`ls`)).slice(0,400))},reconnect:async()=>p(),help:async()=>s(),quit:async()=>n(`info`,`Background work continues; close this browser tab when ready.`)}}function Wc(e){return e.kind===`error`?(typeof e.reply==`string`?e.reply.trim():``)||`Manager could not handle this message.`:null}function Gc(e,t){e.kind===`task`&&t.dispatchTask(e);let n=Wc(e);n&&t.notifyError(n),t.refetchTranscript()}var Kc={skipFirst:0,reconnectKey:0};function qc(e,t){return t.kind===`clear`?{...e,skipFirst:Math.max(0,t.offset)}:t.kind===`reconnect`?{skipFirst:0,reconnectKey:e.reconnectKey+1}:{...e,skipFirst:0}}var Jc=`local_request_id`;function Yc(e,t,n,r=Date.now()){return{type:`ui.operator`,agent_layer:`operator`,text:n,ts:r/1e3,event_id:`local-${e}-${t}-operator`,message_id:`local-${t}-operator`,[Jc]:t}}function Xc(e,t,n,r,i,a=Date.now(),o=`auto`){let s=r.trim();if(!s)return e;let c=e.findIndex(e=>e.type===`ui.argus`&&Number(e[Jc])===n),l=i.endsWith(`-argus`)?`${i.slice(0,-6)}-operator`:``,u=l?e.map(e=>e.type===`ui.operator`&&Number(e[Jc])===n?{...e,message_id:l}:e):e,d=u.find(e=>e.type===`ui.operator`&&Number(e[Jc])===n),f=d?Math.max(0,a-Number(d.ts??a/1e3)*1e3):0;if(c<0)return[...u,{type:`ui.argus`,agent_layer:`manager`,text:s,ts:a/1e3,event_id:`local-${t}-${n}-argus`,message_id:i||`local-${n}-argus`,fragment_mode:o,response_latency_ms:f,[Jc]:n}];let p=u[c],m=[...u];return m[c]={...p,text:kt(String(p.text??``),s,o),message_id:i||p.message_id,fragment_mode:o},m}function Zc(e,t,n){let r=new Map;e.forEach(e=>{let t=String(e.type??``);if(t!==`ui.operator`&&t!==`ui.argus`)return;let n=`${t}\u0000${String(e.text??``)}`;r.set(n,(r.get(n)??0)+1)});let i=t.map(e=>({type:e.role===`operator`?`ui.operator`:`ui.argus`,agent_layer:e.role===`operator`?`operator`:`manager`,text:e.text,ts:e.ts,message_id:e.message_id||`transcript-${e.ts}-${e.role}`,...e.mission_result===!0?{mission_result:!0}:{},...typeof e.item_id==`string`?{item_id:e.item_id}:{},...typeof e.success==`boolean`?{success:e.success}:{},...typeof e.summary==`string`?{summary:e.summary}:{},...typeof e.delivery_id==`string`?{delivery_id:e.delivery_id}:{},...e.delivery&&typeof e.delivery==`object`?{delivery:e.delivery}:{}})),a=Array(i.length).fill(!0);for(let e=i.length-1;e>=0;--e){let t=i[e],n=`${String(t.type)}\u0000${String(t.text??``)}`,o=r.get(n)??0;o>0&&(a[e]=!1,r.set(n,o-1))}let o=[...i.filter((e,t)=>a[t]),...e],s=Array(o.length).fill(!0),c=new Set,l=n.map(e=>{let t=String(e.message_id??``),n=t?o.findIndex((e,n)=>!c.has(n)&&String(e.message_id??``)===t):-1,r=Number(e.ts??0);if(n<0&&(n=o.findIndex((t,n)=>{if(c.has(n)||t.type!==e.type||t.text!==e.text)return!1;let i=Number(t.ts??0);return Math.abs(i-r)<=5})),n>=0){c.add(n),s[n]=!1;let t=o[n];return{...e,...t.mission_result===!0?{mission_result:!0}:{},...typeof t.item_id==`string`?{item_id:t.item_id}:{},...typeof t.success==`boolean`?{success:t.success}:{},...typeof t.summary==`string`?{summary:t.summary}:{},...typeof t.delivery_id==`string`?{delivery_id:t.delivery_id}:{},...t.delivery&&typeof t.delivery==`object`?{delivery:t.delivery}:{}}}return e});return[...o.filter((e,t)=>s[t]),...l].sort((e,t)=>Number(e.ts??0)-Number(t.ts??0))}function Qc(e,t){if(!t.length)return e;let n=new Map(t.map(e=>[e.id,e]));return e.map(e=>{let t=n.get(e.id);return t?{...e,spend_usd:t.spend_usd,known_cost_usd:t.known_cost_usd,spend_status:t.spend_status,usage_calls:t.usage_calls,premium_requests:t.premium_requests,cost_updated_at:t.updated_at}:e})}async function $c(e,t,n,r=``){let i=await e.createDaemon(``,t,r),a=n.trim();return{created:i,startCampaign:a?()=>e.setContinuous(i.sid,!0,a):null}}var el=e=>e instanceof Error?e.message:String(e||`Unknown error`);function tl({localCwd:e,notify:t,onFocusComposer:n,queryClient:r,refetchProjects:i,selectProject:a}){let[o,s]=(0,I.useState)(!1),c=(0,I.useRef)(!1);return{createDaemon:async(o,l,u)=>{if(c.current)return!1;c.current=!0,s(!0);try{let{created:s,startCampaign:c}=await $c(U,o,l,u),d=String(s.workdir||u||``);return r.setQueryData([`projects`],t=>({local_cwd:t?.local_cwd??e,projects:[{id:s.sid,label:o||s.sid,display_name:o,objective:``,launch_cwd:d,workdir:d,last_active:Date.now()/1e3,daemon_alive:!1,daemon_pid:null,uptime_seconds:null},...(t?.projects??[]).filter(e=>e.id!==s.sid)]})),a(s.sid),i(),window.setTimeout(n,0),t(c?`info`:`success`,c?`Session created and selected. Campaign is starting in the background.`:`Session created and selected.`),c&&c().then(()=>{r.invalidateQueries({queryKey:[`snapshot`,s.sid]}),i(),t(`success`,`Campaign started.`)}).catch(e=>{t(`error`,`Session was created, but the campaign could not start: ${el(e)}`)}),!0}catch(e){return t(`error`,`Could not create session: ${el(e)}`),!1}finally{c.current=!1,s(!1)}},creatingDaemon:o}}var nl=e=>e instanceof Error?e.message:String(e||`Unknown error`);function rl({actions:e,manageActions:t,manageTargetSid:n,setManageTargetSid:r,activeSid:i,clearProjectSelection:a,continuous:o,notify:s,refetchProjects:c,selectProject:l,setDaemonManageOpen:u}){let d=e.startDaemon.isPending||e.stopDaemon.isPending||e.forceStopDaemon.isPending||t.startDaemon.isPending||t.forceStopDaemon.isPending||t.updateProject.isPending||t.deleteProject.isPending,f=(0,I.useCallback)(e=>({onSuccess:()=>s(`success`,e),onError:e=>s(`error`,nl(e))}),[s]),p=(0,I.useCallback)(()=>e.startDaemon.mutate(void 0,f(`Daemon start requested.`)),[f,e.startDaemon]),m=(0,I.useCallback)(()=>e.forceStopDaemon.mutate(void 0,f(`Stop requested; the verified daemon process is being interrupted.`)),[f,e.forceStopDaemon]),h=(0,I.useCallback)(async()=>{try{return await t.startDaemon.mutateAsync(),s(`success`,`Daemon resumed.`),!0}catch(e){return s(`error`,nl(e)),!1}},[t.startDaemon,s]),g=(0,I.useCallback)(async()=>{try{return await t.forceStopDaemon.mutateAsync(),await c(),s(`success`,`Daemon stopped. This session can now be deleted.`),!0}catch(e){return s(`error`,nl(e)),!1}},[t.forceStopDaemon,s,c]),_=(0,I.useCallback)(async e=>{if(!n)return!1;try{return await t.updateProject.mutateAsync({sid:n,name:e}),s(`success`,`Session name updated.`),!0}catch(e){return s(`error`,nl(e)),!1}},[t.updateProject,n,s]),v=(0,I.useCallback)(async()=>{if(!n)return!1;try{let e=n,o=await t.deleteProject.mutateAsync();u(!1),r(null);let d=await c();if(e===i){a(`replace`);let e=Dn(d.data?.projects??[])[0];e&&l(e.id,`replace`)}return s(`success`,o.workdir_preserved?`Session moved to recoverable trash. Files remain in ${o.workdir}.`:`Session moved to recoverable trash.`),!0}catch(e){return s(`error`,nl(e)),!1}},[i,a,t.deleteProject,n,s,c,l,u,r]),y=(0,I.useCallback)(e=>{r(e),u(!0)},[u,r]);return{daemonBusy:d,manageDeleteProject:v,manageStopDaemon:g,manageRenameProject:_,manageStartDaemon:h,requestDispose:(0,I.useCallback)((t,n)=>e.disposeBacklog.mutate({id:t,op:n},{onSuccess:()=>s(`success`,n===`done`?`Work marked done.`:`Work removed.`),onError:e=>s(`error`,nl(e))}),[e.disposeBacklog,s]),requestManageSession:y,requestStartDaemon:p,requestStopDaemon:m,requestStopIteration:(0,I.useCallback)(t=>e.stopBacklog.mutate(t,{onSuccess:()=>s(`success`,`Iteration stopped.`),onError:e=>s(`error`,nl(e))}),[e.stopBacklog,s]),toggleContinuous:(0,I.useCallback)(()=>{if(!o)return;let t=!o.enabled;e.setContinuous.mutate({enabled:t,objective:o.objective},f(t?`Continuous campaign enabled.`:`Continuous campaign stopped.`))},[f,e.setContinuous,o])}}function il({focusComposer:e,openHelp:t,toggleKiosk:n,togglePalette:r,toggleReasoning:i,toggleSidebarCollapse:a}){(0,I.useEffect)(()=>{let o=o=>{let s=o.target,c=s?.tagName===`INPUT`||s?.tagName===`TEXTAREA`,l=o.metaKey||o.ctrlKey;l&&o.key.toLowerCase()===`k`?(o.preventDefault(),r()):l&&o.key.toLowerCase()===`t`?(o.preventDefault(),i()):l&&o.key===`.`?(o.preventDefault(),n()):l&&o.key.toLowerCase()===`b`?(o.preventDefault(),a()):l&&o.key.toLowerCase()===`j`?(o.preventDefault(),e()):!c&&o.key===`?`?(o.preventDefault(),t()):!c&&o.key===`/`&&(o.preventDefault(),e())};return window.addEventListener(`keydown`,o),()=>window.removeEventListener(`keydown`,o)},[e,t,n,r,i,a])}var al=e=>e instanceof Error?e.message:String(e||`Unknown error`),ol=`argus.decision.prompted.v1`,sl=()=>{try{return window.sessionStorage.getItem(ol)??``}catch{return``}},cl=e=>{try{window.sessionStorage.setItem(ol,e)}catch{}};function ll({activeSid:e,autoOpen:t=!0,backlog:n,notify:r,pendingQuestions:i,refetchSnapshot:a}){let[o,s]=(0,I.useState)(!1),[c,l]=(0,I.useState)(!1),u=(0,I.useRef)(``),d=(0,I.useMemo)(()=>{let e=(n??[]).map(e=>({...e,operator_decision:e.operator_decision}));return _t(i??[],e)[0]??null},[n,i]);return(0,I.useEffect)(()=>{if(!d||!e){s(!1);return}if(!t)return;let n=`${e}:${d.id}`;u.current!==n&&sl()!==n&&(u.current=n,cl(n),s(!0))},[e,t,d]),{answerPendingReply:async(t,n)=>{if(!(!e||!d||c)){l(!0);try{let i=d.legacy?await U.answerPending(e,d.item_id,n):await U.resolveDecision(e,d.id,t,n);if(i.resolved===!1){r(`info`,String(i.reply||`Manager needs a more specific answer.`));return}s(!1),await a(),i.daemon&&Number(i.daemon.rc??0)!==0?r(`error`,`Answer queued, but the daemon did not start: ${i.daemon.error||`operator action required`}`):r(`success`,String(i.reply||`Manager delivered your answer to the team.`))}catch(e){await a(),r(`error`,`Could not send answer: ${al(e)}`)}finally{l(!1)}}},pendingReply:d,pendingReplyBusy:c,pendingReplyOpen:o,setPendingReplyOpen:s}}var ul=`argus.browser.project.v1`;function dl(){try{return window.sessionStorage.getItem(ul)}catch{return null}}function fl(e){try{e?window.sessionStorage.setItem(ul,e):window.sessionStorage.removeItem(ul)}catch{}}function pl(e,t){let n=new URL(window.location.href);e?n.searchParams.set(`project`,e):n.searchParams.delete(`project`);let r=t===`push`?`pushState`:`replaceState`;window.history[r](window.history.state,``,n.toString())}function ml({cancelActiveMessage:e,notify:t,projects:n,projectsError:r,projectsReady:i,queryClient:a,setArtifactPath:o,setSidebarOpen:s,setTaskItemId:c}){let l=new URLSearchParams(window.location.search),[u,d]=(0,I.useState)(l.get(`project`)||dl()),f=(0,I.useRef)(u),p=(0,I.useRef)(!1);f.current=u;let m=(0,I.useCallback)(t=>{t!==f.current&&(e(),o(null),c(null)),f.current=t,d(t),fl(t)},[e,o,c]),h=(0,I.useCallback)((e,t=`push`)=>{let n=new URLSearchParams(window.location.search).get(`project`);m(e),n!==e&&pl(e,t)},[m]),g=(0,I.useCallback)((e=`replace`)=>{let t=new URLSearchParams(window.location.search).get(`project`);m(null),t!=null&&pl(null,e)},[m]),_=(0,I.useCallback)(e=>{a.prefetchQuery({queryKey:[`snapshot`,e],queryFn:({signal:t})=>U.prefetchSnapshot(e,t),staleTime:3e3})},[a]);return(0,I.useEffect)(()=>{if(!i)return;let e=p.current,r=An(n,f.current,e);if(!e&&(p.current=!0,r.id===f.current?fl(r.id):m(r.id),new URLSearchParams(window.location.search).get(`project`)!==r.id&&pl(r.id,`replace`),r.recovered)){let e=n.find(e=>e.id===r.id);t(`info`,e?`Project “${r.requested}” was not found. Switched to ${e.label||e.id}.`:`Project “${r.requested}” was not found. Create a daemon to continue.`)}},[m,t,n,i]),(0,I.useEffect)(()=>{let e=()=>{let e=new URLSearchParams(window.location.search).get(`project`);if(s(!1),!e){m(null);return}if(!i){m(e);return}let r=kn(n,e);if(m(r.id),r.recovered){pl(r.id,`replace`);let e=n.find(e=>e.id===r.id);t(`info`,e?`Project “${r.requested}” was not found. Switched to ${e.label||e.id}.`:`Project “${r.requested}” was not found. Create a daemon to continue.`)}};return window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)},[m,t,n,i,s]),{activateProject:m,activeSid:i?u&&n.some(e=>e.id===u)?u:null:r?u:null,clearProjectSelection:g,prefetchProject:_,selectProject:h,sid:u,sidRef:f}}function hl(e){try{return globalThis.localStorage?.getItem(e)??null}catch{return null}}function gl(e,t){try{return globalThis.localStorage?.setItem(e,t),!!globalThis.localStorage}catch{return!1}}function _l(e,t,n){let r=n?t+8:56,i=Math.max(320,e-r-360-8);return Math.max(320,Math.min(840,i,Math.round(e*.45)))}var vl=`argus.themeStyle`;function yl(){return`standard`}function bl(){gl(vl,`standard`)}function xl(e,t){let n=hl(e);return n==null?t:n===`true`}function Sl(e){document.documentElement.dataset.theme=e,window.parent!==window&&window.parent.postMessage({type:`argus:theme-changed`,payload:e},`*`)}function Cl(){let e=new URLSearchParams(window.location.search),[t,n]=(0,I.useState)(e.get(`kiosk`)===`1`),[r,i]=(0,I.useState)(()=>xl(`argus.reasoning.visible.v1`,!1)),[a,o]=(0,I.useState)(()=>{let t=e.get(`view`);if(t===`mission`||t===`activity`||t===`workbench`||t===`map`)return t;let n=hl(`argus.workspace.view`);return n===`mission`||n===`activity`||n===`workbench`||n===`map`?n:`map`}),[s,c]=(0,I.useState)(`activity`),[l,u]=(0,I.useState)(()=>xl(`argus.preview.expanded.v5`,!0)),[d,f]=(0,I.useState)(()=>{let e=Number(hl(`argus.sidebar.width.v2`)||256);return Number.isFinite(e)?Math.max(220,Math.min(400,e)):256}),[p,m]=(0,I.useState)(()=>{let e=Number(hl(`argus.preview.width.v2`)||440);return Number.isFinite(e)?Math.max(320,Math.min(840,e)):440}),[h,g]=(0,I.useState)(!1),[_,v]=(0,I.useState)(()=>xl(`argus.sidebar.expanded.v4`,!0)),[y,b]=(0,I.useState)(()=>{let t=e.get(`desktopTheme`);if(t===`light`||t===`dark`)return t;let n=hl(`argus.theme`);return n===`light`||n===`dark`?n:null}),x=yl(),[S,C]=(0,I.useState)(()=>window.matchMedia(`(prefers-color-scheme: dark)`).matches),w=y??(S?`dark`:`light`),T=(0,I.useRef)(w),E=(0,I.useRef)(null),D=(0,I.useRef)(null);(0,I.useEffect)(()=>{gl(`argus.sidebar.expanded.v4`,String(_)),gl(`argus.preview.expanded.v5`,String(l)),gl(`argus.sidebar.width.v2`,String(d)),gl(`argus.preview.width.v2`,String(p))},[_,d,l,p]),(0,I.useEffect)(()=>{gl(`argus.workspace.view`,a)},[a]),(0,I.useEffect)(()=>{gl(`argus.reasoning.visible.v1`,String(r))},[r]),(0,I.useEffect)(()=>{let e=window.matchMedia(`(prefers-color-scheme: dark)`),t=()=>C(e.matches);return t(),e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]),(0,I.useEffect)(()=>{T.current=w,Sl(w)},[w]),(0,I.useEffect)(()=>{document.documentElement.dataset.themeStyle=x,bl()},[x]),(0,I.useEffect)(()=>{window.parent!==window&&window.parent.postMessage({type:`argus:theme-preference`,payload:y||`system`},`*`)},[y]);let ee=(0,I.useCallback)(()=>{let e=T.current===`light`?`dark`:`light`;T.current=e,Sl(e),gl(`argus.theme`,e);let t=new URL(window.location.href);t.searchParams.has(`desktopTheme`)&&(t.searchParams.set(`desktopTheme`,e),window.history.replaceState(window.history.state,``,t.toString())),(0,I.startTransition)(()=>b(e))},[]),O=(0,I.useCallback)(()=>{u(!0),c(`preview`);let e=E.current?.clientWidth??window.innerWidth;if(e>=1024){let t=_l(e,d,_);m(e=>Math.max(e,t))}},[_,d]),te=(0,I.useCallback)((e,t)=>{let n=E.current;if(!n)return;t.preventDefault();let r=n.getBoundingClientRect(),i=e===`left`?d:p;n.dataset.resizing=e,document.body.style.cursor=`col-resize`,document.body.style.userSelect=`none`;let a=t=>{if(e===`left`){let e=l?p+8:56,n=Math.max(220,Math.min(400,r.width-e-360-8));i=Math.max(220,Math.min(n,t.clientX-r.left))}else{let e=_?d+8:56,n=Math.max(320,Math.min(840,r.width-e-360-8));i=Math.max(320,Math.min(n,r.right-t.clientX))}D.current??=window.requestAnimationFrame(()=>{n.style.setProperty(e===`left`?`--sidebar-width`:`--preview-width`,`${i}px`),D.current=null})},o=()=>{D.current!=null&&window.cancelAnimationFrame(D.current),D.current=null,n.style.setProperty(e===`left`?`--sidebar-width`:`--preview-width`,`${i}px`),e===`left`?f(i):m(i),delete n.dataset.resizing,document.body.style.cursor=``,document.body.style.userSelect=``,window.removeEventListener(`pointermove`,a),window.removeEventListener(`pointerup`,o),window.removeEventListener(`pointercancel`,o)};window.addEventListener(`pointermove`,a),window.addEventListener(`pointerup`,o,{once:!0}),window.addEventListener(`pointercancel`,o,{once:!0})},[_,d,l,p]);return(0,I.useEffect)(()=>{let e=()=>{if(window.innerWidth<1024||!E.current)return;let e=E.current.clientWidth,t=_?d:56,n=l?p:56,r=(_?8:0)+(l?8:0),i=Math.max(540,e-360-r);if(t+n<=i)return;let a=l?Math.max(320,Math.min(p,i-t)):n,o=_?Math.max(220,Math.min(d,i-a)):t;o+a>i&&l&&(a=Math.max(320,i-o)),_&&f(o),l&&m(a)};return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[_,d,l,p]),{cycleTheme:ee,kiosk:t,leftPanelOpen:_,leftWidth:d,mobileView:s,openPreview:O,resizeSidebar:te,rightPanelOpen:l,rightWidth:p,setKiosk:n,setLeftPanelOpen:v,setLeftWidth:f,setMobileView:c,setRightPanelOpen:u,setRightWidth:m,setShowReasoning:i,setSidebarOpen:g,setWorkspaceView:o,shellRef:E,showReasoning:r,sidebarOpen:h,themeMode:w,themeStyle:x,workspaceView:a}}function wl(e){let t=e.trim();if(!t||/\s/.test(t))return``;if(!t.includes(`?`)&&!t.includes(`://`))return t;try{return new URL(t,window.location.href).searchParams.get(`token`)?.trim()??``}catch{return``}}function Tl({error:e,onRetry:t}){let{t:n}=Z(),r=L(e),i=e instanceof Ze,[a,o]=(0,I.useState)(!1),[s,c]=(0,I.useState)(``),[l,u]=(0,I.useState)(``);return!r&&!i?null:(0,X.jsxs)(`div`,{role:`alert`,className:`fixed left-1/2 top-3 z-[100] flex w-[min(92vw,42rem)] -translate-x-1/2 flex-wrap items-start gap-3 rounded-xl border border-err/50 bg-panel/95 px-4 py-3 text-left text-sm text-ink shadow-xl backdrop-blur`,children:[(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`mt-0.5 font-mono font-bold text-err`,children:`!`}),(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`strong`,{className:`block text-err`,children:n(r?`connection.pairingTitle`:`connection.unreachableTitle`)}),(0,X.jsx)(`span`,{className:`mt-0.5 block text-xs leading-relaxed text-ink-dim`,children:n(r?`connection.pairingDetail`:`connection.unreachableDetail`)})]}),r&&!a?(0,X.jsx)(`button`,{type:`button`,onClick:()=>o(!0),className:`shrink-0 rounded-md border border-blue/45 bg-blue/10 px-2.5 py-1 text-xs font-medium text-blue hover:bg-blue/15`,children:n(`connection.pairAgain`)}):r?null:(0,X.jsx)(`button`,{type:`button`,onClick:t,className:`shrink-0 rounded-md border border-err/40 px-2.5 py-1 text-xs text-err hover:bg-err/10`,children:n(`common.retry`)}),r&&a?(0,X.jsxs)(`form`,{onSubmit:e=>{e.preventDefault();let t=wl(s);if(!t){u(n(`connection.pairingInvalid`));return}let r=new URL(window.location.href);r.searchParams.set(`token`,t),window.location.replace(r.toString())},className:`flex w-full basis-full flex-wrap gap-2 pl-7`,children:[(0,X.jsx)(`label`,{className:`sr-only`,htmlFor:`pairing-link`,children:n(`connection.pairingInput`)}),(0,X.jsx)(`input`,{id:`pairing-link`,"data-autofocus":!0,type:`password`,autoComplete:`off`,value:s,onChange:e=>{c(e.target.value),u(``)},placeholder:n(`connection.pairingPlaceholder`),className:`h-9 min-w-0 flex-1 rounded-md border border-line bg-bg px-3 text-xs text-ink outline-none focus:border-blue`}),(0,X.jsx)(`button`,{type:`submit`,className:`h-9 rounded-md border border-blue/35 bg-blue/8 px-3 text-xs font-medium text-blue hover:border-blue-deep hover:bg-blue-deep hover:text-white`,children:n(`connection.connect`)}),l?(0,X.jsx)(`span`,{role:`alert`,className:`w-full text-xs text-err`,children:l}):null]}):null]})}function El(e){try{let t=JSON.parse(hl(e)||`[]`);return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}catch{return[]}}function Dl(e,t,n,r=!0){let i=(0,I.useRef)(),[a,o]=(0,I.useState)(null),s=(0,I.useCallback)(t=>{if(!e)return;let n=`argus.delivery.seen.v1:${e}`;gl(n,JSON.stringify([...new Set([...El(n),t])].slice(-80)))},[e]),c=(0,I.useCallback)((t,n)=>{if(!e)return;s(t.delivery_id);let r=Qr(t),i=r.find(e=>e.path===n)?.path||r[0]?.path||null;o({sid:e,receipt:t,path:i})},[e,s]);return(0,I.useEffect)(()=>{if(!e||!t)return;let a=n?.delivery_id;if(i.current?.sid!==e){i.current={sid:e,ids:new Set(a?[a]:[])},o(null);return}!a||i.current.ids.has(a)||!r||(i.current.ids.add(a),n&&Qr(n).length&&!El(`argus.delivery.seen.v1:${e}`).includes(a)&&c(n))},[e,t,n,c,r]),{selection:a?.sid===e?a:null,open:c,close:(0,I.useCallback)(()=>o(null),[]),selectPath:(0,I.useCallback)(e=>o(t=>t&&{...t,path:e}),[])}}var Ol=0,kl=(0,I.lazy)(async()=>({default:(await oi(()=>import(`./ResearchWorkbenchPanel-BOxuXoMY.js`),__vite__mapDeps([2,1,3,4,5,6]))).ResearchWorkbenchPanel})),Al=(0,I.lazy)(async()=>({default:(await oi(()=>import(`./MapPanel-BZxjl6ME.js`),__vite__mapDeps([7,1,3,4,8,9,5,10]))).MapPanel}));function jl(e,t){let[n,r]=(0,I.useState)(e),i=(0,I.useRef)(e),a=(0,I.useRef)(null),o=(0,I.useRef)(0);return i.current=e,(0,I.useEffect)(()=>{if(e===n)return;let s=o.current+t-Date.now();if(s<=0){o.current=Date.now(),r(e);return}a.current||=setTimeout(()=>{a.current=null,o.current=Date.now(),r(i.current)},s)},[e,n,t]),(0,I.useEffect)(()=>()=>{a.current&&clearTimeout(a.current)},[]),n}function Ml(){let{locale:e,t}=Z(),n=oe(),r=_r(),i=vr(),a=(0,I.useMemo)(()=>Dn(Qc(r.data?.projects??[],i.data?.projects??[])),[i.data?.projects,r.data?.projects]),s=r.data?.local_cwd??``,c=[r.error,i.error].find(e=>Qe(e)),[l,u]=(0,I.useState)(`none`),{cycleTheme:d,kiosk:f,leftPanelOpen:p,leftWidth:m,mobileView:h,openPreview:g,resizeSidebar:_,rightPanelOpen:v,rightWidth:y,setKiosk:b,setLeftPanelOpen:x,setLeftWidth:S,setMobileView:C,setRightPanelOpen:w,setRightWidth:T,setShowReasoning:D,setSidebarOpen:ee,setWorkspaceView:O,shellRef:te,showReasoning:ne,sidebarOpen:k,themeMode:re,workspaceView:A}=Cl(),[j,ie]=(0,I.useState)(()=>A===`mission`?`mission`:`activity`),[ae,M]=(0,I.useState)(A===`workbench`);(0,I.useEffect)(()=>{if(A===`workbench`){M(!0);return}A!==`map`&&ie(A)},[A]),Vc();let[se,N]=(0,I.useState)(0),[ce,le]=(0,I.useState)(``),[ue,de]=(0,I.useState)([]),fe=(0,I.useRef)(ce);fe.current=ce;let[P,F]=(0,I.useState)(!1),[pe,me]=(0,I.useState)(0),[he,ge]=(0,I.useState)(Rr),[_e,ve]=(0,I.useState)(!1),[ye,be]=(0,I.useState)([]),[xe,Se]=(0,I.useState)([]),[Ce,we]=(0,I.useState)(null),[Te,Ee]=(0,I.useState)({path:``,token:0}),[De,Oe]=(0,I.useState)(null),[ke,Ae]=(0,I.useState)(!1),[je,Me]=(0,I.useState)(!1),[Ne,Pe]=(0,I.useState)(null),[Fe,Ie]=(0,I.useState)(null),Le=(0,I.useRef)(!1),Re=(0,I.useRef)(null),ze=(0,I.useRef)(0),Be=(0,I.useRef)(),Ve=(0,I.useRef)({sid:``,completionId:``,view:null,artifacts:[]}),He=(0,I.useRef)(null),[Ue,We]=(0,I.useState)(null),[Ge,Ke]=(0,I.useReducer)(qc,Kc),[qe,Je]=(0,I.useState)(`all`),[Ye,Xe]=(0,I.useState)(``),Ze=(0,I.useCallback)(()=>We(null),[]);(0,I.useEffect)(()=>{try{localStorage.setItem(Lr,he)}catch{}},[he]);let L=(0,I.useCallback)((e,t)=>{We({id:++Ol,tone:e,message:t})},[]),$e=(0,I.useCallback)(()=>{let e=!!Re.current;return ze.current+=1,Re.current?.controller.abort(),Re.current=null,ve(!1),Se([]),e},[]),et=(0,I.useCallback)(()=>{$e()&&L(`info`,`Stopped waiting for this reply. Server-side work may still finish in the project timeline.`)},[$e,L]),{activeSid:R,clearProjectSelection:z,prefetchProject:tt,selectProject:nt,sidRef:rt}=ml({cancelActiveMessage:$e,notify:L,projects:a,projectsError:r.isError,projectsReady:r.isSuccess,queryClient:n,setArtifactPath:we,setSidebarOpen:ee,setTaskItemId:Oe});(0,I.useEffect)(()=>()=>{ze.current+=1,Re.current?.controller.abort(),Re.current=null},[]),(0,I.useEffect)(()=>gs(),[]);let it=(0,I.useCallback)(e=>{let t=(e||``).trim(),n=rt.current;!t||!n||P||(F(!0),U.rewritePrompt(n,t).then(e=>{if(F(!1),e.error||!e.rewritten.trim()){L(`error`,`Rewrite failed: ${e.error||`empty rewrite`} — your prompt is unchanged`);return}le(e.rewritten),N(e=>e+1);let t=e.questions.length?` Manager asks: ${e.questions.join(` · `)}`:``;L(`success`,`Prompt rewritten — review it, then send.${t}`)},e=>{F(!1),L(`error`,`Rewrite failed: ${mi(e)} — your prompt is unchanged`)}))},[L,P,rt]),{createDaemon:B,creatingDaemon:at}=tl({localCwd:s,notify:L,onFocusComposer:()=>N(e=>e+1),queryClient:n,refetchProjects:r.refetch,selectProject:nt});(0,I.useEffect)(()=>hs(()=>Ae(!0)),[]);let ot=yr(R),st=yr(Ne),V=ot.data,H=V?.session.id===R?R:null,ct=V?.continuous,lt=Tr(H,!0),ut=Dr(H,j===`mission`),{events:dt,connected:W}=Ir(H,Ge.reconnectKey),ft=(0,I.useMemo)(()=>Nr(dt),[dt]),pt=(0,I.useMemo)(()=>Fr(dt),[dt]);(0,I.useEffect)(()=>{if(!H||!ft)return;let e=window.setTimeout(()=>{n.invalidateQueries({queryKey:[`artifacts`,H],exact:!0})},180);return()=>window.clearTimeout(e)},[ft,H,n]),(0,I.useEffect)(()=>{if(!H||!pt)return;let e=window.setTimeout(()=>{n.invalidateQueries({queryKey:[`snapshot`,H],exact:!0})},80);return()=>window.clearTimeout(e)},[H,n,pt]);let mt=(0,I.useMemo)(()=>Rn(dt),[dt]),ht=wr(H,j===`activity`,120),gt=br(R,20,l===`inspector`),{answerPendingReply:_t,pendingReply:G,pendingReplyBusy:vt,pendingReplyOpen:yt,setPendingReplyOpen:bt}=ll({activeSid:R,autoOpen:A!==`map`,backlog:V?.backlog,notify:L,pendingQuestions:V?.pending_questions,refetchSnapshot:ot.refetch}),xt=(0,I.useMemo)(()=>Zc(dt,ht.data??[],ye),[dt,ye,ht.data]),St=jl(dt,250),Ct=jl(xt,250),wt=(0,I.useMemo)(()=>V?xn(V,xt,lt.data??[]):null,[xt,lt.data,V]),Tt=V?.daemon.alive&&wt?.routing.vertical===`research`?wt.active_role.startsWith(`reviewer`)?`reviewing`:wt.active_role.startsWith(`engineer`)?`revising`:void 0:void 0,Et=ti((0,I.useMemo)(()=>ra(xt),[xt]),wt?.delivery??null,xt),Dt=V?.backlog.some(e=>[`pending`,`running`,`in_progress`,`claimed`].includes(e.status))??!1,Ot=Ss(wt)&&!Dt&&!V?.continuous?.enabled,kt=H&&Ot&&wt?.mission.id?`completion:${H}:${wt.mission.id}`:``;He.current=Et,Ve.current={sid:H||``,completionId:kt,view:wt,artifacts:lt.data??[]};let At=(0,I.useCallback)(()=>{g()},[g]),jt=(0,I.useCallback)((e,t=!0)=>{let n=e.trim();if(!n){t&&O(`mission`);return}if(A===`map`){we(n);return}w(!0),C(`preview`),Ee(e=>({path:n,token:e.token+1}))},[C,w,O,A]),Mt=Dl(H,!!V&&!ht.isPending,Et,!Ce&&!ni(V?.backlog??[],Et?.item_id)),Pt=Mt.open,Ft=(0,I.useMemo)(()=>{let e=new Map;for(let t of xt){let n=t.delivery;n?.delivery_id&&Array.isArray(n.targets)&&e.set(n.delivery_id,n)}for(let t of[wt?.delivery,Et])t&&e.set(t.delivery_id,t);return[...e.values()].filter(e=>Qr(e).length).sort((e,t)=>t.delivered_at-e.delivered_at)},[xt,wt?.delivery,Et]);(0,I.useEffect)(()=>{H&&Et?.delivery_id&&n.invalidateQueries({queryKey:[`artifacts`,H],exact:!0})},[H,Et?.delivery_id,n]),(0,I.useEffect)(()=>{if(!H)return;let e=Be.current;if(!e||e.sid!==H){Be.current={sid:H,id:kt||null};return}if(!kt){Be.current={sid:H,id:null};return}if(e.id===kt)return;let n=window.setTimeout(()=>{let e=Ve.current;if(e.sid!==H||e.completionId!==kt||!e.view)return;let n=e.view.delivery,r=Ds(e.artifacts),i=ls({completionId:kt,title:n?.title||e.view.mission.title||t(`mission.taskCompleted`),summary:n?.summary||e.view.mission.summary,path:n?.primary_target?.path||r?.path});i&&fs(i),Be.current={sid:H,id:kt}},500);return()=>window.clearTimeout(n)},[kt,H,t]),(0,I.useEffect)(()=>ms(e=>{let t=He.current;t&&t.delivery_id===e.deliveryId?Pt(t):e.path?jt(e.path):(C(`activity`),O(`mission`))}),[jt,Pt,C,O]);let K=(0,I.useRef)(xt);K.current=xt,(0,I.useEffect)(()=>{Je(`all`),Xe(``),be([]),Ke({kind:`reset`})},[H]);let It=kr(R,V?.daemon_commands?.revision),Lt=kr(Ne,st.data?.daemon_commands?.revision),Rt=(0,I.useCallback)(async e=>{Ie(e);try{await U.startDaemon(e),await r.refetch(),L(`success`,t(`sidebar.resumeSuccess`))}catch(e){L(`error`,t(`sidebar.resumeFailed`,{error:mi(e)}))}finally{Ie(null)}},[L,r,t]),{daemonBusy:zt,manageDeleteProject:Bt,manageStopDaemon:Vt,manageRenameProject:Ht,manageStartDaemon:Ut,requestDispose:Wt,requestManageSession:Gt,requestStartDaemon:Kt,requestStopDaemon:qt,requestStopIteration:Jt,toggleContinuous:Yt}=rl({actions:It,manageActions:Lt,manageTargetSid:Ne,setManageTargetSid:Pe,activeSid:R,clearProjectSelection:z,continuous:ct,notify:L,refetchProjects:r.refetch,selectProject:nt,setDaemonManageOpen:Me}),Xt=(0,I.useCallback)(async e=>{if(!R)return;let t=await It.updateProject.mutateAsync({sid:R,name:e});L(`success`,`Renamed to "${t.name}".`)},[It.updateProject,R,L]),Zt=(0,I.useMemo)(()=>Uc({activeSid:R,activityEventsRef:K,notify:L,onClearEvents:e=>Ke({kind:`clear`,offset:e}),onDispose:Wt,onOpenConfig:()=>u(`config`),onOpenDoctor:()=>u(`doctor`),onOpenHelp:()=>u(`help`),onOpenIdentity:()=>u(`identity`),onOpenInspector:()=>u(`inspector`),onOpenNewDaemon:()=>Ae(!0),onOpenOperations:()=>u(`operations`),onOpenSidebar:()=>ee(!0),onReconnectEvents:()=>Ke({kind:`reconnect`}),onRenameProject:Xt,onRewriteDraft:it,onSelectProject:nt,onSetArtifactPath:we,onSetEventFilter:Je,onSetEventQuery:Xe,onSetTaskItemId:Oe,onSetWorkspaceView:O,onShowArtifacts:At,onStopIteration:Jt,onStopWaiting:et,refetchSnapshot:ot.refetch}),[R,L,At,Xt,Wt,Jt,nt,ot.refetch,et,O]);il({focusComposer:()=>N(e=>e+1),openHelp:()=>u(`help`),toggleKiosk:()=>b(e=>!e),togglePalette:()=>u(e=>e===`palette`?`none`:`palette`),toggleReasoning:()=>D(e=>!e),toggleSidebarCollapse:()=>x(e=>!e)});let Qt=async(e,n=[],r)=>{let i=R;if(!i||Le.current||Re.current)return!1;Le.current=!0;let a,o;try{if(!n.length){let t=await Hc(e,Zt);if(t.kind===`handled`)return r?.({type:`settled`,outcome:`message`}),!0;if(t.kind===`error`)return L(`error`,t.message),!1}a=++ze.current,o=new AbortController,Re.current={id:a,sid:i,controller:o}}finally{Le.current=!1}let s=()=>{let e=Re.current;return!!(e&&e.id===a&&e.sid===i&&rt.current===i&&!o.signal.aborted)},c=()=>{Re.current?.id===a&&(Re.current=null,ve(!1),Se([]))};ve(!0),Se([]);let l=[];if(n.length)try{let e=await U.uploadAttachments(i,n,o.signal);if(!s())return!1;l=e.attachments.map(e=>({attachment_id:e.attachment_id}))}catch(e){return s()&&(L(`error`,t(`chat.attachmentUploadFailed`,{error:mi(e)})),c()),!1}be(t=>[...t,Yc(i,a,e)]);let u=(e,t=``,n=`auto`)=>{!s()||typeof e!=`string`||!e.trim()||be(r=>Xc(r,i,a,e,t,Date.now(),n))},d=e=>{if(!s())return;let t=e.item;typeof t?.id==`string`&&r?.({type:`task`,taskId:t.id});let n=e.daemon&&typeof e.daemon==`object`?e.daemon:null,i=typeof e.reply==`string`?e.reply:null;n?.admission_required?L(`error`,i||`Task queued, but all daemon slots are busy: ${String(n.error||`operator action required`)}`):n&&Number(n.rc??0)!==0?L(`error`,i||`Task queued, but executor did not start: ${String(n.error||`unknown error`)}`):i&&!r&&L(`success`,i),ot.refetch?.()},f=e=>{s()&&Gc(e,{dispatchTask:d,notifyError:e=>L(`error`,e),refetchTranscript:()=>{ht.refetch()}})};return(async()=>{let t=!1,n=null,a=[];try{try{await U.messageStream(i,e,{onPhase:(e,t,n)=>{!s()||n.heartbeat||(a=Kn(a,{label:e,role:t,kind:n.kind,detail:n.detail,heartbeat:n.heartbeat,quietS:n.quietS}),Se(a))},onDelta:(e,n,r)=>{s()&&(t=!0,a=qn(a),Se(a),u(e,n,r===`append`||r===`snapshot`?r:`auto`))},onDone:e=>{if(!s())return;u(e.reply,``,`snapshot`),f(e);let t=e.item;(e.kind!==`task`||typeof t?.id!=`string`)&&r?.({type:`settled`,outcome:e.kind===`error`?`error`:`message`})},onError:e=>{s()&&(n=e)}},{signal:o.signal,attachments:l,routeOverride:he})}catch(e){s()&&(n=e)}if(!s())return;n&&(L(`error`,hi(n,t)),r?.({type:`settled`,outcome:`error`}))}finally{o.signal.aborted&&r?.({type:`settled`,outcome:`cancelled`}),c()}})(),!0},$t=(0,I.useRef)(Qt);$t.current=Qt;let en=async(e,t=[])=>{let n=fe.current,r=rt.current,i=await Qt(e,t);return i&&rt.current===r&&(le(e=>e===n?``:e),de(e=>e.filter(e=>!t.includes(e)))),i},tn=(0,I.useMemo)(()=>{let n=vo(Nt,e=>{$t.current(e)},e=>{le(e),N(e=>e+1)},e),r=[...f?[]:[{id:`new`,label:t(`palette.newDaemon`),hint:`+`,group:t(`palette.view`),run:()=>Ae(!0)}],{id:`transcript`,label:t(`palette.openTranscript`),hint:`/transcript`,group:t(`palette.view`),run:()=>u(`transcript`)},{id:`inspector`,label:t(`palette.openProject`),hint:t(`palette.projectHint`),group:t(`palette.view`),run:()=>u(`inspector`)},{id:`operations`,label:t(`palette.openOperations`),hint:t(`palette.operationsHint`),group:t(`palette.view`),run:()=>u(`operations`)},{id:`help`,label:t(`help.title`),hint:`?`,group:t(`palette.view`),run:()=>u(`help`)},{id:`reasoning`,label:t(ne?`palette.hideReasoning`:`palette.showReasoning`),hint:`⌘T`,group:t(`palette.view`),run:()=>D(e=>!e)},{id:`kiosk`,label:t(f?`palette.exitKiosk`:`palette.enterKiosk`),hint:`⌘.`,group:t(`palette.view`),run:()=>b(e=>!e)}],i=f?[]:[{id:`message`,label:t(`palette.messageArgus`),hint:`/`,group:t(`palette.action`),run:()=>N(e=>e+1)},..._e?[{id:`cancel-message`,label:t(`palette.stopWaiting`),hint:`Esc`,group:t(`palette.action`),run:et}]:[],...ct?[{id:`continuous`,label:ct.enabled?t(`palette.stopContinuous`):t(`palette.startContinuous`),group:t(`palette.action`),run:Yt}]:[],...V?.daemon.control_available===!1?[]:[V?.daemon.alive?{id:`stop`,label:t(`palette.stopDaemon`),group:t(`palette.action`),run:qt}:{id:`start`,label:t(`palette.startDaemon`),group:t(`palette.action`),run:Kt}]],o=a.map(e=>({id:`p-${e.id}`,label:e.label||e.id,hint:e.daemon_alive?`● ${t(`common.live`)}`:`○`,keywords:`${e.id} ${e.display_name??``} ${e.objective} ${e.daemon_alive?`live running`:`stopped idle`}`,group:t(`palette.project`),run:()=>nt(e.id)}));return[...r,...i,...n,...o]},[a,V?.daemon.alive,f,ne,ct?.enabled,_e,et,e,t]);return(0,X.jsxs)(`div`,{ref:te,style:{"--sidebar-width":`${m}px`,"--preview-width":`${y}px`},className:`workbench-shell ambient-canvas flex w-screen max-w-full overflow-hidden text-ink`,children:[(0,X.jsx)(Tl,{error:c,onRetry:()=>{r.refetch(),i.refetch()}}),Mt.selection&&(0,X.jsx)(vs,{sid:Mt.selection.sid,path:Mt.selection.path,delivery:Mt.selection.receipt,deliveries:Ft,reviewActivity:Mt.selection.sid===H?Tt:void 0,onSelectDelivery:Pt,onSelectPath:Mt.selectPath,onClose:Mt.close},`${Mt.selection.sid}:${Mt.selection.receipt.delivery_id}`),!f&&k?(0,X.jsx)(`button`,{type:`button`,"aria-label":t(`common.closeSessions`),onClick:()=>ee(!1),className:`fixed inset-0 z-30 bg-black/40 lg:hidden`}):null,f?null:(0,X.jsx)(Qs,{projects:a,activeId:R,localCwd:s,onSelect:e=>{nt(e),ee(!1)},onPrefetch:tt,onManage:Gt,onResume:e=>void Rt(e),resumingId:Fe,onOpenPanel:e=>u(e),onNew:()=>Ae(!0),loading:r.isLoading,creating:at,error:r.isError?mi(r.error):void 0,onRetry:()=>void r.refetch(),mobileOpen:k,collapsed:!p,onToggleCollapse:()=>x(e=>!e),themeMode:re,onCycleTheme:d}),!f&&p?(0,X.jsx)(uc,{label:t(`common.resizeSessions`),value:m,min:220,max:400,onPointerDown:e=>_(`left`,e),onReset:()=>S(256),onNudge:e=>S(t=>Math.max(220,Math.min(400,t+e)))}):null,(0,X.jsx)(`main`,{className:`flex min-w-0 flex-1 overflow-x-hidden`,children:V?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`section`,{className:`${h===`activity`?`flex`:`hidden`} glass-panel glass-panel--main h-full min-w-0 flex-1 flex-col lg:flex`,children:[A!==`map`&&(0,X.jsx)(Zr,{snap:V,streamOk:W,onStart:Kt,onStop:qt,onManage:()=>R&&Gt(R),busy:zt,snapshotStale:ot.isError,readOnly:f,missionView:wt}),(0,X.jsxs)(`div`,{className:`hidden h-10 shrink-0 items-center gap-1 border-b border-line/60 px-3 lg:flex`,children:[(0,X.jsxs)(`div`,{className:`workspace-tabs`,"data-active":A,children:[(0,X.jsx)(`span`,{className:`workspace-tab-indicator`,"aria-hidden":`true`}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>O(`mission`),className:`workspace-tab`,"data-selected":A===`mission`,children:t(`mobile.mission`)}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>O(`activity`),className:`workspace-tab`,"data-selected":A===`activity`,children:t(`mobile.activity`)}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>O(`workbench`),className:`workspace-tab`,"data-selected":A===`workbench`,children:t(`mobile.workbench`)}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>O(`map`),className:`workspace-tab`,"data-selected":A===`map`,children:t(`mobile.map`)})]}),A===`mission`?(0,X.jsx)(`span`,{className:`ml-auto hidden max-w-72 truncate text-[10px] text-ink-faint sm:block`,children:wt?.active_role?t(`mission.roleActive`,{role:wt.active_role}):t(`mission.overview`)}):(0,X.jsx)(`span`,{className:`ml-auto`}),!f&&A!==`map`?(0,X.jsx)(`button`,{type:`button`,onClick:()=>u(`operations`),className:`rounded border border-line/60 px-2 py-1 text-[10px] text-ink-faint hover:border-blue/50 hover:text-blue`,children:t(`mission.operations`)}):null]}),A===`map`&&(0,X.jsx)(I.Suspense,{fallback:(0,X.jsx)(`div`,{className:`m-auto text-sm text-ink-faint`,children:t(`common.loading`)}),children:(0,X.jsx)(Al,{snapshot:V,events:St,managerSteps:xe,draft:ce,onDraftChange:le,onSend:Qt,pending:_e,onCancel:et,focusSignal:se,readOnly:f,onOpenSettings:()=>u(`config`),routeOverride:he,onRouteOverrideChange:ge,conversationEvents:Ct,connected:W,artifacts:lt.data??[],deliveryCount:Ft.length,onOpenDelivery:()=>{let e=$r(Ft,wt?.routing.vertical||``);e&&Pt(e.receipt,e.path)},onOpenReceipt:Pt,onOpenArtifact:we,onAnswer:()=>bt(!0)},V.session.id)}),(0,X.jsxs)(`div`,{className:`${A===`workbench`||A===`map`?`hidden`:`flex`} min-h-0 flex-1 flex-col`,children:[(0,X.jsx)(Ko,{alert:mt}),j===`mission`&&wt?(0,X.jsx)(Mc,{view:wt,sid:V.session.id,snapshot:V,gitDiff:ut.data,artifacts:lt.data,onOpenArtifact:jt,onOpenDelivery:Pt,onNotify:L}):(0,X.jsx)(oa,{events:xt,connected:W,showReasoning:ne,onToggleReasoning:()=>D(e=>!e),embedded:!0,filter:qe,query:Ye,skipFirst:Ge.skipFirst,artifacts:lt.data,onOpenArtifact:jt,onOpenDelivery:Pt}),f?null:(0,X.jsx)(`div`,{className:`composer-dock shrink-0 px-4 pt-3`,children:(0,X.jsxs)(`div`,{className:`mx-auto w-full max-w-full lg:max-w-[61.8vw]`,children:[(0,X.jsx)(Wo,{questions:V.pending_questions??[],backlog:V.backlog,onAnswer:()=>bt(!0)}),(0,X.jsx)(ho,{value:ce,attachments:ue,onAttachmentsChange:de,onChange:le,onSend:en,onCancel:et,disabled:!R,pending:_e,focusSignal:se,embedded:!0,steps:xe,onRewrite:it,rewriting:P,slashSelection:pe,onSlashSelectionChange:me,routeOverride:he,onRouteOverrideChange:ge},R||`no-session`)]})})]}),ae&&R?(0,X.jsx)(`div`,{className:`${A===`workbench`?`flex`:`hidden`} min-h-0 flex-1`,children:(0,X.jsx)(I.Suspense,{fallback:(0,X.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center text-xs text-ink-faint`,children:t(`common.loading`)}),children:(0,X.jsx)(kl,{sid:R,active:A===`workbench`})})}):null]}),v&&A!==`map`?(0,X.jsx)(uc,{label:t(`common.resizePreview`),value:y,min:320,max:840,onPointerDown:e=>_(`right`,e),onReset:()=>T(440),onNudge:e=>T(t=>Math.max(320,Math.min(840,t-e)))}):null,(A!==`map`||h===`preview`)&&(0,X.jsxs)(`aside`,{"data-resizable-panel":`right`,className:`${h===`preview`?`flex`:`hidden`} relative min-w-0 flex-1 flex-col overflow-hidden border-l border-line/60 bg-panel transition-[width] duration-[250ms] ease-panel lg:flex lg:flex-none ${v?`lg:w-[var(--preview-width)]`:`lg:w-14`}`,children:[(0,X.jsx)(`div`,{className:`lg:hidden`,children:(0,X.jsx)(Zr,{snap:V,streamOk:W,onStart:Kt,onStop:qt,onManage:()=>R&&Gt(R),busy:zt,snapshotStale:ot.isError,readOnly:f,missionView:wt})}),(0,X.jsx)(Fs,{sid:H,artifacts:lt.data,error:lt.isError,onExpand:we,onOpenFile:At,className:`min-h-0 flex-1 mobile-scroll-region ${v?`lg:flex`:`lg:hidden`}`,embedded:!0,onCollapse:()=>w(!1),missionView:wt,activityEvents:xt,requestedPath:Te.path,requestedPathToken:Te.token}),v?null:(0,X.jsx)(`div`,{className:`hidden h-12 items-center justify-center border-b border-line/50 text-ink-faint lg:flex`,children:(0,X.jsx)(`button`,{type:`button`,onClick:At,"aria-label":t(`common.expandPreview`),title:t(`common.expandPreview`),className:`flex h-8 w-8 items-center justify-center rounded-md border border-line/50 bg-bg/40 hover:border-blue/50 hover:text-ink`,children:(0,X.jsx)(o,{icon:E,className:`h-3.5 w-3.5`})})})]})]}):(0,X.jsx)(Bc,{loading:r.isLoading||!!(R&&ot.isLoading),hasProjects:a.length>0,error:r.isError&&a.length===0?mi(r.error):ot.isError&&!V?mi(ot.error):void 0,onRetry:()=>{r.refetch(),R&&ot.refetch()},onNew:()=>Ae(!0),onChoose:()=>ee(!0),canCreate:!f})}),(0,X.jsx)(bo,{open:l===`palette`,onClose:()=>u(`none`),items:tn}),(0,X.jsx)(So,{open:l===`help`,onClose:()=>u(`none`)}),R&&(0,X.jsx)(Bo,{sid:R,open:l===`doctor`,onClose:()=>u(`none`)}),R&&(0,X.jsx)(Vo,{sid:R,open:l===`config`,onClose:()=>u(`none`)}),R&&(0,X.jsx)(Ho,{sid:R,open:l===`identity`,onClose:()=>u(`none`)}),R&&(0,X.jsx)(Uo,{sid:R,open:l===`transcript`,onClose:()=>u(`none`)}),R&&V?(0,X.jsx)(oc,{open:l===`inspector`,snap:V,journal:gt.data??[],busy:It.disposeBacklog.isPending||It.stopBacklog.isPending,onClose:()=>u(`none`),onDispose:Wt,onStop:Jt,onInspect:Oe}):null,R&&V?(0,X.jsx)(Lc,{open:l===`operations`,sid:R,snap:V,onClose:()=>u(`none`),onChanged:()=>{ot.refetch(),r.refetch()},onRestored:async e=>{await r.refetch(),nt(e)}}):null,(0,X.jsx)(vs,{sid:R,path:Ce,reviewActivity:R===H?Tt:void 0,onClose:()=>we(null)}),(0,X.jsx)(lc,{sid:R,itemId:De,onClose:()=>Oe(null),onDone:e=>Wt(e,`done`),onSkip:e=>Wt(e,`rm`),onStop:Jt,busy:It.disposeBacklog.isPending||It.stopBacklog.isPending,readOnly:f}),(0,X.jsx)(Ls,{open:ke,busy:at,onClose:()=>Ae(!1),onCreate:B}),(0,X.jsx)(Go,{reply:G,open:yt,busy:vt,onClose:()=>bt(!1),onSubmit:_t}),Ne?(0,X.jsx)(Rs,{open:je,sid:Ne,name:st.data?.session.display_name||a.find(e=>e.id===Ne)?.display_name||a.find(e=>e.id===Ne)?.label||``,alive:st.data?.daemon.alive??!!a.find(e=>e.id===Ne)?.daemon_alive,controlAvailable:st.data?.daemon.control_available!==!1,busy:zt,onClose:()=>{Me(!1),Pe(null)},onRename:Ht,onStart:Ut,onStop:Vt,onDelete:Bt}):null,(0,X.jsx)(Is,{notice:Ue,onClose:Ze}),V&&!f?(0,X.jsx)($,{active:h===`preview`?`preview`:A,sidebarOpen:k,onSelect:e=>{if(e===`preview`){C(`preview`);return}C(`activity`),O(e)},onOpenSessions:()=>ee(!0)}):null]})}function Nl({onDone:e}){let{t}=Z(),n=(0,I.useRef)(!1),r=(0,I.useCallback)(()=>{n.current||(n.current=!0,e())},[e]);return(0,I.useEffect)(()=>{let e=window.setTimeout(r,970),t=()=>r();return window.addEventListener(`keydown`,t,{once:!0}),()=>{window.clearTimeout(e),window.removeEventListener(`keydown`,t)}},[r]),(0,X.jsx)(`div`,{role:`status`,"aria-label":t(`splash.starting`),onClick:r,onAnimationEnd:e=>{e.currentTarget===e.target&&r()},className:`argus-web-splash`,children:(0,X.jsx)(`div`,{className:`argus-web-splash-logo`,"aria-hidden":`true`,children:(0,X.jsx)(Ai,{size:168})})})}var Pl=class extends I.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}render(){if(!this.state.failed)return this.props.children;let e=this.props.locale===`zh-CN`;return(0,X.jsx)(`main`,{className:`flex min-h-dvh items-center justify-center bg-bg p-8 text-ink`,role:`alert`,children:(0,X.jsxs)(`section`,{className:`max-w-lg rounded-xl border border-line bg-panel p-8 shadow-lg`,children:[(0,X.jsx)(`p`,{className:`mb-3 text-xs font-semibold uppercase tracking-widest text-blue`,children:`Argus`}),(0,X.jsx)(`h1`,{className:`text-lg font-semibold`,children:e?`工作台暂时无法显示`:`The workspace could not be displayed`}),(0,X.jsx)(`p`,{className:`mt-3 text-sm leading-relaxed text-ink-dim`,children:e?`页面资源未能正确加载。后端任务不会因此被停止;你仍可使用桌面菜单查看日志或设置。重新加载会丢弃页面中尚未发送的输入。`:`A page resource failed to load. Backend work has not been stopped. Desktop menus remain available for logs and settings. Reloading discards unsent input on this page.`}),(0,X.jsxs)(`div`,{className:`mt-6 flex flex-wrap gap-3`,children:[(0,X.jsx)(`button`,{type:`button`,className:`rounded-md bg-blue px-4 py-2 text-sm text-white`,onClick:()=>window.location.reload(),children:e?`重新加载工作台`:`Reload workspace`}),(0,X.jsx)(`button`,{type:`button`,className:`rounded-md border border-line px-4 py-2 text-sm`,onClick:()=>{let e=new URL(window.location.href);e.searchParams.set(`view`,`activity`),window.location.assign(e.toString())},children:e?`返回对话页面`:`Return to conversation`})]})]})})}};function Fl(e,t,n){let r=!1;e.addEventListener(`vite:preloadError`,e=>{let i=e.payload,a=i instanceof Error?i.message:String(i??``);if(!/\/(?:pdf[.-]|pdfjs)[^/\s]*\.(?:m?js)(?:[?#\s]|$)/i.test(a)&&/failed to fetch dynamically imported module|importing a module script failed|loading chunk .+ failed/i.test(a)){if(r){e.preventDefault();return}try{let e=n.storage(),t=`argus.stale-chunk-reloaded`;if(e.getItem(t)===n.releaseId)return;e.setItem(t,n.releaseId)}catch{return}e.preventDefault(),r=!0,t()}})}Fl(window,()=>window.location.reload(),{releaseId:Ne,storage:()=>window.sessionStorage}),We();var Il=window.parent!==window;document.documentElement.dataset.argusEmbedded=String(Il);var Ll=new De({defaultOptions:{queries:{staleTime:3e3,retry:pr,refetchOnWindowFocus:!1}}});function Rl(){let{locale:e}=Z(),[t,n]=(0,I.useState)(!Il);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Pl,{locale:e,children:(0,X.jsx)(Ml,{})}),t?(0,X.jsx)(Nl,{onDone:()=>n(!1)}):null]})}Oe.createRoot(document.getElementById(`root`)).render((0,X.jsx)(I.StrictMode,{children:(0,X.jsx)(de,{client:Ll,children:(0,X.jsx)(Jr,{children:(0,X.jsx)(Rl,{})})})}));export{ba as A,U as B,Ua as C,La as D,za as E,Ai as F,Se as G,qe as H,ki as I,fi as L,Aa as M,sa as N,Ia as O,oa as P,ei as R,Wa as S,Va as T,H as U,Ke as V,et as W,eo as _,Wo as a,Ya as b,co as c,uo as d,oo as f,to as g,no as h,os as i,Da as j,ja as k,lo as l,ro as m,gl as n,go as o,io as p,yc as r,so as s,hl as t,fo as u,Qa as v,Ha as w,Ga as x,Za as y,Z as z}; \ No newline at end of file diff --git a/frontend/web/dist/assets/play-DQD97EkU.js b/frontend/web/dist/assets/play-DQD97EkU.js new file mode 100644 index 000000000..08cf9ac37 --- /dev/null +++ b/frontend/web/dist/assets/play-DQD97EkU.js @@ -0,0 +1 @@ +import{O as e}from"./index-BZHe8e4S.js";var t=e(`ChevronRight`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]),n=e(`GitBranch`,[[`line`,{x1:`6`,x2:`6`,y1:`3`,y2:`15`,key:`17qcm7`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}],[`circle`,{cx:`6`,cy:`18`,r:`3`,key:`fqmcym`}],[`path`,{d:`M18 9a9 9 0 0 1-9 9`,key:`n2h4wq`}]]),r=e(`Play`,[[`polygon`,{points:`6 3 20 12 6 21 6 3`,key:`1oa8hb`}]]);export{n,t as r,r as t}; \ No newline at end of file diff --git a/frontend/web/dist/index.html b/frontend/web/dist/index.html index 01b95f4b1..80da623d4 100644 --- a/frontend/web/dist/index.html +++ b/frontend/web/dist/index.html @@ -38,7 +38,7 @@ document.documentElement.dataset.themeStyle = style; })(); - + diff --git a/frontend/web/src/lib/pluginEnglish.json b/frontend/web/src/lib/pluginEnglish.json index e2abbddcf..c8a305c0b 100644 --- a/frontend/web/src/lib/pluginEnglish.json +++ b/frontend/web/src/lib/pluginEnglish.json @@ -109,5 +109,6 @@ "PLATON 安装配方已更新,点击修复依赖即可使用当前版本。": "The PLATON installation recipe has been updated. Click Repair dependencies to use the current version.", "PLATON 未生成校验规则;请检查运行库": "PLATON did not generate verification rules; check the runtime", "请输入 SHELX 授权信息以安装": "Enter SHELX authorization details to install", - "无法启动,请核对平台与运行库": "Unable to start; check the platform and runtime" + "无法启动,请核对平台与运行库": "Unable to start; check the platform and runtime", + "衍射数据处理、结构求解、精修与三维晶体研究工作台": "Diffraction data processing, structure solution, refinement and a 3D crystallography workbench" } From 4dde7ae554e7d4c409b3e5d40d9d8f807d30a231 Mon Sep 17 00:00:00 2001 From: aHappend <228031504+aHappend@users.noreply.github.com> Date: Thu, 10 Sep 2026 11:26:51 +0000 Subject: [PATCH 3/3] Keep front-door execution guidance within the prompt budget --- argus_skill/release_manifest.json | 4 +-- argus_skill/roles/prompts/manager.py | 15 ++++----- frontend/core/src/release.generated.ts | 4 +-- frontend/tui/bundle/argus.mjs | 2 +- frontend/web/dist/assets/MapPanel-DOAsDr5E.js | 12 +++++++ .../assets/ResearchWorkbenchPanel-DZNe62z_.js | 10 ++++++ frontend/web/dist/assets/index-BmfdUynJ.js | 32 +++++++++++++++++++ frontend/web/dist/assets/play-DT9RZkLC.js | 1 + frontend/web/dist/index.html | 2 +- 9 files changed, 67 insertions(+), 15 deletions(-) create mode 100644 frontend/web/dist/assets/MapPanel-DOAsDr5E.js create mode 100644 frontend/web/dist/assets/ResearchWorkbenchPanel-DZNe62z_.js create mode 100644 frontend/web/dist/assets/index-BmfdUynJ.js create mode 100644 frontend/web/dist/assets/play-DT9RZkLC.js diff --git a/argus_skill/release_manifest.json b/argus_skill/release_manifest.json index 6d7eba544..04dbdd356 100644 --- a/argus_skill/release_manifest.json +++ b/argus_skill/release_manifest.json @@ -1,6 +1,6 @@ { "package_version": "0.1.3", - "release_id": "0.1.3+c89d57853bab4ae4", + "release_id": "0.1.3+dd2c099dcbff094c", "schema_version": 1, - "source_digest": "c89d57853bab4ae42794dc6cc0e348d9338c0440f715efacd88926e0f1ff6445" + "source_digest": "dd2c099dcbff094c07fdb60baec88bfdd9955fa9f820990759d6c06ae236d53d" } diff --git a/argus_skill/roles/prompts/manager.py b/argus_skill/roles/prompts/manager.py index 45c848c30..801587ce3 100644 --- a/argus_skill/roles/prompts/manager.py +++ b/argus_skill/roles/prompts/manager.py @@ -244,15 +244,12 @@ def build_front_door_prompt(text: str, *, active_mission: bool = False) -> str: "task verifiable without network, install, git, publish, background work, " "irreversible effects, or independent review. Supplied-source synthesis may be " "SELF; live research, ambiguity, parallel, or review-sensitive work is TEAM.\n\n" - "SELF_MODE: REPLY=no tools; INSPECT=grounded answer; MICRO=tiny checked mutation; " - "IMPLEMENT=local implementation+tests; DEBUG=diagnosis/fix+tests; " - "REVIEW=local review report; SYNTHESIZE=synthesis " - "from supplied sources. Prefer DEBUG for fixes/regressions; TEAM=NONE. " - "A request to actually inspect data, call tools, calculate or change state is execution work, " - "including a bounded test or acceptance check: do not choose SELF_MODE=REPLY for it. " - "REPLY answers a question from available context; it must not merely describe how you classified a requested action. " - "REPLY is the complete human-facing answer for SELF/REPLY, " - "in the operator's language: lead with the answer in ordinary words; " + "SELF_MODE: REPLY=context-only, no tools; INSPECT=grounded answer; " + "MICRO=checked mutation; IMPLEMENT=code+tests; DEBUG=diagnosis/fix+tests; " + "REVIEW=local review; SYNTHESIZE=supplied sources; TEAM=NONE. " + "Prefer DEBUG for fixes. Data/tool use, calculations, mutations and tests/acceptance " + "require execution, not REPLY. REPLY is the complete human-facing answer " + "in the operator's language; " "never expose route, control, lifetime, or role-protocol labels.\n\n" f"{RESEARCHER_VOICE_BRIEF}\n\n" "LIFETIME: TEAM: default BOUNDED for finite or casual unscoped work absent " diff --git a/frontend/core/src/release.generated.ts b/frontend/core/src/release.generated.ts index 5446af4b2..ffc6edf0f 100644 --- a/frontend/core/src/release.generated.ts +++ b/frontend/core/src/release.generated.ts @@ -1,3 +1,3 @@ // Generated by argus_skill.release_tools.generate_manifest. Do not edit. -export const RELEASE_ID = "0.1.3+c89d57853bab4ae4"; -export const RELEASE_SOURCE_DIGEST = "c89d57853bab4ae42794dc6cc0e348d9338c0440f715efacd88926e0f1ff6445"; +export const RELEASE_ID = "0.1.3+dd2c099dcbff094c"; +export const RELEASE_SOURCE_DIGEST = "dd2c099dcbff094c07fdb60baec88bfdd9955fa9f820990759d6c06ae236d53d"; diff --git a/frontend/tui/bundle/argus.mjs b/frontend/tui/bundle/argus.mjs index 1db45f5c4..11a43a845 100644 --- a/frontend/tui/bundle/argus.mjs +++ b/frontend/tui/bundle/argus.mjs @@ -121,7 +121,7 @@ Read about how to prevent this error on https://github.com/vadimdemedes/ink/#isr Read about how to prevent this error on https://github.com/vadimdemedes/ink/#israwmodesupported`);if(r.setEncoding("utf8"),t){this.rawModeEnabledCount===0&&(r.ref(),r.setRawMode(!0),r.addListener("readable",this.handleReadable)),this.rawModeEnabledCount++;return}--this.rawModeEnabledCount===0&&(r.setRawMode(!1),r.removeListener("readable",this.handleReadable),r.unref())};handleReadable=()=>{let t;for(;(t=this.props.stdin.read())!==null;)this.handleInput(t),this.internal_eventEmitter.emit("input",t)};handleInput=t=>{t===""&&this.props.exitOnCtrlC&&this.handleExit(),t===ab&&this.state.activeFocusId&&this.setState({activeFocusId:void 0}),this.state.isFocusEnabled&&this.state.focusables.length>0&&(t===ib&&this.focusNext(),t===sb&&this.focusPrevious())};handleExit=t=>{this.isRawModeSupported()&&this.handleSetRawMode(!1),this.props.onExit(t)};enableFocus=()=>{this.setState({isFocusEnabled:!0})};disableFocus=()=>{this.setState({isFocusEnabled:!1})};focus=t=>{this.setState(r=>r.focusables.some(s=>s?.id===t)?{activeFocusId:t}:r)};focusNext=()=>{this.setState(t=>{let r=t.focusables.find(s=>s.isActive)?.id;return{activeFocusId:this.findNextFocusable(t)??r}})};focusPrevious=()=>{this.setState(t=>{let r=t.focusables.findLast(s=>s.isActive)?.id;return{activeFocusId:this.findPreviousFocusable(t)??r}})};addFocusable=(t,{autoFocus:r})=>{this.setState(i=>{let s=i.activeFocusId;return!s&&r&&(s=t),{activeFocusId:s,focusables:[...i.focusables,{id:t,isActive:!0}]}})};removeFocusable=t=>{this.setState(r=>({activeFocusId:r.activeFocusId===t?void 0:r.activeFocusId,focusables:r.focusables.filter(i=>i.id!==t)}))};activateFocusable=t=>{this.setState(r=>({focusables:r.focusables.map(i=>i.id!==t?i:{id:t,isActive:!0})}))};deactivateFocusable=t=>{this.setState(r=>({activeFocusId:r.activeFocusId===t?void 0:r.activeFocusId,focusables:r.focusables.map(i=>i.id!==t?i:{id:t,isActive:!1})}))};findNextFocusable=t=>{let r=t.focusables.findIndex(i=>i.id===t.activeFocusId);for(let i=r+1;i{let r=t.focusables.findIndex(i=>i.id===t.activeFocusId);for(let i=r-1;i>=0;i--){let s=t.focusables[i];if(s?.isActive)return s.id}}};var hy=()=>{},xf=class{options;log;throttledLog;isUnmounted;lastOutput;container;rootNode;fullStaticOutput;exitPromise;restoreConsole;unsubscribeResize;constructor(t){FE(this),this.options=t,this.rootNode=Id("ink-root"),this.rootNode.onComputeLayout=this.calculateLayout,this.rootNode.onRender=t.debug?this.onRender:Zg(this.onRender,32,{leading:!0,trailing:!0}),this.rootNode.onImmediateRender=this.onRender,this.log=zD.create(t.stdout),this.throttledLog=t.debug?this.log:Zg(this.log,void 0,{leading:!0,trailing:!0}),this.isUnmounted=!1,this.lastOutput="",this.fullStaticOutput="",this.container=ZA.createContainer(this.rootNode,0,null,!1,null,"id",()=>{},null),this.unsubscribeExit=(0,By.default)(this.unmount,{alwaysLast:!1}),Ab.env.DEV==="true"&&ZA.injectIntoDevTools({bundleType:0,version:"16.13.1",rendererPackageName:"ink"}),t.patchConsole&&this.patchConsole(),HA||(t.stdout.on("resize",this.resized),this.unsubscribeResize=()=>{t.stdout.off("resize",this.resized)})}resized=()=>{this.calculateLayout(),this.onRender()};resolveExitPromise=()=>{};rejectExitPromise=()=>{};unsubscribeExit=()=>{};calculateLayout=()=>{let t=this.options.stdout.columns||80;this.rootNode.yogaNode.setWidth(t),this.rootNode.yogaNode.calculateLayout(void 0,void 0,it.DIRECTION_LTR)};onRender=()=>{if(this.isUnmounted)return;let{output:t,outputHeight:r,staticOutput:i}=GD(this.rootNode),s=i&&i!==` `;if(this.options.debug){s&&(this.fullStaticOutput+=i),this.options.stdout.write(this.fullStaticOutput+t);return}if(HA){s&&this.options.stdout.write(i),this.lastOutput=t;return}if(s&&(this.fullStaticOutput+=i),r>=this.options.stdout.rows){this.options.stdout.write(Mo.clearTerminal+this.fullStaticOutput+t),this.lastOutput=t;return}s&&(this.log.clear(),this.options.stdout.write(i),this.log(t)),!s&&t!==this.lastOutput&&this.throttledLog(t),this.lastOutput=t};render(t){let r=Cy.default.createElement(kf,{stdin:this.options.stdin,stdout:this.options.stdout,stderr:this.options.stderr,writeToStdout:this.writeToStdout,writeToStderr:this.writeToStderr,exitOnCtrlC:this.options.exitOnCtrlC,onExit:this.unmount},t);ZA.updateContainer(r,this.container,null,hy)}writeToStdout(t){if(!this.isUnmounted){if(this.options.debug){this.options.stdout.write(t+this.fullStaticOutput+this.lastOutput);return}if(HA){this.options.stdout.write(t);return}this.log.clear(),this.options.stdout.write(t),this.log(this.lastOutput)}}writeToStderr(t){if(!this.isUnmounted){if(this.options.debug){this.options.stderr.write(t),this.options.stdout.write(this.fullStaticOutput+this.lastOutput);return}if(HA){this.options.stderr.write(t);return}this.log.clear(),this.options.stderr.write(t),this.log(this.lastOutput)}}unmount(t){this.isUnmounted||(this.calculateLayout(),this.onRender(),this.unsubscribeExit(),typeof this.restoreConsole=="function"&&this.restoreConsole(),typeof this.unsubscribeResize=="function"&&this.unsubscribeResize(),HA?this.options.stdout.write(this.lastOutput+` `):this.options.debug||this.log.done(),this.isUnmounted=!0,ZA.updateContainer(null,this.container,null,hy),Tu.delete(this.options.stdout),t instanceof Error?this.rejectExitPromise(t):this.resolveExitPromise())}async waitUntilExit(){return this.exitPromise||=new Promise((t,r)=>{this.resolveExitPromise=t,this.rejectExitPromise=r}),this.exitPromise}clear(){!HA&&!this.options.debug&&this.log.clear()}patchConsole(){this.options.debug||(this.restoreConsole=aC((t,r)=>{t==="stdout"&&this.writeToStdout(r),t==="stderr"&&(r.startsWith("The above error occurred")||this.writeToStderr(r))}))}};var ub=(e,t)=>{let r={stdout:Zd.stdout,stdin:Zd.stdin,stderr:Zd.stderr,debug:!1,exitOnCtrlC:!0,patchConsole:!0,...cb(t)},i=fb(r.stdout,()=>new xf(r));return i.render(e),{rerender:i.render,unmount(){i.unmount()},waitUntilExit:i.waitUntilExit,cleanup:()=>Tu.delete(r.stdout),clear:i.clear}},Zm=ub,cb=(e={})=>e instanceof lb?{stdout:e,stdin:Zd.stdin}:e,fb=(e,t)=>{let r=Tu.get(e);return r||(r=t(),Tu.set(e,r)),r};var fa=Le($t(),1);function Nf(e){let{items:t,children:r,style:i}=e,[s,a]=(0,fa.useState)(0),u=(0,fa.useMemo)(()=>t.slice(s),[t,s]);(0,fa.useLayoutEffect)(()=>{a(t.length)},[t.length]);let E=u.map((h,y)=>r(h,s+y)),m=(0,fa.useMemo)(()=>({position:"absolute",flexDirection:"column",...i}),[i]);return fa.default.createElement("ink-box",{internal_static:!0,style:m},E)}var gb=Le($t(),1);var db=Le($t(),1);var pb=Le($t(),1);var eI=Le($t(),1);import{Buffer as Eb}from"node:buffer";var mb=/^(?:\x1b)([a-zA-Z0-9])$/,Ib=/^(?:\x1b+)(O|N|\[|\[\[)(?:(\d+)(?:;(\d+))?([~^$])|(?:1;)?(\d+)?([a-zA-Z]))/,Dy={OP:"f1",OQ:"f2",OR:"f3",OS:"f4","[11~":"f1","[12~":"f2","[13~":"f3","[14~":"f4","[[A":"f1","[[B":"f2","[[C":"f3","[[D":"f4","[[E":"f5","[15~":"f5","[17~":"f6","[18~":"f7","[19~":"f8","[20~":"f9","[21~":"f10","[23~":"f11","[24~":"f12","[A":"up","[B":"down","[C":"right","[D":"left","[E":"clear","[F":"end","[H":"home",OA:"up",OB:"down",OC:"right",OD:"left",OE:"clear",OF:"end",OH:"home","[1~":"home","[2~":"insert","[3~":"delete","[4~":"end","[5~":"pageup","[6~":"pagedown","[[5~":"pageup","[[6~":"pagedown","[7~":"home","[8~":"end","[a":"up","[b":"down","[c":"right","[d":"left","[e":"clear","[2$":"insert","[3$":"delete","[5$":"pageup","[6$":"pagedown","[7$":"home","[8$":"end",Oa:"up",Ob:"down",Oc:"right",Od:"left",Oe:"clear","[2^":"insert","[3^":"delete","[5^":"pageup","[6^":"pagedown","[7^":"home","[8^":"end","[Z":"tab"},yy=[...Object.values(Dy),"backspace"],hb=e=>["[a","[b","[c","[d","[e","[2$","[3$","[5$","[6$","[7$","[8$","[Z"].includes(e),Cb=e=>["Oa","Ob","Oc","Od","Oe","[2^","[3^","[5^","[6^","[7^","[8^"].includes(e),Bb=(e="")=>{let t;Eb.isBuffer(e)?e[0]>127&&e[1]===void 0?(e[0]-=128,e="\x1B"+String(e)):e=String(e):e!==void 0&&typeof e!="string"?e=String(e):e||(e="");let r={name:"",ctrl:!1,meta:!1,shift:!1,option:!1,sequence:e,raw:e};if(r.sequence=r.sequence||e||r.name,e==="\r")r.raw=void 0,r.name="return";else if(e===` -`)r.name="enter";else if(e===" ")r.name="tab";else if(e==="\b"||e==="\x1B\b")r.name="backspace",r.meta=e.charAt(0)==="\x1B";else if(e==="\x7F"||e==="\x1B\x7F")r.name="delete",r.meta=e.charAt(0)==="\x1B";else if(e==="\x1B"||e==="\x1B\x1B")r.name="escape",r.meta=e.length===2;else if(e===" "||e==="\x1B ")r.name="space",r.meta=e.length===2;else if(e.length===1&&e<="")r.name=String.fromCharCode(e.charCodeAt(0)+97-1),r.ctrl=!0;else if(e.length===1&&e>="0"&&e<="9")r.name="number";else if(e.length===1&&e>="a"&&e<="z")r.name=e;else if(e.length===1&&e>="A"&&e<="Z")r.name=e.toLowerCase(),r.shift=!0;else if(t=mb.exec(e))r.meta=!0,r.shift=/^[A-Z]$/.test(t[1]);else if(t=Ib.exec(e)){let i=[...e];i[0]==="\x1B"&&i[1]==="\x1B"&&(r.option=!0);let s=[t[1],t[2],t[4],t[6]].filter(Boolean).join(""),a=(t[3]||t[5]||1)-1;r.ctrl=!!(a&4),r.meta=!!(a&10),r.shift=!!(a&1),r.code=s,r.name=Dy[s],r.shift=hb(s)||r.shift,r.ctrl=Cb(s)||r.ctrl}return r},Qy=Bb;var wy=Le($t(),1);var Db=()=>(0,wy.useContext)(Vd),ep=Db;var yb=(e,t={})=>{let{stdin:r,setRawMode:i,internal_exitOnCtrlC:s,internal_eventEmitter:a}=ep();(0,eI.useEffect)(()=>{if(t.isActive!==!1)return i(!0),()=>{i(!1)}},[t.isActive,i]),(0,eI.useEffect)(()=>{if(t.isActive===!1)return;let u=E=>{let m=Qy(E),h={upArrow:m.name==="up",downArrow:m.name==="down",leftArrow:m.name==="left",rightArrow:m.name==="right",pageDown:m.name==="pagedown",pageUp:m.name==="pageup",return:m.name==="return",escape:m.name==="escape",ctrl:m.ctrl,shift:m.shift,tab:m.name==="tab",backspace:m.name==="backspace",delete:m.name==="delete",meta:m.meta||m.name==="escape"||m.option},y=m.ctrl?m.name:m.sequence;yy.includes(m.name)&&(y=""),y.startsWith("\x1B")&&(y=y.slice(1)),y.length===1&&typeof y[0]=="string"&&/[A-Z]/.test(y[0])&&(h.shift=!0),(!(y==="c"&&h.ctrl)||!s)&&ZA.batchedUpdates(()=>{e(y,h)})};return a?.on("input",u),()=>{a?.removeListener("input",u)}},[t.isActive,r,s,e])},ls=yb;var vy=Le($t(),1);var Qb=()=>(0,vy.useContext)(Yd),ga=Qb;var Sy=Le($t(),1);var wb=()=>(0,Sy.useContext)(qd),da=wb;var vb=Le($t(),1);var tI=Le($t(),1);var Sb=Le($t(),1);bm();import{randomUUID as np}from"node:crypto";import{homedir as Lb}from"node:os";import{posix as Mb,win32 as aI}from"node:path";var rI=class extends Error{status;method;path;constructor(t,r,i,s){super(t),this.name="ApiError",this.status=r,this.method=i,this.path=s}};function _b(e){let t=e.replace(/\s+/g," ").trim();if(!t)return"";try{let r=JSON.parse(e);for(let i of["detail","error","message"]){let s=r[i];if(typeof s=="string"&&s.trim())return s.trim();if(Array.isArray(s)){let a=s.map(u=>u&&typeof u=="object"?String(u.msg??""):"").filter(Boolean);if(a.length)return a.join("; ")}}}catch{}return t.startsWith("typeof D=="string"):[],u=nI(i?.major),E=nI(i?.minor);if(!r||!i||!s)return{compatible:!1,reason:"malformed /api/meta response"};if(typeof s.source_root!="string"||nI(s.pid)===null||typeof s.package_version!="string"||typeof s.release_id!="string")return{compatible:!1,reason:"malformed /api/meta runtime identity"};if(r.service!==bb)return{compatible:!1,reason:`unexpected service ${String(r.service||"unknown")}`};let m=e;if(i.name!==Ou.name||u!==Ou.major)return{compatible:!1,reason:`protocol ${String(i.name||"unknown")}/${String(u)} is incompatible with client ${Ou.name}/${Ou.major}`,meta:m};if(E===null||E!a.includes(D));if(h.length>0)return{compatible:!1,reason:`missing capabilities: ${h.join(", ")}`,meta:m};if(s.source_root_matches_config===!1)return{compatible:!1,reason:"backend is running from a different installation than configured",meta:m};if(s.release_id!==t.releaseId)return{compatible:!1,reason:"backend and client installations are out of sync; restart or reinstall Argus",meta:m};if(t.sourceDigest){if(typeof s.runtime_source_digest!="string"||!s.runtime_source_digest)return{compatible:!1,reason:"backend cannot verify this local installation; restart it from the current checkout",meta:m};if(s.runtime_source_digest!==t.sourceDigest)return{compatible:!1,reason:"backend is running code from a different local installation; restart it",meta:m}}return{compatible:!0,reason:"",warning:s.release_matches_source===!1?oI:void 0,meta:m}}function Ry(e,t){let r=iI(e);if(!r.compatible||!r.meta)throw new Error(`incompatible Argus API: ${r.reason}`);return r.warning&&t?.(r.warning),r.meta}function by(e){let t=Tf(e),r=Tf(t?.daemon);if(!t||t.schema_version!==rp)throw new Error(`incompatible snapshot schema: expected ${rp}, got ${String(t?.schema_version??"missing")}`);if(!r)throw new Error("invalid snapshot: daemon section is missing");let s=["global_daily_cap_usd","read_status","read_error","protocol_compatible","protocol_error"].filter(E=>!Object.hasOwn(r,E));if(s.length>0)throw new Error(`invalid snapshot: daemon fields missing: ${s.join(", ")}`);let u=["spend_usd","spend_status","usage_summary","request_usage","cost_control","daemon_commands","observability","mission_view","partial","diagnostics"].filter(E=>!Object.hasOwn(t,E));if(u.length>0)throw new Error(`invalid snapshot: fields missing: ${u.join(", ")}`);if(!Array.isArray(t.diagnostics))throw new Error("invalid snapshot: diagnostics must be an array");return e}function sI(e){let t=typeof e=="string"||e instanceof URL?String(e):e.url;try{let r=new URL(t);return r.username="",r.password="",r.searchParams.has("token")&&r.searchParams.set("token","[redacted]"),r.toString()}catch{return t}}function el(e,t){return typeof e=="object"&&e!==null?e[t]:void 0}function kb(e){let t=el(e,"cause"),r=new Set;for(;el(t,"cause")&&!r.has(t);)r.add(t),t=el(t,"cause");return t??e}function xb(e,t,r="GET"){let i=kb(e),s=String(el(i,"code")??"").trim(),a=String(el(i,"address")??"").trim(),u=String(el(i,"port")??"").trim(),E=a&&u?`${a}:${u}`:a,m=i instanceof Error?i.message.trim():String(i??"").trim(),h=e instanceof Error?e.message.trim():String(e??"").trim(),y;return s==="ECONNREFUSED"?y=`connection refused${E?` by ${E}`:""}`:s==="ECONNRESET"?y="connection reset by the local service":s==="ETIMEDOUT"?y="connection timed out":s==="ENOTFOUND"?y="host name could not be resolved":m&&m!==h?y=m:y=h||"network request failed",`${r.toUpperCase()} ${sI(t)} failed: ${y}${s?` (${s})`:""}`}function Fy(e){return e%1e3===0?`${e/1e3}s`:`${e}ms`}async function Nb(e,t,r,i,s){let a=Number.isFinite(r)&&r>0?Math.max(1,Math.trunc(r)):1,u=new AbortController,E=t.signal,m=!1,h=!1,y=()=>u.abort(E?.reason);E?.aborted?y():E?.addEventListener("abort",y,{once:!0});let D=(async()=>{let G=await fetch(e,{...t,signal:u.signal});return h=!0,await s(G)})(),_,O=new Promise((G,re)=>{_=setTimeout(()=>{m=!0;let ne=new Error(`request timed out after ${Fy(a)}`);u.abort(ne),re(ne)},a)});try{return await Promise.race([D,O])}catch(G){throw m?new Error(`${i.toUpperCase()} ${sI(e)} timed out after ${Fy(a)}; the local Argus service did not respond`,{cause:G}):E?.aborted?E.reason instanceof Error?E.reason:new Error(`${i.toUpperCase()} ${sI(e)} was aborted`,{cause:G}):h&&el(G,"cause")===void 0?G:new Error(xb(G,e,i),{cause:G})}finally{_&&clearTimeout(_),E?.removeEventListener("abort",y)}}function pa(e,t,r,i,s=t.method??"GET"){return Nb(e,t,r,s,i)}function Pb(e,t=Lb()){let r=E=>E.includes("\\")||/^[A-Za-z]:[\\/]/.test(E),i=r(e)?aI:Mb,s=i.resolve(e),a=E=>i===aI?E.toLowerCase():E,u=r(t)===(i===aI)?a(i.resolve(t)):"";if(!(a(s)===u||a(s)===a(i.parse(s).root)))return s}function Ub(e,t=""){let r=t.trim();return e===4401?{code:e,reason:r||"event stream authentication was rejected",retryable:!1}:e===4404?{code:e,reason:r||"the selected project no longer exists",retryable:!1}:{code:e,reason:r,retryable:!0}}function AI(e){let t=e.item?.title||"new mission";return e.daemon?.admission_required?`\u2192 queued: choose one running session to park before starting ${t}`:e.daemon&&e.daemon.rc!==0?`\u2192 queued but not running: ${e.daemon.error||"background executor failed to start"}`:`\u2192 dispatched to the team: ${t}`}function ky(e){let t=[],r;for(;(r=e.indexOf(` +`)r.name="enter";else if(e===" ")r.name="tab";else if(e==="\b"||e==="\x1B\b")r.name="backspace",r.meta=e.charAt(0)==="\x1B";else if(e==="\x7F"||e==="\x1B\x7F")r.name="delete",r.meta=e.charAt(0)==="\x1B";else if(e==="\x1B"||e==="\x1B\x1B")r.name="escape",r.meta=e.length===2;else if(e===" "||e==="\x1B ")r.name="space",r.meta=e.length===2;else if(e.length===1&&e<="")r.name=String.fromCharCode(e.charCodeAt(0)+97-1),r.ctrl=!0;else if(e.length===1&&e>="0"&&e<="9")r.name="number";else if(e.length===1&&e>="a"&&e<="z")r.name=e;else if(e.length===1&&e>="A"&&e<="Z")r.name=e.toLowerCase(),r.shift=!0;else if(t=mb.exec(e))r.meta=!0,r.shift=/^[A-Z]$/.test(t[1]);else if(t=Ib.exec(e)){let i=[...e];i[0]==="\x1B"&&i[1]==="\x1B"&&(r.option=!0);let s=[t[1],t[2],t[4],t[6]].filter(Boolean).join(""),a=(t[3]||t[5]||1)-1;r.ctrl=!!(a&4),r.meta=!!(a&10),r.shift=!!(a&1),r.code=s,r.name=Dy[s],r.shift=hb(s)||r.shift,r.ctrl=Cb(s)||r.ctrl}return r},Qy=Bb;var wy=Le($t(),1);var Db=()=>(0,wy.useContext)(Vd),ep=Db;var yb=(e,t={})=>{let{stdin:r,setRawMode:i,internal_exitOnCtrlC:s,internal_eventEmitter:a}=ep();(0,eI.useEffect)(()=>{if(t.isActive!==!1)return i(!0),()=>{i(!1)}},[t.isActive,i]),(0,eI.useEffect)(()=>{if(t.isActive===!1)return;let u=E=>{let m=Qy(E),h={upArrow:m.name==="up",downArrow:m.name==="down",leftArrow:m.name==="left",rightArrow:m.name==="right",pageDown:m.name==="pagedown",pageUp:m.name==="pageup",return:m.name==="return",escape:m.name==="escape",ctrl:m.ctrl,shift:m.shift,tab:m.name==="tab",backspace:m.name==="backspace",delete:m.name==="delete",meta:m.meta||m.name==="escape"||m.option},y=m.ctrl?m.name:m.sequence;yy.includes(m.name)&&(y=""),y.startsWith("\x1B")&&(y=y.slice(1)),y.length===1&&typeof y[0]=="string"&&/[A-Z]/.test(y[0])&&(h.shift=!0),(!(y==="c"&&h.ctrl)||!s)&&ZA.batchedUpdates(()=>{e(y,h)})};return a?.on("input",u),()=>{a?.removeListener("input",u)}},[t.isActive,r,s,e])},ls=yb;var vy=Le($t(),1);var Qb=()=>(0,vy.useContext)(Yd),ga=Qb;var Sy=Le($t(),1);var wb=()=>(0,Sy.useContext)(qd),da=wb;var vb=Le($t(),1);var tI=Le($t(),1);var Sb=Le($t(),1);bm();import{randomUUID as np}from"node:crypto";import{homedir as Lb}from"node:os";import{posix as Mb,win32 as aI}from"node:path";var rI=class extends Error{status;method;path;constructor(t,r,i,s){super(t),this.name="ApiError",this.status=r,this.method=i,this.path=s}};function _b(e){let t=e.replace(/\s+/g," ").trim();if(!t)return"";try{let r=JSON.parse(e);for(let i of["detail","error","message"]){let s=r[i];if(typeof s=="string"&&s.trim())return s.trim();if(Array.isArray(s)){let a=s.map(u=>u&&typeof u=="object"?String(u.msg??""):"").filter(Boolean);if(a.length)return a.join("; ")}}}catch{}return t.startsWith("typeof D=="string"):[],u=nI(i?.major),E=nI(i?.minor);if(!r||!i||!s)return{compatible:!1,reason:"malformed /api/meta response"};if(typeof s.source_root!="string"||nI(s.pid)===null||typeof s.package_version!="string"||typeof s.release_id!="string")return{compatible:!1,reason:"malformed /api/meta runtime identity"};if(r.service!==bb)return{compatible:!1,reason:`unexpected service ${String(r.service||"unknown")}`};let m=e;if(i.name!==Ou.name||u!==Ou.major)return{compatible:!1,reason:`protocol ${String(i.name||"unknown")}/${String(u)} is incompatible with client ${Ou.name}/${Ou.major}`,meta:m};if(E===null||E!a.includes(D));if(h.length>0)return{compatible:!1,reason:`missing capabilities: ${h.join(", ")}`,meta:m};if(s.source_root_matches_config===!1)return{compatible:!1,reason:"backend is running from a different installation than configured",meta:m};if(s.release_id!==t.releaseId)return{compatible:!1,reason:"backend and client installations are out of sync; restart or reinstall Argus",meta:m};if(t.sourceDigest){if(typeof s.runtime_source_digest!="string"||!s.runtime_source_digest)return{compatible:!1,reason:"backend cannot verify this local installation; restart it from the current checkout",meta:m};if(s.runtime_source_digest!==t.sourceDigest)return{compatible:!1,reason:"backend is running code from a different local installation; restart it",meta:m}}return{compatible:!0,reason:"",warning:s.release_matches_source===!1?oI:void 0,meta:m}}function Ry(e,t){let r=iI(e);if(!r.compatible||!r.meta)throw new Error(`incompatible Argus API: ${r.reason}`);return r.warning&&t?.(r.warning),r.meta}function by(e){let t=Tf(e),r=Tf(t?.daemon);if(!t||t.schema_version!==rp)throw new Error(`incompatible snapshot schema: expected ${rp}, got ${String(t?.schema_version??"missing")}`);if(!r)throw new Error("invalid snapshot: daemon section is missing");let s=["global_daily_cap_usd","read_status","read_error","protocol_compatible","protocol_error"].filter(E=>!Object.hasOwn(r,E));if(s.length>0)throw new Error(`invalid snapshot: daemon fields missing: ${s.join(", ")}`);let u=["spend_usd","spend_status","usage_summary","request_usage","cost_control","daemon_commands","observability","mission_view","partial","diagnostics"].filter(E=>!Object.hasOwn(t,E));if(u.length>0)throw new Error(`invalid snapshot: fields missing: ${u.join(", ")}`);if(!Array.isArray(t.diagnostics))throw new Error("invalid snapshot: diagnostics must be an array");return e}function sI(e){let t=typeof e=="string"||e instanceof URL?String(e):e.url;try{let r=new URL(t);return r.username="",r.password="",r.searchParams.has("token")&&r.searchParams.set("token","[redacted]"),r.toString()}catch{return t}}function el(e,t){return typeof e=="object"&&e!==null?e[t]:void 0}function kb(e){let t=el(e,"cause"),r=new Set;for(;el(t,"cause")&&!r.has(t);)r.add(t),t=el(t,"cause");return t??e}function xb(e,t,r="GET"){let i=kb(e),s=String(el(i,"code")??"").trim(),a=String(el(i,"address")??"").trim(),u=String(el(i,"port")??"").trim(),E=a&&u?`${a}:${u}`:a,m=i instanceof Error?i.message.trim():String(i??"").trim(),h=e instanceof Error?e.message.trim():String(e??"").trim(),y;return s==="ECONNREFUSED"?y=`connection refused${E?` by ${E}`:""}`:s==="ECONNRESET"?y="connection reset by the local service":s==="ETIMEDOUT"?y="connection timed out":s==="ENOTFOUND"?y="host name could not be resolved":m&&m!==h?y=m:y=h||"network request failed",`${r.toUpperCase()} ${sI(t)} failed: ${y}${s?` (${s})`:""}`}function Fy(e){return e%1e3===0?`${e/1e3}s`:`${e}ms`}async function Nb(e,t,r,i,s){let a=Number.isFinite(r)&&r>0?Math.max(1,Math.trunc(r)):1,u=new AbortController,E=t.signal,m=!1,h=!1,y=()=>u.abort(E?.reason);E?.aborted?y():E?.addEventListener("abort",y,{once:!0});let D=(async()=>{let G=await fetch(e,{...t,signal:u.signal});return h=!0,await s(G)})(),_,O=new Promise((G,re)=>{_=setTimeout(()=>{m=!0;let ne=new Error(`request timed out after ${Fy(a)}`);u.abort(ne),re(ne)},a)});try{return await Promise.race([D,O])}catch(G){throw m?new Error(`${i.toUpperCase()} ${sI(e)} timed out after ${Fy(a)}; the local Argus service did not respond`,{cause:G}):E?.aborted?E.reason instanceof Error?E.reason:new Error(`${i.toUpperCase()} ${sI(e)} was aborted`,{cause:G}):h&&el(G,"cause")===void 0?G:new Error(xb(G,e,i),{cause:G})}finally{_&&clearTimeout(_),E?.removeEventListener("abort",y)}}function pa(e,t,r,i,s=t.method??"GET"){return Nb(e,t,r,s,i)}function Pb(e,t=Lb()){let r=E=>E.includes("\\")||/^[A-Za-z]:[\\/]/.test(E),i=r(e)?aI:Mb,s=i.resolve(e),a=E=>i===aI?E.toLowerCase():E,u=r(t)===(i===aI)?a(i.resolve(t)):"";if(!(a(s)===u||a(s)===a(i.parse(s).root)))return s}function Ub(e,t=""){let r=t.trim();return e===4401?{code:e,reason:r||"event stream authentication was rejected",retryable:!1}:e===4404?{code:e,reason:r||"the selected project no longer exists",retryable:!1}:{code:e,reason:r,retryable:!0}}function AI(e){let t=e.item?.title||"new mission";return e.daemon?.admission_required?`\u2192 queued: choose one running session to park before starting ${t}`:e.daemon&&e.daemon.rc!==0?`\u2192 queued but not running: ${e.daemon.error||"background executor failed to start"}`:`\u2192 dispatched to the team: ${t}`}function ky(e){let t=[],r;for(;(r=e.indexOf(` `))>=0;){let i=e.slice(0,r);e=e.slice(r+2);for(let s of i.split(` `)){let a=s.trim();if(a.startsWith("data:"))try{t.push(JSON.parse(a.slice(5).trim()))}catch{}}}return{frames:t,rest:e}}var us=class{httpBase;wsBase;project;token;onCompatibilityWarning;metaTimeoutMs;readTimeoutMs;metaPromise;constructor(t){this.httpBase=`http://${t.host}:${t.port}`,this.wsBase=`ws://${t.host}:${t.port}`,this.project=t.project,this.token=t.token,this.onCompatibilityWarning=t.onCompatibilityWarning,this.metaTimeoutMs=t.metaTimeoutMs??8e3,this.readTimeoutMs=t.readTimeoutMs??12e3}authHeaders(){return this.token?{Authorization:`Bearer ${this.token}`}:{}}p(t){return`${this.httpBase}/api/projects/${encodeURIComponent(this.project)}${t}`}meta(){if(!this.metaPromise){let t="/api/meta",r=pa(`${this.httpBase}${t}`,{headers:this.authHeaders()},this.metaTimeoutMs,async i=>{if(i.status===404)throw new Error("incompatible Argus API: service does not expose /api/meta");return await io(i,"GET",t),Ry(await i.json(),this.onCompatibilityWarning)});this.metaPromise=r,r.catch(()=>{this.metaPromise===r&&(this.metaPromise=void 0)})}return this.metaPromise}async listProjects(){return await this.meta(),pa(`${this.httpBase}/api/projects`,{headers:this.authHeaders()},this.readTimeoutMs,async t=>(await io(t,"GET","/api/projects"),(await t.json()).projects))}async createDaemon(t="",r="",i=process.cwd(),s,a=np()){let u="/api/daemons",E=Pb(i),m={objective:t,name:r,launch_cwd:i,command_id:a,expected_revision:s};E&&(m.workdir=E);let h=JSON.stringify(m),y=()=>fetch(`${this.httpBase}${u}`,{method:"POST",headers:{"Content-Type":"application/json",Connection:"close",...this.authHeaders()},body:h}),D=await y();return D.status===400&&/Invalid HTTP request received/i.test(await D.clone().text())&&(D=await y()),await io(D,"POST",u),await D.json()}async replaceDaemon(t,r=!1,i,s=np()){return await this.post("/daemon/replace",{victim_sid:t,resume_continuous:r,command_id:s,expected_revision:i})}async scheduleDaemonUpgrade(t,r,i=np()){let s=`/api/projects/${encodeURIComponent(t)}/daemon/upgrade-schedule`,a=await fetch(`${this.httpBase}${s}`,{method:"POST",headers:{"Content-Type":"application/json",...this.authHeaders()},body:JSON.stringify({command_id:i,expected_revision:r})});return await io(a,"POST",s),await a.json()}stopDaemon(t=np()){let r="/daemon/stop";return pa(this.p(r),{method:"POST",headers:{"Content-Type":"application/json",...this.authHeaders()},body:JSON.stringify({force:!1,drain:!1,command_id:t})},this.readTimeoutMs,async i=>{await io(i,"POST",r);let s=await i.json(),a=Number(s.rc??0);if(!Number.isFinite(a)||![0,1].includes(a)){let u=String(s.error??s.message??`rc=${String(s.rc??"unknown")}`);throw new Error(`executor did not stop cleanly: ${u}`)}return s})}async setProjectLaunchCwd(t,r){let i=`/api/projects/${encodeURIComponent(t)}/launch-cwd`,s=await fetch(`${this.httpBase}${i}`,{method:"POST",headers:{"Content-Type":"application/json",...this.authHeaders()},body:JSON.stringify({launch_cwd:r})});await io(s,"POST",i)}async setProjectWorkdir(t,r){let i=`/api/projects/${encodeURIComponent(t)}/workdir`,s=await fetch(`${this.httpBase}${i}`,{method:"POST",headers:{"Content-Type":"application/json",...this.authHeaders()},body:JSON.stringify({workdir:r})});await io(s,"POST",i)}async renameProject(t){let r=this.p(""),i=await fetch(r,{method:"PATCH",headers:{"Content-Type":"application/json",...this.authHeaders()},body:JSON.stringify({name:t})});return await io(i,"PATCH",r),await i.json()}async snapshot(t=1,r,i=!1){return await this.meta(),pa(this.p(`/snapshot?compact=true&events_limit=${t}`+(i?"&prewarm=true":"")),{headers:this.authHeaders(),signal:r},this.readTimeoutMs,async s=>(await io(s,"GET","/snapshot"),by(await s.json())))}async postTask(t){let r=await fetch(this.p("/tasks"),{method:"POST",headers:{"Content-Type":"application/json",...this.authHeaders()},body:JSON.stringify({text:t})});return await io(r,"POST","/tasks"),(await r.json()).item}async postNudge(t){let r=await fetch(this.p("/nudge"),{method:"POST",headers:{"Content-Type":"application/json",...this.authHeaders()},body:JSON.stringify({text:t})});await io(r,"POST","/nudge")}async message(t,r){let i=await fetch(this.p("/message"),{method:"POST",headers:{"Content-Type":"application/json",...this.authHeaders()},body:JSON.stringify({text:t}),signal:r});return await io(i,"POST","/message"),await i.json()}async messageStream(t,r,i){let s=await fetch(this.p("/message/stream"),{method:"POST",headers:{"Content-Type":"application/json",...this.authHeaders()},body:JSON.stringify({text:t}),signal:i});if(await io(s,"POST","/message/stream"),!s.body)throw new Error("Manager stream returned no response body");let a=h=>{if(!i?.aborted)if(h.type==="phase"){let y=Number(h.quiet_s??0);r.onPhase?.(String(h.label??""),String(h.role??"manager"),{heartbeat:h.heartbeat===!0,quietS:Number.isFinite(y)?y:0,kind:String(h.kind??""),detail:String(h.detail??"")})}else h.type==="delta"?r.onDelta?.(String(h.text??""),String(h.message_id??""),String(h.fragment_mode??"auto")):h.type==="done"?r.onDone?.(h.result??{}):h.type==="error"&&r.onError?.(new Error(String(h.error??"stream error")))},u=s.body.getReader(),E=new TextDecoder,m="";for(;;){let{done:h,value:y}=await u.read();if(h)break;m+=E.decode(y,{stream:!0});let D=ky(m);m=D.rest,D.frames.forEach(a)}i?.aborted||ky(m+` diff --git a/frontend/web/dist/assets/MapPanel-DOAsDr5E.js b/frontend/web/dist/assets/MapPanel-DOAsDr5E.js new file mode 100644 index 000000000..be9a2f5d6 --- /dev/null +++ b/frontend/web/dist/assets/MapPanel-DOAsDr5E.js @@ -0,0 +1,12 @@ +import{r as e,t}from"./rolldown-runtime-hePW80VL.js";import{A as n,k as r}from"./icons-2gFhc0pq.js";import{g as i,i as a,n as o}from"./query-CGMsBv4s.js";import{i as s,r as c}from"./markdown-BtnlLdzu.js";import{n as l,r as u,t as d}from"./play-DT9RZkLC.js";import{A as f,B as p,E as m,F as h,G as g,I as _,L as v,M as y,N as b,O as x,P as S,R as C,S as w,T,_ as E,a as D,b as O,c as k,d as A,f as j,g as M,j as N,k as P,l as F,m as I,n as L,o as R,p as z,r as B,s as V,t as ee,u as te,v as H,w as U,x as W,z as G}from"./index-BmfdUynJ.js";var K=x(`ArrowLeft`,[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]),ne=x(`ChevronLeft`,[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]),re=x(`Compass`,[[`path`,{d:`m16.24 7.76-1.804 5.411a2 2 0 0 1-1.265 1.265L7.76 16.24l1.804-5.411a2 2 0 0 1 1.265-1.265z`,key:`9ktpf1`}],[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),ie=x(`CornerDownLeft`,[[`polyline`,{points:`9 10 4 15 9 20`,key:`r3jprv`}],[`path`,{d:`M20 4v7a4 4 0 0 1-4 4H4`,key:`6o5b7l`}]]),ae=x(`Ellipsis`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`19`,cy:`12`,r:`1`,key:`1wjl8i`}],[`circle`,{cx:`5`,cy:`12`,r:`1`,key:`1pcz8c`}]]),oe=x(`ListChecks`,[[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`path`,{d:`m3 7 2 2 4-4`,key:`1obspn`}],[`path`,{d:`M13 6h8`,key:`15sg57`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 18h8`,key:`oe0vm4`}]]),se=x(`LocateFixed`,[[`line`,{x1:`2`,x2:`5`,y1:`12`,y2:`12`,key:`bvdh0s`}],[`line`,{x1:`19`,x2:`22`,y1:`12`,y2:`12`,key:`1tbv5k`}],[`line`,{x1:`12`,x2:`12`,y1:`2`,y2:`5`,key:`11lu5j`}],[`line`,{x1:`12`,x2:`12`,y1:`19`,y2:`22`,key:`x3vr5v`}],[`circle`,{cx:`12`,cy:`12`,r:`7`,key:`fim9np`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),ce=x(`MessageCircle`,[[`path`,{d:`M7.9 20A9 9 0 1 0 4 16.1L2 22Z`,key:`vv11sd`}]]),le=x(`RotateCcw`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}]]),q=x(`Route`,[[`circle`,{cx:`6`,cy:`19`,r:`3`,key:`1kj8tv`}],[`path`,{d:`M9 19h8.5a3.5 3.5 0 0 0 0-7h-11a3.5 3.5 0 0 1 0-7H15`,key:`1d8sl`}],[`circle`,{cx:`18`,cy:`5`,r:`3`,key:`gq8acd`}]]),ue=x(`Search`,[[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}],[`path`,{d:`m21 21-4.3-4.3`,key:`1qie3q`}]]),de=x(`Settings2`,[[`path`,{d:`M20 7h-9`,key:`3s1dr2`}],[`path`,{d:`M14 17H5`,key:`gfn3mx`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}],[`circle`,{cx:`7`,cy:`7`,r:`3`,key:`dfmy0x`}]]),J=r();function fe({events:e,connected:t,pending:n,artifacts:r,zh:i,onClose:a,onOpenArtifact:o,onOpenDelivery:s}){let c=e.filter(e=>e.type===`ui.operator`||e.type===`ui.argus`);return(0,J.jsxs)(`aside`,{className:`map-conversation nowheel nodrag nopan`,"aria-label":i?`地图对话`:`Map conversation`,children:[(0,J.jsxs)(`header`,{children:[(0,J.jsx)(ce,{size:16}),(0,J.jsx)(`strong`,{children:i?`与 Argus 对话`:`Talk to Argus`}),(0,J.jsx)(`button`,{type:`button`,onClick:a,"aria-label":i?`关闭对话`:`Close conversation`,children:(0,J.jsx)(j,{size:18})})]}),c.length?(0,J.jsx)(S,{events:c,connected:t,showReasoning:!1,onToggleReasoning:()=>{},embedded:!0,showHeader:!1,artifacts:r,onOpenArtifact:o,onOpenDelivery:s}):(0,J.jsx)(`p`,{className:`map-conversation-empty`,children:i?`在下方发送目标或问题,回复会保留在这里。`:`Send a goal or question below. Your conversation stays here.`}),n&&(0,J.jsx)(`p`,{className:`map-conversation-pending`,role:`status`,children:i?`Argus 正在回复…`:`Argus is replying…`})]})}var Y=e(n(),1),pe=g(),me=(e,t,n)=>e+(t-e)*n,X=e=>e*e*(3-2*e),he=(e,t,n)=>Math.max(t,Math.min(n,e));function ge(e,t,n){let r=Math.hypot(t.x-e.x,t.y-e.y),i=Math.min(140,Math.max(54,r*.22))*(t.x>=e.x?-1:1),a=Math.min(120,r*.3),o={x:he(e.x+i,28,n-28),y:e.y-a},s={x:he(t.x+i*.6,28,n-28),y:t.y+a};return n=>{let r=1-n;return{x:r**3*e.x+3*r**2*n*o.x+3*r*n**2*s.x+n**3*t.x,y:r**3*e.y+3*r**2*n*o.y+3*r*n**2*s.y+n**3*t.y}}}function _e({flight:e,canvas:t,zh:n,historical:r=!1,onReveal:i,onLand:a,onFinish:o}){let s=(0,Y.useRef)(null),c=(0,Y.useRef)(null),l=(0,Y.useRef)(null),u=(0,Y.useRef)(null),d=`dispatch-wake-${(0,Y.useId)().replace(/:/g,``)}`,f=(0,Y.useRef)({onReveal:i,onLand:a,onFinish:o});f.current={onReveal:i,onLand:a,onFinish:o};let p=e.result?.type===`task`&&!r;return(0,Y.useEffect)(()=>{if(!e.result)return;let n=0,i,a,o=()=>f.current.onFinish(e.id);if(e.result.type!==`task`||r)return i=setTimeout(o,2200),()=>clearTimeout(i);let d=s.current;if(!d)return;let p=e.result.taskId,m=window.matchMedia(`(prefers-reduced-motion: reduce)`).matches,h=t.current,g=()=>{cancelAnimationFrame(n),clearTimeout(i),f.current.onLand(e.id),o()};h?.addEventListener(`pointerdown`,g,{once:!0}),h?.addEventListener(`wheel`,g,{once:!0,passive:!0});let _=performance.now(),v=0,y=!1,b=0,x,S=r=>{if(r-_>6e3){o();return}let s=t.current?.querySelector(`.map-macro[data-task-id="${CSS.escape(p)}"]`);if(!s||s.getBoundingClientRect().width<8){r-v>600&&(f.current.onReveal(p),v=r),n=requestAnimationFrame(S);return}if(m){f.current.onLand(e.id),i=setTimeout(o,1200);return}y||(f.current.onReveal(p),y=!0,v=r);let h=s.getBoundingClientRect();if((!x||Math.abs(x.x-h.x)+Math.abs(x.y-h.y)+Math.abs(x.width-h.width)>.7)&&(b=r),x=h,r-v<360||r-b<100){n=requestAnimationFrame(S);return}let g=t.current?.querySelector(`.map-composer`)?.getBoundingClientRect(),C=g?{x:g.left,y:g.top,width:g.width,height:g.height}:e.origin,w={x:C.x+C.width/2,y:C.y+C.height/2},T={x:w.x,y:w.y-26},E={x:h.left+h.width/2,y:h.top+h.height/2},D=ge(T,E,innerWidth),O=Math.min(320,C.width),k=Math.min(68,C.height),A=performance.now(),j=!1,M=t=>{if(!s.isConnected){o();return}let r=Math.min(1,(t-A)/1050),p=X(Math.min(1,r/.22)),m=X(he((r-.22)/.6,0,1)),h=X(he((r-.82)/.18,0,1)),g=r<.22?{x:w.x,y:me(w.y,T.y,p)}:D(m),_=me(52,22,h),v=me(O,_,p),y=me(k,_,p);if(d.style.width=`${v}px`,d.style.height=`${y}px`,d.style.transform=`translate3d(${g.x-v/2}px,${g.y-y/2}px,0)`,d.style.opacity=String(Math.min(1,r/.045)*(1-h)),d.style.setProperty(`--dispatch-copy`,String(1-X(Math.min(1,r/.12)))),d.style.setProperty(`--dispatch-mark`,String(me(1,.7,h))),d.dataset.phase=r<.22?`compress`:r<.82?`travel`:`arrive`,c.current&&l.current&&r>.22){let e=Math.max(0,m-.16),t=Array.from({length:13},(t,n)=>D(me(e,m,n/12)));c.current.setAttribute(`d`,t.map((e,t)=>`${t?`L`:`M`} ${e.x} ${e.y}`).join(` `)),c.current.style.opacity=String(.7*(1-h)),l.current.setAttribute(`x1`,String(t[0].x)),l.current.setAttribute(`y1`,String(t[0].y)),l.current.setAttribute(`x2`,String(g.x)),l.current.setAttribute(`y2`,String(g.y))}r>=.82&&!j&&(j=!0,f.current.onLand(e.id),u.current&&(u.current.style.left=`${E.x}px`,u.current.style.top=`${E.y}px`,a=u.current.animate([{transform:`translate(-50%,-50%) scale(.65)`,opacity:.65},{transform:`translate(-50%,-50%) scale(2.8)`,opacity:0}],{duration:650,easing:`cubic-bezier(.16,1,.3,1)`,fill:`both`}))),r<1?n=requestAnimationFrame(M):i=setTimeout(o,550)};n=requestAnimationFrame(M)};return n=requestAnimationFrame(S),()=>{cancelAnimationFrame(n),clearTimeout(i),a?.cancel(),h?.removeEventListener(`pointerdown`,g),h?.removeEventListener(`wheel`,g)}},[e.id,e.result,t,r]),p?(0,pe.createPortal)((0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`svg`,{className:`map-dispatch-trail`,"aria-hidden":`true`,children:[(0,J.jsx)(`defs`,{children:(0,J.jsxs)(`linearGradient`,{ref:l,id:d,gradientUnits:`userSpaceOnUse`,children:[(0,J.jsx)(`stop`,{stopColor:`#6fbcce`,stopOpacity:`0`}),(0,J.jsx)(`stop`,{offset:`1`,stopColor:`#87d9cf`})]})}),(0,J.jsx)(`path`,{ref:c,fill:`none`,stroke:`url(#${d})`,strokeWidth:`2.5`,strokeLinecap:`round`})]}),(0,J.jsxs)(`div`,{ref:s,className:`map-dispatch-flight`,"data-testid":`map-dispatch-flight`,"data-state":`task`,"data-task-id":e.result?.type===`task`?e.result.taskId:void 0,"aria-hidden":`true`,children:[(0,J.jsx)(`div`,{className:`map-dispatch-symbol`,children:(0,J.jsx)(h,{size:25})}),(0,J.jsxs)(`div`,{className:`map-dispatch-copy`,children:[(0,J.jsx)(`strong`,{children:e.text}),(0,J.jsx)(`span`,{children:n?`进入任务地图`:`Into your task map`})]})]}),(0,J.jsx)(`div`,{ref:u,className:`map-dispatch-halo`,"aria-hidden":`true`})]}),document.body):null}var ve=()=>({revision:0,cards:{},steps:{},links:{}}),ye=(e,t)=>`${e}\u0000${t}`,be=class{initialized=!1;seen=new Set;revision=0;loadingHistory=!1;observe(e,t=!1){let n=ve(),r=0;for(let t of e.cards){this.seen.has(`card:${t.id}`)||(n.cards[t.id]=Math.min(r++*100,400)),this.seen.add(`card:${t.id}`);let i=e.layouts[t.id],a=0;for(let e of i.steps){let r=ye(t.id,e.id);this.seen.has(`step:${r}`)||(n.steps[r]=160+Math.min(a++*120,720)),this.seen.add(`step:${r}`)}for(let e of i.links){let r=ye(t.id,e.id);this.seen.has(`link:${r}`)||(n.links[r]=Math.max(0,(n.steps[ye(t.id,e.target)]??160)-160)),this.seen.add(`link:${r}`)}}for(let t of e.links)this.seen.has(`outer:${t.id}`)||(n.links[t.id]=0),this.seen.add(`outer:${t.id}`);let i=!this.initialized||t||this.loadingHistory;return this.loadingHistory=t,this.initialized=!0,i||![n.cards,n.steps,n.links].some(e=>Object.keys(e).length)?null:{...n,revision:++this.revision}}};function xe(e,t=!1){let n=(0,Y.useRef)(new be),r=(0,Y.useRef)(new Set),[i,a]=(0,Y.useState)(ve);return(0,Y.useEffect)(()=>{let i=n.current.observe(e,t);if(t)r.current.forEach(clearTimeout),r.current.clear(),a(ve());else if(i){a(e=>({revision:i.revision,cards:{...e.cards,...i.cards},steps:{...e.steps,...i.steps},links:{...e.links,...i.links}}));let e=setTimeout(()=>{r.current.delete(e),a(e=>({revision:e.revision,cards:Object.fromEntries(Object.entries(e.cards).filter(([e])=>!(e in i.cards))),steps:Object.fromEntries(Object.entries(e.steps).filter(([e])=>!(e in i.steps))),links:Object.fromEntries(Object.entries(e.links).filter(([e])=>!(e in i.links)))}))},2e3);r.current.add(e)}},[e,t]),(0,Y.useEffect)(()=>()=>{r.current.forEach(clearTimeout),r.current.clear()},[]),i}function Se(e){if(typeof e==`string`||typeof e==`number`)return``+e;let t=``;if(Array.isArray(e))for(let n=0,r;n{}};function we(){for(var e=0,t=arguments.length,n={},r;e=0&&(n=e.slice(r+1),e=e.slice(0,r)),e&&!t.hasOwnProperty(e))throw Error(`unknown type: `+e);return{type:e,name:n}})}Te.prototype=we.prototype={constructor:Te,on:function(e,t){var n=this._,r=Ee(e+``,n),i,a=-1,o=r.length;if(arguments.length<2){for(;++a0)for(var n=Array(i),r=0,i,a;r=0&&(t=e.slice(0,n))!==`xmlns`&&(e=e.slice(n+1)),ke.hasOwnProperty(t)?{space:ke[t],local:e}:e}function je(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===`http://www.w3.org/1999/xhtml`&&t.documentElement.namespaceURI===`http://www.w3.org/1999/xhtml`?t.createElement(e):t.createElementNS(n,e)}}function Me(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Ne(e){var t=Ae(e);return(t.local?Me:je)(t)}function Pe(){}function Fe(e){return e==null?Pe:function(){return this.querySelector(e)}}function Ie(e){typeof e!=`function`&&(e=Fe(e));for(var t=this._groups,n=t.length,r=Array(n),i=0;i=v&&(v=_+1);!(b=g[v])&&++v=0;)(o=r[i])&&(a&&o.compareDocumentPosition(a)^4&&a.parentNode.insertBefore(o,a),a=o);return this}function ft(e){e||=pt;function t(t,n){return t&&n?e(t.__data__,n.__data__):!t-!n}for(var n=this._groups,r=n.length,i=Array(r),a=0;at?1:e>=t?0:NaN}function mt(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function ht(){return Array.from(this)}function gt(){for(var e=this._groups,t=0,n=e.length;t1?this.each((t==null?Ot:typeof t==`function`?At:kt)(e,t,n??``)):Mt(this.node(),e)}function Mt(e,t){return e.style.getPropertyValue(t)||Dt(e).getComputedStyle(e,null).getPropertyValue(t)}function Nt(e){return function(){delete this[e]}}function Pt(e,t){return function(){this[e]=t}}function Ft(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function It(e,t){return arguments.length>1?this.each((t==null?Nt:typeof t==`function`?Ft:Pt)(e,t)):this.node()[e]}function Lt(e){return e.trim().split(/^|\s+/)}function Rt(e){return e.classList||new zt(e)}function zt(e){this._node=e,this._names=Lt(e.getAttribute(`class`)||``)}zt.prototype={add:function(e){this._names.indexOf(e)<0&&(this._names.push(e),this._node.setAttribute(`class`,this._names.join(` `)))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute(`class`,this._names.join(` `)))},contains:function(e){return this._names.indexOf(e)>=0}};function Bt(e,t){for(var n=Rt(e),r=-1,i=t.length;++r=0&&(t=e.slice(n+1),e=e.slice(0,n)),{type:e,name:t}})}function gn(e){return function(){var t=this.__on;if(t){for(var n=0,r=-1,i=t.length,a;n()=>e;function Rn(e,{sourceEvent:t,subject:n,target:r,identifier:i,active:a,x:o,y:s,dx:c,dy:l,dispatch:u}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},identifier:{value:i,enumerable:!0,configurable:!0},active:{value:a,enumerable:!0,configurable:!0},x:{value:o,enumerable:!0,configurable:!0},y:{value:s,enumerable:!0,configurable:!0},dx:{value:c,enumerable:!0,configurable:!0},dy:{value:l,enumerable:!0,configurable:!0},_:{value:u}})}Rn.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function zn(e){return!e.ctrlKey&&!e.button}function Bn(){return this.parentNode}function Vn(e,t){return t??{x:e.x,y:e.y}}function Hn(){return navigator.maxTouchPoints||`ontouchstart`in this}function Un(){var e=zn,t=Bn,n=Vn,r=Hn,i={},a=we(`start`,`drag`,`end`),o=0,s,c,l,u,d=0;function f(e){e.on(`mousedown.drag`,p).filter(r).on(`touchstart.drag`,g).on(`touchmove.drag`,_,jn).on(`touchend.drag touchcancel.drag`,v).style(`touch-action`,`none`).style(`-webkit-tap-highlight-color`,`rgba(0,0,0,0)`)}function p(n,r){if(!(u||!e.call(this,n,r))){var i=y(this,t.call(this,n,r),n,r,`mouse`);i&&(On(n.view).on(`mousemove.drag`,m,Mn).on(`mouseup.drag`,h,Mn),Fn(n.view),Nn(n),l=!1,s=n.clientX,c=n.clientY,i(`start`,n))}}function m(e){if(Pn(e),!l){var t=e.clientX-s,n=e.clientY-c;l=t*t+n*n>d}i.mouse(`drag`,e)}function h(e){On(e.view).on(`mousemove.drag mouseup.drag`,null),In(e.view,l),Pn(e),i.mouse(`end`,e)}function g(n,r){if(e.call(this,n,r)){var i=n.changedTouches,a=t.call(this,n,r),o=i.length,s,c;for(s=0;s>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?fr(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?fr(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=$n.exec(e))?new hr(t[1],t[2],t[3],1):(t=er.exec(e))?new hr(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=tr.exec(e))?fr(t[1],t[2],t[3],t[4]):(t=nr.exec(e))?fr(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=rr.exec(e))?Sr(t[1],t[2]/100,t[3]/100,1):(t=ir.exec(e))?Sr(t[1],t[2]/100,t[3]/100,t[4]):ar.hasOwnProperty(e)?dr(ar[e]):e===`transparent`?new hr(NaN,NaN,NaN,0):null}function dr(e){return new hr(e>>16&255,e>>8&255,e&255,1)}function fr(e,t,n,r){return r<=0&&(e=t=n=NaN),new hr(e,t,n,r)}function pr(e){return e instanceof Kn||(e=ur(e)),e?(e=e.rgb(),new hr(e.r,e.g,e.b,e.opacity)):new hr}function mr(e,t,n,r){return arguments.length===1?pr(e):new hr(e,t,n,r??1)}function hr(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}Wn(hr,mr,Gn(Kn,{brighter(e){return e=e==null?Jn:Jn**+e,new hr(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?qn:qn**+e,new hr(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new hr(br(this.r),br(this.g),br(this.b),yr(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:gr,formatHex:gr,formatHex8:_r,formatRgb:vr,toString:vr}));function gr(){return`#${xr(this.r)}${xr(this.g)}${xr(this.b)}`}function _r(){return`#${xr(this.r)}${xr(this.g)}${xr(this.b)}${xr((isNaN(this.opacity)?1:this.opacity)*255)}`}function vr(){let e=yr(this.opacity);return`${e===1?`rgb(`:`rgba(`}${br(this.r)}, ${br(this.g)}, ${br(this.b)}${e===1?`)`:`, ${e})`}`}function yr(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function br(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function xr(e){return e=br(e),(e<16?`0`:``)+e.toString(16)}function Sr(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new Tr(e,t,n,r)}function Cr(e){if(e instanceof Tr)return new Tr(e.h,e.s,e.l,e.opacity);if(e instanceof Kn||(e=ur(e)),!e)return new Tr;if(e instanceof Tr)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,i=Math.min(t,n,r),a=Math.max(t,n,r),o=NaN,s=a-i,c=(a+i)/2;return s?(o=t===a?(n-r)/s+(n0&&c<1?0:o,new Tr(o,s,c,e.opacity)}function wr(e,t,n,r){return arguments.length===1?Cr(e):new Tr(e,t,n,r??1)}function Tr(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}Wn(Tr,wr,Gn(Kn,{brighter(e){return e=e==null?Jn:Jn**+e,new Tr(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?qn:qn**+e,new Tr(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,r=n+(n<.5?n:1-n)*t,i=2*n-r;return new hr(Or(e>=240?e-240:e+120,i,r),Or(e,i,r),Or(e<120?e+240:e-120,i,r),this.opacity)},clamp(){return new Tr(Er(this.h),Dr(this.s),Dr(this.l),yr(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(){let e=yr(this.opacity);return`${e===1?`hsl(`:`hsla(`}${Er(this.h)}, ${Dr(this.s)*100}%, ${Dr(this.l)*100}%${e===1?`)`:`, ${e})`}`}}));function Er(e){return e=(e||0)%360,e<0?e+360:e}function Dr(e){return Math.max(0,Math.min(1,e||0))}function Or(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}var kr=e=>()=>e;function Ar(e,t){return function(n){return e+n*t}}function jr(e,t,n){return e**=+n,t=t**+n-e,n=1/n,function(r){return(e+r*t)**+n}}function Mr(e){return(e=+e)==1?Nr:function(t,n){return n-t?jr(t,n,e):kr(isNaN(t)?n:t)}}function Nr(e,t){var n=t-e;return n?Ar(e,n):kr(isNaN(e)?t:e)}var Pr=(function e(t){var n=Mr(t);function r(e,t){var r=n((e=mr(e)).r,(t=mr(t)).r),i=n(e.g,t.g),a=n(e.b,t.b),o=Nr(e.opacity,t.opacity);return function(t){return e.r=r(t),e.g=i(t),e.b=a(t),e.opacity=o(t),e+``}}return r.gamma=e,r})(1);function Fr(e,t){t||=[];var n=e?Math.min(t.length,e.length):0,r=t.slice(),i;return function(a){for(i=0;in&&(a=t.slice(n,a),s[o]?s[o]+=a:s[++o]=a),(r=r[0])===(i=i[0])?s[o]?s[o]+=i:s[++o]=i:(s[++o]=null,c.push({i:o,x:zr(r,i)})),n=Hr.lastIndex;return n180?t+=360:t-e>180&&(e+=360),a.push({i:n.push(i(n)+`rotate(`,null,r)-2,x:zr(e,t)}))}function s(e,t,n,a){e===t?t&&n.push(i(n)+`skewX(`+t+r):a.push({i:n.push(i(n)+`skewX(`,null,r)-2,x:zr(e,t)})}function c(e,t,n,r,a,o){if(e!==n||t!==r){var s=a.push(i(a)+`scale(`,null,`,`,null,`)`);o.push({i:s-4,x:zr(e,n)},{i:s-2,x:zr(t,r)})}else(n!==1||r!==1)&&a.push(i(a)+`scale(`+n+`,`+r+`)`)}return function(t,n){var r=[],i=[];return t=e(t),n=e(n),a(t.translateX,t.translateY,n.translateX,n.translateY,r,i),o(t.rotate,n.rotate,r,i),s(t.skewX,n.skewX,r,i),c(t.scaleX,t.scaleY,n.scaleX,n.scaleY,r,i),t=n=null,function(e){for(var t=-1,n=i.length,a;++t=0&&e._call.call(void 0,t),e=e._next;--si}function Ci(){mi=(pi=gi.now())+hi,si=ci=0;try{Si()}finally{si=0,Ti(),mi=0}}function wi(){var e=gi.now(),t=e-pi;t>ui&&(hi-=t,pi=e)}function Ti(){for(var e,t=di,n,r=1/0;t;)t._call?(r>t._time&&(r=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:di=n);fi=e,Ei(r)}function Ei(e){si||(ci&&=clearTimeout(ci),e-mi>24?(e<1/0&&(ci=setTimeout(Ci,e-gi.now()-hi)),li&&=clearInterval(li)):(li||=(pi=gi.now(),setInterval(wi,ui)),si=1,_i(Ci)))}function Di(e,t,n){var r=new bi;return t=t==null?0:+t,r.restart(n=>{r.stop(),e(n+t)},t,n),r}var Oi=we(`start`,`end`,`cancel`,`interrupt`),ki=[];function Ai(e,t,n,r,i,a){var o=e.__transition;if(!o)e.__transition={};else if(n in o)return;Pi(e,n,{name:t,index:r,group:i,on:Oi,tween:ki,time:a.time,delay:a.delay,duration:a.duration,ease:a.ease,timer:null,state:0})}function ji(e,t){var n=Ni(e,t);if(n.state>0)throw Error(`too late; already scheduled`);return n}function Mi(e,t){var n=Ni(e,t);if(n.state>3)throw Error(`too late; already running`);return n}function Ni(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw Error(`transition not found`);return n}function Pi(e,t,n){var r=e.__transition,i;r[t]=n,n.timer=xi(a,0,n.time);function a(e){n.state=1,n.timer.restart(o,n.delay,n.time),n.delay<=e&&o(e-n.delay)}function o(a){var l,u,d,f;if(n.state!==1)return c();for(l in r)if(f=r[l],f.name===n.name){if(f.state===3)return Di(o);f.state===4?(f.state=6,f.timer.stop(),f.on.call(`interrupt`,e,e.__data__,f.index,f.group),delete r[l]):+l2&&r.state<5,r.state=6,r.timer.stop(),r.on.call(i?`interrupt`:`cancel`,e,e.__data__,r.index,r.group),delete n[o]}a&&delete e.__transition}}function Ii(e){return this.each(function(){Fi(this,e)})}function Li(e,t){var n,r;return function(){var i=Mi(this,e),a=i.tween;if(a!==n){r=n=a;for(var o=0,s=r.length;o=0&&(e=e.slice(0,t)),!e||e===`start`})}function pa(e,t,n){var r,i,a=fa(t)?ji:Mi;return function(){var o=a(this,e),s=o.on;s!==r&&(i=(r=s).copy()).on(t,n),o.on=i}}function ma(e,t){var n=this._id;return arguments.length<2?Ni(this.node(),n).on.on(e):this.each(pa(n,e,t))}function ha(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function ga(){return this.on(`end.remove`,ha(this._id))}function _a(e){var t=this._name,n=this._id;typeof e!=`function`&&(e=Fe(e));for(var r=this._groups,i=r.length,a=Array(i),o=0;o()=>e;function qa(e,{sourceEvent:t,target:n,transform:r,dispatch:i}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:r,enumerable:!0,configurable:!0},_:{value:i}})}function Ja(e,t,n){this.k=e,this.x=t,this.y=n}Ja.prototype={constructor:Ja,scale:function(e){return e===1?this:new Ja(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new Ja(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return`translate(`+this.x+`,`+this.y+`) scale(`+this.k+`)`}};var Ya=new Ja(1,0,0);Xa.prototype=Ja.prototype;function Xa(e){for(;!e.__zoom;)if(!(e=e.parentNode))return Ya;return e.__zoom}function Za(e){e.stopImmediatePropagation()}function Qa(e){e.preventDefault(),e.stopImmediatePropagation()}function $a(e){return(!e.ctrlKey||e.type===`wheel`)&&!e.button}function eo(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e,e.hasAttribute(`viewBox`)?(e=e.viewBox.baseVal,[[e.x,e.y],[e.x+e.width,e.y+e.height]]):[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]):[[0,0],[e.clientWidth,e.clientHeight]]}function to(){return this.__zoom||Ya}function no(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function ro(){return navigator.maxTouchPoints||`ontouchstart`in this}function io(e,t,n){var r=e.invertX(t[0][0])-n[0][0],i=e.invertX(t[1][0])-n[1][0],a=e.invertY(t[0][1])-n[0][1],o=e.invertY(t[1][1])-n[1][1];return e.translate(i>r?(r+i)/2:Math.min(0,r)||Math.max(0,i),o>a?(a+o)/2:Math.min(0,a)||Math.max(0,o))}function ao(){var e=$a,t=eo,n=io,r=no,i=ro,a=[0,1/0],o=[[-1/0,-1/0],[1/0,1/0]],s=250,c=oi,l=we(`start`,`zoom`,`end`),u,d,f,p=500,m=150,h=0,g=10;function _(e){e.property(`__zoom`,to).on(`wheel.zoom`,w,{passive:!1}).on(`mousedown.zoom`,T).on(`dblclick.zoom`,E).filter(i).on(`touchstart.zoom`,D).on(`touchmove.zoom`,O).on(`touchend.zoom touchcancel.zoom`,k).style(`-webkit-tap-highlight-color`,`rgba(0,0,0,0)`)}_.transform=function(e,t,n,r){var i=e.selection?e.selection():e;i.property(`__zoom`,to),e===i?i.interrupt().each(function(){S(this,arguments).event(r).start().zoom(null,typeof t==`function`?t.apply(this,arguments):t).end()}):x(e,t,n,r)},_.scaleBy=function(e,t,n,r){_.scaleTo(e,function(){return this.__zoom.k*(typeof t==`function`?t.apply(this,arguments):t)},n,r)},_.scaleTo=function(e,r,i,a){_.transform(e,function(){var e=t.apply(this,arguments),a=this.__zoom,s=i==null?b(e):typeof i==`function`?i.apply(this,arguments):i,c=a.invert(s),l=typeof r==`function`?r.apply(this,arguments):r;return n(y(v(a,l),s,c),e,o)},i,a)},_.translateBy=function(e,r,i,a){_.transform(e,function(){return n(this.__zoom.translate(typeof r==`function`?r.apply(this,arguments):r,typeof i==`function`?i.apply(this,arguments):i),t.apply(this,arguments),o)},null,a)},_.translateTo=function(e,r,i,a,s){_.transform(e,function(){var e=t.apply(this,arguments),s=this.__zoom,c=a==null?b(e):typeof a==`function`?a.apply(this,arguments):a;return n(Ya.translate(c[0],c[1]).scale(s.k).translate(typeof r==`function`?-r.apply(this,arguments):-r,typeof i==`function`?-i.apply(this,arguments):-i),e,o)},a,s)};function v(e,t){return t=Math.max(a[0],Math.min(a[1],t)),t===e.k?e:new Ja(t,e.x,e.y)}function y(e,t,n){var r=t[0]-n[0]*e.k,i=t[1]-n[1]*e.k;return r===e.x&&i===e.y?e:new Ja(e.k,r,i)}function b(e){return[(+e[0][0]+ +e[1][0])/2,(+e[0][1]+ +e[1][1])/2]}function x(e,n,r,i){e.on(`start.zoom`,function(){S(this,arguments).event(i).start()}).on(`interrupt.zoom end.zoom`,function(){S(this,arguments).event(i).end()}).tween(`zoom`,function(){var e=this,a=arguments,o=S(e,a).event(i),s=t.apply(e,a),l=r==null?b(s):typeof r==`function`?r.apply(e,a):r,u=Math.max(s[1][0]-s[0][0],s[1][1]-s[0][1]),d=e.__zoom,f=typeof n==`function`?n.apply(e,a):n,p=c(d.invert(l).concat(u/d.k),f.invert(l).concat(u/f.k));return function(e){if(e===1)e=f;else{var t=p(e),n=u/t[2];e=new Ja(n,l[0]-t[0]*n,l[1]-t[1]*n)}o.zoom(null,e)}})}function S(e,t,n){return!n&&e.__zooming||new C(e,t)}function C(e,n){this.that=e,this.args=n,this.active=0,this.sourceEvent=null,this.extent=t.apply(e,n),this.taps=0}C.prototype={event:function(e){return e&&(this.sourceEvent=e),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit(`start`)),this},zoom:function(e,t){return this.mouse&&e!==`mouse`&&(this.mouse[1]=t.invert(this.mouse[0])),this.touch0&&e!==`touch`&&(this.touch0[1]=t.invert(this.touch0[0])),this.touch1&&e!==`touch`&&(this.touch1[1]=t.invert(this.touch1[0])),this.that.__zoom=t,this.emit(`zoom`),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit(`end`)),this},emit:function(e){var t=On(this.that).datum();l.call(e,this.that,new qa(e,{sourceEvent:this.sourceEvent,target:_,type:e,transform:this.that.__zoom,dispatch:l}),t)}};function w(t,...i){if(!e.apply(this,arguments))return;var s=S(this,i).event(t),c=this.__zoom,l=Math.max(a[0],Math.min(a[1],c.k*2**r.apply(this,arguments))),u=An(t);if(s.wheel)(s.mouse[0][0]!==u[0]||s.mouse[0][1]!==u[1])&&(s.mouse[1]=c.invert(s.mouse[0]=u)),clearTimeout(s.wheel);else if(c.k===l)return;else s.mouse=[u,c.invert(u)],Fi(this),s.start();Qa(t),s.wheel=setTimeout(d,m),s.zoom(`mouse`,n(y(v(c,l),s.mouse[0],s.mouse[1]),s.extent,o));function d(){s.wheel=null,s.end()}}function T(t,...r){if(f||!e.apply(this,arguments))return;var i=t.currentTarget,a=S(this,r,!0).event(t),s=On(t.view).on(`mousemove.zoom`,d,!0).on(`mouseup.zoom`,p,!0),c=An(t,i),l=t.clientX,u=t.clientY;Fn(t.view),Za(t),a.mouse=[c,this.__zoom.invert(c)],Fi(this),a.start();function d(e){if(Qa(e),!a.moved){var t=e.clientX-l,r=e.clientY-u;a.moved=t*t+r*r>h}a.event(e).zoom(`mouse`,n(y(a.that.__zoom,a.mouse[0]=An(e,i),a.mouse[1]),a.extent,o))}function p(e){s.on(`mousemove.zoom mouseup.zoom`,null),In(e.view,a.moved),Qa(e),a.event(e).end()}}function E(r,...i){if(e.apply(this,arguments)){var a=this.__zoom,c=An(r.changedTouches?r.changedTouches[0]:r,this),l=a.invert(c),u=a.k*(r.shiftKey?.5:2),d=n(y(v(a,u),c,l),t.apply(this,i),o);Qa(r),s>0?On(this).transition().duration(s).call(x,d,c,r):On(this).call(_.transform,d,c,r)}}function D(t,...n){if(e.apply(this,arguments)){var r=t.touches,i=r.length,a=S(this,n,t.changedTouches.length===i).event(t),o,s,c,l;for(Za(t),s=0;s`Seems like you have not used ${e===`svelte`?`SvelteFlowProvider`:`ReactFlowProvider`} as an ancestor. Help: https://${e}flow.dev/error#001`,error002:()=>`It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.`,error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>`The parent container needs a width and a height to render the graph.`,error005:()=>`Only child nodes can use a parent extent.`,error006:()=>`Can't create edge. An edge needs a source and a target.`,error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,{id:t,sourceHandle:n,targetHandle:r})=>`Couldn't create edge for ${e} handle id: "${e===`source`?n:r}", edge id: ${t}.`,error010:()=>`Handle: No node id found. Make sure to only use a Handle inside a custom Node.`,error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(e=`react`)=>`It seems that you haven't loaded the styles. Please import '@xyflow/${e}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>`useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.`,error015:()=>`It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs.`,error016:e=>`Edge with id "${e}" does not exist, it may have been removed. This can happen when an edge is deleted before the "onEdgeClick" handler is called.`},so=[[-1/0,-1/0],[1/0,1/0]],co=[`Enter`,` `,`Escape`],lo={"node.a11yDescription.default":`Press enter or space to select a node. Press delete to remove it and escape to cancel.`,"node.a11yDescription.keyboardDisabled":`Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.`,"node.a11yDescription.ariaLiveMessage":({direction:e,x:t,y:n})=>`Moved selected node ${e}. New position, x: ${t}, y: ${n}`,"edge.a11yDescription.default":`Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.`,"controls.ariaLabel":`Control Panel`,"controls.zoomIn.ariaLabel":`Zoom In`,"controls.zoomOut.ariaLabel":`Zoom Out`,"controls.fitView.ariaLabel":`Fit View`,"controls.interactive.ariaLabel":`Toggle Interactivity`,"minimap.ariaLabel":`Mini Map`,"handle.ariaLabel":`Handle`},uo;(function(e){e.Strict=`strict`,e.Loose=`loose`})(uo||={});var fo;(function(e){e.Free=`free`,e.Vertical=`vertical`,e.Horizontal=`horizontal`})(fo||={});var po;(function(e){e.Partial=`partial`,e.Full=`full`})(po||={});var mo={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null},ho;(function(e){e.Bezier=`default`,e.Straight=`straight`,e.Step=`step`,e.SmoothStep=`smoothstep`,e.SimpleBezier=`simplebezier`})(ho||={});var go;(function(e){e.Arrow=`arrow`,e.ArrowClosed=`arrowclosed`})(go||={});var Z;(function(e){e.Left=`left`,e.Top=`top`,e.Right=`right`,e.Bottom=`bottom`})(Z||={});var _o={[Z.Left]:Z.Right,[Z.Right]:Z.Left,[Z.Top]:Z.Bottom,[Z.Bottom]:Z.Top};function vo(e){return e===null?null:e?`valid`:`invalid`}var yo=e=>`id`in e&&`source`in e&&`target`in e,bo=e=>`id`in e&&`position`in e&&!(`source`in e)&&!(`target`in e),xo=e=>`id`in e&&`internals`in e&&!(`source`in e)&&!(`target`in e),So=(e,t=[0,0])=>{let{width:n,height:r}=ns(e),i=e.origin??t,a=n*i[0],o=r*i[1];return{x:e.position.x-a,y:e.position.y-o}},Co=(e,t={nodeOrigin:[0,0]})=>e.length===0?{x:0,y:0,width:0,height:0}:Ro(e.reduce((e,n)=>{let r=typeof n==`string`,i=!t.nodeLookup&&!r?n:void 0;return t.nodeLookup&&(i=r?t.nodeLookup.get(n):xo(n)?n:t.nodeLookup.get(n.id)),Io(e,i?Bo(i,t.nodeOrigin):{x:0,y:0,x2:0,y2:0})},{x:1/0,y:1/0,x2:-1/0,y2:-1/0})),wo=(e,t={})=>{let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0},r=!1;return e.forEach(e=>{(t.filter===void 0||t.filter(e))&&(n=Io(n,Bo(e)),r=!0)}),r?Ro(n):{x:0,y:0,width:0,height:0}},To=(e,t,[n,r,i]=[0,0,1],a=!1,o=!1)=>{let s=(t.x-n)/i,c=(t.y-r)/i,l=t.width/i,u=t.height/i,d=[];for(let t of e.values()){let{measured:e,selectable:n=!0,hidden:r=!1}=t;if(o&&!n||r)continue;let i=e.width??t.width??t.initialWidth??0,f=e.height??t.height??t.initialHeight??0,{x:p,y:m}=t.internals.positionAbsolute,h=Ho(s,c,l,u,p,m,i,f),g=i*f,_=a&&h>0;(!t.internals.handleBounds||_||h>=g||t.dragging)&&d.push(t)}return d},Eo=(e,t)=>{let n=new Set;return e.forEach(e=>{n.add(e.id)}),t.filter(e=>n.has(e.source)||n.has(e.target))};function Do(e,t){let n=new Map,r=t?.nodes?new Set(t.nodes.map(e=>e.id)):null;return e.forEach(e=>{e.measured.width&&e.measured.height&&(t?.includeHiddenNodes||!e.hidden)&&(!r||r.has(e.id))&&n.set(e.id,e)}),n}async function Oo({nodes:e,width:t,height:n,panZoom:r,minZoom:i,maxZoom:a},o){if(e.size===0)return!0;let s=$o(wo(Do(e,o)),t,n,o?.minZoom??i,o?.maxZoom??a,o?.padding??.1);return await r.setViewport(s,{duration:o?.duration,ease:o?.ease,interpolate:o?.interpolate}),!0}function ko({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:r=[0,0],nodeExtent:i,onError:a}){let o=n.get(e),s=o.parentId?n.get(o.parentId):void 0,{x:c,y:l}=s?s.internals.positionAbsolute:{x:0,y:0},u=o.origin??r,d=o.extent||i;if(o.extent===`parent`&&!o.expandParent){if(!s)a?.(`005`,oo.error005());else{let e=s.measured.width,t=s.measured.height;e&&t&&(d=[[c,l],[c+e,l+t]])}}else s&&ts(o.extent)&&(d=[[o.extent[0][0]+c,o.extent[0][1]+l],[o.extent[1][0]+c,o.extent[1][1]+l]]);let f=ts(d)?Mo(t,d,o.measured):t;return(o.measured.width===void 0||o.measured.height===void 0)&&a?.(`015`,oo.error015()),{position:{x:f.x-c+(o.measured.width??0)*u[0],y:f.y-l+(o.measured.height??0)*u[1]},positionAbsolute:f}}async function Ao({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:r,onBeforeDelete:i}){let a=new Set(e.map(e=>e.id)),o=[];for(let e of n){if(e.deletable===!1)continue;let t=a.has(e.id),n=!t&&e.parentId&&o.find(t=>t.id===e.parentId);(t||n)&&o.push(e)}let s=new Set(t.map(e=>e.id)),c=r.filter(e=>e.deletable!==!1),l=Eo(o,c);for(let e of c)s.has(e.id)&&!l.find(t=>t.id===e.id)&&l.push(e);if(!i)return{edges:l,nodes:o};let u=await i({nodes:o,edges:l});return typeof u==`boolean`?u?{edges:l,nodes:o}:{edges:[],nodes:[]}:u}var jo=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),Mo=(e={x:0,y:0},t,n)=>({x:jo(e.x,t[0][0],t[1][0]-(n?.width??0)),y:jo(e.y,t[0][1],t[1][1]-(n?.height??0))});function No(e,t,n){let{width:r,height:i}=ns(n),{x:a,y:o}=n.internals.positionAbsolute;return Mo(e,[[a,o],[a+r,o+i]],t)}var Po=(e,t,n)=>en?-jo(Math.abs(e-n),1,t)/t:0,Fo=(e,t,n=15,r=40)=>[Po(e.x,r,t.width-r)*n,Po(e.y,r,t.height-r)*n],Io=(e,t)=>({x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x2,t.x2),y2:Math.max(e.y2,t.y2)}),Lo=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),Ro=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),zo=(e,t=[0,0])=>{let{x:n,y:r}=xo(e)?e.internals.positionAbsolute:So(e,t);return{x:n,y:r,width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}},Bo=(e,t=[0,0])=>{let{x:n,y:r}=xo(e)?e.internals.positionAbsolute:So(e,t);return{x:n,y:r,x2:n+(e.measured?.width??e.width??e.initialWidth??0),y2:r+(e.measured?.height??e.height??e.initialHeight??0)}},Vo=(e,t)=>Ro(Io(Lo(e),Lo(t))),Ho=(e,t,n,r,i,a,o,s)=>{let c=Math.max(0,Math.min(e+n,i+o)-Math.max(e,i)),l=Math.max(0,Math.min(t+r,a+s)-Math.max(t,a));return Math.ceil(c*l)},Uo=(e,t)=>Ho(e.x,e.y,e.width,e.height,t.x,t.y,t.width,t.height),Wo=e=>Go(e.width)&&Go(e.height)&&Go(e.x)&&Go(e.y),Go=e=>!isNaN(e)&&isFinite(e),Ko=(e,t)=>(e,t)=>{},qo=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),Jo=({x:e,y:t},[n,r,i],a=!1,o=[1,1])=>{let s={x:(e-n)/i,y:(t-r)/i};return a?qo(s,o):s},Yo=({x:e,y:t},[n,r,i])=>({x:e*i+n,y:t*i+r});function Xo(e,t){if(typeof e==`number`)return Math.floor((t-t/(1+e))*.5);if(typeof e==`string`&&e.endsWith(`px`)){let t=parseFloat(e);if(!Number.isNaN(t))return Math.floor(t)}if(typeof e==`string`&&e.endsWith(`%`)){let n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(t*n*.01)}return console.error(`The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function Zo(e,t,n){if(typeof e==`string`||typeof e==`number`){let r=Xo(e,n),i=Xo(e,t);return{top:r,right:i,bottom:r,left:i,x:i*2,y:r*2}}if(typeof e==`object`){let r=Xo(e.top??e.y??0,n),i=Xo(e.bottom??e.y??0,n),a=Xo(e.left??e.x??0,t),o=Xo(e.right??e.x??0,t);return{top:r,right:o,bottom:i,left:a,x:a+o,y:r+i}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function Qo(e,t,n,r,i,a){let{x:o,y:s}=Yo(e,[t,n,r]),{x:c,y:l}=Yo({x:e.x+e.width,y:e.y+e.height},[t,n,r]),u=i-c,d=a-l;return{left:Math.floor(o),top:Math.floor(s),right:Math.floor(u),bottom:Math.floor(d)}}var $o=(e,t,n,r,i,a)=>{let o=Zo(a,t,n),s=(t-o.x)/e.width,c=(n-o.y)/e.height,l=jo(Math.min(s,c),r,i),u=e.x+e.width/2,d=e.y+e.height/2,f=t/2-u*l,p=n/2-d*l,m=Qo(e,f,p,l,t,n),h={left:Math.min(m.left-o.left,0),top:Math.min(m.top-o.top,0),right:Math.min(m.right-o.right,0),bottom:Math.min(m.bottom-o.bottom,0)};return{x:f-h.left+h.right,y:p-h.top+h.bottom,zoom:l}},es=()=>typeof navigator<`u`&&navigator?.userAgent?.indexOf(`Mac`)>=0;function ts(e){return e!=null&&e!==`parent`}function ns(e){return{width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}}function rs(e){return(e.measured?.width??e.width??e.initialWidth)!==void 0&&(e.measured?.height??e.height??e.initialHeight)!==void 0}function is(e,t={width:0,height:0},n,r,i){let a={...e},o=r.get(n);if(o){let e=o.origin||i;a.x+=o.internals.positionAbsolute.x-(t.width??0)*e[0],a.y+=o.internals.positionAbsolute.y-(t.height??0)*e[1]}return a}function as(e,t){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}function os(){let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}function ss(e){return{...lo,...e||{}}}function cs(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:r,containerBounds:i}){let{x:a,y:o}=ms(e),s=Jo({x:a-(i?.left??0),y:o-(i?.top??0)},r),{x:c,y:l}=n?qo(s,t):s;return{xSnapped:c,ySnapped:l,...s}}var ls=e=>({width:e.offsetWidth,height:e.offsetHeight}),us=e=>e?.getRootNode?.()||window?.document,ds=[`INPUT`,`SELECT`,`TEXTAREA`];function fs(e){let t=e.composedPath?.()?.[0]||e.target;return t?.nodeType===1?ds.includes(t.nodeName)||t.hasAttribute(`contenteditable`)||!!t.closest(`.nokey`):!1}var ps=e=>`clientX`in e,ms=(e,t)=>{let n=ps(e),r=n?e.clientX:e.touches?.[0].clientX,i=n?e.clientY:e.touches?.[0].clientY;return{x:r-(t?.left??0),y:i-(t?.top??0)}},hs=(e,t,n,r,i)=>{let a=t.querySelectorAll(`.${e}`);return!a||!a.length?null:Array.from(a).map(t=>{let a=t.getBoundingClientRect();return{id:t.getAttribute(`data-handleid`),type:e,nodeId:i,position:t.getAttribute(`data-handlepos`),x:(a.left-n.left)/r,y:(a.top-n.top)/r,...ls(t)}})};function gs({sourceX:e,sourceY:t,targetX:n,targetY:r,sourceControlX:i,sourceControlY:a,targetControlX:o,targetControlY:s}){let c=e*.125+i*.375+o*.375+n*.125,l=t*.125+a*.375+s*.375+r*.125;return[c,l,Math.abs(c-e),Math.abs(l-t)]}function _s(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function vs({pos:e,x1:t,y1:n,x2:r,y2:i,c:a}){switch(e){case Z.Left:return[t-_s(t-r,a),n];case Z.Right:return[t+_s(r-t,a),n];case Z.Top:return[t,n-_s(n-i,a)];case Z.Bottom:return[t,n+_s(i-n,a)]}}function ys({sourceX:e,sourceY:t,sourcePosition:n=Z.Bottom,targetX:r,targetY:i,targetPosition:a=Z.Top,curvature:o=.25}){let[s,c]=vs({pos:n,x1:e,y1:t,x2:r,y2:i,c:o}),[l,u]=vs({pos:a,x1:r,y1:i,x2:e,y2:t,c:o}),[d,f,p,m]=gs({sourceX:e,sourceY:t,targetX:r,targetY:i,sourceControlX:s,sourceControlY:c,targetControlX:l,targetControlY:u});return[`M${e},${t} C${s},${c} ${l},${u} ${r},${i}`,d,f,p,m]}function bs({sourceX:e,sourceY:t,targetX:n,targetY:r}){let i=Math.abs(n-e)/2,a=n0}var Cs=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`xy-edge__${e}${t||``}-${n}${r||``}`,ws=(e,t)=>t.some(t=>t.source===e.source&&t.target===e.target&&(t.sourceHandle===e.sourceHandle||!t.sourceHandle&&!e.sourceHandle)&&(t.targetHandle===e.targetHandle||!t.targetHandle&&!e.targetHandle)),Ts=(e,t,n={})=>{if(!e.source||!e.target)return n.onError?.(`006`,oo.error006()),t;let r=n.getEdgeId||Cs,i;return i=yo(e)?{...e}:{...e,id:r(e)},ws(i,t)?t:(i.sourceHandle===null&&delete i.sourceHandle,i.targetHandle===null&&delete i.targetHandle,t.concat(i))};function Es({sourceX:e,sourceY:t,targetX:n,targetY:r}){let[i,a,o,s]=bs({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,i,a,o,s]}var Ds={[Z.Left]:{x:-1,y:0},[Z.Right]:{x:1,y:0},[Z.Top]:{x:0,y:-1},[Z.Bottom]:{x:0,y:1}},Os=({source:e,sourcePosition:t=Z.Bottom,target:n})=>t===Z.Left||t===Z.Right?e.xMath.sqrt((t.x-e.x)**2+(t.y-e.y)**2);function As({source:e,sourcePosition:t=Z.Bottom,target:n,targetPosition:r=Z.Top,center:i,offset:a,stepPosition:o}){let s=Ds[t],c=Ds[r],l={x:e.x+s.x*a,y:e.y+s.y*a},u={x:n.x+c.x*a,y:n.y+c.y*a},d=Os({source:l,sourcePosition:t,target:u}),f=d.x===0?`y`:`x`,p=d[f],m=[],h,g,_={x:0,y:0},v={x:0,y:0},[,,y,b]=bs({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(s[f]*c[f]===-1){f===`x`?(h=i.x??l.x+(u.x-l.x)*o,g=i.y??(l.y+u.y)/2):(h=i.x??(l.x+u.x)/2,g=i.y??l.y+(u.y-l.y)*o);let e=[{x:h,y:l.y},{x:h,y:u.y}],t=[{x:l.x,y:g},{x:u.x,y:g}];m=s[f]===p?f===`x`?e:t:f===`x`?t:e}else{let i=[{x:l.x,y:u.y}],o=[{x:u.x,y:l.y}];if(m=f===`x`?s.x===p?o:i:s.y===p?i:o,t===r){let t=Math.abs(e[f]-n[f]);if(t<=a){let r=Math.min(a-1,a-t);s[f]===p?_[f]=(l[f]>e[f]?-1:1)*r:v[f]=(u[f]>n[f]?-1:1)*r}}if(t!==r){let e=f===`x`?`y`:`x`,t=s[f]===c[e],n=l[e]>u[e],r=l[e]=Math.max(Math.abs(d.y-m[0].y),Math.abs(y.y-m[0].y))?(h=(d.x+y.x)/2,g=m[0].y):(h=m[0].x,g=(d.y+y.y)/2)}let x={x:l.x+_.x,y:l.y+_.y},S={x:u.x+v.x,y:u.y+v.y};return[[e,...x.x!==m[0].x||x.y!==m[0].y?[x]:[],...m,...S.x!==m[m.length-1].x||S.y!==m[m.length-1].y?[S]:[],n],h,g,y,b]}function js(e,t,n,r){let i=Math.min(ks(e,t)/2,ks(t,n)/2,r),{x:a,y:o}=t;if(e.x===a&&a===n.x||e.y===o&&o===n.y)return`L${a} ${o}`;if(e.y===o){let t=e.xe.id===t):e[0])||null}function Rs(e,t){return e?typeof e==`string`?e:`${t?`${t}__`:``}${Object.keys(e).sort().map(t=>`${t}=${e[t]}`).join(`&`)}`:``}function zs(e,{id:t,defaultColor:n,defaultMarkerStart:r,defaultMarkerEnd:i}){let a=new Set;return e.reduce((e,o)=>([o.markerStart||r,o.markerEnd||i].forEach(r=>{if(r&&typeof r==`object`){let i=Rs(r,t);a.has(i)||(e.push({id:i,color:r.color||n,...r}),a.add(i))}}),e),[]).sort((e,t)=>e.id.localeCompare(t.id))}var Bs=1e3,Vs=10,Hs={nodeOrigin:[0,0],nodeExtent:so,elevateNodesOnSelect:!0,zIndexMode:`basic`,defaults:{}},Us={...Hs,checkEquality:!0};function Ws(e,t){let n={...e};for(let e in t)t[e]!==void 0&&(n[e]=t[e]);return n}function Gs(e,t,n){let r=Ws(Hs,n);for(let n of e.values())if(n.parentId)Xs(n,e,t,r);else{let e=Mo(So(n,r.nodeOrigin),ts(n.extent)?n.extent:r.nodeExtent,ns(n));n.internals.positionAbsolute=e}}function Ks(e,t){if(!e.handles)return e.measured?t?.internals.handleBounds:void 0;let n=[],r=[];for(let t of e.handles){let i={id:t.id,width:t.width??1,height:t.height??1,nodeId:e.id,x:t.x,y:t.y,position:t.position,type:t.type};t.type===`source`?n.push(i):t.type===`target`&&r.push(i)}return{source:n,target:r}}function qs(e){return e===`manual`}function Js(e,t,n,r={}){let i=Ws(Us,r),a={i:0},o=new Map(t),s=i?.elevateNodesOnSelect&&!qs(i.zIndexMode)?Bs:0,c=e.length>0,l=!1;t.clear(),n.clear();for(let u of e){let e=o.get(u.id);if(i.checkEquality&&u===e?.internals.userNode)t.set(u.id,e);else{let n=Mo(So(u,i.nodeOrigin),ts(u.extent)?u.extent:i.nodeExtent,ns(u));e={...i.defaults,...u,measured:{width:u.measured?.width,height:u.measured?.height},internals:{positionAbsolute:n,handleBounds:Ks(u,e),z:Zs(u,s,i.zIndexMode),userNode:u}},t.set(u.id,e)}(e.measured===void 0||e.measured.width===void 0||e.measured.height===void 0)&&!e.hidden&&(c=!1),u.parentId&&Xs(e,t,n,r,a),l||=u.selected??!1}return{nodesInitialized:c,hasSelectedNodes:l}}function Ys(e,t){if(!e.parentId)return;let n=t.get(e.parentId);n?n.set(e.id,e):t.set(e.parentId,new Map([[e.id,e]]))}function Xs(e,t,n,r,i){let{elevateNodesOnSelect:a,nodeOrigin:o,nodeExtent:s,zIndexMode:c}=Ws(Hs,r),l=e.parentId,u=t.get(l);if(!u){console.warn(`Parent node ${l} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}Ys(e,n),i&&!u.parentId&&u.internals.rootParentIndex===void 0&&c===`auto`&&(u.internals.rootParentIndex=++i.i,u.internals.z=u.internals.z+i.i*Vs),i&&u.internals.rootParentIndex!==void 0&&(i.i=u.internals.rootParentIndex);let{x:d,y:f,z:p}=Qs(e,u,o,s,a&&!qs(c)?Bs:0,c),{positionAbsolute:m}=e.internals,h=d!==m.x||f!==m.y;(h||p!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:h?{x:d,y:f}:m,z:p}})}function Zs(e,t,n){let r=Go(e.zIndex)?e.zIndex:0;return qs(n)?r:r+(e.selected?t:0)}function Qs(e,t,n,r,i,a){let{x:o,y:s}=t.internals.positionAbsolute,c=ns(e),l=So(e,n),u=ts(e.extent)?Mo(l,e.extent,c):l,d=Mo({x:o+u.x,y:s+u.y},r,c);e.extent===`parent`&&(d=No(d,c,t));let f=Zs(e,i,a),p=t.internals.z??0;return{x:d.x,y:d.y,z:p>=f?p+1:f}}function $s(e,t,n,r=[0,0]){let i=[],a=new Map;for(let n of e){let e=t.get(n.parentId);if(!e)continue;let r=Vo(a.get(n.parentId)?.expandedRect??zo(e),n.rect);a.set(n.parentId,{expandedRect:r,parent:e})}return a.size>0&&a.forEach(({expandedRect:t,parent:a},o)=>{let s=a.internals.positionAbsolute,c=ns(a),l=a.origin??r,u=t.x0||d>0||m||h)&&(i.push({id:o,type:`position`,position:{x:a.position.x-u+m,y:a.position.y-d+h}}),n.get(o)?.forEach(t=>{e.some(e=>e.id===t.id)||i.push({id:t.id,type:`position`,position:{x:t.position.x+u,y:t.position.y+d}})})),(c.width0){let e=$s(f,t,n,i);l.push(...e)}return{changes:l,updatedInternals:c}}async function tc({delta:e,panZoom:t,transform:n,translateExtent:r,width:i,height:a}){if(!t||!e.x&&!e.y)return!1;let o=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[i,a]],r);return!!o&&(o.x!==n[0]||o.y!==n[1]||o.k!==n[2])}function nc(e,t,n,r,i,a){let o=i,s=r.get(o)||new Map;r.set(o,s.set(n,t)),o=`${i}-${e}`;let c=r.get(o)||new Map;if(r.set(o,c.set(n,t)),a){o=`${i}-${e}-${a}`;let s=r.get(o)||new Map;r.set(o,s.set(n,t))}}function rc(e,t,n){e.clear(),t.clear();for(let r of n){let{source:n,target:i,sourceHandle:a=null,targetHandle:o=null}=r,s={edgeId:r.id,source:n,target:i,sourceHandle:a,targetHandle:o},c=`${n}-${a}--${i}-${o}`;nc(`source`,s,`${i}-${o}--${n}-${a}`,e,n,a),nc(`target`,s,c,e,i,o),t.set(r.id,r)}}function ic(e,t){if(!e.parentId)return!1;let n=t.get(e.parentId);return n?n.selected?!0:ic(n,t):!1}function ac(e,t,n){let r=e;do{if(r?.matches?.(t))return!0;if(r===n)return!1;r=r?.parentElement}while(r);return!1}function oc(e,t,n,r){let i=new Map;for(let[a,o]of e)if((o.selected||o.id===r)&&(!o.parentId||!ic(o,e))&&(o.draggable||t&&o.draggable===void 0)){let t=e.get(a);t&&i.set(a,{id:a,position:t.position||{x:0,y:0},distance:{x:n.x-t.internals.positionAbsolute.x,y:n.y-t.internals.positionAbsolute.y},extent:t.extent,parentId:t.parentId,origin:t.origin,expandParent:t.expandParent,internals:{positionAbsolute:t.internals.positionAbsolute||{x:0,y:0}},measured:{width:t.measured.width??0,height:t.measured.height??0}})}return i}function sc({nodeId:e,dragItems:t,nodeLookup:n,dragging:r=!0}){let i=[];for(let[e,a]of t){let t=n.get(e)?.internals.userNode;t&&i.push({...t,position:a.position,dragging:r})}if(!e)return[i[0],i];let a=n.get(e)?.internals.userNode;return[a?{...a,position:t.get(e)?.position||a.position,dragging:r}:i[0],i]}function cc({dragItems:e,snapGrid:t,x:n,y:r}){let i=e.values().next().value;if(!i)return null;let a={x:n-i.distance.x,y:r-i.distance.y},o=qo(a,t);return{x:o.x-a.x,y:o.y-a.y}}function lc({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:r,onDragStop:i}){let a={x:null,y:null},o=0,s=new Map,c=!1,l={x:0,y:0},u=null,d=!1,f=null,p=!1,m=!1,h=null;function g({noDragClassName:g,handleSelector:_,domNode:v,isSelectable:y,nodeId:b,nodeClickDistance:x=0}){f=On(v);function S({x:e,y:n}){let{nodeLookup:i,nodeExtent:o,snapGrid:c,snapToGrid:l,nodeOrigin:u,onNodeDrag:d,onSelectionDrag:f,onError:p,updateNodePositions:g}=t();a={x:e,y:n};let _=!1,v=s.size>1,y=v&&o?Lo(wo(s)):null,x=v&&l?cc({dragItems:s,snapGrid:c,x:e,y:n}):null;for(let[t,r]of s){if(!i.has(t))continue;let a={x:e-r.distance.x,y:n-r.distance.y};l&&(a=x?{x:Math.round(a.x+x.x),y:Math.round(a.y+x.y)}:qo(a,c));let s=null;if(v&&o&&!r.extent&&y){let{positionAbsolute:e}=r.internals,t=e.x-y.x+o[0][0],n=e.x+r.measured.width-y.x2+o[1][0],i=e.y-y.y+o[0][1],a=e.y+r.measured.height-y.y2+o[1][1];s=[[t,i],[n,a]]}let{position:d,positionAbsolute:f}=ko({nodeId:t,nextPosition:a,nodeLookup:i,nodeExtent:s||o,nodeOrigin:u,onError:p});_=_||r.position.x!==d.x||r.position.y!==d.y,r.position=d,r.internals.positionAbsolute=f}if(m||=_,_&&(g(s,!0),h&&(r||d||!b&&f))){let[e,t]=sc({nodeId:b,dragItems:s,nodeLookup:i});r?.(h,s,e,t),d?.(h,e,t),b||f?.(h,t)}}async function C(){if(!u)return;let{transform:e,panBy:n,autoPanSpeed:r,autoPanOnNodeDrag:i}=t();if(!i){c=!1,cancelAnimationFrame(o);return}let[s,d]=Fo(l,u,r);(s!==0||d!==0)&&(a.x=(a.x??0)-s/e[2],a.y=(a.y??0)-d/e[2],await n({x:s,y:d})&&S(a)),o=requestAnimationFrame(C)}function w(r){let{nodeLookup:i,multiSelectionActive:o,nodesDraggable:c,transform:l,snapGrid:f,snapToGrid:p,selectNodesOnDrag:m,onNodeDragStart:h,onSelectionDragStart:g,unselectNodesAndEdges:_}=t();d=!0,(!m||!y)&&!o&&b&&(i.get(b)?.selected||_()),y&&m&&b&&e?.(b);let v=cs(r.sourceEvent,{transform:l,snapGrid:f,snapToGrid:p,containerBounds:u});if(a=v,s=oc(i,c,v,b),s.size>0&&(n||h||!b&&g)){let[e,t]=sc({nodeId:b,dragItems:s,nodeLookup:i});n?.(r.sourceEvent,s,e,t),h?.(r.sourceEvent,e,t),b||g?.(r.sourceEvent,t)}}let T=Un().clickDistance(x).on(`start`,e=>{let{domNode:n,nodeDragThreshold:r,transform:i,snapGrid:o,snapToGrid:s}=t();u=n?.getBoundingClientRect()||null,p=!1,m=!1,h=e.sourceEvent,r===0&&w(e),a=cs(e.sourceEvent,{transform:i,snapGrid:o,snapToGrid:s,containerBounds:u}),l=ms(e.sourceEvent,u)}).on(`drag`,e=>{let{autoPanOnNodeDrag:n,transform:r,snapGrid:i,snapToGrid:o,nodeDragThreshold:f,nodeLookup:m}=t(),g=cs(e.sourceEvent,{transform:r,snapGrid:i,snapToGrid:o,containerBounds:u});if(h=e.sourceEvent,(e.sourceEvent.type===`touchmove`&&e.sourceEvent.touches.length>1||b&&!m.has(b))&&(p=!0),!p){if(!c&&n&&d&&(c=!0,C()),!d){let t=ms(e.sourceEvent,u),n=t.x-l.x,r=t.y-l.y;Math.sqrt(n*n+r*r)>f&&w(e)}(a.x!==g.xSnapped||a.y!==g.ySnapped)&&s&&d&&(l=ms(e.sourceEvent,u),S(g))}}).on(`end`,e=>{if(!d||p){p&&s.size>0&&t().updateNodePositions(s,!1);return}if(c=!1,d=!1,cancelAnimationFrame(o),s.size>0){let{nodeLookup:n,updateNodePositions:r,onNodeDragStop:a,onSelectionDragStop:o}=t();if(m&&=(r(s,!1),!1),i||a||!b&&o){let[t,r]=sc({nodeId:b,dragItems:s,nodeLookup:n,dragging:!1});i?.(e.sourceEvent,s,t,r),a?.(e.sourceEvent,t,r),b||o?.(e.sourceEvent,r)}}}).filter(e=>{let t=e.target;return!e.button&&(!g||!ac(t,`.${g}`,v))&&(!_||ac(t,_,v))});f.call(T)}function _(){f?.on(`.drag`,null)}return{update:g,destroy:_}}function uc(e,t,n){let r=[],i={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(let e of t.values())Uo(i,zo(e))>0&&r.push(e);return r}var dc=250;function fc(e,t,n,r){let i=[],a=1/0,o=uc(e,n,t+dc);for(let n of o){let o=[...n.internals.handleBounds?.source??[],...n.internals.handleBounds?.target??[]];for(let s of o){if(r.nodeId===s.nodeId&&r.type===s.type&&r.id===s.id)continue;let{x:o,y:c}=Is(n,s,s.position,!0),l=Math.sqrt((o-e.x)**2+(c-e.y)**2);l>t||(l1){let e=r.type===`source`?`target`:`source`;return i.find(t=>t.type===e)??i[0]}return i[0]}function pc(e,t,n,r,i,a=!1){let o=r.get(e);if(!o)return null;let s=i===`strict`?o.internals.handleBounds?.[t]:[...o.internals.handleBounds?.source??[],...o.internals.handleBounds?.target??[]],c=(n?s?.find(e=>e.id===n):s?.[0])??null;return c&&a?{...c,...Is(o,c,c.position,!0)}:c}function mc(e,t){return e||(t?.classList.contains(`target`)?`target`:t?.classList.contains(`source`)?`source`:null)}function hc(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}var gc=()=>!0;function _c(e,{connectionMode:t,connectionRadius:n,handleId:r,nodeId:i,edgeUpdaterType:a,isTarget:o,domNode:s,nodeLookup:c,lib:l,autoPanOnConnect:u,flowId:d,panBy:f,cancelConnection:p,onConnectStart:m,onConnect:h,onConnectEnd:g,isValidConnection:_=gc,onReconnectEnd:v,updateConnection:y,getTransform:b,getFromHandle:x,autoPanSpeed:S,dragThreshold:C=1,handleDomNode:w}){let T=us(e.target),E=0,D,{x:O,y:k}=ms(e),A=mc(a,w),j=s?.getBoundingClientRect(),M=!1;if(!j||!A)return;let N=pc(i,A,r,c,t);if(!N)return;let P=ms(e,j),F=!1,I=null,L=!1,R=null;function z(){if(!u||!j)return;let[e,t]=Fo(P,j,S);f({x:e,y:t}),E=requestAnimationFrame(z)}let B={...N,nodeId:i,type:A,position:N.position},V=c.get(i),ee={inProgress:!0,isValid:null,from:Is(V,B,Z.Left,!0),fromHandle:B,fromPosition:B.position,fromNode:V,to:P,toHandle:null,toPosition:_o[B.position],toNode:null,pointer:P};function te(){M=!0,y(ee),m?.(e,{nodeId:i,handleId:r,handleType:A})}C===0&&te();function H(e){if(!M){let{x:t,y:n}=ms(e),r=t-O,i=n-k;if(!(r*r+i*i>C*C))return;te()}if(!x()||!B){U(e);return}let a=b();P=ms(e,j),D=fc(Jo(P,a,!1,[1,1]),n,c,B),F||=(z(),!0);let s=vc(e,{handle:D,connectionMode:t,fromNodeId:i,fromHandleId:r,fromType:o?`target`:`source`,isValidConnection:_,doc:T,lib:l,flowId:d,nodeLookup:c});R=s.handleDomNode,I=s.connection,L=hc(!!D,s.isValid);let u=c.get(i),f=u?Is(u,B,Z.Left,!0):ee.from,p={...ee,from:f,isValid:L,to:s.toHandle&&L?Yo({x:s.toHandle.x,y:s.toHandle.y},a):P,toHandle:s.toHandle,toPosition:L&&s.toHandle?s.toHandle.position:_o[B.position],toNode:s.toHandle?c.get(s.toHandle.nodeId):null,pointer:P};y(p),ee=p}function U(e){if(!(`touches`in e&&e.touches.length>0)){if(M){(D||R)&&I&&L&&h?.(I);let{inProgress:t,...n}=ee,r={...n,toPosition:ee.toHandle?ee.toPosition:null};g?.(e,r),a&&v?.(e,r)}p(),cancelAnimationFrame(E),F=!1,L=!1,I=null,R=null,T.removeEventListener(`mousemove`,H),T.removeEventListener(`mouseup`,U),T.removeEventListener(`touchmove`,H),T.removeEventListener(`touchend`,U)}}T.addEventListener(`mousemove`,H),T.addEventListener(`mouseup`,U),T.addEventListener(`touchmove`,H),T.addEventListener(`touchend`,U)}function vc(e,{handle:t,connectionMode:n,fromNodeId:r,fromHandleId:i,fromType:a,doc:o,lib:s,flowId:c,isValidConnection:l=gc,nodeLookup:u}){let d=a===`target`,f=t?o.querySelector(`.${s}-flow__handle[data-id="${c}-${t?.nodeId}-${t?.id}-${t?.type}"]`):null,{x:p,y:m}=ms(e),h=o.elementFromPoint(p,m),g=h?.classList.contains(`${s}-flow__handle`)?h:f,_={handleDomNode:g,isValid:!1,connection:null,toHandle:null};if(g){let e=mc(void 0,g),t=g.getAttribute(`data-nodeid`),a=g.getAttribute(`data-handleid`),o=g.classList.contains(`connectable`),s=g.classList.contains(`connectableend`);if(!t||!e)return _;let c={source:d?t:r,sourceHandle:d?a:i,target:d?r:t,targetHandle:d?i:a};_.connection=c,_.isValid=o&&s&&(n===uo.Strict?d&&e===`source`||!d&&e===`target`:t!==r||a!==i)&&l(c),_.toHandle=pc(t,e,a,u,n,!0)}return _}var yc={onPointerDown:_c,isValid:vc};function bc({domNode:e,panZoom:t,getTransform:n,getViewScale:r}){let i=On(e);function a({translateExtent:e,width:a,height:o,zoomStep:s=1,pannable:c=!0,zoomable:l=!0,inversePan:u=!1}){let d=e=>{if(e.sourceEvent.type!==`wheel`||!t)return;let r=n(),i=e.sourceEvent.ctrlKey&&es()?10:1,a=-e.sourceEvent.deltaY*(e.sourceEvent.deltaMode===1?.05:e.sourceEvent.deltaMode?1:.002)*s,o=r[2]*2**(a*i);t.scaleTo(o)},f=[0,0],p=ao().on(`start`,e=>{(e.sourceEvent.type===`mousedown`||e.sourceEvent.type===`touchstart`)&&(f=[e.sourceEvent.clientX??e.sourceEvent.touches[0].clientX,e.sourceEvent.clientY??e.sourceEvent.touches[0].clientY])}).on(`zoom`,c?i=>{let s=n();if(i.sourceEvent.type!==`mousemove`&&i.sourceEvent.type!==`touchmove`||!t)return;let c=[i.sourceEvent.clientX??i.sourceEvent.touches[0].clientX,i.sourceEvent.clientY??i.sourceEvent.touches[0].clientY],l=[c[0]-f[0],c[1]-f[1]];f=c;let d=r()*Math.max(s[2],Math.log(s[2]))*(u?-1:1),p={x:s[0]-l[0]*d,y:s[1]-l[1]*d},m=[[0,0],[a,o]];t.setViewportConstrained({x:p.x,y:p.y,zoom:s[2]},m,e)}:null).on(`zoom.wheel`,l?d:null);i.call(p,{})}function o(){i.on(`zoom`,null)}return{update:a,destroy:o,pointer:An}}var xc=e=>({x:e.x,y:e.y,zoom:e.k}),Sc=({x:e,y:t,zoom:n})=>Ya.translate(e,t).scale(n),Cc=(e,t)=>e.target.closest(`.${t}`),wc=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),Tc=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,Ec=(e,t=0,n=Tc,r=()=>{})=>{let i=typeof t==`number`&&t>0;return i||r(),i?e.transition().duration(t).ease(n).on(`end`,r):e},Dc=e=>{let t=e.ctrlKey&&es()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function Oc({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:r,panOnScrollMode:i,panOnScrollSpeed:a,zoomOnPinch:o,onPanZoomStart:s,onPanZoom:c,onPanZoomEnd:l}){return u=>{if(Cc(u,t))return u.ctrlKey&&u.preventDefault(),!1;u.preventDefault(),u.stopImmediatePropagation();let d=n.property(`__zoom`).k||1;if(u.ctrlKey&&o){let e=An(u),t=d*2**Dc(u);r.scaleTo(n,t,e,u);return}let f=u.deltaMode===1?20:1,p=i===fo.Vertical?0:u.deltaX*f,m=i===fo.Horizontal?0:u.deltaY*f;!es()&&u.shiftKey&&i!==fo.Vertical&&(p=u.deltaY*f,m=0),r.translateBy(n,-(p/d)*a,-(m/d)*a,{internal:!0});let h=xc(n.property(`__zoom`));clearTimeout(e.panScrollTimeout),e.isPanScrolling?(c?.(u,h),e.panScrollTimeout=setTimeout(()=>{l?.(u,h),e.isPanScrolling=!1},150)):(e.isPanScrolling=!0,s?.(u,h))}}function kc({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(r,i){let a=r.type===`wheel`,o=!t&&a&&!r.ctrlKey,s=Cc(r,e);if(r.ctrlKey&&a&&s&&r.preventDefault(),o||s)return null;r.preventDefault(),n.call(this,r,i)}}function Ac({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return r=>{if(r.sourceEvent?.internal)return;let i=xc(r.transform);e.mouseButton=r.sourceEvent?.button||0,e.isZoomingOrPanning=!0,e.prevViewport=i,r.sourceEvent?.type===`mousedown`&&t(!0),n&&n?.(r.sourceEvent,i)}}function jc({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:r,onPanZoom:i}){return a=>{e.usedRightMouseButton=!!(n&&wc(t,e.mouseButton??0)),a.sourceEvent?.sync||r([a.transform.x,a.transform.y,a.transform.k]),i&&!a.sourceEvent?.internal&&i?.(a.sourceEvent,xc(a.transform))}}function Mc({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:r,onPanZoomEnd:i,onPaneContextMenu:a}){return o=>{if(!o.sourceEvent?.internal&&(e.isZoomingOrPanning=!1,a&&wc(t,e.mouseButton??0)&&!e.usedRightMouseButton&&o.sourceEvent&&a(o.sourceEvent),e.usedRightMouseButton=!1,r(!1),i)){let t=xc(o.transform);e.prevViewport=t,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{i?.(o.sourceEvent,t)},n?150:0)}}}function Nc({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:n,panOnDrag:r,panOnScroll:i,zoomOnDoubleClick:a,userSelectionActive:o,noWheelClassName:s,noPanClassName:c,lib:l,connectionInProgress:u}){return d=>{let f=e||t,p=n&&d.ctrlKey,m=d.type===`wheel`;if(d.button===1&&d.type===`mousedown`&&(Cc(d,`${l}-flow__node`)||Cc(d,`${l}-flow__edge`)))return!0;if(!r&&!f&&!i&&!a&&!n||o||u&&!m||Cc(d,s)&&m||Cc(d,c)&&(!m||i&&m&&!e)||!n&&d.ctrlKey&&m)return!1;if(!n&&d.type===`touchstart`&&d.touches?.length>1)return d.preventDefault(),!1;if(!f&&!i&&!p&&m||!r&&(d.type===`mousedown`||d.type===`touchstart`)||Array.isArray(r)&&!r.includes(d.button)&&d.type===`mousedown`)return!1;let h=Array.isArray(r)&&r.includes(d.button)||!d.button||d.button<=1;return(!d.ctrlKey||m)&&h}}function Pc({domNode:e,minZoom:t,maxZoom:n,translateExtent:r,viewport:i,onPanZoom:a,onPanZoomStart:o,onPanZoomEnd:s,onDraggingChange:c}){let l={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},u=e.getBoundingClientRect(),d=ao().scaleExtent([t,n]).translateExtent(r),f=On(e).call(d);v({x:i.x,y:i.y,zoom:jo(i.zoom,t,n)},[[0,0],[u.width,u.height]],r);let p=f.on(`wheel.zoom`),m=f.on(`dblclick.zoom`);d.wheelDelta(Dc);async function h(e,t){return f?new Promise(n=>{d?.interpolate(t?.interpolate===`linear`?Kr:oi).transform(Ec(f,t?.duration,t?.ease,()=>n(!0)),e)}):!1}function g({noWheelClassName:e,noPanClassName:t,onPaneContextMenu:n,userSelectionActive:r,panOnScroll:i,panOnDrag:u,panOnScrollMode:h,panOnScrollSpeed:g,preventScrolling:v,zoomOnPinch:y,zoomOnScroll:b,zoomOnDoubleClick:x,zoomActivationKeyPressed:S,lib:C,onTransformChange:w,connectionInProgress:T,paneClickDistance:E,selectionOnDrag:D}){r&&!l.isZoomingOrPanning&&_();let O=i&&!S&&!r;d.clickDistance(D?1/0:!Go(E)||E<0?0:E);let k=O?Oc({zoomPanValues:l,noWheelClassName:e,d3Selection:f,d3Zoom:d,panOnScrollMode:h,panOnScrollSpeed:g,zoomOnPinch:y,onPanZoomStart:o,onPanZoom:a,onPanZoomEnd:s}):kc({noWheelClassName:e,preventScrolling:v,d3ZoomHandler:p});f.on(`wheel.zoom`,k,{passive:!1});let A=Ac({zoomPanValues:l,onDraggingChange:c,onPanZoomStart:o});d.on(`start`,A);let j=jc({zoomPanValues:l,panOnDrag:u,onPaneContextMenu:!!n,onPanZoom:a,onTransformChange:w});d.on(`zoom`,j);let M=Mc({zoomPanValues:l,panOnDrag:u,panOnScroll:i,onPaneContextMenu:n,onPanZoomEnd:s,onDraggingChange:c});d.on(`end`,M);let N=Nc({zoomActivationKeyPressed:S,panOnDrag:u,zoomOnScroll:b,panOnScroll:i,zoomOnDoubleClick:x,zoomOnPinch:y,userSelectionActive:r,noPanClassName:t,noWheelClassName:e,lib:C,connectionInProgress:T});d.filter(N),x?f.on(`dblclick.zoom`,m):f.on(`dblclick.zoom`,null)}function _(){d.on(`zoom`,null)}async function v(e,t,n){let r=Sc(e),i=d?.constrain()(r,t,n);return i&&await h(i),i}async function y(e,t){let n=Sc(e);return await h(n,t),n}function b(e){if(f){let t=Sc(e),n=f.property(`__zoom`);(n.k!==e.zoom||n.x!==e.x||n.y!==e.y)&&d?.transform(f,t,null,{sync:!0})}}function x(){let e=f?Xa(f.node()):{x:0,y:0,k:1};return{x:e.x,y:e.y,zoom:e.k}}async function S(e,t){return f?new Promise(n=>{d?.interpolate(t?.interpolate===`linear`?Kr:oi).scaleTo(Ec(f,t?.duration,t?.ease,()=>n(!0)),e)}):!1}async function C(e,t){return f?new Promise(n=>{d?.interpolate(t?.interpolate===`linear`?Kr:oi).scaleBy(Ec(f,t?.duration,t?.ease,()=>n(!0)),e)}):!1}function w(e){d?.scaleExtent(e)}function T(e){d?.translateExtent(e)}function E(e){let t=!Go(e)||e<0?0:e;d?.clickDistance(t)}return{update:g,destroy:_,setViewport:y,setViewportConstrained:v,getViewport:x,scaleTo:S,scaleBy:C,setScaleExtent:w,setTranslateExtent:T,syncViewport:b,setClickDistance:E}}var Fc;(function(e){e.Line=`line`,e.Handle=`handle`})(Fc||={});function Ic({width:e,prevWidth:t,height:n,prevHeight:r,affectsX:i,affectsY:a}){let o=e-t,s=n-r,c=[o>0?1:o<0?-1:0,s>0?1:s<0?-1:0];return o&&i&&(c[0]*=-1),s&&a&&(c[1]*=-1),c}function Lc(e){return{isHorizontal:e.includes(`right`)||e.includes(`left`),isVertical:e.includes(`bottom`)||e.includes(`top`),affectsX:e.includes(`left`),affectsY:e.includes(`top`)}}function Rc(e,t){return Math.max(0,t-e)}function zc(e,t){return Math.max(0,e-t)}function Bc(e,t,n){return Math.max(0,t-e,e-n)}function Vc(e,t){return e?!t:t}function Hc(e,t,n,r,i,a,o,s){let{affectsX:c,affectsY:l}=t,{isHorizontal:u,isVertical:d}=t,f=u&&d,{xSnapped:p,ySnapped:m}=n,{minWidth:h,maxWidth:g,minHeight:_,maxHeight:v}=r,{x:y,y:b,width:x,height:S,aspectRatio:C}=e,w=Math.floor(u?p-e.pointerX:0),T=Math.floor(d?m-e.pointerY:0),E=x+(c?-w:w),D=S+(l?-T:T),O=-a[0]*x,k=-a[1]*S,A=Bc(E,h,g),j=Bc(D,_,v);if(o){let e=0,t=0;c&&w<0?e=Rc(y+w+O,o[0][0]):!c&&w>0&&(e=zc(y+E+O,o[1][0])),l&&T<0?t=Rc(b+T+k,o[0][1]):!l&&T>0&&(t=zc(b+D+k,o[1][1])),A=Math.max(A,e),j=Math.max(j,t)}if(s){let e=0,t=0;c&&w>0?e=zc(y+w,s[0][0]):!c&&w<0&&(e=Rc(y+E,s[1][0])),l&&T>0?t=zc(b+T,s[0][1]):!l&&T<0&&(t=Rc(b+D,s[1][1])),A=Math.max(A,e),j=Math.max(j,t)}if(i){if(u){let e=Bc(E/C,_,v)*C;if(A=Math.max(A,e),o){let e=0;e=!c&&!l||c&&!l&&f?zc(b+k+E/C,o[1][1])*C:Rc(b+k+(c?w:-w)/C,o[0][1])*C,A=Math.max(A,e)}if(s){let e=0;e=!c&&!l||c&&!l&&f?Rc(b+E/C,s[1][1])*C:zc(b+(c?w:-w)/C,s[0][1])*C,A=Math.max(A,e)}}if(d){let e=Bc(D*C,h,g)/C;if(j=Math.max(j,e),o){let e=0;e=!c&&!l||l&&!c&&f?zc(y+D*C+O,o[1][0])/C:Rc(y+(l?T:-T)*C+O,o[0][0])/C,j=Math.max(j,e)}if(s){let e=0;e=!c&&!l||l&&!c&&f?Rc(y+D*C,s[1][0])/C:zc(y+(l?T:-T)*C,s[0][0])/C,j=Math.max(j,e)}}}T+=T<0?j:-j,w+=w<0?A:-A,i&&(f?E>D*C?T=(Vc(c,l)?-w:w)/C:w=(Vc(c,l)?-T:T)*C:u?(T=w/C,l=c):(w=T*C,c=l));let M=c?y+w:y,N=l?b+T:b;return{width:x+(c?-w:w),height:S+(l?-T:T),x:a[0]*w*(c?-1:1)+M,y:a[1]*T*(l?-1:1)+N}}var Uc={width:0,height:0,x:0,y:0},Wc={...Uc,pointerX:0,pointerY:0,aspectRatio:1};function Gc(e,t,n){let r=t.position.x+e.position.x,i=t.position.y+e.position.y,a=e.measured.width??0,o=e.measured.height??0,s=n[0]*a,c=n[1]*o;return[[r-s,i-c],[r+a-s,i+o-c]]}function Kc({domNode:e,nodeId:t,getStoreItems:n,onChange:r,onEnd:i}){let a=On(e),o={controlDirection:Lc(`bottom-right`),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function s({controlPosition:e,boundaries:s,keepAspectRatio:c,resizeDirection:l,onResizeStart:u,onResize:d,onResizeEnd:f,shouldResize:p}){let m={...Uc},h={...Wc};o={boundaries:s,resizeDirection:l,keepAspectRatio:c,controlDirection:Lc(e)};let g,_=null,v=[],y,b,x,S=!1,C=Un().on(`start`,e=>{let{nodeLookup:r,transform:i,snapGrid:a,snapToGrid:o,nodeOrigin:s,paneDomNode:c}=n();if(g=r.get(t),!g)return;_=c?.getBoundingClientRect()??null;let{xSnapped:l,ySnapped:d}=cs(e.sourceEvent,{transform:i,snapGrid:a,snapToGrid:o,containerBounds:_});m={width:g.measured.width??0,height:g.measured.height??0,x:g.position.x??0,y:g.position.y??0},h={...m,pointerX:l,pointerY:d,aspectRatio:m.width/m.height},y=void 0,b=ts(g.extent)?g.extent:void 0,g.parentId&&(g.extent===`parent`||g.expandParent)&&(y=r.get(g.parentId)),y&&g.extent===`parent`&&(b=[[0,0],[y.measured.width,y.measured.height]]),v=[],x=void 0;for(let[e,n]of r)if(n.parentId===t&&(v.push({id:e,position:{...n.position},extent:n.extent}),n.extent===`parent`||n.expandParent)){let e=Gc(n,g,n.origin??s);x=x?[[Math.min(e[0][0],x[0][0]),Math.min(e[0][1],x[0][1])],[Math.max(e[1][0],x[1][0]),Math.max(e[1][1],x[1][1])]]:e}u?.(e,{...m})}).on(`drag`,e=>{let{transform:t,snapGrid:i,snapToGrid:a,nodeOrigin:s}=n(),c=cs(e.sourceEvent,{transform:t,snapGrid:i,snapToGrid:a,containerBounds:_}),l=[];if(!g)return;let{x:u,y:f,width:C,height:w}=m,T={},E=g.origin??s,{width:D,height:O,x:k,y:A}=Hc(h,o.controlDirection,c,o.boundaries,o.keepAspectRatio,E,b,x),j=D!==C,M=O!==w,N=k!==u&&j,P=A!==f&&M;if(!N&&!P&&!j&&!M)return;if((N||P||E[0]===1||E[1]===1)&&(T.x=N?k:m.x,T.y=P?A:m.y,m.x=T.x,m.y=T.y,v.length>0)){let e=k-u,t=A-f;for(let n of v)n.position={x:n.position.x-e+E[0]*(D-C),y:n.position.y-t+E[1]*(O-w)},l.push(n)}if((j||M)&&(T.width=j&&(!o.resizeDirection||o.resizeDirection===`horizontal`)?D:m.width,T.height=M&&(!o.resizeDirection||o.resizeDirection===`vertical`)?O:m.height,m.width=T.width,m.height=T.height),y&&g.expandParent){let e=E[0]*(T.width??0);T.x&&T.x{S&&=(f?.(e,{...m}),i?.({...m}),!1)});a.call(C)}function c(){a.on(`.drag`,null)}return{update:s,destroy:c}}var qc=t((e=>{var t=n();function r(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var i=typeof Object.is==`function`?Object.is:r,a=t.useState,o=t.useEffect,s=t.useLayoutEffect,c=t.useDebugValue;function l(e,t){var n=t(),r=a({inst:{value:n,getSnapshot:t}}),i=r[0].inst,l=r[1];return s(function(){i.value=n,i.getSnapshot=t,u(i)&&l({inst:i})},[e,n,t]),o(function(){return u(i)&&l({inst:i}),e(function(){u(i)&&l({inst:i})})},[e]),c(n),n}function u(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!i(e,n)}catch{return!0}}function d(e,t){return t()}var f=typeof window>`u`||window.document===void 0||window.document.createElement===void 0?d:l;e.useSyncExternalStore=t.useSyncExternalStore===void 0?f:t.useSyncExternalStore})),Jc=t(((e,t)=>{t.exports=qc()})),Yc=t((e=>{var t=n(),r=Jc();function i(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var a=typeof Object.is==`function`?Object.is:i,o=r.useSyncExternalStore,s=t.useRef,c=t.useEffect,l=t.useMemo,u=t.useDebugValue;e.useSyncExternalStoreWithSelector=function(e,t,n,r,i){var d=s(null);if(d.current===null){var f={hasValue:!1,value:null};d.current=f}else f=d.current;d=l(function(){function e(e){if(!o){if(o=!0,s=e,e=r(e),i!==void 0&&f.hasValue){var t=f.value;if(i(t,e))return c=t}return c=e}if(t=c,a(s,e))return t;var n=r(e);return i!==void 0&&i(t,n)?(s=e,t):(s=e,c=n)}var o=!1,s,c,l=n===void 0?null:n;return[function(){return e(t())},l===null?void 0:function(){return e(l())}]},[t,n,r,i]);var p=o(e,d[0],d[1]);return c(function(){f.hasValue=!0,f.value=p},[p]),u(p),p}})),Xc=e(t(((e,t)=>{t.exports=Yc()}))(),1),Zc=e=>{let t,n=new Set,r=(e,r)=>{let i=typeof e==`function`?e(t):e;if(!Object.is(i,t)){let e=t;t=r??(typeof i!=`object`||!i)?i:Object.assign({},t,i),n.forEach(n=>n(t,e))}},i=()=>t,a={setState:r,getState:i,getInitialState:()=>o,subscribe:e=>(n.add(e),()=>n.delete(e)),destroy:()=>{n.clear()}},o=t=e(r,i,a);return a},Qc=e=>e?Zc(e):Zc,{useDebugValue:$c}=Y.default,{useSyncExternalStoreWithSelector:el}=Xc.default,tl=e=>e;function nl(e,t=tl,n){let r=el(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return $c(r),r}var rl=(e,t)=>{let n=Qc(e),r=(e,r=t)=>nl(n,e,r);return Object.assign(r,n),r},il=(e,t)=>e?rl(e,t):rl;function al(e,t){if(Object.is(e,t))return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(let[n,r]of e)if(!Object.is(r,t.get(n)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}let n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let r of n)if(!Object.prototype.hasOwnProperty.call(t,r)||!Object.is(e[r],t[r]))return!1;return!0}var ol=(0,Y.createContext)(null),sl=ol.Provider,cl=oo.error001(`react`);function Q(e,t){let n=(0,Y.useContext)(ol);if(n===null)throw Error(cl);return nl(n,e,t)}function $(){let e=(0,Y.useContext)(ol);if(e===null)throw Error(cl);return(0,Y.useMemo)(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}var ll={display:`none`},ul={position:`absolute`,width:1,height:1,margin:-1,border:0,padding:0,overflow:`hidden`,clip:`rect(0px, 0px, 0px, 0px)`,clipPath:`inset(100%)`},dl=`react-flow__node-desc`,fl=`react-flow__edge-desc`,pl=`react-flow__aria-live`,ml=e=>e.ariaLiveMessage,hl=e=>e.ariaLabelConfig;function gl({rfId:e}){let t=Q(ml);return(0,J.jsx)(`div`,{id:`${pl}-${e}`,"aria-live":`assertive`,"aria-atomic":`true`,style:ul,children:t})}function _l({rfId:e,disableKeyboardA11y:t}){let n=Q(hl);return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{id:`${dl}-${e}`,style:ll,children:t?n[`node.a11yDescription.default`]:n[`node.a11yDescription.keyboardDisabled`]}),(0,J.jsx)(`div`,{id:`${fl}-${e}`,style:ll,children:n[`edge.a11yDescription.default`]}),!t&&(0,J.jsx)(gl,{rfId:e})]})}var vl=(0,Y.forwardRef)(({position:e=`top-left`,children:t,className:n,style:r,...i},a)=>{let o=`${e}`.split(`-`);return(0,J.jsx)(`div`,{className:Se([`react-flow__panel`,n,...o]),style:r,ref:a,...i,children:t})});vl.displayName=`Panel`;var yl=`https://reactflow.dev?utm_source=attribution`;function bl({proOptions:e,position:t=`bottom-right`}){return e?.hideAttribution?null:(0,J.jsx)(vl,{position:t,className:`react-flow__attribution`,"data-message":`Please only hide this attribution when you are subscribed to React Flow Pro: ${yl}`,children:(0,J.jsx)(`a`,{href:yl,target:`_blank`,rel:`noopener noreferrer`,"aria-label":`React Flow attribution`,children:`React Flow`})})}var xl=e=>{let t=[],n=[];for(let[,n]of e.nodeLookup)n.selected&&t.push(n.internals.userNode);for(let[,t]of e.edgeLookup)t.selected&&n.push(t);return{selectedNodes:t,selectedEdges:n}},Sl=e=>e.id;function Cl(e,t){return al(e.selectedNodes.map(Sl),t.selectedNodes.map(Sl))&&al(e.selectedEdges.map(Sl),t.selectedEdges.map(Sl))}function wl({onSelectionChange:e}){let t=$(),{selectedNodes:n,selectedEdges:r}=Q(xl,Cl);return(0,Y.useEffect)(()=>{let i={nodes:n,edges:r};e?.(i),t.getState().onSelectionChangeHandlers.forEach(e=>e(i))},[n,r,e]),null}var Tl=e=>!!e.onSelectionChangeHandlers;function El({onSelectionChange:e}){let t=Q(Tl);return e||t?(0,J.jsx)(wl,{onSelectionChange:e}):null}var Dl=[0,0],Ol={x:0,y:0,zoom:1},kl=[...`nodes.edges.defaultNodes.defaultEdges.onConnect.onConnectStart.onConnectEnd.onClickConnectStart.onClickConnectEnd.nodesDraggable.autoPanOnNodeFocus.nodesConnectable.nodesFocusable.edgesFocusable.edgesReconnectable.elevateNodesOnSelect.elevateEdgesOnSelect.minZoom.maxZoom.nodeExtent.onNodesChange.onEdgesChange.elementsSelectable.connectionMode.snapGrid.snapToGrid.translateExtent.connectOnClick.defaultEdgeOptions.fitView.fitViewOptions.onNodesDelete.onEdgesDelete.onDelete.onNodeDrag.onNodeDragStart.onNodeDragStop.onSelectionDrag.onSelectionDragStart.onSelectionDragStop.onMoveStart.onMove.onMoveEnd.noPanClassName.nodeOrigin.autoPanOnConnect.autoPanOnNodeDrag.onError.connectionRadius.isValidConnection.selectNodesOnDrag.nodeDragThreshold.connectionDragThreshold.onBeforeDelete.debug.autoPanSpeed.ariaLabelConfig.zIndexMode`.split(`.`),`rfId`],Al=e=>({setNodes:e.setNodes,setEdges:e.setEdges,setMinZoom:e.setMinZoom,setMaxZoom:e.setMaxZoom,setTranslateExtent:e.setTranslateExtent,setNodeExtent:e.setNodeExtent,reset:e.reset,setDefaultNodesAndEdges:e.setDefaultNodesAndEdges}),jl={translateExtent:so,nodeOrigin:Dl,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:`nopan`,rfId:`1`};function Ml(e){let{setNodes:t,setEdges:n,setMinZoom:r,setMaxZoom:i,setTranslateExtent:a,setNodeExtent:o,reset:s,setDefaultNodesAndEdges:c}=Q(Al,al),l=$();(0,Y.useEffect)(()=>(c(e.defaultNodes,e.defaultEdges),()=>{u.current=jl,s()}),[]);let u=(0,Y.useRef)(jl);return(0,Y.useEffect)(()=>{for(let s of kl){let c=e[s];c!==u.current[s]&&e[s]!==void 0&&(s===`nodes`?t(c):s===`edges`?n(c):s===`minZoom`?r(c):s===`maxZoom`?i(c):s===`translateExtent`?a(c):s===`nodeExtent`?o(c):s===`ariaLabelConfig`?l.setState({ariaLabelConfig:ss(c)}):s===`fitView`?l.setState({fitViewQueued:c}):s===`fitViewOptions`?l.setState({fitViewOptions:c}):l.setState({[s]:c}))}u.current=e},kl.map(t=>e[t])),null}function Nl(){return typeof window>`u`||!window.matchMedia?null:window.matchMedia(`(prefers-color-scheme: dark)`)}function Pl(e){let[t,n]=(0,Y.useState)(e===`system`?null:e);return(0,Y.useEffect)(()=>{if(e!==`system`){n(e);return}let t=Nl(),r=()=>n(t?.matches?`dark`:`light`);return r(),t?.addEventListener(`change`,r),()=>{t?.removeEventListener(`change`,r)}},[e]),t===null?Nl()?.matches?`dark`:`light`:t}var Fl=typeof document<`u`?document:null;function Il(e=null,t={target:Fl,actInsideInputWithModifier:!0}){let[n,r]=(0,Y.useState)(!1),i=(0,Y.useRef)(!1),a=(0,Y.useRef)(new Set([])),[o,s]=(0,Y.useMemo)(()=>{if(e!==null){let t=(Array.isArray(e)?e:[e]).filter(e=>typeof e==`string`).map(e=>e.replace(`+`,` +`).replace(` + +`,` ++`).split(` +`));return[t,t.reduce((e,t)=>e.concat(...t),[])]}return[[],[]]},[e]);return(0,Y.useEffect)(()=>{let n=t?.target??Fl,c=t?.actInsideInputWithModifier??!0;if(e!==null){let e=e=>{if(i.current=e.ctrlKey||e.metaKey||e.shiftKey||e.altKey,(!i.current||i.current&&!c)&&fs(e))return!1;let n=Rl(e.code,s);if(a.current.add(e[n]),Ll(o,a.current,!1)){let n=e.composedPath?.()?.[0]||e.target,a=n?.nodeName===`BUTTON`||n?.nodeName===`A`;t.preventDefault!==!1&&(i.current||!a)&&e.preventDefault(),r(!0)}},l=e=>{let t=Rl(e.code,s);Ll(o,a.current,!0)?(r(!1),a.current.clear()):a.current.delete(e[t]),e.key===`Meta`&&a.current.clear(),i.current=!1},u=()=>{a.current.clear(),r(!1)};return n?.addEventListener(`keydown`,e),n?.addEventListener(`keyup`,l),window.addEventListener(`blur`,u),window.addEventListener(`contextmenu`,u),()=>{n?.removeEventListener(`keydown`,e),n?.removeEventListener(`keyup`,l),window.removeEventListener(`blur`,u),window.removeEventListener(`contextmenu`,u)}}},[e,r]),n}function Ll(e,t,n){return e.filter(e=>n||e.length===t.size).some(e=>e.every(e=>t.has(e)))}function Rl(e,t){return t.includes(e)?`code`:`key`}var zl=()=>{let e=$();return(0,Y.useMemo)(()=>({zoomIn:async t=>{let{panZoom:n}=e.getState();return n?n.scaleBy(1.2,t):!1},zoomOut:async t=>{let{panZoom:n}=e.getState();return n?n.scaleBy(1/1.2,t):!1},zoomTo:async(t,n)=>{let{panZoom:r}=e.getState();return r?r.scaleTo(t,n):!1},getZoom:()=>e.getState().transform[2],setViewport:async(t,n)=>{let{transform:[r,i,a],panZoom:o}=e.getState();return o?(await o.setViewport({x:t.x??r,y:t.y??i,zoom:t.zoom??a},n),!0):!1},getViewport:()=>{let[t,n,r]=e.getState().transform;return{x:t,y:n,zoom:r}},setCenter:async(t,n,r)=>e.getState().setCenter(t,n,r),fitBounds:async(t,n)=>{let{width:r,height:i,minZoom:a,maxZoom:o,panZoom:s}=e.getState(),c=$o(t,r,i,a,o,n?.padding??.1);return s?(await s.setViewport(c,{duration:n?.duration,ease:n?.ease,interpolate:n?.interpolate}),!0):!1},screenToFlowPosition:(t,n={})=>{let{transform:r,snapGrid:i,snapToGrid:a,domNode:o}=e.getState();if(!o)return t;let{x:s,y:c}=o.getBoundingClientRect(),l={x:t.x-s,y:t.y-c},u=n.snapGrid??i;return Jo(l,r,n.snapToGrid??a,u)},flowToScreenPosition:t=>{let{transform:n,domNode:r}=e.getState();if(!r)return t;let{x:i,y:a}=r.getBoundingClientRect(),o=Yo(t,n);return{x:o.x+i,y:o.y+a}}}),[])};function Bl(e,t){let n=[],r=new Map,i=[];for(let t of e)if(t.type===`add`){i.push(t);continue}else if(t.type===`remove`||t.type===`replace`)r.set(t.id,[t]);else{let e=r.get(t.id);e?e.push(t):r.set(t.id,[t])}for(let e of t){let t=r.get(e.id);if(!t){n.push(e);continue}if(t[0].type===`remove`)continue;if(t[0].type===`replace`){n.push({...t[0].item});continue}let i={...e};for(let e of t)Vl(e,i);n.push(i)}return i.length&&i.forEach(e=>{e.index===void 0?n.push({...e.item}):n.splice(e.index,0,{...e.item})}),n}function Vl(e,t){switch(e.type){case`select`:t.selected=e.selected;break;case`position`:e.position!==void 0&&(t.position=e.position),e.dragging!==void 0&&(t.dragging=e.dragging);break;case`dimensions`:e.dimensions!==void 0&&(t.measured={...e.dimensions},e.setAttributes&&((e.setAttributes===!0||e.setAttributes===`width`)&&(t.width=e.dimensions.width),(e.setAttributes===!0||e.setAttributes===`height`)&&(t.height=e.dimensions.height))),typeof e.resizing==`boolean`&&(t.resizing=e.resizing)}}function Hl(e,t){return Bl(e,t)}function Ul(e,t){return Bl(e,t)}function Wl(e,t){return{id:e,type:`select`,selected:t}}function Gl(e,t=new Set,n=!1){let r=[];for(let[i,a]of e){let e=t.has(i);!(a.selected===void 0&&!e)&&a.selected!==e&&(n&&(a.selected=e),r.push(Wl(a.id,e)))}return r}function Kl({items:e=[],lookup:t}){let n=[],r=new Map(e.map(e=>[e.id,e]));for(let[r,i]of e.entries()){let e=t.get(i.id),a=e?.internals?.userNode??e;a!==void 0&&a!==i&&n.push({id:i.id,item:i,type:`replace`}),a===void 0&&n.push({item:i,type:`add`,index:r})}for(let[e]of t)r.get(e)===void 0&&n.push({id:e,type:`remove`});return n}function ql(e){return{id:e.id,type:`remove`}}var Jl=Ko(`React Flow`,`https://reactflow.dev/`);function Yl(e,t,n={}){return Ts(e,t,{...n,onError:n.onError??Jl})}var Xl=e=>bo(e),Zl=e=>yo(e);function Ql(e){return(0,Y.forwardRef)(e)}var $l=typeof window<`u`?Y.useLayoutEffect:Y.useEffect;function eu(e){let[t,n]=(0,Y.useState)(BigInt(0)),[r]=(0,Y.useState)(()=>tu(()=>n(e=>e+BigInt(1))));return $l(()=>{let t=r.get();t.length&&(e(t),r.reset())},[t]),r}function tu(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}var nu=(0,Y.createContext)(null);function ru({children:e}){let t=$(),n=eu((0,Y.useCallback)(e=>{let{nodes:n=[],setNodes:r,hasDefaultNodes:i,onNodesChange:a,nodeLookup:o,fitViewQueued:s,onNodesChangeMiddlewareMap:c}=t.getState(),l=n;for(let t of e)l=typeof t==`function`?t(l):t;let u=Kl({items:l,lookup:o});for(let e of c.values())u=e(u);i&&r(l),u.length>0?a?.(u):s&&window.requestAnimationFrame(()=>{let{fitViewQueued:e,nodes:n,setNodes:r}=t.getState();e&&r(n)})},[])),r=eu((0,Y.useCallback)(e=>{let{edges:n=[],setEdges:r,hasDefaultEdges:i,onEdgesChange:a,edgeLookup:o}=t.getState(),s=n;for(let t of e)s=typeof t==`function`?t(s):t;i?r(s):a&&a(Kl({items:s,lookup:o}))},[])),i=(0,Y.useMemo)(()=>({nodeQueue:n,edgeQueue:r}),[]);return(0,J.jsx)(nu.Provider,{value:i,children:e})}function iu(){let e=(0,Y.useContext)(nu);if(!e)throw Error(`useBatchContext must be used within a BatchProvider`);return e}var au=e=>!!e.panZoom;function ou(){let e=zl(),t=$(),n=iu(),r=Q(au),i=(0,Y.useMemo)(()=>{let e=e=>t.getState().nodeLookup.get(e),r=e=>{n.nodeQueue.push(e)},i=e=>{n.edgeQueue.push(e)},a=e=>{let{nodeLookup:n,nodeOrigin:r}=t.getState(),i=Xl(e)?e:n.get(e.id),a=i.parentId?is(i.position,i.measured,i.parentId,n,r):i.position;return zo({...i,position:a,width:i.measured?.width??i.width,height:i.measured?.height??i.height})},o=(e,t,n={replace:!1})=>{r(r=>r.map(r=>{if(r.id===e){let e=typeof t==`function`?t(r):t;return n.replace&&Xl(e)?e:{...r,...e}}return r}))},s=(e,t,n={replace:!1})=>{i(r=>r.map(r=>{if(r.id===e){let e=typeof t==`function`?t(r):t;return n.replace&&Zl(e)?e:{...r,...e}}return r}))};return{getNodes:()=>t.getState().nodes.map(e=>({...e})),getNode:t=>e(t)?.internals.userNode,getInternalNode:e,getEdges:()=>{let{edges:e=[]}=t.getState();return e.map(e=>({...e}))},getEdge:e=>t.getState().edgeLookup.get(e),setNodes:r,setEdges:i,addNodes:e=>{let t=Array.isArray(e)?e:[e];n.nodeQueue.push(e=>[...e,...t])},addEdges:e=>{let t=Array.isArray(e)?e:[e];n.edgeQueue.push(e=>[...e,...t])},toObject:()=>{let{nodes:e=[],edges:n=[],transform:r}=t.getState(),[i,a,o]=r;return{nodes:e.map(e=>({...e})),edges:n.map(e=>({...e})),viewport:{x:i,y:a,zoom:o}}},deleteElements:async({nodes:e=[],edges:n=[]})=>{let{nodes:r,edges:i,onNodesDelete:a,onEdgesDelete:o,triggerNodeChanges:s,triggerEdgeChanges:c,onDelete:l,onBeforeDelete:u}=t.getState(),{nodes:d,edges:f}=await Ao({nodesToRemove:e,edgesToRemove:n,nodes:r,edges:i,onBeforeDelete:u}),p=f.length>0,m=d.length>0;if(p){let e=f.map(ql);o?.(f),c(e)}if(m){let e=d.map(ql);a?.(d),s(e)}return(m||p)&&l?.({nodes:d,edges:f}),{deletedNodes:d,deletedEdges:f}},getIntersectingNodes:(e,n=!0,r)=>{let i=Wo(e),o=i?e:a(e),s=r!==void 0;return o?(r||t.getState().nodes).filter(r=>{let a=t.getState().nodeLookup.get(r.id);if(a&&!i&&(r.id===e.id||!a.internals.positionAbsolute))return!1;let c=zo(s?r:a),l=Uo(c,o);return n&&l>0||l>=c.width*c.height||l>=o.width*o.height}):[]},isNodeIntersecting:(e,t,n=!0)=>{let r=Wo(e)?e:a(e);if(!r)return!1;let i=Uo(r,t);return n&&i>0||i>=t.width*t.height||i>=r.width*r.height},updateNode:o,updateNodeData:(e,t,n={replace:!1})=>{o(e,e=>{let r=typeof t==`function`?t(e):t;return n.replace?{...e,data:r}:{...e,data:{...e.data,...r}}},n)},updateEdge:s,updateEdgeData:(e,t,n={replace:!1})=>{s(e,e=>{let r=typeof t==`function`?t(e):t;return n.replace?{...e,data:r}:{...e,data:{...e.data,...r}}},n)},getNodesBounds:e=>{let{nodeLookup:n,nodeOrigin:r}=t.getState();return Co(e,{nodeLookup:n,nodeOrigin:r})},getHandleConnections:({type:e,id:n,nodeId:r})=>Array.from(t.getState().connectionLookup.get(`${r}-${e}${n?`-${n}`:``}`)?.values()??[]),getNodeConnections:({type:e,handleId:n,nodeId:r})=>Array.from(t.getState().connectionLookup.get(`${r}${e?n?`-${e}-${n}`:`-${e}`:``}`)?.values()??[]),fitView:async e=>{let r=t.getState().fitViewResolver??os();return t.setState({fitViewQueued:!0,fitViewOptions:e,fitViewResolver:r}),n.nodeQueue.push(e=>[...e]),r.promise}}},[]);return(0,Y.useMemo)(()=>({...i,...e,viewportInitialized:r}),[r])}var su=e=>e.selected,cu=typeof window<`u`?window:void 0;function lu({deleteKeyCode:e,multiSelectionKeyCode:t}){let n=$(),{deleteElements:r}=ou(),i=Il(e,{actInsideInputWithModifier:!1}),a=Il(t,{target:cu});(0,Y.useEffect)(()=>{if(i){let{edges:e,nodes:t}=n.getState();r({nodes:t.filter(su),edges:e.filter(su)}),n.setState({nodesSelectionActive:!1})}},[i]),(0,Y.useEffect)(()=>{n.setState({multiSelectionActive:a})},[a])}function uu(e){let t=$();(0,Y.useEffect)(()=>{let n=()=>{if(!e.current||!(e.current.checkVisibility?.()??!0))return!1;let n=ls(e.current);(n.height===0||n.width===0)&&t.getState().onError?.(`004`,oo.error004()),t.setState({width:n.width||500,height:n.height||500})};if(e.current){n(),window.addEventListener(`resize`,n);let t=new ResizeObserver(()=>n());return t.observe(e.current),()=>{window.removeEventListener(`resize`,n),t&&e.current&&t.unobserve(e.current)}}},[])}var du={position:`absolute`,width:`100%`,height:`100%`,top:0,left:0},fu=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function pu({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:r=!1,panOnScrollSpeed:i=.5,panOnScrollMode:a=fo.Free,zoomOnDoubleClick:o=!0,panOnDrag:s=!0,defaultViewport:c,translateExtent:l,minZoom:u,maxZoom:d,zoomActivationKeyCode:f,preventScrolling:p=!0,children:m,noWheelClassName:h,noPanClassName:g,onViewportChange:_,isControlledViewport:v,paneClickDistance:y,selectionOnDrag:b}){let x=$(),S=(0,Y.useRef)(null),{userSelectionActive:C,lib:w,connectionInProgress:T}=Q(fu,al),E=Il(f),D=(0,Y.useRef)();uu(S);let O=(0,Y.useCallback)(e=>{_?.({x:e[0],y:e[1],zoom:e[2]}),v||x.setState({transform:e})},[_,v]);return(0,Y.useEffect)(()=>{if(S.current){D.current=Pc({domNode:S.current,minZoom:u,maxZoom:d,translateExtent:l,viewport:c,onDraggingChange:e=>x.setState(t=>t.paneDragging===e?t:{paneDragging:e}),onPanZoomStart:(e,t)=>{let{onViewportChangeStart:n,onMoveStart:r}=x.getState();r?.(e,t),n?.(t)},onPanZoom:(e,t)=>{let{onViewportChange:n,onMove:r}=x.getState();r?.(e,t),n?.(t)},onPanZoomEnd:(e,t)=>{let{onViewportChangeEnd:n,onMoveEnd:r}=x.getState();r?.(e,t),n?.(t)}});let{x:e,y:t,zoom:n}=D.current.getViewport();return x.setState({panZoom:D.current,transform:[e,t,n],domNode:S.current.closest(`.react-flow`)}),()=>{D.current?.destroy()}}},[]),(0,Y.useEffect)(()=>{D.current?.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:n,panOnScroll:r,panOnScrollSpeed:i,panOnScrollMode:a,zoomOnDoubleClick:o,panOnDrag:s,zoomActivationKeyPressed:E,preventScrolling:p,noPanClassName:g,userSelectionActive:C,noWheelClassName:h,lib:w,onTransformChange:O,connectionInProgress:T,selectionOnDrag:b,paneClickDistance:y})},[e,t,n,r,i,a,o,s,E,p,g,C,h,w,O,T,b,y]),(0,J.jsx)(`div`,{className:`react-flow__renderer`,ref:S,style:du,children:m})}var mu=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function hu(){let{userSelectionActive:e,userSelectionRect:t}=Q(mu,al);return e&&t?(0,J.jsx)(`div`,{className:`react-flow__selection react-flow__container`,style:{width:t.width,height:t.height,transform:`translate(${t.x}px, ${t.y}px)`}}):null}var gu=(e,t)=>n=>{n.target===t.current&&e?.(n)},_u=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,dragging:e.paneDragging,panBy:e.panBy,autoPanSpeed:e.autoPanSpeed});function vu({isSelecting:e,selectionKeyPressed:t,selectionMode:n=po.Full,panOnDrag:r,autoPanOnSelection:i,paneClickDistance:a,selectionOnDrag:o,onSelectionStart:s,onSelectionEnd:c,onPaneClick:l,onPaneContextMenu:u,onPaneScroll:d,onPaneMouseEnter:f,onPaneMouseMove:p,onPaneMouseLeave:m,children:h}){let g=(0,Y.useRef)(0),_=$(),{userSelectionActive:v,elementsSelectable:y,dragging:b,panBy:x,autoPanSpeed:S}=Q(_u,al),C=y&&(e||v),w=(0,Y.useRef)(null),T=(0,Y.useRef)(),E=(0,Y.useRef)(new Set),D=(0,Y.useRef)(new Set),O=(0,Y.useRef)(!1),k=(0,Y.useRef)(!1),A=(0,Y.useRef)({x:0,y:0}),j=(0,Y.useRef)(!1),M=e=>{if(k.current||O.current||_.getState().connection.inProgress){k.current=!1,O.current=!1;return}l?.(e),_.getState().resetSelectedElements(),_.setState({nodesSelectionActive:!1})},N=e=>{if(Array.isArray(r)&&r?.includes(2)){e.preventDefault();return}u?.(e)},P=d?e=>d(e):void 0,F=e=>{k.current&&=(e.stopPropagation(),!1)},I=n=>{let{domNode:r,transform:i}=_.getState();if(T.current=r?.getBoundingClientRect(),!T.current)return;let a=n.target===w.current;if(!a&&n.target.closest(`.nokey`)||!e||!(o&&a||t)||n.button!==0||!n.isPrimary)return;n.target?.setPointerCapture?.(n.pointerId),k.current=!1;let{x:s,y:c}=ms(n.nativeEvent,T.current),l=Jo({x:s,y:c},i);_.setState({userSelectionRect:{width:0,height:0,startX:l.x,startY:l.y,x:s,y:c}}),a||(n.stopPropagation(),n.preventDefault())};function L(e,t){let{userSelectionRect:r}=_.getState();if(!r)return;let{transform:i,nodeLookup:a,edgeLookup:o,connectionLookup:s,triggerNodeChanges:c,triggerEdgeChanges:l,defaultEdgeOptions:u}=_.getState(),d={x:r.startX,y:r.startY},{x:f,y:p}=Yo(d,i),m={startX:d.x,startY:d.y,x:ee.id)),D.current=new Set;let v=u?.selectable??!0;for(let e of E.current){let t=s.get(e);if(t)for(let{edgeId:e}of t.values()){let t=o.get(e);t&&(t.selectable??v)&&D.current.add(e)}}as(h,E.current)||c(Gl(a,E.current,!0)),as(g,D.current)||l(Gl(o,D.current)),_.setState({userSelectionRect:m,userSelectionActive:!0,nodesSelectionActive:!1})}function R(){if(!i||!T.current)return;let[e,t]=Fo(A.current,T.current,S);x({x:e,y:t}).then(e=>{if(!k.current||!e){g.current=requestAnimationFrame(R);return}let{x:t,y:n}=A.current;L(t,n),g.current=requestAnimationFrame(R)})}let z=()=>{cancelAnimationFrame(g.current),g.current=0,j.current=!1};(0,Y.useEffect)(()=>()=>z(),[]);let B=e=>{let{userSelectionRect:n,transform:r,resetSelectedElements:i}=_.getState();if(!T.current||!n)return;let{x:o,y:c}=ms(e.nativeEvent,T.current);A.current={x:o,y:c};let l=Yo({x:n.startX,y:n.startY},r);if(!k.current){let n=t?0:a;if(Math.hypot(o-l.x,c-l.y)<=n)return;i(),s?.(e)}k.current=!0,j.current||=(R(),!0),L(o,c)},V=e=>{if(!C){e.target===w.current&&_.getState().connection.inProgress&&(O.current=!0);return}e.button===0&&(e.target?.releasePointerCapture?.(e.pointerId),!v&&e.target===w.current&&_.getState().userSelectionRect&&M?.(e),_.setState({userSelectionActive:!1,userSelectionRect:null}),k.current&&(c?.(e),_.setState({nodesSelectionActive:E.current.size>0})),z())},ee=e=>{e.target?.releasePointerCapture?.(e.pointerId),z()},te=r===!0||Array.isArray(r)&&r.includes(0);return(0,J.jsxs)(`div`,{className:Se([`react-flow__pane`,{draggable:te,dragging:b,selection:e}]),onClick:C?void 0:gu(M,w),onContextMenu:gu(N,w),onWheel:gu(P,w),onPointerEnter:C?void 0:f,onPointerMove:C?B:p,onPointerUp:V,onPointerCancel:C?ee:void 0,onPointerDownCapture:C?I:void 0,onClickCapture:C?F:void 0,onPointerLeave:m,ref:w,style:du,children:[h,(0,J.jsx)(hu,{})]})}function yu({id:e,store:t,unselect:n=!1,nodeRef:r}){let{addSelectedNodes:i,unselectNodesAndEdges:a,multiSelectionActive:o,nodeLookup:s,onError:c}=t.getState(),l=s.get(e);if(!l){c?.(`012`,oo.error012(e));return}t.setState({nodesSelectionActive:!1}),l.selected?(n||l.selected&&o)&&(a({nodes:[l],edges:[]}),requestAnimationFrame(()=>r?.current?.blur())):i([e])}function bu({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:r,nodeId:i,isSelectable:a,nodeClickDistance:o}){let s=$(),[c,l]=(0,Y.useState)(!1),u=(0,Y.useRef)();return(0,Y.useEffect)(()=>{u.current=lc({getStoreItems:()=>s.getState(),onNodeMouseDown:t=>{yu({id:t,store:s,nodeRef:e})},onDragStart:()=>{l(!0)},onDragStop:()=>{l(!1)}})},[]),(0,Y.useEffect)(()=>{if(!(t||!e.current||!u.current))return u.current.update({noDragClassName:n,handleSelector:r,domNode:e.current,isSelectable:a,nodeId:i,nodeClickDistance:o}),()=>{u.current?.destroy()}},[n,r,t,a,e,i,o]),c}var xu=e=>t=>t.selected&&(t.draggable||e&&t.draggable===void 0);function Su(){let e=$();return(0,Y.useCallback)(t=>{let{nodeExtent:n,snapToGrid:r,snapGrid:i,nodesDraggable:a,onError:o,updateNodePositions:s,nodeLookup:c,nodeOrigin:l}=e.getState(),u=new Map,d=xu(a),f=r?i[0]:5,p=r?i[1]:5,m=t.direction.x*f*t.factor,h=t.direction.y*p*t.factor;for(let[,e]of c){if(!d(e))continue;let t={x:e.internals.positionAbsolute.x+m,y:e.internals.positionAbsolute.y+h};r&&(t=qo(t,i));let{position:a,positionAbsolute:s}=ko({nodeId:e.id,nextPosition:t,nodeLookup:c,nodeExtent:n,nodeOrigin:l,onError:o});e.position=a,e.internals.positionAbsolute=s,u.set(e.id,e)}s(u)},[])}var Cu=(0,Y.createContext)(null),wu=Cu.Provider;Cu.Consumer;var Tu=()=>(0,Y.useContext)(Cu),Eu=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),Du=(0,Y.createContext)(null);function Ou({children:e}){let t=Q(Eu,al);return(0,J.jsx)(Du.Provider,{value:t,children:e})}function ku(){let e=(0,Y.useContext)(Du);if(!e)throw Error(`useHandleConfig must be used within a HandleConfigProvider`);return e}var Au={connectingFrom:!1,connectingTo:!1,clickConnecting:!1,isPossibleEndHandle:!0,connectionInProcess:!1,clickConnectionInProcess:!1,valid:!1},ju=(e,t,n)=>r=>{let{connectionClickStartHandle:i,connectionMode:a,connection:o}=r,{fromHandle:s,toHandle:c,isValid:l}=o;if(!s&&!i)return Au;let u=c?.nodeId===e&&c?.id===t&&c?.type===n;return{connectingFrom:s?.nodeId===e&&s?.id===t&&s?.type===n,connectingTo:u,clickConnecting:i?.nodeId===e&&i?.id===t&&i?.type===n,isPossibleEndHandle:a===uo.Strict?s?.type!==n:e!==s?.nodeId||t!==s?.id,connectionInProcess:!!s,clickConnectionInProcess:!!i,valid:u&&l}};function Mu({type:e=`source`,position:t=Z.Top,isValidConnection:n,isConnectable:r=!0,isConnectableStart:i=!0,isConnectableEnd:a=!0,id:o,onConnect:s,children:c,className:l,onMouseDown:u,onTouchStart:d,...f},p){let m=o||null,h=e===`target`,g=$(),_=Tu(),{connectOnClick:v,noPanClassName:y,rfId:b}=ku(),{connectingFrom:x,connectingTo:S,clickConnecting:C,isPossibleEndHandle:w,connectionInProcess:T,clickConnectionInProcess:E,valid:D}=Q(ju(_,m,e),al);_||g.getState().onError?.(`010`,oo.error010());let O=e=>{let{defaultEdgeOptions:t,onConnect:n,hasDefaultEdges:r}=g.getState(),i={...t,...e};if(r){let{edges:e,setEdges:t,onError:n}=g.getState();t(Yl(i,e,{onError:n}))}n?.(i),s?.(i)},k=e=>{if(!_)return;let t=ps(e.nativeEvent);if(i&&(t&&e.button===0||!t)){let t=g.getState();yc.onPointerDown(e.nativeEvent,{handleDomNode:e.currentTarget,autoPanOnConnect:t.autoPanOnConnect,connectionMode:t.connectionMode,connectionRadius:t.connectionRadius,domNode:t.domNode,nodeLookup:t.nodeLookup,lib:t.lib,isTarget:h,handleId:m,nodeId:_,flowId:t.rfId,panBy:t.panBy,cancelConnection:t.cancelConnection,onConnectStart:t.onConnectStart,onConnectEnd:(...e)=>g.getState().onConnectEnd?.(...e),updateConnection:t.updateConnection,onConnect:O,isValidConnection:n||((...e)=>g.getState().isValidConnection?.(...e)??!0),getTransform:()=>g.getState().transform,getFromHandle:()=>g.getState().connection.fromHandle,autoPanSpeed:t.autoPanSpeed,dragThreshold:t.connectionDragThreshold})}t?u?.(e):d?.(e)};return(0,J.jsx)(`div`,{"data-handleid":m,"data-nodeid":_,"data-handlepos":t,"data-id":`${b}-${_}-${m}-${e}`,className:Se([`react-flow__handle`,`react-flow__handle-${t}`,`nodrag`,y,l,{source:!h,target:h,connectable:r,connectablestart:i,connectableend:a,clickconnecting:C,connectingfrom:x,connectingto:S,valid:D,connectionindicator:r&&(!T||w)&&(T||E?a:i)}]),onMouseDown:k,onTouchStart:k,onClick:v?t=>{let{onClickConnectStart:r,onClickConnectEnd:a,connectionClickStartHandle:o,connectionMode:s,isValidConnection:c,lib:l,rfId:u,nodeLookup:d,connection:f}=g.getState();if(!_||!o&&!i)return;if(!o){r?.(t.nativeEvent,{nodeId:_,handleId:m,handleType:e}),g.setState({connectionClickStartHandle:{nodeId:_,type:e,id:m}});return}let p=us(t.target),h=n||c,{connection:v,isValid:y}=yc.isValid(t.nativeEvent,{handle:{nodeId:_,id:m,type:e},connectionMode:s,fromNodeId:o.nodeId,fromHandleId:o.id||null,fromType:o.type,isValidConnection:h,flowId:u,doc:p,lib:l,nodeLookup:d});y&&v&&O(v);let b=structuredClone(f);delete b.inProgress,b.toPosition=b.toHandle?b.toHandle.position:null,a?.(t,b),g.setState({connectionClickStartHandle:null})}:void 0,ref:p,...f,children:c})}var Nu=(0,Y.memo)(Ql(Mu));function Pu({data:e,isConnectable:t,sourcePosition:n=Z.Bottom}){return(0,J.jsxs)(J.Fragment,{children:[e?.label,(0,J.jsx)(Nu,{type:`source`,position:n,isConnectable:t})]})}function Fu({data:e,isConnectable:t,targetPosition:n=Z.Top,sourcePosition:r=Z.Bottom}){return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Nu,{type:`target`,position:n,isConnectable:t}),e?.label,(0,J.jsx)(Nu,{type:`source`,position:r,isConnectable:t})]})}function Iu(){return null}function Lu({data:e,isConnectable:t,targetPosition:n=Z.Top}){return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Nu,{type:`target`,position:n,isConnectable:t}),e?.label]})}var Ru={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},zu={input:Pu,default:Fu,output:Lu,group:Iu};function Bu(e){return e.internals.handleBounds===void 0?{width:e.width??e.initialWidth??e.style?.width,height:e.height??e.initialHeight??e.style?.height}:{width:e.width??e.style?.width,height:e.height??e.style?.height}}var Vu=e=>{let{width:t,height:n,x:r,y:i}=wo(e.nodeLookup,{filter:e=>!!e.selected});return{width:Go(t)?t:null,height:Go(n)?n:null,userSelectionActive:e.userSelectionActive,transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]}) translate(${r}px,${i}px)`}};function Hu({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){let r=$(),{width:i,height:a,transformString:o,userSelectionActive:s}=Q(Vu,al),c=Su(),l=(0,Y.useRef)(null);(0,Y.useEffect)(()=>{n||l.current?.focus({preventScroll:!0})},[n]);let u=!s&&i!==null&&a!==null;if(bu({nodeRef:l,disabled:!u}),!u)return null;let d=e?t=>{e(t,r.getState().nodes.filter(e=>e.selected))}:void 0;return(0,J.jsx)(`div`,{className:Se([`react-flow__nodesselection`,`react-flow__container`,t]),style:{transform:o},children:(0,J.jsx)(`div`,{ref:l,className:`react-flow__nodesselection-rect`,onContextMenu:d,tabIndex:n?void 0:-1,onKeyDown:n?void 0:e=>{Object.prototype.hasOwnProperty.call(Ru,e.key)&&(e.preventDefault(),c({direction:Ru[e.key],factor:e.shiftKey?4:1}))},style:{width:i,height:a}})})}var Uu=typeof window<`u`?window:void 0,Wu=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function Gu({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:i,onPaneContextMenu:a,onPaneScroll:o,paneClickDistance:s,deleteKeyCode:c,selectionKeyCode:l,selectionOnDrag:u,selectionMode:d,onSelectionStart:f,onSelectionEnd:p,multiSelectionKeyCode:m,panActivationKeyCode:h,zoomActivationKeyCode:g,elementsSelectable:_,zoomOnScroll:v,zoomOnPinch:y,panOnScroll:b,panOnScrollSpeed:x,panOnScrollMode:S,zoomOnDoubleClick:C,panOnDrag:w,autoPanOnSelection:T,defaultViewport:E,translateExtent:D,minZoom:O,maxZoom:k,preventScrolling:A,onSelectionContextMenu:j,noWheelClassName:M,noPanClassName:N,disableKeyboardA11y:P,onViewportChange:F,isControlledViewport:I}){let{nodesSelectionActive:L,userSelectionActive:R}=Q(Wu,al),z=Il(l,{target:Uu}),B=Il(h,{target:Uu}),V=B||w,ee=B||b,te=u&&V!==!0,H=z||R||te;return lu({deleteKeyCode:c,multiSelectionKeyCode:m}),(0,J.jsx)(pu,{onPaneContextMenu:a,elementsSelectable:_,zoomOnScroll:v,zoomOnPinch:y,panOnScroll:ee,panOnScrollSpeed:x,panOnScrollMode:S,zoomOnDoubleClick:C,panOnDrag:!z&&V,defaultViewport:E,translateExtent:D,minZoom:O,maxZoom:k,zoomActivationKeyCode:g,preventScrolling:A,noWheelClassName:M,noPanClassName:N,onViewportChange:F,isControlledViewport:I,paneClickDistance:s,selectionOnDrag:te,children:(0,J.jsxs)(vu,{onSelectionStart:f,onSelectionEnd:p,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:i,onPaneContextMenu:a,onPaneScroll:o,panOnDrag:V,autoPanOnSelection:T,isSelecting:!!H,selectionMode:d,selectionKeyPressed:z,paneClickDistance:s,selectionOnDrag:te,children:[e,L&&(0,J.jsx)(Hu,{onSelectionContextMenu:j,noPanClassName:N,disableKeyboardA11y:P})]})})}Gu.displayName=`FlowRenderer`;var Ku=(0,Y.memo)(Gu),qu=e=>t=>e?To(t.nodeLookup,{x:0,y:0,width:t.width,height:t.height},t.transform,!0).map(e=>e.id):Array.from(t.nodeLookup.keys());function Ju(e){return Q((0,Y.useCallback)(qu(e),[e]),al)}var Yu=e=>e.updateNodeInternals;function Xu(){let e=Q(Yu),[t]=(0,Y.useState)(()=>typeof ResizeObserver>`u`?null:new ResizeObserver(t=>{let n=new Map;t.forEach(e=>{let t=e.target.getAttribute(`data-id`);n.set(t,{id:t,nodeElement:e.target,force:!0})}),e(n)}));return(0,Y.useEffect)(()=>()=>{t?.disconnect()},[t]),t}function Zu({node:e,nodeType:t,hasDimensions:n,resizeObserver:r}){let i=$(),a=(0,Y.useRef)(null),o=(0,Y.useRef)(null),s=(0,Y.useRef)(e.sourcePosition),c=(0,Y.useRef)(e.targetPosition),l=(0,Y.useRef)(t),u=n&&!!e.internals.handleBounds;return(0,Y.useEffect)(()=>{a.current&&!e.hidden&&(!u||o.current!==a.current)&&(o.current&&r?.unobserve(o.current),r?.observe(a.current),o.current=a.current)},[u,e.hidden]),(0,Y.useEffect)(()=>()=>{o.current&&=(r?.unobserve(o.current),null)},[]),(0,Y.useEffect)(()=>{if(a.current){let n=l.current!==t,r=s.current!==e.sourcePosition,o=c.current!==e.targetPosition;(n||r||o)&&(l.current=t,s.current=e.sourcePosition,c.current=e.targetPosition,i.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:a.current,force:!0}]])))}},[e.id,t,e.sourcePosition,e.targetPosition]),a}function Qu({id:e,onClick:t,onMouseEnter:n,onMouseMove:r,onMouseLeave:i,onContextMenu:a,onDoubleClick:o,nodesDraggable:s,elementsSelectable:c,nodesConnectable:l,nodesFocusable:u,resizeObserver:d,noDragClassName:f,noPanClassName:p,disableKeyboardA11y:m,rfId:h,nodeTypes:g,nodeClickDistance:_,onError:v}){let{node:y,internals:b,isParent:x}=Q(t=>{let n=t.nodeLookup.get(e),r=t.parentLookup.has(e);return{node:n,internals:n.internals,isParent:r}},al),S=y.type||`default`,C=g?.[S]||zu[S];C===void 0&&(v?.(`003`,oo.error003(S)),S=`default`,C=g?.default||zu.default);let w=!!(y.draggable||s&&y.draggable===void 0),T=!!(y.selectable||c&&y.selectable===void 0),E=!!(y.connectable||l&&y.connectable===void 0),D=!!(y.focusable||u&&y.focusable===void 0),O=$(),k=rs(y),A=Zu({node:y,nodeType:S,hasDimensions:k,resizeObserver:d}),j=bu({nodeRef:A,disabled:y.hidden||!w,noDragClassName:f,handleSelector:y.dragHandle,nodeId:e,isSelectable:T,nodeClickDistance:_}),M=Su();if(y.hidden)return null;let N=ns(y),P=Bu(y),F=T||w||t||n||r||i,I=n?e=>n(e,{...b.userNode}):void 0,L=r?e=>r(e,{...b.userNode}):void 0,R=i?e=>i(e,{...b.userNode}):void 0,z=a?e=>a(e,{...b.userNode}):void 0,B=o?e=>o(e,{...b.userNode}):void 0,V=n=>{let{selectNodesOnDrag:r,nodeDragThreshold:i}=O.getState();T&&(!r||!w||i>0)&&yu({id:e,store:O,nodeRef:A}),t&&t(n,{...b.userNode})},ee=t=>{if(!(fs(t.nativeEvent)||m)){if(co.includes(t.key)&&T){let n=t.key===`Escape`;yu({id:e,store:O,unselect:n,nodeRef:A})}else if(w&&y.selected&&Object.prototype.hasOwnProperty.call(Ru,t.key)){t.preventDefault();let{ariaLabelConfig:e}=O.getState();O.setState({ariaLiveMessage:e[`node.a11yDescription.ariaLiveMessage`]({direction:t.key.replace(`Arrow`,``).toLowerCase(),x:~~b.positionAbsolute.x,y:~~b.positionAbsolute.y})}),M({direction:Ru[t.key],factor:t.shiftKey?4:1})}}},te=()=>{if(m||!A.current?.matches(`:focus-visible`))return;let{transform:t,width:n,height:r,autoPanOnNodeFocus:i,setCenter:a}=O.getState();i&&(To(new Map([[e,y]]),{x:0,y:0,width:n,height:r},t,!0).length>0||a(y.position.x+N.width/2,y.position.y+N.height/2,{zoom:t[2]}))};return(0,J.jsx)(`div`,{className:Se([`react-flow__node`,`react-flow__node-${S}`,{[p]:w},y.className,{selected:y.selected,selectable:T,parent:x,draggable:w,dragging:j}]),ref:A,style:{zIndex:b.z,transform:`translate(${b.positionAbsolute.x}px,${b.positionAbsolute.y}px)`,pointerEvents:F?`all`:`none`,visibility:k?`visible`:`hidden`,...y.style,...P},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:I,onMouseMove:L,onMouseLeave:R,onContextMenu:z,onClick:V,onDoubleClick:B,onKeyDown:D?ee:void 0,tabIndex:D?0:void 0,onFocus:D?te:void 0,role:y.ariaRole??(D?`group`:void 0),"aria-roledescription":`node`,"aria-describedby":m?void 0:`${dl}-${h}`,"aria-label":y.ariaLabel,...y.domAttributes,children:(0,J.jsx)(wu,{value:e,children:(0,J.jsx)(C,{id:e,data:y.data,type:S,positionAbsoluteX:b.positionAbsolute.x,positionAbsoluteY:b.positionAbsolute.y,selected:y.selected??!1,selectable:T,draggable:w,deletable:y.deletable??!0,isConnectable:E,sourcePosition:y.sourcePosition,targetPosition:y.targetPosition,dragging:j,dragHandle:y.dragHandle,zIndex:b.z,parentId:y.parentId,...N})})})}var $u=(0,Y.memo)(Qu),ed=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function td(e){let{nodesDraggable:t,nodesConnectable:n,nodesFocusable:r,elementsSelectable:i,onError:a}=Q(ed,al),o=Ju(e.onlyRenderVisibleElements),s=Xu();return(0,J.jsx)(`div`,{className:`react-flow__nodes`,style:du,children:o.map(o=>(0,J.jsx)($u,{id:o,nodeTypes:e.nodeTypes,nodeExtent:e.nodeExtent,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,resizeObserver:s,nodesDraggable:t,nodesConnectable:n,nodesFocusable:r,elementsSelectable:i,nodeClickDistance:e.nodeClickDistance,onError:a},o))})}td.displayName=`NodeRenderer`;var nd=(0,Y.memo)(td);function rd(e){return Q((0,Y.useCallback)(t=>{if(!e)return t.edges.map(e=>e.id);let n=[];if(t.width&&t.height)for(let e of t.edges){let r=t.nodeLookup.get(e.source),i=t.nodeLookup.get(e.target);r&&i&&Ss({sourceNode:r,targetNode:i,width:t.width,height:t.height,transform:t.transform})&&n.push(e.id)}return n},[e]),al)}var id=({color:e=`none`,strokeWidth:t=1})=>{let n={strokeWidth:t,...e&&{stroke:e}};return(0,J.jsx)(`polyline`,{className:`arrow`,style:n,strokeLinecap:`round`,fill:`none`,strokeLinejoin:`round`,points:`-5,-4 0,0 -5,4`})},ad=({color:e=`none`,strokeWidth:t=1})=>{let n={strokeWidth:t,...e&&{stroke:e,fill:e}};return(0,J.jsx)(`polyline`,{className:`arrowclosed`,style:n,strokeLinecap:`round`,strokeLinejoin:`round`,points:`-5,-4 0,0 -5,4 -5,-4`})},od={[go.Arrow]:id,[go.ArrowClosed]:ad};function sd(e){let t=$();return(0,Y.useMemo)(()=>Object.prototype.hasOwnProperty.call(od,e)?od[e]:(t.getState().onError?.(`009`,oo.error009(e)),null),[e])}var cd=({id:e,type:t,color:n,width:r=12.5,height:i=12.5,markerUnits:a=`strokeWidth`,strokeWidth:o,orient:s=`auto-start-reverse`})=>{let c=sd(t);return c?(0,J.jsx)(`marker`,{className:`react-flow__arrowhead`,id:e,markerWidth:`${r}`,markerHeight:`${i}`,viewBox:`-10 -10 20 20`,markerUnits:a,orient:s,refX:`0`,refY:`0`,children:(0,J.jsx)(c,{color:n,strokeWidth:o})}):null},ld=({defaultColor:e,rfId:t})=>{let n=Q(e=>e.edges),r=Q(e=>e.defaultEdgeOptions),i=(0,Y.useMemo)(()=>zs(n,{id:t,defaultColor:e,defaultMarkerStart:r?.markerStart,defaultMarkerEnd:r?.markerEnd}),[n,r,t,e]);return i.length?(0,J.jsx)(`svg`,{className:`react-flow__marker`,"aria-hidden":`true`,children:(0,J.jsx)(`defs`,{children:i.map(e=>(0,J.jsx)(cd,{id:e.id,type:e.type,color:e.color,width:e.width,height:e.height,markerUnits:e.markerUnits,strokeWidth:e.strokeWidth,orient:e.orient},e.id))})}):null};ld.displayName=`MarkerDefinitions`;var ud=(0,Y.memo)(ld);function dd({x:e,y:t,label:n,labelStyle:r,labelShowBg:i=!0,labelBgStyle:a,labelBgPadding:o=[2,4],labelBgBorderRadius:s=2,children:c,className:l,...u}){let[d,f]=(0,Y.useState)({x:1,y:0,width:0,height:0}),p=Se([`react-flow__edge-textwrapper`,l]),m=(0,Y.useRef)(null);return(0,Y.useEffect)(()=>{if(m.current){let e=m.current.getBBox();f({x:e.x,y:e.y,width:e.width,height:e.height})}},[n]),n?(0,J.jsxs)(`g`,{transform:`translate(${e-d.width/2} ${t-d.height/2})`,className:p,visibility:d.width?`visible`:`hidden`,...u,children:[i&&(0,J.jsx)(`rect`,{width:d.width+2*o[0],x:-o[0],y:-o[1],height:d.height+2*o[1],className:`react-flow__edge-textbg`,style:a,rx:s,ry:s}),(0,J.jsx)(`text`,{className:`react-flow__edge-text`,y:d.height/2,dy:`0.3em`,ref:m,style:r,children:n}),c]}):null}dd.displayName=`EdgeText`;var fd=(0,Y.memo)(dd);function pd({path:e,labelX:t,labelY:n,label:r,labelStyle:i,labelShowBg:a,labelBgStyle:o,labelBgPadding:s,labelBgBorderRadius:c,interactionWidth:l=20,...u}){return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`path`,{...u,d:e,fill:`none`,className:Se([`react-flow__edge-path`,u.className])}),l?(0,J.jsx)(`path`,{d:e,fill:`none`,strokeOpacity:0,strokeWidth:l,className:`react-flow__edge-interaction`}):null,r&&Go(t)&&Go(n)?(0,J.jsx)(fd,{x:t,y:n,label:r,labelStyle:i,labelShowBg:a,labelBgStyle:o,labelBgPadding:s,labelBgBorderRadius:c}):null]})}function md({pos:e,x1:t,y1:n,x2:r,y2:i}){return e===Z.Left||e===Z.Right?[.5*(t+r),n]:[t,.5*(n+i)]}function hd({sourceX:e,sourceY:t,sourcePosition:n=Z.Bottom,targetX:r,targetY:i,targetPosition:a=Z.Top}){let[o,s]=md({pos:n,x1:e,y1:t,x2:r,y2:i}),[c,l]=md({pos:a,x1:r,y1:i,x2:e,y2:t}),[u,d,f,p]=gs({sourceX:e,sourceY:t,targetX:r,targetY:i,sourceControlX:o,sourceControlY:s,targetControlX:c,targetControlY:l});return[`M${e},${t} C${o},${s} ${c},${l} ${r},${i}`,u,d,f,p]}function gd(e){return(0,Y.memo)(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:a,sourcePosition:o,targetPosition:s,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:h,markerStart:g,interactionWidth:_})=>{let[v,y,b]=hd({sourceX:n,sourceY:r,sourcePosition:o,targetX:i,targetY:a,targetPosition:s}),x=e.isInternal?void 0:t;return(0,J.jsx)(pd,{id:x,path:v,labelX:y,labelY:b,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:h,markerStart:g,interactionWidth:_})})}var _d=gd({isInternal:!1}),vd=gd({isInternal:!0});_d.displayName=`SimpleBezierEdge`,vd.displayName=`SimpleBezierEdgeInternal`;function yd(e){return(0,Y.memo)(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:a,label:o,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,sourcePosition:p=Z.Bottom,targetPosition:m=Z.Top,markerEnd:h,markerStart:g,pathOptions:_,interactionWidth:v})=>{let[y,b,x]=Ms({sourceX:n,sourceY:r,sourcePosition:p,targetX:i,targetY:a,targetPosition:m,borderRadius:_?.borderRadius,offset:_?.offset,stepPosition:_?.stepPosition}),S=e.isInternal?void 0:t;return(0,J.jsx)(pd,{id:S,path:y,labelX:b,labelY:x,label:o,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,markerEnd:h,markerStart:g,interactionWidth:v})})}var bd=yd({isInternal:!1}),xd=yd({isInternal:!0});bd.displayName=`SmoothStepEdge`,xd.displayName=`SmoothStepEdgeInternal`;function Sd(e){return(0,Y.memo)(({id:t,...n})=>{let r=e.isInternal?void 0:t;return(0,J.jsx)(bd,{...n,id:r,pathOptions:(0,Y.useMemo)(()=>({borderRadius:0,offset:n.pathOptions?.offset}),[n.pathOptions?.offset])})})}var Cd=Sd({isInternal:!1}),wd=Sd({isInternal:!0});Cd.displayName=`StepEdge`,wd.displayName=`StepEdgeInternal`;function Td(e){return(0,Y.memo)(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:a,label:o,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,markerEnd:p,markerStart:m,interactionWidth:h})=>{let[g,_,v]=Es({sourceX:n,sourceY:r,targetX:i,targetY:a}),y=e.isInternal?void 0:t;return(0,J.jsx)(pd,{id:y,path:g,labelX:_,labelY:v,label:o,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,markerEnd:p,markerStart:m,interactionWidth:h})})}var Ed=Td({isInternal:!1}),Dd=Td({isInternal:!0});Ed.displayName=`StraightEdge`,Dd.displayName=`StraightEdgeInternal`;function Od(e){return(0,Y.memo)(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:a,sourcePosition:o=Z.Bottom,targetPosition:s=Z.Top,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:h,markerStart:g,pathOptions:_,interactionWidth:v})=>{let[y,b,x]=ys({sourceX:n,sourceY:r,sourcePosition:o,targetX:i,targetY:a,targetPosition:s,curvature:_?.curvature}),S=e.isInternal?void 0:t;return(0,J.jsx)(pd,{id:S,path:y,labelX:b,labelY:x,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:h,markerStart:g,interactionWidth:v})})}var kd=Od({isInternal:!1}),Ad=Od({isInternal:!0});kd.displayName=`BezierEdge`,Ad.displayName=`BezierEdgeInternal`;var jd={default:Ad,straight:Dd,step:wd,smoothstep:xd,simplebezier:vd},Md={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null,zIndex:void 0},Nd=(e,t,n)=>n===Z.Left?e-t:n===Z.Right?e+t:e,Pd=(e,t,n)=>n===Z.Top?e-t:n===Z.Bottom?e+t:e,Fd=`react-flow__edgeupdater`;function Id({position:e,centerX:t,centerY:n,radius:r=10,onMouseDown:i,onMouseEnter:a,onMouseOut:o,type:s}){return(0,J.jsx)(`circle`,{onMouseDown:i,onMouseEnter:a,onMouseOut:o,className:Se([Fd,`${Fd}-${s}`]),cx:Nd(t,r,e),cy:Pd(n,r,e),r,stroke:`transparent`,fill:`transparent`})}function Ld({isReconnectable:e,reconnectRadius:t,edge:n,sourceX:r,sourceY:i,targetX:a,targetY:o,sourcePosition:s,targetPosition:c,onReconnect:l,onReconnectStart:u,onReconnectEnd:d,setReconnecting:f,setUpdateHover:p}){let m=$(),h=(e,t)=>{if(e.button!==0)return;let{autoPanOnConnect:r,domNode:i,connectionMode:a,connectionRadius:o,lib:s,onConnectStart:c,cancelConnection:p,nodeLookup:h,rfId:g,panBy:_,updateConnection:v}=m.getState(),y=t.type===`target`;yc.onPointerDown(e.nativeEvent,{autoPanOnConnect:r,connectionMode:a,connectionRadius:o,domNode:i,handleId:t.id,nodeId:t.nodeId,nodeLookup:h,isTarget:y,edgeUpdaterType:t.type,lib:s,flowId:g,cancelConnection:p,panBy:_,isValidConnection:(...e)=>m.getState().isValidConnection?.(...e)??!0,onConnect:e=>l?.(n,e),onConnectStart:(r,i)=>{f(!0),u?.(e,n,t.type),c?.(r,i)},onConnectEnd:(...e)=>m.getState().onConnectEnd?.(...e),onReconnectEnd:(e,r)=>{f(!1),d?.(e,n,t.type,r)},updateConnection:v,getTransform:()=>m.getState().transform,getFromHandle:()=>m.getState().connection.fromHandle,dragThreshold:m.getState().connectionDragThreshold,handleDomNode:e.currentTarget})},g=e=>h(e,{nodeId:n.target,id:n.targetHandle??null,type:`target`}),_=e=>h(e,{nodeId:n.source,id:n.sourceHandle??null,type:`source`}),v=()=>p(!0),y=()=>p(!1);return(0,J.jsxs)(J.Fragment,{children:[(e===!0||e===`source`)&&(0,J.jsx)(Id,{position:s,centerX:r,centerY:i,radius:t,onMouseDown:g,onMouseEnter:v,onMouseOut:y,type:`source`}),(e===!0||e===`target`)&&(0,J.jsx)(Id,{position:c,centerX:a,centerY:o,radius:t,onMouseDown:_,onMouseEnter:v,onMouseOut:y,type:`target`})]})}function Rd({id:e,edgesFocusable:t,edgesReconnectable:n,elementsSelectable:r,onClick:i,onDoubleClick:a,onContextMenu:o,onMouseEnter:s,onMouseMove:c,onMouseLeave:l,reconnectRadius:u,onReconnect:d,onReconnectStart:f,onReconnectEnd:p,rfId:m,edgeTypes:h,noPanClassName:g,onError:_,disableKeyboardA11y:v}){let y=Q(t=>t.edgeLookup.get(e)),b=Q(e=>e.defaultEdgeOptions);y=b?{...b,...y}:y;let x=y.type||`default`,S=h?.[x]||jd[x];S===void 0&&(_?.(`011`,oo.error011(x)),x=`default`,S=h?.default||jd.default);let C=!!(y.focusable||t&&y.focusable===void 0),w=d!==void 0&&(y.reconnectable||n&&y.reconnectable===void 0),T=!!(y.selectable||r&&y.selectable===void 0),E=(0,Y.useRef)(null),[D,O]=(0,Y.useState)(!1),[k,A]=(0,Y.useState)(!1),j=$(),{zIndex:M=y.zIndex,sourceX:N,sourceY:P,targetX:F,targetY:I,sourcePosition:L,targetPosition:R}=Q((0,Y.useCallback)(t=>{let n=t.nodeLookup.get(y.source),r=t.nodeLookup.get(y.target);if(!n||!r)return Md;let i=Ps({id:e,sourceNode:n,targetNode:r,sourceHandle:y.sourceHandle||null,targetHandle:y.targetHandle||null,connectionMode:t.connectionMode,onError:_}),a=xs({selected:y.selected,zIndex:y.zIndex,sourceNode:n,targetNode:r,elevateOnSelect:t.elevateEdgesOnSelect,zIndexMode:t.zIndexMode});return{...i||Md,zIndex:a}},[y.source,y.target,y.sourceHandle,y.targetHandle,y.selected,y.zIndex]),al),z=(0,Y.useMemo)(()=>y.markerStart?`url('#${Rs(y.markerStart,m)}')`:void 0,[y.markerStart,m]),B=(0,Y.useMemo)(()=>y.markerEnd?`url('#${Rs(y.markerEnd,m)}')`:void 0,[y.markerEnd,m]);if(y.hidden||N===null||P===null||F===null||I===null)return null;let V=t=>{let{addSelectedEdges:n,unselectNodesAndEdges:r,multiSelectionActive:a}=j.getState();T&&(j.setState({nodesSelectionActive:!1}),y.selected&&a?(r({nodes:[],edges:[y]}),E.current?.blur()):n([e])),i&&i(t,y)},ee=a?e=>{a(e,{...y})}:void 0,te=o?e=>{o(e,{...y})}:void 0,H=s?e=>{s(e,{...y})}:void 0,U=c?e=>{c(e,{...y})}:void 0,W=l?e=>{l(e,{...y})}:void 0;return(0,J.jsx)(`svg`,{style:{zIndex:M},children:(0,J.jsxs)(`g`,{className:Se([`react-flow__edge`,`react-flow__edge-${x}`,y.className,g,{selected:y.selected,animated:y.animated,inactive:!T&&!i,updating:D,selectable:T}]),onClick:V,onDoubleClick:ee,onContextMenu:te,onMouseEnter:H,onMouseMove:U,onMouseLeave:W,onKeyDown:C?t=>{if(!v&&co.includes(t.key)&&T){let{unselectNodesAndEdges:n,addSelectedEdges:r}=j.getState();t.key===`Escape`?(E.current?.blur(),n({edges:[y]})):r([e])}}:void 0,tabIndex:C?0:void 0,role:y.ariaRole??(C?`group`:`img`),"aria-roledescription":`edge`,"data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":y.ariaLabel===null?void 0:y.ariaLabel||`Edge from ${y.source} to ${y.target}`,"aria-describedby":C?`${fl}-${m}`:void 0,ref:E,...y.domAttributes,children:[!k&&(0,J.jsx)(S,{id:e,source:y.source,target:y.target,type:y.type,selected:y.selected,animated:y.animated,selectable:T,deletable:y.deletable??!0,label:y.label,labelStyle:y.labelStyle,labelShowBg:y.labelShowBg,labelBgStyle:y.labelBgStyle,labelBgPadding:y.labelBgPadding,labelBgBorderRadius:y.labelBgBorderRadius,sourceX:N,sourceY:P,targetX:F,targetY:I,sourcePosition:L,targetPosition:R,data:y.data,style:y.style,sourceHandleId:y.sourceHandle,targetHandleId:y.targetHandle,markerStart:z,markerEnd:B,pathOptions:`pathOptions`in y?y.pathOptions:void 0,interactionWidth:y.interactionWidth}),w&&(0,J.jsx)(Ld,{edge:y,isReconnectable:w,reconnectRadius:u,onReconnect:d,onReconnectStart:f,onReconnectEnd:p,sourceX:N,sourceY:P,targetX:F,targetY:I,sourcePosition:L,targetPosition:R,setUpdateHover:O,setReconnecting:A})]})})}var zd=(0,Y.memo)(Rd),Bd=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function Vd({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:n,edgeTypes:r,noPanClassName:i,onReconnect:a,onEdgeContextMenu:o,onEdgeMouseEnter:s,onEdgeMouseMove:c,onEdgeMouseLeave:l,onEdgeClick:u,reconnectRadius:d,onEdgeDoubleClick:f,onReconnectStart:p,onReconnectEnd:m,disableKeyboardA11y:h}){let{edgesFocusable:g,edgesReconnectable:_,elementsSelectable:v,onError:y}=Q(Bd,al),b=rd(t);return(0,J.jsxs)(`div`,{className:`react-flow__edges`,children:[(0,J.jsx)(ud,{defaultColor:e,rfId:n}),b.map(e=>(0,J.jsx)(zd,{id:e,edgesFocusable:g,edgesReconnectable:_,elementsSelectable:v,noPanClassName:i,onReconnect:a,onContextMenu:o,onMouseEnter:s,onMouseMove:c,onMouseLeave:l,onClick:u,reconnectRadius:d,onDoubleClick:f,onReconnectStart:p,onReconnectEnd:m,rfId:n,onError:y,edgeTypes:r,disableKeyboardA11y:h},e))]})}Vd.displayName=`EdgeRenderer`;var Hd=(0,Y.memo)(Vd),Ud=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function Wd({children:e}){let t=Q(Ud);return(0,J.jsx)(`div`,{className:`react-flow__viewport xyflow__viewport react-flow__container`,style:{transform:t},children:e})}function Gd(e){let t=ou(),n=(0,Y.useRef)(!1);(0,Y.useEffect)(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}var Kd=e=>e.panZoom?.syncViewport;function qd(e){let t=Q(Kd),n=$();return(0,Y.useEffect)(()=>{e&&(t?.(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function Jd(e){return e.connection.inProgress?{...e.connection,to:Jo(e.connection.to,e.transform)}:{...e.connection}}function Yd(e){return e?t=>e(Jd(t)):Jd}function Xd(e){return Q(Yd(e),al)}var Zd=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function Qd({containerStyle:e,style:t,type:n,component:r}){let{nodesConnectable:i,width:a,height:o,isValid:s,inProgress:c}=Q(Zd,al);return a&&i&&c?(0,J.jsx)(`svg`,{style:e,width:a,height:o,className:`react-flow__connectionline react-flow__container`,children:(0,J.jsx)(`g`,{className:Se([`react-flow__connection`,vo(s)]),children:(0,J.jsx)($d,{style:t,type:n,CustomComponent:r,isValid:s})})}):null}var $d=({style:e,type:t=ho.Bezier,CustomComponent:n,isValid:r})=>{let{inProgress:i,from:a,fromNode:o,fromHandle:s,fromPosition:c,to:l,toNode:u,toHandle:d,toPosition:f,pointer:p}=Xd();if(!i)return;if(n)return(0,J.jsx)(n,{connectionLineType:t,connectionLineStyle:e,fromNode:o,fromHandle:s,fromX:a.x,fromY:a.y,toX:l.x,toY:l.y,fromPosition:c,toPosition:f,connectionStatus:vo(r),toNode:u,toHandle:d,pointer:p});let m=``,h={sourceX:a.x,sourceY:a.y,sourcePosition:c,targetX:l.x,targetY:l.y,targetPosition:f};switch(t){case ho.Bezier:[m]=ys(h);break;case ho.SimpleBezier:[m]=hd(h);break;case ho.Step:[m]=Ms({...h,borderRadius:0});break;case ho.SmoothStep:[m]=Ms(h);break;default:[m]=Es(h)}return(0,J.jsx)(`path`,{d:m,fill:`none`,className:`react-flow__connection-path`,style:e})};$d.displayName=`ConnectionLine`;var ef={};function tf(e=ef){(0,Y.useRef)(e),$(),(0,Y.useEffect)(()=>{},[e])}function nf(){$(),(0,Y.useRef)(!1),(0,Y.useEffect)(()=>{},[])}function rf({nodeTypes:e,edgeTypes:t,onInit:n,onNodeClick:r,onEdgeClick:i,onNodeDoubleClick:a,onEdgeDoubleClick:o,onNodeMouseEnter:s,onNodeMouseMove:c,onNodeMouseLeave:l,onNodeContextMenu:u,onSelectionContextMenu:d,onSelectionStart:f,onSelectionEnd:p,connectionLineType:m,connectionLineStyle:h,connectionLineComponent:g,connectionLineContainerStyle:_,selectionKeyCode:v,selectionOnDrag:y,selectionMode:b,multiSelectionKeyCode:x,panActivationKeyCode:S,zoomActivationKeyCode:C,deleteKeyCode:w,onlyRenderVisibleElements:T,elementsSelectable:E,defaultViewport:D,translateExtent:O,minZoom:k,maxZoom:A,preventScrolling:j,defaultMarkerColor:M,zoomOnScroll:N,zoomOnPinch:P,panOnScroll:F,panOnScrollSpeed:I,panOnScrollMode:L,zoomOnDoubleClick:R,panOnDrag:z,autoPanOnSelection:B,onPaneClick:V,onPaneMouseEnter:ee,onPaneMouseMove:te,onPaneMouseLeave:H,onPaneScroll:U,onPaneContextMenu:W,paneClickDistance:G,nodeClickDistance:K,onEdgeContextMenu:ne,onEdgeMouseEnter:re,onEdgeMouseMove:ie,onEdgeMouseLeave:ae,reconnectRadius:oe,onReconnect:se,onReconnectStart:ce,onReconnectEnd:le,noDragClassName:q,noWheelClassName:ue,noPanClassName:de,disableKeyboardA11y:fe,nodeExtent:Y,rfId:pe,viewport:me,onViewportChange:X}){return tf(e),tf(t),nf(),Gd(n),qd(me),(0,J.jsx)(Ku,{onPaneClick:V,onPaneMouseEnter:ee,onPaneMouseMove:te,onPaneMouseLeave:H,onPaneContextMenu:W,onPaneScroll:U,paneClickDistance:G,deleteKeyCode:w,selectionKeyCode:v,selectionOnDrag:y,selectionMode:b,onSelectionStart:f,onSelectionEnd:p,multiSelectionKeyCode:x,panActivationKeyCode:S,zoomActivationKeyCode:C,elementsSelectable:E,zoomOnScroll:N,zoomOnPinch:P,zoomOnDoubleClick:R,panOnScroll:F,panOnScrollSpeed:I,panOnScrollMode:L,panOnDrag:z,autoPanOnSelection:B,defaultViewport:D,translateExtent:O,minZoom:k,maxZoom:A,onSelectionContextMenu:d,preventScrolling:j,noDragClassName:q,noWheelClassName:ue,noPanClassName:de,disableKeyboardA11y:fe,onViewportChange:X,isControlledViewport:!!me,children:(0,J.jsxs)(Wd,{children:[(0,J.jsx)(Hd,{edgeTypes:t,onEdgeClick:i,onEdgeDoubleClick:o,onReconnect:se,onReconnectStart:ce,onReconnectEnd:le,onlyRenderVisibleElements:T,onEdgeContextMenu:ne,onEdgeMouseEnter:re,onEdgeMouseMove:ie,onEdgeMouseLeave:ae,reconnectRadius:oe,defaultMarkerColor:M,noPanClassName:de,disableKeyboardA11y:fe,rfId:pe}),(0,J.jsx)(Qd,{style:h,type:m,component:g,containerStyle:_}),(0,J.jsx)(`div`,{className:`react-flow__edgelabel-renderer`}),(0,J.jsx)(nd,{nodeTypes:e,onNodeClick:r,onNodeDoubleClick:a,onNodeMouseEnter:s,onNodeMouseMove:c,onNodeMouseLeave:l,onNodeContextMenu:u,nodeClickDistance:K,onlyRenderVisibleElements:T,noPanClassName:de,noDragClassName:q,disableKeyboardA11y:fe,nodeExtent:Y,rfId:pe}),(0,J.jsx)(`div`,{className:`react-flow__viewport-portal`})]})})}rf.displayName=`GraphView`;var af=(0,Y.memo)(rf),of=Ko(`React Flow`,`https://reactflow.dev/`),sf=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:i,height:a,fitView:o,fitViewOptions:s,minZoom:c=.5,maxZoom:l=2,nodeOrigin:u,nodeExtent:d,zIndexMode:f=`basic`}={})=>{let p=new Map,m=new Map,h=new Map,g=new Map,_=r??t??[],v=n??e??[],y=u??[0,0],b=d??so;rc(h,g,_);let{nodesInitialized:x}=Js(v,p,m,{nodeOrigin:y,nodeExtent:b,zIndexMode:f}),S=[0,0,1];if(o&&i&&a){let{x:e,y:t,zoom:n}=$o(wo(p,{filter:e=>!!((e.width||e.initialWidth)&&(e.height||e.initialHeight))}),i,a,c,l,s?.padding??.1);S=[e,t,n]}return{rfId:`1`,width:i??0,height:a??0,transform:S,nodes:v,nodesInitialized:x,nodeLookup:p,parentLookup:m,edges:_,edgeLookup:g,connectionLookup:h,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:n!==void 0,hasDefaultEdges:r!==void 0,panZoom:null,minZoom:c,maxZoom:l,translateExtent:so,nodeExtent:b,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:uo.Strict,domNode:null,paneDragging:!1,noPanClassName:`nopan`,nodeOrigin:y,nodeDragThreshold:1,connectionDragThreshold:1,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesReconnectable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,elevateEdgesOnSelect:!0,selectNodesOnDrag:!0,multiSelectionActive:!1,fitViewQueued:o??!1,fitViewOptions:s,fitViewResolver:null,connection:{...mo},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:``,autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:of,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:`react`,debug:!1,ariaLabelConfig:lo,zIndexMode:f,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},cf=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:i,height:a,fitView:o,fitViewOptions:s,minZoom:c,maxZoom:l,nodeOrigin:u,nodeExtent:d,zIndexMode:f})=>il((p,m)=>{async function h(){let{nodeLookup:e,panZoom:t,fitViewOptions:n,fitViewResolver:r,width:i,height:a,minZoom:o,maxZoom:s}=m();t&&(await Oo({nodes:e,width:i,height:a,panZoom:t,minZoom:o,maxZoom:s},n),r?.resolve(!0),p({fitViewResolver:null}))}return{...sf({nodes:e,edges:t,width:i,height:a,fitView:o,fitViewOptions:s,minZoom:c,maxZoom:l,nodeOrigin:u,nodeExtent:d,defaultNodes:n,defaultEdges:r,zIndexMode:f}),setNodes:e=>{let{nodeLookup:t,parentLookup:n,nodeOrigin:r,elevateNodesOnSelect:i,fitViewQueued:a,zIndexMode:o,nodesSelectionActive:s}=m(),{nodesInitialized:c,hasSelectedNodes:l}=Js(e,t,n,{nodeOrigin:r,nodeExtent:d,elevateNodesOnSelect:i,checkEquality:!0,zIndexMode:o}),u=s&&l;a&&c?(h(),p({nodes:e,nodesInitialized:c,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:u})):p({nodes:e,nodesInitialized:c,nodesSelectionActive:u})},setEdges:e=>{let{connectionLookup:t,edgeLookup:n}=m();rc(t,n,e),p({edges:e})},setDefaultNodesAndEdges:(e,t)=>{if(e){let{setNodes:t}=m();t(e),p({hasDefaultNodes:!0})}if(t){let{setEdges:e}=m();e(t),p({hasDefaultEdges:!0})}},updateNodeInternals:e=>{let{triggerNodeChanges:t,nodeLookup:n,parentLookup:r,domNode:i,nodeOrigin:a,nodeExtent:o,debug:s,fitViewQueued:c,zIndexMode:l}=m(),{changes:u,updatedInternals:d}=ec(e,n,r,i,a,o,l);d&&(Gs(n,r,{nodeOrigin:a,nodeExtent:o,zIndexMode:l}),c?(h(),p({fitViewQueued:!1,fitViewOptions:void 0})):p({}),u?.length>0&&(s&&console.log(`React Flow: trigger node changes`,u),t?.(u)))},updateNodePositions:(e,t=!1)=>{let n=[],r=[],{nodeLookup:i,triggerNodeChanges:a,connection:o,updateConnection:s,onNodesChangeMiddlewareMap:c}=m();for(let[a,c]of e){let e=i.get(a),l=!!(e?.expandParent&&e?.parentId&&c?.position),u={id:a,type:`position`,position:l?{x:Math.max(0,c.position.x),y:Math.max(0,c.position.y)}:c.position,dragging:t};if(e&&o.inProgress&&o.fromNode.id===e.id){let t=Is(e,o.fromHandle,Z.Left,!0);s({...o,from:t})}l&&e.parentId&&n.push({id:a,parentId:e.parentId,rect:{...c.internals.positionAbsolute,width:c.measured.width??0,height:c.measured.height??0}}),r.push(u)}if(n.length>0){let{parentLookup:e,nodeOrigin:t}=m(),a=$s(n,i,e,t);r.push(...a)}for(let e of c.values())r=e(r);a(r)},triggerNodeChanges:e=>{let{onNodesChange:t,setNodes:n,nodes:r,hasDefaultNodes:i,debug:a}=m();e?.length&&(i&&n(Hl(e,r)),a&&console.log(`React Flow: trigger node changes`,e),t?.(e))},triggerEdgeChanges:e=>{let{onEdgesChange:t,setEdges:n,edges:r,hasDefaultEdges:i,debug:a}=m();e?.length&&(i&&n(Ul(e,r)),a&&console.log(`React Flow: trigger edge changes`,e),t?.(e))},addSelectedNodes:e=>{let{multiSelectionActive:t,edgeLookup:n,nodeLookup:r,triggerNodeChanges:i,triggerEdgeChanges:a}=m();if(t){i(e.map(e=>Wl(e,!0)));return}i(Gl(r,new Set([...e]),!0)),a(Gl(n))},addSelectedEdges:e=>{let{multiSelectionActive:t,edgeLookup:n,nodeLookup:r,triggerNodeChanges:i,triggerEdgeChanges:a}=m();if(t){a(e.map(e=>Wl(e,!0)));return}a(Gl(n,new Set([...e]))),i(Gl(r,new Set,!0))},unselectNodesAndEdges:({nodes:e,edges:t}={})=>{let{edges:n,nodes:r,nodeLookup:i,triggerNodeChanges:a,triggerEdgeChanges:o}=m(),s=e||r,c=t||n,l=[];for(let e of s){if(!e.selected)continue;let t=i.get(e.id);t&&(t.selected=!1),l.push(Wl(e.id,!1))}let u=[];for(let e of c)e.selected&&u.push(Wl(e.id,!1));a(l),o(u)},setMinZoom:e=>{let{panZoom:t,maxZoom:n}=m();t?.setScaleExtent([e,n]),p({minZoom:e})},setMaxZoom:e=>{let{panZoom:t,minZoom:n}=m();t?.setScaleExtent([n,e]),p({maxZoom:e})},setTranslateExtent:e=>{m().panZoom?.setTranslateExtent(e),p({translateExtent:e})},resetSelectedElements:()=>{let{edges:e,nodes:t,triggerNodeChanges:n,triggerEdgeChanges:r,elementsSelectable:i}=m();if(!i)return;let a=t.reduce((e,t)=>t.selected?[...e,Wl(t.id,!1)]:e,[]),o=e.reduce((e,t)=>t.selected?[...e,Wl(t.id,!1)]:e,[]);n(a),r(o)},setNodeExtent:e=>{let{nodes:t,nodeLookup:n,parentLookup:r,nodeOrigin:i,elevateNodesOnSelect:a,nodeExtent:o,zIndexMode:s}=m();(e[0][0]!==o[0][0]||e[0][1]!==o[0][1]||e[1][0]!==o[1][0]||e[1][1]!==o[1][1])&&(Js(t,n,r,{nodeOrigin:i,nodeExtent:e,elevateNodesOnSelect:a,checkEquality:!1,zIndexMode:s}),p({nodeExtent:e}))},panBy:e=>{let{transform:t,width:n,height:r,panZoom:i,translateExtent:a}=m();return tc({delta:e,panZoom:i,transform:t,translateExtent:a,width:n,height:r})},setCenter:async(e,t,n)=>{let{width:r,height:i,maxZoom:a,panZoom:o}=m();if(!o)return!1;let s=n?.zoom===void 0?a:n.zoom;return await o.setViewport({x:r/2-e*s,y:i/2-t*s,zoom:s},{duration:n?.duration,ease:n?.ease,interpolate:n?.interpolate}),!0},cancelConnection:()=>{p({connection:{...mo}})},updateConnection:e=>{p({connection:e})},reset:()=>p({...sf()})}},Object.is);function lf({initialNodes:e,initialEdges:t,defaultNodes:n,defaultEdges:r,initialWidth:i,initialHeight:a,initialMinZoom:o,initialMaxZoom:s,initialFitViewOptions:c,fitView:l,nodeOrigin:u,nodeExtent:d,zIndexMode:f,children:p}){let[m]=(0,Y.useState)(()=>cf({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:i,height:a,fitView:l,minZoom:o,maxZoom:s,fitViewOptions:c,nodeOrigin:u,nodeExtent:d,zIndexMode:f}));return(0,J.jsx)(sl,{value:m,children:(0,J.jsx)(ru,{children:(0,J.jsx)(Ou,{children:p})})})}function uf({children:e,nodes:t,edges:n,defaultNodes:r,defaultEdges:i,width:a,height:o,fitView:s,fitViewOptions:c,minZoom:l,maxZoom:u,nodeOrigin:d,nodeExtent:f,zIndexMode:p}){return(0,Y.useContext)(ol)?(0,J.jsx)(J.Fragment,{children:e}):(0,J.jsx)(lf,{initialNodes:t,initialEdges:n,defaultNodes:r,defaultEdges:i,initialWidth:a,initialHeight:o,fitView:s,initialFitViewOptions:c,initialMinZoom:l,initialMaxZoom:u,nodeOrigin:d,nodeExtent:f,zIndexMode:p,children:e})}var df={width:`100%`,height:`100%`,overflow:`hidden`,position:`relative`,zIndex:0};function ff({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,className:i,nodeTypes:a,edgeTypes:o,onNodeClick:s,onEdgeClick:c,onInit:l,onMove:u,onMoveStart:d,onMoveEnd:f,onConnect:p,onConnectStart:m,onConnectEnd:h,onClickConnectStart:g,onClickConnectEnd:_,onNodeMouseEnter:v,onNodeMouseMove:y,onNodeMouseLeave:b,onNodeContextMenu:x,onNodeDoubleClick:S,onNodeDragStart:C,onNodeDrag:w,onNodeDragStop:T,onNodesDelete:E,onEdgesDelete:D,onDelete:O,onSelectionChange:k,onSelectionDragStart:A,onSelectionDrag:j,onSelectionDragStop:M,onSelectionContextMenu:N,onSelectionStart:P,onSelectionEnd:F,onBeforeDelete:I,connectionMode:L,connectionLineType:R=ho.Bezier,connectionLineStyle:z,connectionLineComponent:B,connectionLineContainerStyle:V,deleteKeyCode:ee=`Backspace`,selectionKeyCode:te=`Shift`,selectionOnDrag:H=!1,selectionMode:U=po.Full,panActivationKeyCode:W=`Space`,multiSelectionKeyCode:G=es()?`Meta`:`Control`,zoomActivationKeyCode:K=es()?`Meta`:`Control`,snapToGrid:ne,snapGrid:re,onlyRenderVisibleElements:ie=!1,selectNodesOnDrag:ae,nodesDraggable:oe,autoPanOnNodeFocus:se,nodesConnectable:ce,nodesFocusable:le,nodeOrigin:q=Dl,edgesFocusable:ue,edgesReconnectable:de,elementsSelectable:fe=!0,defaultViewport:pe=Ol,minZoom:me=.5,maxZoom:X=2,translateExtent:he=so,preventScrolling:ge=!0,nodeExtent:_e,defaultMarkerColor:ve=`#b1b1b7`,zoomOnScroll:ye=!0,zoomOnPinch:be=!0,panOnScroll:xe=!1,panOnScrollSpeed:Ce=.5,panOnScrollMode:we=fo.Free,zoomOnDoubleClick:Te=!0,panOnDrag:Ee=!0,onPaneClick:De,onPaneMouseEnter:Oe,onPaneMouseMove:ke,onPaneMouseLeave:Ae,onPaneScroll:je,onPaneContextMenu:Me,paneClickDistance:Ne=1,nodeClickDistance:Pe=0,children:Fe,onReconnect:Ie,onReconnectStart:Le,onReconnectEnd:Re,onEdgeContextMenu:ze,onEdgeDoubleClick:Be,onEdgeMouseEnter:Ve,onEdgeMouseMove:He,onEdgeMouseLeave:Ue,reconnectRadius:We=10,onNodesChange:Ge,onEdgesChange:Ke,noDragClassName:qe=`nodrag`,noWheelClassName:Je=`nowheel`,noPanClassName:Ye=`nopan`,fitView:Xe,fitViewOptions:Ze,connectOnClick:Qe,attributionPosition:$e,proOptions:et,defaultEdgeOptions:tt,elevateNodesOnSelect:nt=!0,elevateEdgesOnSelect:rt=!1,disableKeyboardA11y:it=!1,autoPanOnConnect:at,autoPanOnNodeDrag:ot,autoPanOnSelection:st=!0,autoPanSpeed:ct,connectionRadius:lt,isValidConnection:ut,onError:dt,style:ft,id:pt,nodeDragThreshold:mt,connectionDragThreshold:ht,viewport:gt,onViewportChange:_t,width:vt,height:yt,colorMode:bt=`light`,debug:xt,onScroll:St,ariaLabelConfig:Ct,zIndexMode:wt=`basic`,...Tt},Et){let Dt=pt||`1`,Ot=Pl(bt),kt=(0,Y.useCallback)(e=>{e.currentTarget.scrollTo({top:0,left:0,behavior:`instant`}),St?.(e)},[St]);return(0,J.jsx)(`div`,{"data-testid":`rf__wrapper`,...Tt,onScroll:kt,style:{...ft,...df},ref:Et,className:Se([`react-flow`,i,Ot]),id:pt,role:`application`,children:(0,J.jsxs)(uf,{nodes:e,edges:t,width:vt,height:yt,fitView:Xe,fitViewOptions:Ze,minZoom:me,maxZoom:X,nodeOrigin:q,nodeExtent:_e,zIndexMode:wt,children:[(0,J.jsx)(Ml,{nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:p,onConnectStart:m,onConnectEnd:h,onClickConnectStart:g,onClickConnectEnd:_,nodesDraggable:oe,autoPanOnNodeFocus:se,nodesConnectable:ce,nodesFocusable:le,edgesFocusable:ue,edgesReconnectable:de,elementsSelectable:fe,elevateNodesOnSelect:nt,elevateEdgesOnSelect:rt,minZoom:me,maxZoom:X,nodeExtent:_e,onNodesChange:Ge,onEdgesChange:Ke,snapToGrid:ne,snapGrid:re,connectionMode:L,translateExtent:he,connectOnClick:Qe,defaultEdgeOptions:tt,fitView:Xe,fitViewOptions:Ze,onNodesDelete:E,onEdgesDelete:D,onDelete:O,onNodeDragStart:C,onNodeDrag:w,onNodeDragStop:T,onSelectionDrag:j,onSelectionDragStart:A,onSelectionDragStop:M,onMove:u,onMoveStart:d,onMoveEnd:f,noPanClassName:Ye,nodeOrigin:q,rfId:Dt,autoPanOnConnect:at,autoPanOnNodeDrag:ot,autoPanSpeed:ct,onError:dt,connectionRadius:lt,isValidConnection:ut,selectNodesOnDrag:ae,nodeDragThreshold:mt,connectionDragThreshold:ht,onBeforeDelete:I,debug:xt,ariaLabelConfig:Ct,zIndexMode:wt}),(0,J.jsx)(af,{onInit:l,onNodeClick:s,onEdgeClick:c,onNodeMouseEnter:v,onNodeMouseMove:y,onNodeMouseLeave:b,onNodeContextMenu:x,onNodeDoubleClick:S,nodeTypes:a,edgeTypes:o,connectionLineType:R,connectionLineStyle:z,connectionLineComponent:B,connectionLineContainerStyle:V,selectionKeyCode:te,selectionOnDrag:H,selectionMode:U,deleteKeyCode:ee,multiSelectionKeyCode:G,panActivationKeyCode:W,zoomActivationKeyCode:K,onlyRenderVisibleElements:ie,defaultViewport:pe,translateExtent:he,minZoom:me,maxZoom:X,preventScrolling:ge,zoomOnScroll:ye,zoomOnPinch:be,zoomOnDoubleClick:Te,panOnScroll:xe,panOnScrollSpeed:Ce,panOnScrollMode:we,panOnDrag:Ee,autoPanOnSelection:st,onPaneClick:De,onPaneMouseEnter:Oe,onPaneMouseMove:ke,onPaneMouseLeave:Ae,onPaneScroll:je,onPaneContextMenu:Me,paneClickDistance:Ne,nodeClickDistance:Pe,onSelectionContextMenu:N,onSelectionStart:P,onSelectionEnd:F,onReconnect:Ie,onReconnectStart:Le,onReconnectEnd:Re,onEdgeContextMenu:ze,onEdgeDoubleClick:Be,onEdgeMouseEnter:Ve,onEdgeMouseMove:He,onEdgeMouseLeave:Ue,reconnectRadius:We,defaultMarkerColor:ve,noDragClassName:qe,noWheelClassName:Je,noPanClassName:Ye,rfId:Dt,disableKeyboardA11y:it,nodeExtent:_e,viewport:gt,onViewportChange:_t}),(0,J.jsx)(El,{onSelectionChange:k}),Fe,(0,J.jsx)(bl,{proOptions:et,position:$e}),(0,J.jsx)(_l,{rfId:Dt,disableKeyboardA11y:it})]})})}var pf=Ql(ff),mf=e=>e.domNode?.querySelector(`.react-flow__edgelabel-renderer`);function hf({children:e}){let t=Q(mf);return t?(0,pe.createPortal)(e,t):null}function gf(e){let[t,n]=(0,Y.useState)(e);return[t,n,(0,Y.useCallback)(e=>n(t=>Hl(e,t)),[])]}var _f=e=>t=>{if(!e.includeHiddenNodes)return t.nodesInitialized;if(t.nodeLookup.size===0)return!1;for(let[,{internals:e}]of t.nodeLookup)if(e.handleBounds===void 0||!rs(e.userNode))return!1;return!0};function vf(e={includeHiddenNodes:!1}){return Q(_f(e))}oo.error014();function yf({dimensions:e,lineWidth:t,variant:n,className:r}){return(0,J.jsx)(`path`,{strokeWidth:t,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:Se([`react-flow__background-pattern`,n,r])})}function bf({radius:e,className:t}){return(0,J.jsx)(`circle`,{cx:e,cy:e,r:e,className:Se([`react-flow__background-pattern`,`dots`,t])})}var xf;(function(e){e.Lines=`lines`,e.Dots=`dots`,e.Cross=`cross`})(xf||={});var Sf={[xf.Dots]:1,[xf.Lines]:1,[xf.Cross]:6},Cf=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function wf({id:e,variant:t=xf.Dots,gap:n=20,size:r,lineWidth:i=1,offset:a=0,color:o,bgColor:s,style:c,className:l,patternClassName:u}){let d=(0,Y.useRef)(null),{transform:f,patternId:p}=Q(Cf,al),m=r||Sf[t],h=t===xf.Dots,g=t===xf.Cross,_=Array.isArray(n)?n:[n,n],v=[_[0]*f[2]||1,_[1]*f[2]||1],y=m*f[2],b=Array.isArray(a)?a:[a,a],x=g?[y,y]:v,S=[b[0]*f[2]||1+x[0]/2,b[1]*f[2]||1+x[1]/2],C=`${p}${e||``}`;return(0,J.jsxs)(`svg`,{className:Se([`react-flow__background`,l]),style:{...c,...du,"--xy-background-color-props":s,"--xy-background-pattern-color-props":o},ref:d,"data-testid":`rf__background`,children:[(0,J.jsx)(`pattern`,{id:C,x:f[0]%v[0],y:f[1]%v[1],width:v[0],height:v[1],patternUnits:`userSpaceOnUse`,patternTransform:`translate(-${S[0]},-${S[1]})`,children:h?(0,J.jsx)(bf,{radius:y/2,className:u}):(0,J.jsx)(yf,{dimensions:x,lineWidth:i,variant:t,className:u})}),(0,J.jsx)(`rect`,{x:`0`,y:`0`,width:`100%`,height:`100%`,fill:`url(#${C})`})]})}wf.displayName=`Background`;var Tf=(0,Y.memo)(wf);function Ef(){return(0,J.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 32 32`,children:(0,J.jsx)(`path`,{d:`M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z`})})}function Df(){return(0,J.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 32 5`,children:(0,J.jsx)(`path`,{d:`M0 0h32v4.2H0z`})})}function Of(){return(0,J.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 32 30`,children:(0,J.jsx)(`path`,{d:`M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z`})})}function kf(){return(0,J.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 25 32`,children:(0,J.jsx)(`path`,{d:`M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z`})})}function Af(){return(0,J.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 25 32`,children:(0,J.jsx)(`path`,{d:`M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z`})})}function jf({children:e,className:t,...n}){return(0,J.jsx)(`button`,{type:`button`,className:Se([`react-flow__controls-button`,t]),...n,children:e})}var Mf=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function Nf({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:r=!0,fitViewOptions:i,onZoomIn:a,onZoomOut:o,onFitView:s,onInteractiveChange:c,className:l,children:u,position:d=`bottom-left`,orientation:f=`vertical`,"aria-label":p}){let m=$(),{isInteractive:h,minZoomReached:g,maxZoomReached:_,ariaLabelConfig:v}=Q(Mf,al),{zoomIn:y,zoomOut:b,fitView:x}=ou();return(0,J.jsxs)(vl,{className:Se([`react-flow__controls`,f===`horizontal`?`horizontal`:`vertical`,l]),position:d,style:e,"data-testid":`rf__controls`,"aria-label":p??v[`controls.ariaLabel`],children:[t&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(jf,{onClick:()=>{y(),a?.()},className:`react-flow__controls-zoomin`,title:v[`controls.zoomIn.ariaLabel`],"aria-label":v[`controls.zoomIn.ariaLabel`],disabled:_,children:(0,J.jsx)(Ef,{})}),(0,J.jsx)(jf,{onClick:()=>{b(),o?.()},className:`react-flow__controls-zoomout`,title:v[`controls.zoomOut.ariaLabel`],"aria-label":v[`controls.zoomOut.ariaLabel`],disabled:g,children:(0,J.jsx)(Df,{})})]}),n&&(0,J.jsx)(jf,{className:`react-flow__controls-fitview`,onClick:()=>{x(i),s?.()},title:v[`controls.fitView.ariaLabel`],"aria-label":v[`controls.fitView.ariaLabel`],children:(0,J.jsx)(Of,{})}),r&&(0,J.jsx)(jf,{className:`react-flow__controls-interactive`,onClick:()=>{m.setState({nodesDraggable:!h,nodesConnectable:!h,elementsSelectable:!h}),c?.(!h)},title:v[`controls.interactive.ariaLabel`],"aria-label":v[`controls.interactive.ariaLabel`],children:h?(0,J.jsx)(Af,{}):(0,J.jsx)(kf,{})}),u]})}Nf.displayName=`Controls`;var Pf=(0,Y.memo)(Nf);function Ff({id:e,x:t,y:n,width:r,height:i,style:a,color:o,strokeColor:s,strokeWidth:c,className:l,borderRadius:u,shapeRendering:d,selected:f,onClick:p}){let{background:m,backgroundColor:h}=a||{},g=o||m||h;return(0,J.jsx)(`rect`,{className:Se([`react-flow__minimap-node`,{selected:f},l]),x:t,y:n,rx:u,ry:u,width:r,height:i,style:{fill:g,stroke:s,strokeWidth:c},shapeRendering:d,onClick:p?t=>p(t,e):void 0})}var If=(0,Y.memo)(Ff),Lf=e=>e.nodes.map(e=>e.id),Rf=e=>e instanceof Function?e:()=>e;function zf({nodeStrokeColor:e,nodeColor:t,nodeClassName:n=``,nodeBorderRadius:r=5,nodeStrokeWidth:i,nodeComponent:a=If,onClick:o}){let s=Q(Lf,al),c=Rf(t),l=Rf(e),u=Rf(n),d=typeof window>`u`||window.chrome?`crispEdges`:`geometricPrecision`;return(0,J.jsx)(J.Fragment,{children:s.map(e=>(0,J.jsx)(Vf,{id:e,nodeColorFunc:c,nodeStrokeColorFunc:l,nodeClassNameFunc:u,nodeBorderRadius:r,nodeStrokeWidth:i,NodeComponent:a,onClick:o,shapeRendering:d},e))})}function Bf({id:e,nodeColorFunc:t,nodeStrokeColorFunc:n,nodeClassNameFunc:r,nodeBorderRadius:i,nodeStrokeWidth:a,shapeRendering:o,NodeComponent:s,onClick:c}){let{node:l,x:u,y:d,width:f,height:p}=Q(t=>{let n=t.nodeLookup.get(e);if(!n)return{node:void 0,x:0,y:0,width:0,height:0};let r=n.internals.userNode,{x:i,y:a}=n.internals.positionAbsolute,{width:o,height:s}=ns(r);return{node:r,x:i,y:a,width:o,height:s}},al);return!l||l.hidden||!rs(l)?null:(0,J.jsx)(s,{x:u,y:d,width:f,height:p,style:l.style,selected:!!l.selected,className:r(l),color:t(l),borderRadius:i,strokeColor:n(l),strokeWidth:a,shapeRendering:o,onClick:c,id:l.id})}var Vf=(0,Y.memo)(Bf),Hf=(0,Y.memo)(zf),Uf=200,Wf=150,Gf=e=>!e.hidden,Kf=e=>{let t={x:-e.transform[0]/e.transform[2],y:-e.transform[1]/e.transform[2],width:e.width/e.transform[2],height:e.height/e.transform[2]};return{viewBB:t,boundingRect:e.nodeLookup.size>0?Vo(wo(e.nodeLookup,{filter:Gf}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},qf=`react-flow__minimap-desc`;function Jf({style:e,className:t,nodeStrokeColor:n,nodeColor:r,nodeClassName:i=``,nodeBorderRadius:a=5,nodeStrokeWidth:o,nodeComponent:s,bgColor:c,maskColor:l,maskStrokeColor:u,maskStrokeWidth:d,position:f=`bottom-right`,onClick:p,onNodeClick:m,pannable:h=!1,zoomable:g=!1,ariaLabel:_,inversePan:v,zoomStep:y=1,offsetScale:b=5}){let x=$(),S=(0,Y.useRef)(null),{boundingRect:C,viewBB:w,rfId:T,panZoom:E,translateExtent:D,flowWidth:O,flowHeight:k,ariaLabelConfig:A}=Q(Kf,al),j=e?.width??Uf,M=e?.height??Wf,N=C.width/j,P=C.height/M,F=Math.max(N,P),I=F*j,L=F*M,R=b*F,z=C.x-(I-C.width)/2-R,B=C.y-(L-C.height)/2-R,V=I+R*2,ee=L+R*2,te=`${qf}-${T}`,H=(0,Y.useRef)(0),U=(0,Y.useRef)();H.current=F,(0,Y.useEffect)(()=>{if(S.current&&E)return U.current=bc({domNode:S.current,panZoom:E,getTransform:()=>x.getState().transform,getViewScale:()=>H.current}),()=>{U.current?.destroy()}},[E]),(0,Y.useEffect)(()=>{U.current?.update({translateExtent:D,width:O,height:k,inversePan:v,pannable:h,zoomStep:y,zoomable:g})},[h,g,v,y,D,O,k]);let W=p?e=>{let[t,n]=U.current?.pointer(e)||[0,0];p(e,{x:t,y:n})}:void 0,G=m?(0,Y.useCallback)((e,t)=>{let n=x.getState().nodeLookup.get(t).internals.userNode;m(e,n)},[]):void 0,K=_??A[`minimap.ariaLabel`];return(0,J.jsx)(vl,{position:f,style:{...e,"--xy-minimap-background-color-props":typeof c==`string`?c:void 0,"--xy-minimap-mask-background-color-props":typeof l==`string`?l:void 0,"--xy-minimap-mask-stroke-color-props":typeof u==`string`?u:void 0,"--xy-minimap-mask-stroke-width-props":typeof d==`number`?d*F:void 0,"--xy-minimap-node-background-color-props":typeof r==`string`?r:void 0,"--xy-minimap-node-stroke-color-props":typeof n==`string`?n:void 0,"--xy-minimap-node-stroke-width-props":typeof o==`number`?o:void 0},className:Se([`react-flow__minimap`,t]),"data-testid":`rf__minimap`,children:(0,J.jsxs)(`svg`,{width:j,height:M,viewBox:`${z} ${B} ${V} ${ee}`,className:`react-flow__minimap-svg`,role:`img`,"aria-labelledby":te,ref:S,onClick:W,children:[K&&(0,J.jsx)(`title`,{id:te,children:K}),(0,J.jsx)(Hf,{onClick:G,nodeColor:r,nodeStrokeColor:n,nodeBorderRadius:a,nodeClassName:i,nodeStrokeWidth:o,nodeComponent:s}),(0,J.jsx)(`path`,{className:`react-flow__minimap-mask`,d:`M${z-R},${B-R}h${V+R*2}v${ee+R*2}h${-V-R*2}z + M${w.x},${w.y}h${w.width}v${w.height}h${-w.width}z`,fillRule:`evenodd`,pointerEvents:`none`})]})})}Jf.displayName=`MiniMap`;var Yf=(0,Y.memo)(Jf),Xf=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,Zf={[Fc.Line]:`right`,[Fc.Handle]:`bottom-right`};function Qf({nodeId:e,position:t,variant:n=Fc.Handle,className:r,style:i=void 0,children:a,color:o,minWidth:s=10,minHeight:c=10,maxWidth:l=Number.MAX_VALUE,maxHeight:u=Number.MAX_VALUE,keepAspectRatio:d=!1,resizeDirection:f,autoScale:p=!0,shouldResize:m,onResizeStart:h,onResize:g,onResizeEnd:_}){let v=Tu(),y=typeof e==`string`?e:v,b=$(),x=(0,Y.useRef)(null),S=n===Fc.Handle,C=Q((0,Y.useCallback)(Xf(S&&p),[S,p]),al),w=(0,Y.useRef)(null),T=t??Zf[n];(0,Y.useEffect)(()=>{if(!(!x.current||!y))return w.current||=Kc({domNode:x.current,nodeId:y,getStoreItems:()=>{let{nodeLookup:e,transform:t,snapGrid:n,snapToGrid:r,nodeOrigin:i,domNode:a}=b.getState();return{nodeLookup:e,transform:t,snapGrid:n,snapToGrid:r,nodeOrigin:i,paneDomNode:a}},onChange:(e,t)=>{let{triggerNodeChanges:n,nodeLookup:r,parentLookup:i,nodeOrigin:a}=b.getState(),o=[],s={x:e.x,y:e.y},c=r.get(y);if(c&&c.expandParent&&c.parentId){let t=c.origin??a,n=e.width??c.measured.width??0,l=e.height??c.measured.height??0,u=$s([{id:c.id,parentId:c.parentId,rect:{width:n,height:l,...is({x:e.x??c.position.x,y:e.y??c.position.y},{width:n,height:l},c.parentId,r,t)}}],r,i,a);o.push(...u),s.x=e.x?Math.max(t[0]*n,e.x):void 0,s.y=e.y?Math.max(t[1]*l,e.y):void 0}if(s.x!==void 0&&s.y!==void 0){let e={id:y,type:`position`,position:{...s}};o.push(e)}if(e.width!==void 0&&e.height!==void 0){let t={id:y,type:`dimensions`,resizing:!0,setAttributes:f?f===`horizontal`?`width`:`height`:!0,dimensions:{width:e.width,height:e.height}};o.push(t)}for(let e of t){let t={...e,type:`position`};o.push(t)}n(o)},onEnd:({width:e,height:t})=>{let n={id:y,type:`dimensions`,resizing:!1,dimensions:{width:e,height:t}};b.getState().triggerNodeChanges([n])}}),w.current.update({controlPosition:T,boundaries:{minWidth:s,minHeight:c,maxWidth:l,maxHeight:u},keepAspectRatio:d,resizeDirection:f,onResizeStart:h,onResize:g,onResizeEnd:_,shouldResize:m}),()=>{w.current?.destroy()}},[T,s,c,l,u,d,h,g,_,m]);let E=T.split(`-`);return(0,J.jsx)(`div`,{className:Se([`react-flow__resize-control`,`nodrag`,...E,n,r]),ref:x,style:{...i,scale:C,...o&&{[S?`backgroundColor`:`borderColor`]:o}},children:a})}(0,Y.memo)(Qf);var $f=new Set([`running`,`in_progress`,`claimed`]);function ep(e){return e.pending_question?`question`:$f.has(e.status)?`running`:e.status.startsWith(`paused`)||e.status===`blocked`?`paused`:[`done`,`failed`,`aborted`,`skipped`,`superseded`,`pending`,`missing`].includes(e.status)?e.status:`unknown`}function tp(e){let t=new Set,n=[],r=new Map([...e.keys()].map(e=>[e,[]]));for(let[t,n]of e)for(let e of n)r.get(e).push(t);for(let r of e.keys()){let i=[[r,!1]];for(;i.length;){let[r,a]=i.pop();if(a)n.push(r);else if(!t.has(r)){t.add(r),i.push([r,!0]);for(let n of e.get(r))t.has(n)||i.push([n,!1])}}}let i=new Map;for(let e of n.reverse()){if(i.has(e))continue;let t=i.size,n=[e];for(;n.length;){let e=n.pop();if(!i.has(e)){i.set(e,t);for(let t of r.get(e))n.push(t)}}}return i}function np(e){let t=new Map(e.map(e=>[e.id,e])),n=[...t.values()].sort((e,t)=>(e.ts??0)-(t.ts??0)||e.id.localeCompare(t.id)),r=[],i=new Set;for(let e of n)for(let n of new Set(e.deps??[]))t.has(n)||i.add(n),r.push({id:JSON.stringify([`dep`,n,e.id]),source:n,target:e.id,kind:`dependency`,missing:!t.has(n)});let a=[...[...i].map(e=>({id:e,title:`未包含的依赖`,objective:`该引用不在当前数据范围内。`,status:`missing`,deps:[],role:`system`})),...n],o=new Map(a.map(e=>[e.id,0])),s=new Map(a.map(e=>[e.id,[]]));r.forEach(e=>{o.set(e.target,(o.get(e.target)??0)+1),s.get(e.source)?.push(e.target)});let c=a.filter(e=>o.get(e.id)===0).map(e=>e.id),l=0;for(let e=0;et.id!==e.id&&t.plan_id===e.superseded_by_plan_id);t.length&&r.push({id:JSON.stringify([`replacement`,e.id,e.superseded_by_plan_id]),source:e.id,target:t[0].id,kind:`replacement`,target_plan_id:e.superseded_by_plan_id,target_count:t.length})}if(u){let e=tp(s);r.filter(t=>t.kind===`dependency`&&e.get(t.source)===e.get(t.target)).forEach(e=>{e.cycle=!0})}return{tasks:a,links:r,missing:i.size,cyclic:u}}function rp(e,t){let n=e.team_task_id?.match(/route-(\d+)/)?.[1],r=e.team_role===`idea-route`?t?`研究路线`:`Research route`:e.team_role===`idea-review`?t?`独立复核`:`Independent review`:e.team_role===`idea-selector`?t?`方案选择`:`Idea selection`:``;return r?`${r}${n?` ${n}`:``}`:e.title||(t?`并行子任务`:`Parallel task`)}function ip(e){let t=String(e||``).split(/\r?\n/).map(e=>e.replace(/^\s*(?:RESULT|SUMMARY|NEXT_ACTION)\s*=\s*/i,``).trim()).filter(e=>e&&!/^(?:Decision\s*:|(?:MILESTONE_STATUS|NEXT_OWNER|OPERATOR_QUESTION|OPERATOR_OPTIONS)\s*=)/i.test(e)).join(` `);return t.length>160?`${t.slice(0,159)}…`:t}function ap(e){let t=new Map;for(let n of e){if(n.type!==`idea.portfolio.formed`)continue;let e=Number(n.width);if(!Number.isInteger(e)||e<=0)continue;let r=t.get(n.item_id);(!r||n.ts>=r.ts)&&t.set(n.item_id,{ts:n.ts,width:e})}return new Map([...t].map(([e,t])=>[e,t.width]))}function op(e,t,n){let r=new Map;for(let e of t){if(e.type!==`team.task`||!e.item_id)continue;let t=r.get(e.item_id)??new Map;t.set(e.id,e),r.set(e.item_id,t)}if(!r.size)return e;let i=new Set(e.tasks.map(e=>e.id)),a=[],o=[];for(let t of e.tasks){if(t.branch)continue;let e=[...r.get(t.id)?.values()??[]].filter(e=>!i.has(e.id)).sort((e,t)=>e.ts-t.ts||e.id.localeCompare(t.id));if(!e.length)continue;let s=e.slice(0,16),c=new Set(s.map(e=>e.id));for(let e of s)i.add(e.id),a.push({id:e.id,title:rp(e,n),objective:ip(e.text),excerpt:ip(e.text),status:e.status||`unknown`,deps:[],pending_question:e.pending_question,role:`team`,team_role:e.team_role,ts:e.ts,branch:!0,parent_id:t.id});let l=new Set(s.flatMap(e=>(e.deps??[]).filter(t=>c.has(t)&&t!==e.id)));for(let e of s){let n=[...new Set(e.deps??[])].filter(t=>c.has(t)&&t!==e.id);if(n.length)for(let t of n)o.push({id:JSON.stringify([`fanout`,t,e.id]),source:t,target:e.id,kind:`fanout`});else o.push({id:JSON.stringify([`fanout`,t.id,e.id]),source:t.id,target:e.id,kind:`fanout`});l.has(e.id)||o.push({id:JSON.stringify([`fanin`,e.id,t.id]),source:e.id,target:t.id,kind:`fanin`})}let u=e.length-s.length,d=`team-overflow:${t.id}`;u>0&&!i.has(d)&&(i.add(d),a.push({id:d,title:n?`还有 ${u} 条`:`+${u} more`,objective:n?`更多并行子任务收录在所属任务卡片中。`:`The remaining parallel subtasks live inside the owning card.`,status:`recorded`,deps:[],role:`team`,ts:e[16]?.ts,branch:!0,parent_id:t.id,overflow_count:u}),o.push({id:JSON.stringify([`fanout`,t.id,d]),source:t.id,target:d,kind:`fanout`},{id:JSON.stringify([`fanin`,d,t.id]),source:d,target:t.id,kind:`fanin`}))}return a.length?{...e,tasks:[...e.tasks,...a],links:[...e.links,...o]}:e}function sp(e,t,n){let r=e.links.map(e=>{let r=t.find(t=>t.source===e.source&&t.target===e.target);return r&&e.kind===`dependency`?{...e,label:r.label,evidence:`${n?`执行依赖`:`Execution dependency`} · ${r.evidence}`}:e}),i=new Map(e.tasks.map(e=>[e.id,e.id])),a=e=>{let t=i.get(e);return t===e?e:a(t)},o=(e,t)=>{i.set(a(e),a(t))};for(let e of r.filter(e=>e.kind===`dependency`))o(e.source,e.target);for(let n of t)!i.has(n.source)||!i.has(n.target)||e.tasks.findIndex(e=>e.id===n.source)>=e.tasks.findIndex(e=>e.id===n.target)||a(n.source)===a(n.target)||(r.push({...n,kind:`semantic`,id:`semantic:${n.source}:${n.target}`}),o(n.source,n.target));for(let t=1;tcp+Math.min(500,Math.max(0,e-8)*60);function dp(e,t,n,r,i,a,o){let s=new Map(n.map(e=>[e,t[e].y+i[e].height/2]));for(let c=0;c<6;c++)for(let l of c%2?[...e].reverse():e){let e=new Set(l),c=[],u=[],d=0;l.forEach((f,p)=>{let m=s.get(f)*.8,h=.8;for(let o of a[r.get(f)]){let r=n[o.index];e.has(r)||(m+=(t[r].y+i[r].height/2)*o.weight,h+=o.weight)}c.push(d);let g=m/h-i[f].height/2-d;for(u.push({start:p,end:p,sum:g*h,weight:h});u.length>1;){let e=u[u.length-2],t=u[u.length-1];if(e.sum/e.weight<=t.sum/t.weight)break;e.end=t.end,e.sum+=t.sum,e.weight+=t.weight,u.pop()}d+=i[f].height+(p+1[e,t])),a=t.filter(e=>e.kind!==`replacement`&&e.source!==e.target).map(e=>({source:i.get(e.source),target:i.get(e.target),weight:e.kind===`dependency`||e.kind===`continuation`?1:.4})),o=e.map(()=>[]),s=e.map(()=>[]),c=e.map(()=>[]);for(let e of a)o[e.source].push(e.target),s[e.target].push(e.source),c[e.source].push({index:e.target,weight:e.weight}),c[e.target].push({index:e.source,weight:e.weight});let l=e.reduce((e,t)=>e+n[t].width*n[t].height,0),u=Math.sqrt(l/e.length),d=e.reduce((e,t)=>e+n[t].height,0)/e.length,f=Math.ceil(Math.sqrt(e.length)*1.8),p=e.map(()=>[]);for(let e of a)p[Math.max(e.source,e.target)].push(e);let m=e.map((t,n)=>{let r=0;return Array.from({length:Math.min(f,e.length-n)+1},(e,t)=>{if(t)for(let e of p[n+t-1])Math.min(e.source,e.target)1||s[e.target].length>1)&&(r+=e.weight*.9),r+=Math.max(0,Math.abs(e.target-e.source)-1)*e.weight);return r})}),h={},g=1/0,_=new Set;for(let t=1;t<=f;t++){let o=t*d+(t-1)*lp,f=Array(e.length+1).fill(1/0),p=Array(e.length+1).fill(0);f[0]=0;for(let r=1;r<=e.length;r++){let i=0;for(let a=r-1;a>=Math.max(0,r-t);a--){i+=n[e[a]].height+(a===r-1?0:lp);let t=m[a][r-a];a>0&&s[a].some(e=>s[a-1].includes(e))&&(t+=.7);let c=f[a]+.2+(i/o-1)**2+t;c0;t=p[t])v.unshift(e.slice(p[t],t));let y=JSON.stringify(v);if(_.has(y))continue;_.add(y);let b=v.map(e=>Math.max(...e.map(e=>n[e].width))),x=v.map(e=>e.reduce((e,t)=>e+n[t].height,0)+(e.length-1)*lp),S=b.reduce((e,t)=>e+t,0)+(v.length-1)*r,C=Math.max(...x),w={},T=0;v.forEach((e,t)=>{let i=(C-x[t])/2;for(let r of e)w[r]={x:T+(b[t]-n[r].width)/2,y:i},i+=n[r].height+lp;T+=b[t]+r}),dp(v,w,e,i,n,c,()=>lp);let E=Math.min(...e.map(e=>w[e].y));for(let t of e)w[t].y-=E;C=Math.max(...e.map(e=>w[e].y+n[e].height));let D=a.reduce((t,r)=>{let i=w[e[r.source]],a=w[e[r.target]];return t+Math.hypot(a.x+n[e[r.target]].width/2-i.x-n[e[r.source]].width/2,a.y+n[e[r.target]].height/2-i.y-n[e[r.source]].height/2)*r.weight},0)/Math.max(1,a.length)/u,O=2*Math.log(S/C/2.1)**2+.08*S*C/l+.14*D+.08*f[e.length]/v.length;O[e,t])),a=e=>e.source!==e.target&&i.has(e.source)&&i.has(e.target),o=new Set,s=new Map;for(let e of t)!a(e)||e.kind!==`fanout`&&e.kind!==`fanin`||(e.kind===`fanout`?o.add(e.target):o.add(e.source),(s.get(e.source)??s.set(e.source,new Set).get(e.source)).add(e.target),(s.get(e.target)??s.set(e.target,new Set).get(e.target)).add(e.source));let c=e.map(()=>[]),l=t.filter(e=>e.kind!==`replacement`&&a(e)).map(e=>({source:i.get(e.source),target:i.get(e.target),weight:e.kind===`dependency`||e.kind===`continuation`?1:e.kind===`fanout`||e.kind===`fanin`?.8:.4}));for(let e of l)c[e.source].push({index:e.target,weight:e.weight}),c[e.target].push({index:e.source,weight:e.weight});let u=e.map(()=>[]);for(let e of t){if(!pp.has(e.kind)||!a(e))continue;let t=i.get(e.source),n=i.get(e.target);td[e]))+1:f+1;d.push(e),f=Math.max(f,e)}let p=[];e.forEach((e,t)=>{(p[d[t]]??=[]).push(e)});let m=p.filter(e=>e?.length),h=(e,t)=>o.has(e)&&o.has(t)?lp/2:lp,g=e=>e.reduce((t,r,i)=>t+n[r].height+(i?h(e[i-1],r):0),0),_=e.reduce((e,t)=>e+n[t].width*n[t].height,0),v=Math.sqrt(_/e.length),y=e.filter(e=>!o.has(e)),b=(y.length?y:e).reduce((e,t)=>e+n[t].height,0)/Math.max(1,y.length||e.length),x=Math.ceil(Math.sqrt(e.length)*1.8),S={},C=1/0,w=new Set;for(let t=1;t<=x;t++){let a=t*b+(t-1)*lp,u=[];for(let e of m){let t=[],n=()=>{if(!t.length)return;let e=o.has(t[0]);if(e)u.push({nodes:t,isBranch:e});else{let n=[];for(let r of t)n.length&&g([...n,r])>a&&(u.push({nodes:n,isBranch:e}),n=[]),n.push(r);n.length&&u.push({nodes:n,isBranch:e})}t=[]};for(let r of e)t.length&&o.has(t[0])!==o.has(r)&&n(),t.push(r);n()}let d=[],f=[];for(let e of u){let t=d.at(-1),n=t&&e.nodes.some(e=>t.some(t=>s.get(e)?.has(t)));!t||n||f.at(-1)!==e.isBranch||g([...t,...e.nodes])>a?(d.push([...e.nodes]),f.push(e.isBranch)):t.push(...e.nodes)}let p=JSON.stringify(d);if(w.has(p))continue;w.add(p);let y=d.map(e=>Math.max(...e.map(e=>n[e].width))),x=d.map(g),T=y.reduce((e,t)=>e+t,0)+(d.length-1)*r,E=Math.max(...x),D={},O=0;d.forEach((e,t)=>{let i=(E-x[t])/2;e.forEach((r,a)=>{D[r]={x:O+(y[t]-n[r].width)/2,y:i},i+=n[r].height+(a+1D[e].y));for(let t of e)D[t].y-=k;E=Math.max(...e.map(e=>D[e].y+n[e].height));let A=l.reduce((t,r)=>{let i=D[e[r.source]],a=D[e[r.target]];return t+Math.hypot(a.x+n[e[r.target]].width/2-i.x-n[e[r.source]].width/2,a.y+n[e[r.target]].height/2-i.y-n[e[r.source]].height/2)*r.weight},0)/Math.max(1,l.length)/v,j=2*Math.log(T/E/2.1)**2+.08*T*E/_+.14*A;j=e.length*.3?mp(e,t,n):fp(e,t,n)}function gp(e){let t=new Map,n=new Map,r=new Map;return e.map(e=>{let i=`${e.source}\u0000${e.target}`,a=(t.get(e.source)??0)+(n.get(e.target)??0)-(r.get(i)??0);return t.set(e.source,(t.get(e.source)??0)+1),n.set(e.target,(n.get(e.target)??0)+1),r.set(i,(r.get(i)??0)+1),a})}function _p(e,t){if(e.x===t.x&&e.y===t.y)return{sourceHandle:`right`,targetHandle:`bottom`};let n=t.x+t.width/2-e.x-e.width/2,r=t.y+t.height/2-e.y-e.height/2,i=r>0?t.y-e.y-e.height:e.y-t.y-t.height,a=n>0?t.x-e.x-e.width:e.x-t.x-t.width;return i>=0&&a<0?r>=0?{sourceHandle:`bottom`,targetHandle:`top`}:{sourceHandle:`top`,targetHandle:`bottom`}:n>=0?{sourceHandle:`right`,targetHandle:`left`}:{sourceHandle:`left`,targetHandle:`right`}}var vp={width:1440,height:1080},yp=[`plan`,`execution`,`review`,`revision`,`result`];function bp(e,t){let n=e.team_task_id?.match(/route-(\d+)/)?.[1],r=e.team_role===`idea-route`?t?`研究路线`:`Research route`:e.team_role===`idea-review`?t?`独立复核`:`Independent review`:e.team_role===`idea-selector`?t?`方案选择`:`Idea selection`:``;return r?`${r}${n?` ${n}`:``}`:e.title||(t?`并行子任务`:`Parallel task`)}function xp(e,t,n){return e.pending_question?t?`需要答复,展开查看具体问题`:`Needs your input; open to read the question`:e.status===`failed`?t?`本次执行失败,展开查看原因`:`This attempt failed; open to read the reason`:e.status===`blocked`?t?`执行受阻,展开查看原因`:`Work is blocked; open to read the reason`:e.status===`done`?e.team_role===`idea-review`?t?`独立复核已完成,展开查看记录`:`Independent review completed; open to read the record`:t?`子任务执行已完成,展开查看记录`:`Subtask execution completed; open to read the record`:e.status===`pending`?n?t?`等待前置子任务完成后开始`:`Waiting for prerequisite subtasks to finish`:t?`等待分配 Agent 执行`:`Waiting for an agent to start`:$f.has(e.status||``)?e.team_role===`idea-route`?t?`正在开展来源研究,整理候选方案`:`Researching sources and developing a candidate idea`:e.team_role===`idea-review`?t?`正在独立核对依据、创新性和风险`:`Independently checking evidence, novelty and risks`:e.team_role===`idea-selector`?t?`正在对比研究路线及复核意见`:`Comparing research routes and independent reviews`:t?`Agent 正在执行此子任务`:`An agent is working on this subtask`:t?`展开查看子任务执行记录`:`Open to read the subtask record`}var Sp=e=>e?`暂无详细记录`:`No details available yet.`,Cp=[{match:/provider[\s-]?turn/i,bare:/^One Engineer call used its whole per-call provider-turn allowance/,zh:`继续换了个新会话接着做,之前的进展都在`,en:`Continued in a fresh session; earlier progress is kept`},{match:/budget (limit|cap|exhausted)|blocking budget|预算上限/i,bare:/^Paused because this project reached its budget limit/,zh:`花费到了预算上限,先暂停;提高预算后可以继续`,en:`Paused at the budget limit; work resumes once the budget is raised`},{match:/quarantin/i,bare:/^The task signature is quarantined out of planner rotation/,zh:`这个方向连续失败,先搁置,不再自动重试`,en:`This direction kept failing and is set aside; it will not retry on its own`},{match:/backend[\s\S]{0,24}?(fail|unavailable|paused)|backend_failure|provider cooldown|configured model is unavailable/i,bare:/^(?:backend failure; retrying in a fresh|The backend has failed the same way \d+ times in a row)/,zh:`模型服务暂时不稳定,稍后会自动重试`,en:`The model service was briefly unavailable; it retries after a short wait`}];function wp(e,t){let n=String(e||``).trim(),r=n.search(/Runner receipt:/i),i=r>=0?n.slice(r).trim():``,a=i?Cp.find(e=>e.match.test(n)):Cp.find(e=>e.bare?.test(n));return a?{summary:t?a.zh:a.en,receipt:i||n}:{summary:``,receipt:i}}function Tp(e,t=140){let n=e.replace(/\s+/g,` `).trim();if(!n)return``;let r=n.match(/^.*?[。!?!?.](?=\s|$)/),i=(r?r[0]:n).trim();return i.length>t?`${i.slice(0,t-1).trimEnd()}…`:i}function Ep(e){let t=e.replace(/\s+/g,` `).trim().split(/[。!?;;::,,\n]|\.(?=\s|$)|[!?](?=\s|$)/)[0]?.trim();return t&&t.length>=6&&t.length<=40?t:``}function Dp(e){return String(e||``).split(/\r?\n/).filter(e=>!/^(?:Decision\s*:|(?:MILESTONE_STATUS|NEXT_OWNER|OPERATOR_QUESTION|OPERATOR_OPTIONS)\s*=)/i.test(e.trim())).map(e=>e.replace(/^\s*(?:RESULT|SUMMARY)\s*=\s*/i,``).replace(/^\s*NEXT_ACTION\s*=\s*/i,``)).join(` +`).trim()}function Op(e,t,n){let r=[{id:`${e.id}:brief`,kind:`plan`,title:n?`任务目标`:`Task brief`,detail:e.objective||e.title,status:`recorded`,source:`task`,eventIds:[]}],i=new Set,a=0,o=t.filter(t=>t.item_id===e.id).sort((e,t)=>e.ts-t.ts||(e.type===`team.task`&&t.type===`team.task`?(e.team_task_id||e.id).localeCompare(t.team_task_id||t.id):0)),s=new Map(o.filter(e=>e.type===`team.task`).map(e=>[e.id,e]));for(let e of o){if(i.has(e.id))continue;if(i.add(e.id),e.type===`team.task`){let t=[...new Set(e.deps||[])],i=t.map(e=>s.has(e)?bp(s.get(e),n):n?`其他记录中的子任务`:`Task outside this view`),a=Dp(e.text);r.push({id:e.id,kind:e.team_role===`idea-review`||e.role===`reviewer`?`review`:e.team_role===`idea-selector`?`plan`:`execution`,title:bp(e,n),summary:xp(e,n,t.some(e=>s.has(e)&&s.get(e).status!==`done`)),detail:[a,e.reason&&!a.includes(e.reason)?e.reason:``,e.pending_question?`${n?`需要答复`:`Needs input`}: ${e.pending_question}`:``,i.length?`${n?`依赖`:`Depends on`}: ${i.join(` · `)}`:``].filter(Boolean).join(` + +`),status:e.pending_question?`question`:e.status||`unknown`,ts:e.ts,source:`team`,eventIds:[e.id],teamId:e.team_id,teamTaskId:e.team_task_id,teamRole:e.team_role,deps:t,updatedAt:e.updated_ts,revision:e.revision});continue}e.type===`life.mission.started`&&a++;let t=e.type.includes(`review`)||e.type===`life.phase.started`&&e.role===`reviewer`?`review`:e.type===`life.planner.task_added`?`plan`:e.type===`life.mission.completed`||e.type===`life.mission.failed`?`result`:e.type===`round.start`||e.type===`round.main.completed`||e.type===`life.mission.started`||e.type===`life.phase.started`?`execution`:null;if(!t)continue;let o=e.round_index,c=e.type.endsWith(`.completed`)||e.type.endsWith(`.failed`),l=t===`review`&&e.review_skipped===!0,u=(l?`skipped`:e.status)||(e.success===!1||e.type.endsWith(`.failed`)?`failed`:e.success===!0?`done`:c?`recorded`:`started`),d=wp(e.text||``,n),f=String(e.text||``),p=d.receipt?f.lastIndexOf(d.receipt):-1,m=Dp(p>=0?f.slice(0,p):f),h=u===`done`?n?`审查通过`:`Review passed`:u===`continue`?n?`审查:继续推进`:`Review: keep going`:[`blocked`,`replan`,`replan_requested`].includes(u)?n?`审查:需要调整`:`Review: needs a change`:u===`failed`?n?`审查未通过`:`Review failed`:``,g=t===`execution`?Ep(m):``,_=l?n?`审查未执行`:`Review not performed`:t===`review`?c?h||(n?`审查意见`:`Review outcome`):n?`开始审查`:`Review started`:t===`result`?n?`执行结果`:`Execution result`:t===`plan`?n?`任务进入计划`:`Added to plan`:g||(e.type===`life.mission.started`?n?`开始执行`:`Execution started`:e.type===`round.main.completed`?n?`本轮执行记录`:`Round execution`:n?`执行尝试`:`Execution attempt`);r.push({id:e.id,kind:t,title:_,summary:d.summary||Tp(m)||void 0,detail:[m||d.summary||Sp(n),l&&e.next_action?`${n?`下一步`:`Next action`}: ${e.next_action}`:``,d.receipt?`${n?`——运行记录:`:`— runner receipt: `}${d.receipt.replace(/^Runner receipt:\s*/i,``)}`:``].filter(Boolean).join(` + +`),status:u,ts:e.ts,round:o,episode:a,source:e.association===`single_active_window`?`interval`:`event`,eventIds:[e.id]}),!l&&e.next_action&&[`continue`,`blocked`,`replan`,`replan_requested`].includes(e.status||``)&&r.push({id:`${e.id}:next`,kind:`revision`,title:n?`建议的修订`:`Requested revision`,detail:e.next_action,status:`requested`,ts:e.ts,round:o,episode:a,source:e.association===`single_active_window`?`interval`:`event`,eventIds:[e.id]})}!r.some(e=>e.kind===`execution`)&&$f.has(e.status)&&r.push({id:`${e.id}:active`,kind:`execution`,title:n?`执行进展`:`Execution progress`,detail:e.summary||``,status:e.status,source:`task`,eventIds:[]}),!r.some(e=>e.kind===`result`)&&[`done`,`failed`,`aborted`,`skipped`,`superseded`].includes(e.status)&&r.push({id:`${e.id}:outcome`,kind:`result`,title:n?`任务状态记录`:`Recorded task outcome`,detail:e.summary||``,status:e.status,source:`task`,eventIds:[]});let c=[],l=new Map;for(let e of r){let t=e.round!=null&&[`execution`,`review`].includes(e.kind),n=`${e.episode}:${e.round}:${e.kind}`,r=t?l.get(n):void 0;if(r)r.title=e.title,r.summary=e.summary??r.summary,r.detail=e.detail,r.status=e.status,r.eventIds.push(...e.eventIds),e.source===`interval`&&(r.source=`interval`);else{let r={...e,eventIds:[...e.eventIds]};c.push(r),t&&l.set(n,r)}}return c}function kp(e,t,n,r=Op(e,t,n),i=0){let a=1,o=1/0;for(let e=1;e<=Math.min(3,r.length);e++){let t=Math.ceil(r.length/e),n=Math.max(640,t*232+(t-1)*108+96),i=408+(e-1)*236,s=Math.abs(Math.log(n/i/1.6))+.6*(t*e-r.length)/(t*e);s{let o=t*a,s=Math.min(o+a,r.length),c=u+t*340;return r.slice(o,s).forEach((e,t)=>{d[e.id]={x:c,y:180+t*236}}),{id:`steps:${i+o}`,title:n?`环节 ${i+o+1}–${i+s}`:`Steps ${i+o+1}–${i+s}`,x:c,y:142}});return{steps:r,links:jp(r,n),columns:f,positions:d,width:c,height:l}}function Ap(e){let t=Math.max(600/e.height,Math.min(1e3/e.height,vp.width/e.width));return{width:e.width*t,height:e.height*t,scale:t}}function jp(e,t){let n=e.filter(e=>e.source===`team`);if(n.length){let r=e.filter(e=>e.source!==`team`),i=new Map(n.map(e=>[e.id,e])),a=r.find(e=>e.source===`task`&&e.kind===`plan`),o=[];for(let e of n){for(let n of e.deps||[]){let r=i.get(n);!r||r.id===e.id||r.teamId!==e.teamId||o.push({id:`link:${r.id}:${e.id}`,source:r.id,target:e.id,relation:`dependency`,label:t?`前置任务`:`Depends on`,explanation:t?`${e.title} 的任务记录明确依赖 ${r.title}。`:`${e.title} explicitly depends on ${r.title} in its taskboard.`,contextual:!1})}a&&!e.deps?.length&&o.push({id:`link:${a.id}:${e.id}`,source:a.id,target:e.id,relation:`assignment`,label:t?`任务分支`:`Branch`,explanation:t?`该子任务属于当前主任务;此线不表示等待主任务完成。`:`This worker belongs to the current mission; the link does not require the parent to finish first.`,contextual:!0})}return[...jp(r,t),...o]}return e.slice(1).map((n,r)=>{let i=e[r],a=i.episode===n.episode,o=a&&i.round!=null&&i.round===n.round,s=`record_order`,c=t?`后续记录`:`Later record`,l=t?`同一任务的相邻观察,未确认直接因果或执行依赖。`:`Adjacent observations of the same task; no causal dependency is asserted.`;i.kind===`plan`&&[`plan`,`execution`].includes(n.kind)?(s=`assignment`,c=t?n.kind===`plan`?`纳入计划`:`执行此任务`:`Execute`,l=t?`同一任务的目标/计划与其执行记录关联。`:`The task brief or plan is linked to execution of that same task.`):i.kind===`execution`&&n.kind===`review`&&o?(s=`review`,c=t?`提交审查`:`Review`,l=t?`同一个任务、同一执行段、同一轮次的执行与审查记录。`:`Execution and review belong to the same task, episode and numbered round.`):i.kind===`review`&&n.kind===`revision`&&n.eventIds.some(e=>i.eventIds.includes(e))?(s=`revision`,c=t?`提出修订`:`Revise`,l=t?`这条修订建议来自对应的审查记录。`:`This revision was requested in the corresponding review.`):i.kind===`revision`&&n.kind===`execution`&&a&&i.round!=null&&n.round!=null&&n.round>i.round?(s=`next_attempt`,c=t?`进入下轮`:`Next round`,l=t?`修订建议之后出现了同一任务的下一轮执行;不表示建议的全部内容已被采纳。`:`A later round follows the revision request; this does not certify every requested change was applied.`):n.kind===`result`&&n.source===`task`?(s=`snapshot`,c=t?`状态记录`:`Recorded status`,l=t?`任务状态记录;部分执行过程可能缺失。`:`Links to the captured state of this task; intermediate records may be missing.`):n.kind===`result`&&[`review`,`execution`,`revision`].includes(i.kind)&&(s=`outcome`,c=t?`形成结果`:`Outcome`,l=t?`同一任务的后续完成/失败事件,不等同于成功认证。`:`A completion or failure event of this task, not a certification of success.`);let u=[`record_order`,`snapshot`].includes(s)||i.source===`interval`||n.source===`interval`;return(i.source===`interval`||n.source===`interval`)&&(l+=t?` 部分旧记录按唯一活动任务区间归属,因此使用虚线。`:` Some legacy observations are associated by the sole active mission window, so this link is dashed.`),{id:`link:${i.id}:${n.id}`,source:i.id,target:n.id,relation:s,label:c,explanation:l,contextual:u}})}function Mp(e){let t=[],n=[];for(let r=0;r12&&(t.push(n),n=[]),n.push(...i)}return n.length&&t.push(n),t}function Np(e,t,n,r){for(let i of[n,r]){let n={x:(i.x-t.x)/t.zoom,y:(i.y-t.y)/t.zoom},r=e.find(e=>!e.hidden&&n.x>=e.position.x&&n.x<=e.position.x+(e.width??1152)&&n.y>=e.position.y&&n.y<=e.position.y+(e.height??824));if(r)return r.id}return null}function Pp(e,t,n,r,i=sp(e,[],n)){let a=[],o={},s=[],c=new Map;for(let[r,i]of e.tasks.entries()){let e=Op(i,t,n),l=Mp(e),u=l.length,d=e=>e===1?i.id:JSON.stringify([`part`,i.id,e]),f=0;for(let c=1;c<=u;c++){let p=l[c-1],m=d(c);if(a.push({id:m,task:i,ordinal:r+1,part:c,partCount:u,start:f+1,end:f+p.length,totalSteps:e.length,previousId:c>1?d(c-1):void 0,nextId:c1){let t=jp([e[f-1],p[0]],n)[0];s.push({id:JSON.stringify([`continuation`,i.id,c]),source:d(c-1),target:m,kind:`continuation`,label:t?n?`继续`:`Continued`:n?`更多分支`:`More branches`,evidence:t?`${i.title} · ${t.label} · ${e[f-1].title} → ${p[0].title}`:`${i.title} · ${n?`同一任务的其他分支,不表示串行依赖。`:`Other branches of the same mission, without a serial dependency.`}`})}f+=p.length}c.set(i.id,d(u))}let l=Object.fromEntries(Object.entries(o).map(([e,t])=>[e,Ap(t)])),u=[...i.map(e=>({...e,source:c.get(e.source),target:e.target})),...s],d=a.map(e=>e.id),f=JSON.stringify([d.map(e=>[e,l[e].width,l[e].height]),u.map(e=>[e.source,e.target,e.kind])]);return{cards:a,links:u,layouts:o,positions:r?.structure===f?r.positions:hp(d,u,l),frames:l,structure:f}}var Fp=({children:e})=>(0,J.jsxs)(`span`,{children:[e,` `]}),Ip=(0,Y.memo)(function({children:e}){return(0,J.jsx)(s,{remarkPlugins:[c],components:{p:Fp,h1:Fp,h2:Fp,h3:Fp,h4:Fp,h5:Fp,h6:Fp,ul:Fp,ol:Fp,blockquote:Fp,pre:Fp,li:({children:e})=>(0,J.jsxs)(`span`,{className:`markdown-excerpt-item`,children:[e,` `]}),table:Fp,thead:Fp,tbody:Fp,tr:Fp,th:({children:e})=>(0,J.jsxs)(`strong`,{children:[e,` · `]}),td:Fp,a:({children:e})=>(0,J.jsx)(`span`,{className:`markdown-excerpt-link`,children:e}),img:({alt:e})=>(0,J.jsx)(`span`,{children:e}),input:({checked:e})=>(0,J.jsx)(`span`,{children:e?`✓ `:`○ `}),hr:()=>(0,J.jsx)(`span`,{children:` · `}),code:({children:e})=>(0,J.jsx)(`code`,{children:e})},children:C(e)})});function Lp({path:e,delay:t,padding:n=24,children:r}){let i=`map-growth-${(0,Y.useId)().replace(/:/g,``)}`;if(t==null)return(0,J.jsx)(J.Fragment,{children:r});let a=(e.match(/-?\d+(?:\.\d+)?(?:e[+-]?\d+)?/gi)??[]).map(Number),o=a.filter((e,t)=>t%2==0),s=a.filter((e,t)=>t%2==1);if(!o.length||!s.length)return(0,J.jsx)(J.Fragment,{children:r});let c=Math.min(...o)-n,l=Math.min(...s)-n;return(0,J.jsxs)(`g`,{"data-map-growing-edge":`true`,children:[(0,J.jsx)(`defs`,{children:(0,J.jsx)(`mask`,{id:i,maskUnits:`userSpaceOnUse`,x:c,y:l,width:Math.max(...o)-c+n,height:Math.max(...s)-l+n,children:(0,J.jsx)(`path`,{className:`map-growth-mask`,d:e,pathLength:1,fill:`none`,stroke:`white`,strokeWidth:n*2,strokeLinecap:`round`,style:{animationDelay:`${t}ms`}})})}),(0,J.jsx)(`g`,{mask:`url(#${i})`,children:r})]})}function Rp({layout:e,growing:t={},activeStep:n,activeTeamSteps:r=[]}){let i=`submap-arrow-${(0,Y.useId)().replace(/:/g,``)}`;return(0,J.jsxs)(`svg`,{className:`submap-relations`,width:e.width,height:e.height,"aria-label":`Task process relationships`,children:[(0,J.jsx)(`defs`,{children:(0,J.jsx)(`marker`,{id:i,viewBox:`0 0 10 10`,refX:`9`,refY:`5`,markerWidth:`8`,markerHeight:`8`,orient:`auto`,children:(0,J.jsx)(`path`,{d:`M 0 0 L 10 5 L 0 10 z`,fill:`#91a8bc`})})}),e.links.map(a=>{let o=e.positions[a.source],s=e.positions[a.target],c=o.x===s.x&&s.y>o.y,l=o.x+(c?116:232),u=o.y+(c?180:90),d=s.x+(c?116:0),f=s.y+(c?0:90),p=(l+d)/2,m=(u+f)/2,h=c?`M ${l} ${u} L ${d} ${f}`:`M ${l} ${u} C ${p} ${u}, ${p} ${f}, ${d} ${f}`;return(0,J.jsxs)(`g`,{"data-testid":`submap-relation`,"data-relation":a.relation,"data-source":a.source,"data-target":a.target,"aria-label":`${a.label}: ${a.explanation}`,children:[(0,J.jsx)(`title`,{children:a.explanation}),(0,J.jsx)(Lp,{path:h,delay:t[a.id],children:(0,J.jsx)(`path`,{className:`submap-relation-path`,d:h,fill:`none`,stroke:`#91a8bc`,strokeWidth:`2`,strokeDasharray:a.contextual?`5 6`:void 0,markerEnd:`url(#${i})`})}),(n===a.target||r.includes(a.target))&&(0,J.jsx)(`path`,{className:`submap-flow`,d:h,pathLength:1,fill:`none`,stroke:`#4b9cae`,strokeWidth:`3`,strokeDasharray:`.09 .91`,strokeLinecap:`round`,"aria-hidden":`true`}),(0,J.jsxs)(`g`,{className:`submap-relation-label`,transform:`translate(${p}, ${m})`,children:[(0,J.jsx)(`rect`,{x:`-38`,y:`-11`,width:`76`,height:`22`,rx:`6`}),(0,J.jsx)(`text`,{textAnchor:`middle`,dominantBaseline:`central`,children:a.label})]})]},a.id)})]})}var zp=(0,Y.createContext)({notes:{}}),Bp=(0,Y.createContext)({}),Vp={plan:[`Planner`,`Planner`],execution:[`Engineer`,`Engineer`],review:[`Reviewer`,`Reviewer`],revision:[`修订`,`Revise`],result:[`结果`,`Result`]},Hp={plan:l,execution:d,review:I,revision:le,result:O},Up={done:[`已完成`,`Completed`],running:[`进行中`,`In progress`],pending:[`待开始`,`Planned`],failed:[`未通过`,`Failed`],aborted:[`已取消`,`Cancelled`],skipped:[`已跳过`,`Skipped`],superseded:[`已替代`,`Superseded`],question:[`待答复`,`Needs input`],paused:[`已暂停`,`Paused`],paused_external_work:[`等待后台任务`,`Waiting on background work`],missing:[`引用缺失`,`Missing`],unknown:[`状态未知`,`Unknown`],continue:[`需修订`,`Revise`],blocked:[`受阻`,`Blocked`],started:[`开始记录`,`Started`],recorded:[`已记录`,`Recorded`],requested:[`修订建议`,`Suggested`],replan:[`调整计划`,`Revise plan`],replan_requested:[`调整计划`,`Revise plan`]},Wp=(e,t)=>e.source===`team`?t?`子任务工作记录`:`Subtask work record`:e.source===`task`?t?`任务记录`:`Task record`:e.source===`interval`?t?`根据同期记录关联`:`By execution window`:t?`来自任务记录`:`Linked event`,Gp=(0,Y.memo)(function({id:e,data:t}){let{task:n,ordinal:r,zh:i,layout:a,focused:o,detailed:s}=t,{artifacts:c,onOpenArtifact:l}=(0,Y.useContext)(Bp),d=(0,Y.useContext)(zp).notes[n.id]??[],f=Q(e=>{let n=e.transform[2]*t.frame.width;return n<140?`micro`:n<230?`compact`:`full`}),[p]=(0,Y.useState)(()=>!t.restoring&&!t.seenCards?.has(e));(0,Y.useEffect)(()=>{t.seenCards?.add(e)},[t.seenCards,e]);let[m,h]=(0,Y.useState)(null),g=m||a,v=e=>e.source===`team`&&a.steps.find(t=>t.id===e.id)||e,y=t.canvasSize?.width||window.innerWidth,b=t.canvasSize?.height||window.innerHeight;(0,Y.useEffect)(()=>{s||(S(null),h(null))},[s]);let[x,S]=(0,Y.useState)(null),E=(0,Y.useRef)(n.status),[D,O]=(0,Y.useState)(!1);(0,Y.useEffect)(()=>{let e=E.current!==n.status;if(E.current=n.status,!e||n.status!==`done`)return;O(!0);let t=setTimeout(()=>O(!1),1500);return()=>clearTimeout(t)},[n.status]);let k=g.steps.find(e=>e.id===x),A=k?v(k):void 0,N=A?.updatedAt??A?.ts,P=t.part===t.partCount,F=P?n.status===`missing`?`missing`:t.paused&&$f.has(n.status)?`paused`:ep(n):`recorded`,I=F===`paused`&&n.status===`paused_external_work`?n.status:F,L=Math.min(t.frame.width/288,t.frame.height/218),R=t.copy?.cards||{},z=!!R[n.id]?.summary&&R[n.id]?.task_status!==n.status&&($f.has(n.status)||n.status===`pending`),B=e=>{let t=R[e.id];if(e.source!==`team`)return t;let n=t?.event_ids?.indexOf(e.id)??-1;return v(e).revision&&n>=0&&t?.event_revisions?.[n]===v(e).revision?t:void 0},V=(R[n.id]?.title||n.title)+(t.part>1?i?` · 续篇 ${t.part-1}`:` · Continued ${t.part-1}`:``),ee=i?`环节 ${t.start}–${t.end} / ${t.totalSteps}`:`Steps ${t.start}–${t.end} / ${t.totalSteps}`,te=t.partCount>1?g.steps.map(e=>B(e)?.summary||v(e).summary||v(e).detail).filter(e=>e&&![Sp(!0),Sp(!1)].includes(e)).at(-1):void 0,H=Math.min(t.frame.width/g.width,t.frame.height/g.height),U=P&&t.live&&$f.has(n.status)?[...g.steps].reverse().find(e=>e.source!==`team`&&![`plan`,`result`].includes(e.kind))?.id:null,W=t.paused?null:U,G=a.steps.filter(e=>e.source===`team`),K=t.live?G.filter(e=>$f.has(e.status)).map(e=>e.id):[],re=G.filter(e=>e.status===`done`).length,ie=G.filter(e=>$f.has(e.status)).length,ae=e=>e.source===`team`?K.includes(e.id):W===e.id,oe=e=>e.source===`team`?v(e).status:U===e.id?t.paused?`paused`:`running`:e.status,se=e=>({source:t.source,task_id:n.id,task_title:V,lang:i?`zh`:`en`,part:t.partCount>1?t.part:void 0,step_id:e?.id,step_title:e?.title,team_id:e?.teamId,team_task_id:e?.teamTaskId,event_ids:e?e.eventIds:t.partCount>1?[...new Set(g.steps.flatMap(e=>e.eventIds))]:R[n.id]?.event_ids||[]}),ce=Math.min(640,g.width-48,Math.max(260,(y-50)/1.05)),le=Math.min(600,g.height-48,Math.max(300,(b-(y<640?180:160))/1.05)),q=e=>({x:Math.max(24,Math.min(g.positions[e.id].x-16,g.width-ce-24)),y:Math.max(24,Math.min(g.positions[e.id].y-16,g.height-le-24)),width:ce,height:le,scale:H}),ue=A?q(A):null,de=n=>{h(g),S(n.id),t.readStep(e,q(n))};(0,Y.useEffect)(()=>{A&&t.readStep(e,q(A))},[y,b]);let fe=e=>(Up[e===`paused_external_work`?e:e.startsWith(`paused_`)?`paused`:$f.has(e)?`running`:e]??Up.unknown)[+!i];return(0,J.jsxs)(`article`,{className:`map-macro map-state-${F}`,"data-testid":`map-macro`,"data-task-id":n.id,"data-card-id":e,"data-part":t.part,"data-arrive":p,"data-growing":t.growthDelay!=null,"data-dispatch":t.dispatchState,style:{animationDelay:`${t.growthDelay??0}ms`},"data-focused":o,"data-detailed":s,"aria-label":V,"data-overview-density":f,"data-completed-now":D,"data-active":K.length>0||P&&t.live&&!t.paused&&$f.has(n.status),onContextMenu:e=>{e.preventDefault(),e.stopPropagation(),t.menu(se(),{x:e.clientX,y:e.clientY})},children:[[`source`,`target`].flatMap(e=>[Z.Left,Z.Right,Z.Top,Z.Bottom].map(t=>(0,J.jsx)(Nu,{id:t,type:e,position:t,isConnectable:!1},`${e}-${t}`))),(0,J.jsx)(`div`,{className:`macro-summary`,"aria-hidden":s,style:{"--summary-scale":L,"--summary-height":`${t.frame.height/L-20}px`,width:t.frame.width/L-20,transform:`translate(-50%, -50%) scale(${L})`},children:(0,J.jsxs)(`button`,{className:`map-card map-state-${F} nodrag nopan`,"data-testid":`map-card`,"data-task-id":n.id,"data-card-id":e,"data-part":t.part,tabIndex:s?-1:0,onClick:()=>t.open(e),"aria-label":`${V} · ${i?`放大任务`:`Explore task`}`,children:[(0,J.jsxs)(`div`,{className:`map-card-top`,children:[(0,J.jsxs)(`span`,{className:`map-card-number`,children:[String(r).padStart(2,`0`),t.partCount>1&&` · ${t.part}/${t.partCount}`]}),(0,J.jsxs)(`span`,{className:`map-status`,children:[F===`done`?(0,J.jsx)(T,{size:11}):F===`failed`?(0,J.jsx)(j,{size:11}):F===`question`?(0,J.jsx)(w,{size:11}):F===`paused`?(0,J.jsx)(M,{size:11}):(0,J.jsx)(`span`,{className:`map-state-dot`}),fe(I)]})]}),(0,J.jsxs)(`h3`,{children:[(0,J.jsx)(Ip,{children:V}),d.length>0&&(0,J.jsx)(`span`,{className:`macro-note-badge`,title:i?`操作员批注`:`Operator notes`,children:d.length})]}),(0,J.jsx)(`div`,{className:`map-card-copy`,children:(0,J.jsx)(Ip,{children:te||R[n.id]?.summary||n.pending_question||n.summary||n.objective||(i?`放大查看任务内部`:`Zoom to explore`)})}),(0,J.jsx)(`div`,{className:`map-card-stages`,"aria-label":i?`任务阶段`:`Task stages`,children:[`plan`,`execution`,`review`,`result`].map(e=>{let t=Hp[e],n=g.steps.some(t=>t.kind===e),r=g.steps.some(t=>t.kind===e&&ae(t));return(0,J.jsxs)(`span`,{className:`submap-kind-${e}`,"data-present":n,"data-active":r,title:Vp[e][+!i],children:[(0,J.jsx)(t,{size:12}),(0,J.jsx)(`span`,{children:i?{plan:`规划`,execution:`执行`,review:`审查`,result:`交付`}[e]:Vp[e][1]})]},e)})}),G.length>0&&(0,J.jsx)(`span`,{className:`map-card-teambar`,"aria-hidden":!0,children:(0,J.jsx)(`i`,{style:{width:`${Math.round(re/G.length*100)}%`}})}),(0,J.jsxs)(`div`,{className:`map-card-bottom`,children:[(0,J.jsx)(`span`,{className:G.length?`map-card-team-summary`:void 0,title:ee,children:G.length?(i?`子任务 ${re}/${G.length} 完成 · ${ie} 进行中`:`Subtasks ${re}/${G.length} done · ${ie} running`)+((t.plannedWidth??0)>G.length?i?` · 计划并行 ×${t.plannedWidth}`:` · planned ×${t.plannedWidth}`:``):t.plannedWidth&&$f.has(n.status)?i?`并行编队 ×${t.plannedWidth} 展开中`:`Fanning out ×${t.plannedWidth}`:t.partCount>1?ee:`${g.steps.length} ${i?`个环节`:`steps`}`}),(0,J.jsxs)(`span`,{className:`map-card-submap-hint`,children:[z?i?`描述更新中`:`Summary updating`:i?`查看进展`:`View progress`,(0,J.jsx)(u,{size:12})]})]})]})}),(0,J.jsxs)(`div`,{className:`macro-detail ${A?`is-reading`:``}`,"aria-hidden":!s,style:{width:g.width,height:g.height,transform:`scale(${H})`,transformOrigin:`top left`},children:[(0,J.jsxs)(`header`,{className:`macro-heading`,children:[(0,J.jsx)(`span`,{className:`macro-index`,children:String(r).padStart(2,`0`)}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`small`,{children:t.partCount>1?i?`第 ${t.part} / ${t.partCount} 部分`:`Part ${t.part} / ${t.partCount}`:i?`任务内部`:`INSIDE THIS TASK`}),(0,J.jsx)(`h2`,{children:(0,J.jsx)(Ip,{children:V})})]}),(0,J.jsx)(`span`,{className:`macro-state`,children:fe(I)})]}),(0,J.jsx)(`div`,{className:`macro-stage-key`,children:yp.map(e=>(0,J.jsx)(`span`,{className:`submap-kind-${e} ${g.steps.some(t=>t.kind===e)?``:`is-unrecorded`}`,children:Vp[e][+!i]},e))}),d.length>0&&(0,J.jsxs)(`aside`,{className:`macro-notes`,"aria-label":i?`操作员批注`:`Operator notes`,children:[(0,J.jsx)(`small`,{children:i?`批注`:`Notes`}),d.map(e=>(0,J.jsx)(`p`,{children:e.text},e.id))]}),(0,J.jsx)(Rp,{layout:g,growing:t.growingLinks,activeStep:W,activeTeamSteps:K}),g.columns.map(e=>(0,J.jsx)(`div`,{className:`macro-column-label`,style:{left:e.x,top:e.y},children:e.title},e.id)),g.steps.map(e=>{let n=v(e),r=Hp[n.kind];return(0,J.jsxs)(`button`,{className:`submap-step submap-kind-${n.kind} nodrag nopan ${x===n.id?`is-selected`:``}`,"data-testid":`submap-step`,"data-step-id":n.id,"data-source":n.source,"data-team-id":n.teamId,"data-team-task-id":n.teamTaskId,"data-status":oe(n),"data-active":ae(n),"data-growing":t.growingSteps?.[n.id]!=null,onContextMenu:e=>{e.preventDefault(),e.stopPropagation(),t.menu(se(n),{x:e.clientX,y:e.clientY})},style:{animationDelay:`${t.growingSteps?.[n.id]??0}ms`,left:g.positions[n.id].x,top:g.positions[n.id].y},tabIndex:s?0:-1,onClick:()=>de(n),"aria-expanded":x===n.id,children:[(0,J.jsxs)(`div`,{className:`submap-step-meta`,children:[(0,J.jsxs)(`span`,{children:[(0,J.jsx)(r,{size:16}),n.source===`team`?i?`子任务 · `:`Subtask · `:``,Vp[n.kind][+!i],n.round!=null&&(0,J.jsx)(`em`,{className:`submap-round`,children:i?`第 ${n.round} 轮`:`R${n.round}`})]}),(0,J.jsx)(`small`,{children:n.source===`team`&&oe(n)===`failed`?i?`失败`:`Failed`:fe(oe(n))})]}),(0,J.jsx)(`h4`,{children:(0,J.jsx)(Ip,{children:n.title})}),(0,J.jsx)(`div`,{className:`submap-step-copy`,children:(0,J.jsx)(Ip,{children:B(n)?.summary||v(n).summary||n.detail||Sp(i)})}),(0,J.jsxs)(`div`,{className:`submap-step-foot`,children:[(0,J.jsx)(`span`,{title:Wp(n,i),children:i?`查看详情`:`Read more`}),(0,J.jsx)(u,{size:14})]})]},n.id)}),t.partCount>1&&!A&&(0,J.jsxs)(`nav`,{className:`macro-part-nav nodrag nopan`,"aria-label":i?`任务各部分`:`Task parts`,children:[(0,J.jsx)(`span`,{children:ee}),(0,J.jsxs)(`div`,{children:[(0,J.jsxs)(`button`,{disabled:!t.previousId,onClick:()=>t.previousId&&t.open(t.previousId),children:[(0,J.jsx)(ne,{size:14}),i?`上一部分`:`Previous part`]}),(0,J.jsxs)(`button`,{disabled:!t.nextId,onClick:()=>t.nextId&&t.open(t.nextId),children:[i?`下一部分`:`Next part`,(0,J.jsx)(u,{size:14})]})]})]}),A&&ue&&(0,J.jsxs)(`section`,{className:`macro-reader nodrag nopan nowheel`,"data-testid":`map-reader`,"data-kind":A.kind,role:`region`,"aria-label":i?`卡片详情`:`Card details`,style:{left:ue.x,top:ue.y,width:ue.width,height:ue.height},onContextMenu:e=>{e.preventDefault(),e.stopPropagation(),t.menu(se(A),{x:e.clientX,y:e.clientY})},children:[(0,J.jsxs)(`header`,{children:[(0,J.jsx)(`span`,{children:Vp[A.kind][+!i]}),(0,J.jsx)(`button`,{"aria-label":`Close step details`,onClick:()=>{S(null),h(null),t.open(e)},children:(0,J.jsx)(j,{size:20})})]}),(0,J.jsx)(`h3`,{children:(0,J.jsx)(Ip,{children:A.title})}),(0,J.jsx)(`div`,{className:`macro-reader-body`,children:(0,J.jsx)(_,{artifacts:c,onOpenArtifact:l,children:C(B(A)?.detail||A.detail||Sp(i))})}),(0,J.jsxs)(`footer`,{children:[(0,J.jsx)(`span`,{title:Wp(A,i),children:N?new Date(N*1e3).toLocaleString(i?`zh-CN`:`en-US`):``}),!t.readOnly&&(0,J.jsx)(`button`,{onClick:()=>t.quote(se(A)),children:i?`引用此项`:`Reference`})]})]})]})]})});function Kp(e){let t={};for(let n of e)(t[n.node_id]??=[]).push(n);for(let e of Object.values(t))e.sort((e,t)=>e.ts-t.ts||e.id.localeCompare(t.id));return t}var qp={width:640,height:190},Jp={"idea-route":q,"idea-review":I,"idea-selector":oe},Yp={done:`✓`,failed:`✕`,question:`?`,paused:`‖`,running:`▶`,superseded:`↪`},Xp={done:[`已完成`,`Completed`],running:[`进行中`,`In progress`],pending:[`待开始`,`Planned`],failed:[`未通过`,`Failed`],question:[`待答复`,`Needs input`],paused:[`已暂停`,`Paused`],aborted:[`已取消`,`Cancelled`],skipped:[`已跳过`,`Skipped`],superseded:[`已替代`,`Superseded`],unknown:[`已记录`,`Recorded`]},Zp=(0,Y.memo)(function({data:e}){let{task:t,zh:n,fanIndex:r,fanCount:i}=e,a=ep(t),o=t.overflow_count?ae:Jp[t.team_role??``]??l,s=(Xp[a]??Xp.unknown)[+!n],c=Yp[a],u=typeof r==`number`&&typeof i==`number`;return(0,J.jsxs)(`button`,{type:`button`,className:`map-branch map-state-${a} nodrag nopan`,"data-testid":`map-branch`,"data-branch-id":t.id,"data-status":a,"data-overflow":!!t.overflow_count,title:t.excerpt||t.objective||t.title,"aria-label":`${t.title} · ${s} · ${n?`打开所属任务`:`Open the owning task`}`,onClick:()=>e.open(e.parentCardId),children:[[`source`,`target`].flatMap(e=>[Z.Left,Z.Right,Z.Top,Z.Bottom].map(t=>(0,J.jsx)(Nu,{id:t,type:e,position:t,isConnectable:!1},`${e}-${t}`))),(0,J.jsx)(`span`,{className:`map-branch-glyph`,"aria-hidden":`true`,children:(0,J.jsx)(o,{})}),c&&(0,J.jsx)(`span`,{className:`map-branch-state`,"aria-hidden":`true`,children:c}),(0,J.jsx)(`span`,{className:`map-branch-title`,children:t.title}),u&&(0,J.jsx)(`span`,{className:`map-branch-fan`,"data-testid":`map-branch-fan`,title:n?`并行分支 ${r} / ${i}`:`Parallel branch ${r} of ${i}`,children:`${r}/${i}`}),(0,J.jsx)(`span`,{className:`map-branch-dot`,"aria-hidden":`true`})]})}),Qp={x:52,y:125,zoom:.24},$p=.035,em=3.5,tm=(e,t,n)=>Math.max(t,Math.min(n,e));function nm(e){let t=e.getBoundingClientRect(),n=e.querySelector(`.map-canvas-toolbar`)?.getBoundingClientRect(),r=e.querySelector(`.map-composer-dock`)?.getBoundingClientRect(),i=e.querySelector(`.react-flow__minimap`)?.getBoundingClientRect(),a=e.querySelector(`.map-legend`)?.getBoundingClientRect(),o=e.querySelector(`.react-flow__controls`)?.getBoundingClientRect(),s=e.dataset.reading===`true`,c=e.clientWidth<640?20:50,l=Math.max(n?n.bottom-t.top+20:85,!s&&e.clientWidth<640&&a?a.bottom-t.top+16:0,!s&&e.clientWidth<640&&o?o.bottom-t.top+16:0),u=Math.max(r?t.bottom-r.top+24:100,!s&&i?t.bottom-i.top+20:0);return{x:c,y:l,width:Math.max(180,e.clientWidth-c*2),height:Math.max(100,e.clientHeight-l-u)}}var rm=.72,im=.85,am=(e,t)=>e?0:t;function om(e,t,n){let r=Math.min(t.width/n.width,t.height/n.height),i=Math.min(e.width,e.height)/Math.min(n.width,n.height);return Math.min(Math.max(r,rm*i),im*i)}function sm(e,t,n){let r=tm(Math.min(t.width/(n.width+160),t.height/(n.height+160)),$p,.27),i=(e,t,n,r)=>r>t?(n-r)/2:tm((n-r)/2,e,e+t-r);return{x:i(t.x,t.width,e.width,n.width*r)-n.x*r,y:i(t.y,t.height,e.height,n.height*r)-n.y*r,zoom:r}}function cm(e,t,n){let r=Math.min(48,e.height*.35),i=e.height-r,a=Math.min(em,Math.min(1.05,e.width/n.width,i/n.height)/n.scale);return{x:e.x+e.width/2-(t.x+(n.x+n.width/2)*n.scale)*a,y:e.y+r+i/2-(t.y+(n.y+n.height/2)*n.scale)*a,zoom:a}}function lm(e,t=!0){let n=ou(),[r,i]=(0,Y.useState)(null),[a,o]=(0,Y.useState)(!1),[s,c]=(0,Y.useState)({width:0,height:0}),l=(0,Y.useRef)(null),u=(0,Y.useRef)(!1),d=(0,Y.useRef)(!1),f=(0,Y.useRef)(!1),p=(0,Y.useRef)(()=>{}),m=(0,Y.useRef)(null),h=(0,Y.useRef)(null),g=(0,Y.useRef)(()=>{}),_=(0,Y.useRef)(()=>{}),[v,y]=(0,Y.useState)(()=>window.matchMedia(`(prefers-reduced-motion: reduce)`).matches),b=(0,Y.useRef)(Qp),x=(0,Y.useRef)(null),S=(0,Y.useRef)(null),C=(0,Y.useRef)(null),w=(0,Y.useRef)(0),T=(0,Y.useRef)(null),E=(0,Y.useCallback)(()=>{cancelAnimationFrame(w.current),w.current=0,T.current=null},[]),D=(0,Y.useCallback)((t,r)=>{t&&(f.current=!1,d.current=!1);let a=e.current;if(!a)return;let s={x:a.clientWidth/2,y:a.clientHeight/2},c=x.current&&x.current.until>performance.now()?x.current:s,p=S.current??(u.current?m.current:null)??Np(n.getNodes().filter(e=>e.data.frame),r,c,s),h=p&&(n.getNode(p)?.data)?.frame?.scale||1,g=tm((r.zoom-.3)/.14,0,1)*tm((r.zoom*h-.28)/.3,0,1),_=C.current,v=u.current?1:_?.id===p?tm((r.zoom-_.zoom*.65)/(_.zoom*.35),0,1):g;l.current=v>0?p:null,a.style.setProperty(`--detail-alpha`,String(v)),a.style.setProperty(`--summary-alpha`,String(1-v)),a.style.setProperty(`--context-alpha`,String(p?1-v*.72:1)),a.dataset.zoom=r.zoom.toFixed(2),a.style.setProperty(`--map-zoom`,String(r.zoom)),i(v>0&&p?p:null),o(v>=.55),r.zoom<=.32&&!S.current&&!T.current&&!C.current&&(b.current=r)},[n,e]),O=(0,Y.useCallback)(t=>{f.current=!1,E();let r=n.getNode(t),i=e.current;if(!r||!i)return;n.getZoom()<=.32&&!C.current&&(b.current=n.getViewport()),S.current=t,u.current=!1,delete i.dataset.reading,d.current=!0;let a=nm(i),o=r.width||1440,s=r.height||1080,c=tm(Math.max(om({width:i.clientWidth,height:i.clientHeight},a,{width:o,height:s}),i.clientWidth<640||(r.data.layout?.steps.length??0)>20?.6/(r.data.frame?.scale||1):0),$p,em);C.current={id:t,zoom:c};let l=a.x+Math.max(0,(a.width-o*c)/2)-r.position.x*c,p=a.y+Math.max(0,(a.height-s*c)/2)-r.position.y*c;n.setViewport({x:l,y:p,zoom:c},{duration:am(v,380)}).then(()=>{S.current=null})},[E,n,v,e]);_.current=O;let k=(0,Y.useCallback)(()=>{f.current=!1,E(),S.current=null,u.current=!1,e.current&&delete e.current.dataset.reading,d.current=!1,C.current=null,x.current=null;let t=e.current?.querySelector(`.map-macro[data-focused="true"]`)?.dataset.cardId;n.setViewport(b.current,{duration:am(v,320)}).then(()=>{t&&e.current?.querySelector(`[data-testid="map-card"][data-card-id="${CSS.escape(t)}"]`)?.focus({preventScroll:!0})})},[E,n,v,e]),A=(0,Y.useCallback)((t,r)=>{f.current=!1,E(),S.current=t;let i=n.getNode(t),a=e.current;!i||!a||(u.current=!0,a.dataset.reading=`true`,d.current=!0,m.current=t,h.current={id:t,rect:r},n.setViewport(cm(nm(a),i.position,r),{duration:am(v,340)}).then(()=>{S.current=null}))},[E,n,v,e]);g.current=A;let j=(0,Y.useCallback)(e=>{f.current=!1,E(),u.current=!1,d.current=!1,S.current=null,x.current=null,n.setCenter(e.x,e.y,{zoom:n.getZoom(),duration:am(v,180)})},[E,n,v]),M=(0,Y.useCallback)(()=>{f.current=!0,E(),S.current=null,u.current=!1,d.current=!1,C.current=null,x.current=null;let t=e.current,r=n.getNodes().filter(e=>!e.hidden);!t||!r.length||n.setViewport(sm({width:t.clientWidth,height:t.clientHeight},nm(t),n.getNodesBounds(r)),{duration:am(v,320)})},[E,n,v,e]);p.current=M;let N=(0,Y.useCallback)(()=>{f.current?p.current():d.current&&u.current&&h.current?g.current(h.current.id,h.current.rect):d.current&&l.current&&_.current(l.current)},[]);return(0,Y.useEffect)(()=>{let t=e.current;if(!t)return;let n,r=t.querySelector(`.map-composer-dock`),i=-1,a=-1,o=-1,s=new ResizeObserver(()=>{let e=r?.getBoundingClientRect().height||0;(i!==t.clientWidth||a!==t.clientHeight||o!==e)&&(i=t.clientWidth,a=t.clientHeight,o=e,t.style.setProperty(`--map-composer-height`,`${o}px`),c(e=>e.width===i&&e.height===a?e:{width:i,height:a}),clearTimeout(n),n=setTimeout(()=>{d.current&&u.current&&h.current?g.current(h.current.id,h.current.rect):d.current&&l.current&&!u.current?_.current(l.current):f.current&&p.current()},100))});return s.observe(t),r&&s.observe(r),()=>{s.disconnect(),clearTimeout(n)}},[e,t]),(0,Y.useEffect)(()=>{let e=window.matchMedia(`(prefers-reduced-motion: reduce)`),t=()=>y(e.matches);return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]),(0,Y.useEffect)(()=>{let t=e.current;if(!t)return;let r=e=>{if(e.target.closest(`.nowheel, .map-canvas-toolbar, .map-legend, .react-flow__minimap, .react-flow__controls`))return;e.preventDefault(),e.stopPropagation(),f.current=!1,u.current=!1,d.current=!0,S.current=null;let r=t.getBoundingClientRect(),i=e.clientX-r.left,a=e.clientY-r.top;x.current={x:i,y:a,until:performance.now()+1e3};let o=T.current??n.getViewport();!T.current&&o.zoom<=.32&&!C.current&&(b.current=o);let s=e.deltaY*(e.deltaMode===1?16:e.deltaMode===2?t.clientHeight:1),c=tm(o.zoom*Math.exp(-tm(s,-400,400)*.002),$p,em);if(T.current={x:i-(i-o.x)*c/o.zoom,y:a-(a-o.y)*c/o.zoom,zoom:c},v){n.setViewport(T.current),T.current=null;return}if(w.current)return;let l=performance.now(),p=e=>{if(!T.current)return;let t=1-Math.exp(-Math.min(e-l,64)/55);l=e;let r=n.getViewport(),i=T.current,a=Math.abs(i.zoom-r.zoom)<15e-5&&Math.abs(i.x-r.x)+Math.abs(i.y-r.y)<.15;n.setViewport(a?i:{x:r.x+(i.x-r.x)*t,y:r.y+(i.y-r.y)*t,zoom:r.zoom+(i.zoom-r.zoom)*t}),a?(w.current=0,T.current=null):w.current=requestAnimationFrame(p)};w.current=requestAnimationFrame(p)},i=()=>{E(),S.current=null,x.current=null},a=e=>{e.defaultPrevented||document.querySelector(`[role="dialog"][aria-modal="true"]`)||e.key===`Escape`&&![`INPUT`,`TEXTAREA`,`SELECT`].includes(e.target.tagName)&&k()};return t.addEventListener(`wheel`,r,{passive:!1,capture:!0}),t.addEventListener(`pointerdown`,i,!0),window.addEventListener(`keydown`,a),()=>{E(),t.removeEventListener(`wheel`,r,!0),t.removeEventListener(`pointerdown`,i,!0),window.removeEventListener(`keydown`,a)}},[k,E,n,v,e]),{capture:(0,Y.useCallback)(()=>({viewport:n.getViewport(),overview:b.current,focusId:l.current,detailed:!!l.current&&(u.current||!!C.current||n.getZoom()>=.44)}),[n]),restore:(0,Y.useCallback)(e=>{E(),b.current=e.overview;let t=e.focusId&&n.getNode(e.focusId)?e.focusId:null;S.current=e.detailed?t:null,C.current=e.detailed&&t?{id:t,zoom:e.viewport.zoom}:null,d.current=!1,f.current=!1,n.setViewport(e.viewport,{duration:0}),D(null,e.viewport)},[E,n,D]),focusId:r,canvasSize:s,detailed:a,enter:O,back:k,fit:M,fitUpdatedScene:N,navigate:j,readStep:A,onMove:D,reducedMotion:v}}function um(e,t,n,r=!0,i,s,c=!1){let l=n?`zh-CN`:`en-US`,u=e.kind===`live`?`project`:`dataset`,d=e.id.replace(/^live:/,``),f=[`map-copy`,u,d,l,s],m=JSON.stringify(f),h=(0,Y.useRef)(m);h.current=m;let g=a(),_=o({queryKey:f,queryFn:async({signal:e})=>{let t=await p.mapCopy(u,d,l,e,s),n=g.getQueryData(f);return V(n,t,n?.model_revision)},staleTime:1/0,gcTime:72e5,refetchOnWindowFocus:!1}),v=e.tasks.find(e=>e.id===t),y=(0,Y.useMemo)(()=>i??(v?Op(v,e.events,n):[]),[v,e.events,n,i]),[b,x]=(0,Y.useState)(0),[S,C]=(0,Y.useState)(!1),w=(0,Y.useRef)(!0),T=(0,Y.useRef)(null),E=(0,Y.useRef)(c);E.current=c;let D=(0,Y.useRef)(0),O=te(e,y,t).filter(t=>k(t,e,_.data)).slice(0,8),A=JSON.stringify([m,O,O.map(t=>e.tasks.find(e=>e.id===t.task_id)?.revision),_.data?.model_revision]);return(0,Y.useEffect)(()=>(w.current=!0,()=>{w.current=!1}),[]),(0,Y.useEffect)(()=>{D.current=0},[m,c]),(0,Y.useEffect)(()=>{if(!r||!_.data?.available||!O.length||!Number.isFinite(D.current)||T.current)return;let e=_.data?.model_revision,t=setTimeout(()=>{let t=g.fetchQuery({queryKey:[`map-copy-generation`,...f],queryFn:()=>p.generateMapCopy(u,d,{cards:O,locale:l},void 0,s),staleTime:0,gcTime:0,retry:!1});T.current=t,C(!0),t.then(t=>{g.setQueryData(f,n=>V(n,t,e)),h.current===m&&(D.current=t.retry_after?Date.now()+t.retry_after*1e3:0)}).catch(()=>{h.current===m&&(D.current=E.current?1/0:Date.now()+6e4)}).finally(()=>{T.current===t&&(T.current=null),w.current&&h.current===m&&(C(!1),x(e=>e+1))})},Math.max(700,D.current-Date.now()));return()=>clearTimeout(t)},[A,b,_.data?.available,r,c]),{copy:_.data,generating:S,ready:_.isFetched}}function dm({value:e,onChange:t,onSend:n,attachments:r,onAttachmentsChange:i,pending:a,pendingLabel:o,dispatchStatus:s,onCancel:c,focusSignal:l,sessionName:u,historical:d,zh:p,routeOverride:g=`auto`,onRouteOverrideChange:_}){let{t:x}=G(),S=(0,Y.useId)(),C=(0,Y.useRef)(null),w=(0,Y.useRef)(null),E=(0,Y.useRef)(null),D=(0,Y.useRef)(!1),O=(0,Y.useRef)(!0),k=(0,Y.useRef)(),[M,I]=(0,Y.useState)(``),[L,R]=(0,Y.useState)(!1),[B,V]=(0,Y.useState)(()=>!!(e.trim()||r.length)),[ee,te]=(0,Y.useState)(44),H=(0,Y.useRef)(e);H.current=e;let W=!B,{refs:K,text:ne}=A(e),re=!!(e.trim()||r.length),ae=(0,Y.useRef)(re);ae.current=re,(0,Y.useEffect)(()=>{O.current=!0;let e=e=>{let t=e.type===`focusout`?e.relatedTarget:e.target;t?.closest?.(`.map-island-launch, .map-island-stop, .map-composer-brand`)||(w.current?.contains(t)?V(!0):ae.current||V(!1))},t=e=>{let t=e.target;w.current?.contains(t)||t?.closest?.(`.map-context-menu`)||ae.current||(V(!1),w.current?.contains(document.activeElement)&&document.activeElement?.blur())},n=e=>{if(e.key!==`c`||e.metaKey||e.ctrlKey||e.altKey||e.defaultPrevented||e.isComposing)return;let t=e.target;t&&(t.tagName===`INPUT`||t.tagName===`TEXTAREA`||t.tagName===`SELECT`||t.isContentEditable)||t?.closest?.(`[role="dialog"], [role="menu"]`)||(e.preventDefault(),V(!0),C.current?.focus())};return document.addEventListener(`focusin`,e),document.addEventListener(`focusout`,e),document.addEventListener(`pointerdown`,t),document.addEventListener(`keydown`,n),()=>{O.current=!1,clearTimeout(k.current),document.removeEventListener(`focusin`,e),document.removeEventListener(`focusout`,e),document.removeEventListener(`pointerdown`,t),document.removeEventListener(`keydown`,n)}},[]);let oe=(0,Y.useRef)(l);(0,Y.useEffect)(()=>{l!==oe.current&&(oe.current=l,V(!0),C.current?.focus())},[l]);let se=(0,Y.useRef)(K.length);(0,Y.useEffect)(()=>{K.length>se.current&&(V(!0),C.current?.focus()),se.current=K.length},[K.length]);let ce=()=>{if(!C.current)return;C.current.style.height=`0px`;let e=Math.min(156,Math.max(44,C.current.scrollHeight));C.current.style.height=`${e}px`,te(e)};(0,Y.useEffect)(ce,[ne]),(0,Y.useEffect)(()=>(window.addEventListener(`resize`,ce),()=>window.removeEventListener(`resize`,ce)),[]);let le=()=>{V(!0),C.current?.focus()},q=()=>{V(!1),w.current?.contains(document.activeElement)&&document.activeElement?.blur()},ue=(0,Y.useRef)(),de=(0,Y.useRef)(typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(`(hover: hover) and (pointer: fine)`).matches);(0,Y.useEffect)(()=>()=>clearTimeout(ue.current),[]);let fe=()=>{de.current&&(clearTimeout(ue.current),V(!0))},pe=()=>{de.current&&(clearTimeout(ue.current),ue.current=setTimeout(()=>{ae.current||w.current?.contains(document.activeElement)||V(!1)},320))},me=async()=>{if(!(!ne.trim()||a||D.current)){D.current=!0;try{await n(e,r)&&O.current&&(I(``),R(!0),(!H.current.trim()||H.current===e)&&q(),clearTimeout(k.current),k.current=setTimeout(()=>R(!1),1800))}finally{D.current=!1}}},X=e=>{if(a||D.current||!e.length)return;let{accepted:t,issues:n}=N(r,e);i([...r,...t]),I(n.map(e=>e.code===`unsupported`?x(`chat.attachUnsupported`,{name:e.fileName}):e.code===`too-large`?x(`chat.attachTooLarge`,{name:e.fileName,size:v(e.limitBytes)}):e.code===`too-many`?x(`chat.attachTooMany`,{count:e.limitCount}):x(`chat.attachTotalTooLarge`,{size:v(e.limitBytes)})).join(` `))},he=s?{launching:[p?`任务已接收`:`Task accepted`,p?`正在放入地图…`:`Adding it to your map…`],task:[p?`任务已进入地图`:`Your task is on the map`,p?`跟随地图,查看执行进展`:`Follow its progress on the map`],message:[p?`Argus 已回复`:`Argus replied`,p?`在对话中查看回复`:`Open the conversation to read it`],error:[p?`发送没有成功`:`Message could not be sent`,p?`草稿已保留,可以重试`:`Your draft is ready to retry`],cancelled:[p?`已停止等待`:`Waiting stopped`,p?`随时继续对话`:`Continue whenever you are ready`]}[s]:void 0,ge=he?.[0]||(a?p?`Argus 正在处理`:`Argus is working`:L?p?`已发送给 Argus`:`Sent to Argus`:p?`交给 Argus`:`Ask Argus`),_e=he?.[1]||(a?o||(p?`正在处理你的消息…`:`Processing your message…`):L?p?`点此继续对话`:`Tap to keep the conversation going`:re?p?`草稿已保留,点此继续`:`Draft saved — tap to continue`:p?`描述目标,看它变成成果`:`Turn your next idea into a result`),ve=s||(a?`working`:L?`sent`:`idle`);return(0,J.jsxs)(`div`,{ref:w,className:`map-composer-dock map-island-dock`,"data-compact":W,"data-state":ve,"data-pending":a,style:{"--map-editor-height":`${ee}px`},onPointerEnter:fe,onPointerLeave:pe,onTransitionEnd:e=>{e.target===w.current&&e.propertyName===`width`&&ce()},children:[!W&&K.length>0&&(0,J.jsx)(`div`,{className:`map-reference-chips`,children:K.map((e,n)=>(0,J.jsxs)(`span`,{title:`${e.source} · ${e.task_id} ${e.step_id||``}`,children:[(0,J.jsxs)(`span`,{children:[p?`引用`:`Reference`,` · `,e.step_title||e.task_title]}),(0,J.jsx)(`button`,{"aria-label":p?`移除引用`:`Remove reference`,onClick:()=>t(K.filter((e,t)=>n!==t).map(F).join(``)+ne),children:(0,J.jsx)(j,{size:12})})]},`${e.task_id}:${e.step_id}:${n}`))}),!W&&!!r.length&&(0,J.jsx)(`div`,{className:`map-attachment-tray nowheel`,role:`group`,"aria-label":p?`待发送附件`:`Selected attachments`,children:r.map((e,t)=>(0,J.jsx)(P,{file:e,disabled:a,removeLabel:x(`chat.attachRemove`,{name:e.name}),onRemove:()=>{i(r.filter(t=>t!==e)),I(``)}},`${e.name}:${e.lastModified}:${t}`))}),!W&&M&&(0,J.jsx)(`div`,{className:`map-attachment-notice nowheel`,role:`alert`,children:M}),(0,J.jsxs)(`div`,{className:`map-composer map-island-surface`,children:[(0,J.jsx)(`button`,{type:`button`,className:`map-composer-brand map-attach`,"aria-label":x(`chat.attach`),title:x(`chat.attach`),"aria-hidden":W,tabIndex:W?-1:0,disabled:a&&!W,onClick:()=>E.current?.click(),children:(0,J.jsx)(h,{size:25})}),(0,J.jsxs)(`button`,{type:`button`,className:`map-island-launch`,"aria-label":p?`打开消息输入`:`Open message composer`,"aria-expanded":!W,"aria-controls":S,"aria-hidden":!W,tabIndex:W?0:-1,onClick:le,children:[(0,J.jsxs)(`span`,{className:`map-island-copy`,children:[(0,J.jsx)(`strong`,{children:ge}),(0,J.jsx)(`small`,{title:_e,children:_e})]}),(0,J.jsx)(`span`,{className:`map-island-indicator`,"aria-hidden":`true`,children:ve===`working`||ve===`launching`?(0,J.jsxs)(`span`,{className:`map-island-wave`,children:[(0,J.jsx)(`i`,{}),(0,J.jsx)(`i`,{}),(0,J.jsx)(`i`,{})]}):ve===`sent`||ve===`task`||ve===`message`?(0,J.jsx)(T,{size:16}):(0,J.jsx)(ie,{size:15})})]}),W&&a&&(0,J.jsx)(`button`,{type:`button`,className:`map-island-stop`,onClick:c,"aria-label":p?`停止等待`:`Stop waiting`,children:(0,J.jsx)(z,{size:13})}),(0,J.jsxs)(`form`,{id:S,className:`map-composer-editor`,"aria-hidden":W,onSubmit:e=>{e.preventDefault(),me()},children:[(0,J.jsx)(`input`,{ref:E,type:`file`,multiple:!0,accept:f,hidden:!0,disabled:a,onChange:e=>{X(Array.from(e.target.files||[])),e.target.value=``}}),(0,J.jsx)(`textarea`,{ref:C,rows:1,tabIndex:W?-1:0,value:ne,"aria-label":p?`给 Argus 发送消息`:`Message Argus`,placeholder:p?`告诉 Argus,你想完成什么…`:`What would you like Argus to do?`,onFocus:()=>V(!0),onChange:e=>{R(!1),t(K.map(F).join(``)+e.target.value)},onPaste:e=>{let t=y(e.clipboardData);t.length&&(e.preventDefault(),X(t))},onKeyDown:e=>{e.key===`Escape`&&!b(e)&&!ne.trim()&&!r.length&&(e.preventDefault(),e.stopPropagation(),q()),e.key===`Enter`&&!e.shiftKey&&!b(e)&&(e.preventDefault(),me())}}),(0,J.jsxs)(`div`,{className:`map-island-toolbar`,children:[(0,J.jsx)(`button`,{type:`button`,className:`map-island-collapse`,tabIndex:W?-1:0,onClick:q,"aria-label":p?`收起消息输入`:`Collapse message composer`,title:p?`收起(草稿会保留)`:`Collapse (draft is kept)`,children:(0,J.jsx)(U,{size:15})}),(0,J.jsx)(`span`,{className:`map-island-key-hint`,"aria-hidden":`true`,children:p?`Enter 发送`:`Enter to send`}),_&&(0,J.jsxs)(`select`,{className:`map-route-select`,tabIndex:W?-1:0,"aria-label":x(`chat.routeLabel`),title:x(`chat.routeHint`),value:g,disabled:a,onChange:e=>_(e.target.value),children:[(0,J.jsx)(`option`,{value:`auto`,children:x(`chat.routeAuto`)}),(0,J.jsx)(`option`,{value:`task`,children:x(`chat.routeTask`)}),(0,J.jsx)(`option`,{value:`chat`,children:x(`chat.routeChat`)})]}),a?(0,J.jsx)(`button`,{type:`button`,onClick:e=>{e.preventDefault(),c()},tabIndex:W?-1:0,"aria-label":p?`停止等待`:`Stop waiting`,className:`map-send is-pending`,children:(0,J.jsx)(z,{size:15})}):(0,J.jsx)(`button`,{type:`submit`,tabIndex:W?-1:0,disabled:!ne.trim(),"aria-label":p?`发送消息`:`Send message`,className:`map-send`,children:(0,J.jsx)(m,{size:20})})]})]})]}),(0,J.jsx)(`span`,{className:`map-composer-caption`,role:`status`,children:he?`${he[0]} · ${he[1]}`:a?o||(p?`Argus 正在处理…`:`Argus is responding…`):L?p?`已发送`:`Sent`:d?`${p?`发送至`:`Send to`} ${u}`:``})]})}function fm(e,t){let n=1-t;return{x:n**3*e[0].x+3*n**2*t*e[1].x+3*n*t**2*e[2].x+t**3*e[3].x,y:n**3*e[0].y+3*n**2*t*e[1].y+3*n*t**2*e[2].y+t**3*e[3].y}}function pm(e,t,n=!1){if(!e.length)return null;let r=n?[...e].reverse():e,i=0;for(let e=1;e0&&i+n>=t){let a=(t-i)/n;return{x:r[e-1].x+(r[e].x-r[e-1].x)*a,y:r[e-1].y+(r[e].y-r[e-1].y)*a}}i+=n}return r[r.length-1]}function mm(e,t,n=0){return e.x>t.x-n&&e.xt.y-n&&e.y({x:n===`left`?-e.x:e.x,y:n===`up`?-e.y:e.y}),s=o(e),c=o(t);i=i.map(e=>({...e,x:n===`left`?-e.x-e.width:e.x,y:n===`up`?-e.y-e.height:e.y}));let l=Math.max(80,n===`loop`?Math.max(Math.abs(c.x-s.x),Math.abs(c.y-s.y))*2.8:0,Math.abs(a?c.y-s.y:c.x-s.x)*(.4+r*.06)),u=[s,a?{x:s.x+0,y:s.y+l}:{x:s.x+l,y:s.y},n===`loop`?{x:c.x,y:c.y+l}:a?{x:c.x-0,y:c.y-l}:{x:c.x-l,y:c.y},c],d=e=>e.flatMap(e=>Array.from({length:31},(t,n)=>fm(e,n/30))),f=e=>d(e).reduce((e,t)=>e+i.filter(e=>mm(t,e,22)).length,0),p=[u],m=f(p)*1e5;if(m){let e={x:(s.x+c.x)/2,y:(s.y+c.y)/2},t=a?e.x:e.y,n=[...new Set(i.flatMap(e=>a?[e.x-110-r*30,e.x+e.width+110+r*30]:[e.y-110-r*30,e.y+e.height+110+r*30]))].sort((e,n)=>Math.abs(e-t)-Math.abs(n-t)).slice(0,12);for(let e of n){let n=(e-t)*4/3;for(let r of[.25,.4,.55]){let i=Math.max(60,Math.abs(a?c.y-s.y:c.x-s.x)*r),o=[a?[s,{x:s.x+n,y:s.y+i},{x:c.x+n,y:c.y-i},c]:[s,{x:s.x+i,y:s.y+n},{x:c.x-i,y:c.y+n},c]],l=f(o)*1e5+Math.abs(e-t)+Math.abs(r-.4)*100;le.map(o)),{path:`M ${e.x} ${e.y}`+p.map(e=>` C ${e[1].x} ${e[1].y}, ${e[2].x} ${e[2].y}, ${e[3].x} ${e[3].y}`).join(``),points:d(p),labels:[.5,.4,.6,.3,.7,.2,.8,.35,.45,.55,.65,.25,.75,.15,.85].map(e=>{let t=Math.min(p.length-1,Math.floor(e*p.length));return fm(p[t],e*p.length-t)})}}var gm=new WeakMap,_m=.5;function vm(e){return e<_m?0:Math.max(_m,Math.floor(e*8)/8)}function ym(e){return e==null?``:String(e).replace(/\s+/g,` `).trim()}function bm(e){let t=[...ym(e)].reduce((e,t)=>e+(/[^\x00-\x7F]/.test(t)?10.5:6),20);return{width:Math.min(t,166),height:26}}function xm(e,t){let n=e.getState(),r=[...n.nodeLookup.values()].filter(e=>!e.hidden).map(e=>({id:e.id,...e.internals.positionAbsolute,width:e.width||e.measured.width||0,height:e.height||e.measured.height||0}));function i(e,t){let r=n.nodeLookup.get(e);if(!r)return null;let{x:i,y:a}=r.internals.positionAbsolute,o=r.width||r.measured.width||0,s=r.height||r.measured.height||0;return{x:i+(t===`left`?0:t===`right`?o:o/2),y:a+(t===`top`?0:t===`bottom`?s:s/2)}}let a=n.edges.filter(e=>!e.hidden).map(e=>({...e,s:i(e.source,e.sourceHandle),t:i(e.target,e.targetHandle)})),o=JSON.stringify([r,a.map(e=>[e.id,e.s,e.t,e.label,e.data?.lane,e.sourceHandle,e.targetHandle,e.className])]),s=gm.get(e);if(!s||s.key!==o){let t=new Map,n=new Map;for(let e of a)n.set(e.id,/(?:^|\s)map-edge-(\w+)/.exec(e.className??``)?.[1]),e.s&&e.t&&t.set(e.id,hm(e.s,e.t,e.source===e.target?`loop`:e.sourceHandle===`left`?`left`:e.sourceHandle===`top`?`up`:e.sourceHandle===`bottom`,Number(e.data?.lane||0),r.filter(t=>t.id!==e.source&&t.id!==e.target)));s={key:o,routes:t,kinds:n,zoom:-1,labels:new Map},gm.set(e,s)}let c=vm(t);return s.zoom!==c&&(s.zoom=c,s.labels=new Map,c&&Sm(s,a,r,c)),s}function Sm(e,t,n,r){let i=[...n];for(let n of t){let t=e.routes.get(n.id);if(!t||!n.label)continue;let a=bm(n.label),o=a.width/r,s=a.height/r,c=[0,3,4,5,6][Number(n.data?.lane||0)%5],l=[t.labels[c],...t.labels.filter((e,t)=>t!==c)].filter(e=>i.every(t=>e.x+o/2<=t.x||e.x-o/2>=t.x+t.width||e.y+s/2<=t.y||e.y-s/2>=t.y+t.height)),u,d=1/0;for(let t of l){let r={x:t.x-o/2,y:t.y-s/2,width:o,height:s},i=0;for(let[t,a]of e.routes)t!==n.id&&a.points.some(e=>mm(e,r))&&i++;if(iMath.round(e.transform[2]*24)/24||e.transform[2]),a=`relation-arrow-${(0,Y.useId)().replace(/:/g,``)}`,o=xm($(),i),s=o.routes.get(e),c=o.labels.get(e);if(!s)return null;let l=o.kinds.get(e),u=l===`fanout`||l===`fanin`,d=!l||n?.stroke===Cm?n?.stroke||`#7594ad`:`var(--map-edge-${l}, ${n?.stroke||`#7594ad`})`,f=(Number(n?.strokeWidth||2)+(u?.4:0))/i,p=u?pm(s.points,(l===`fanout`?2:15)/i,l===`fanin`):null,m=typeof t==`string`?ym(t):void 0;return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`defs`,{children:(0,J.jsx)(`marker`,{id:a,viewBox:`0 0 10 10`,refX:`9`,refY:`5`,markerWidth:10.5/i,markerHeight:10.5/i,markerUnits:`userSpaceOnUse`,orient:`auto`,children:(0,J.jsx)(`path`,{d:`M 0 0 L 10 5 L 0 10 z`,style:{fill:d}})})}),(0,J.jsxs)(Lp,{path:s.path,delay:r?.growthDelay,padding:24/i,children:[(0,J.jsx)(pd,{id:e,path:s.path,markerEnd:`url(#${a})`,style:{...n,stroke:d,vectorEffect:`none`,strokeWidth:f,strokeDasharray:n?.strokeDasharray?String(n.strokeDasharray).split(/[\s,]+/).map(e=>Number(e)/i).join(` `):void 0}}),p&&(0,J.jsx)(`circle`,{className:`map-edge-joint`,cx:p.x,cy:p.y,r:3.2/i,style:{fill:d},"aria-hidden":`true`})]}),r?.active&&(0,J.jsx)(hf,{children:(0,J.jsx)(`div`,{className:`map-edge-spark`,"aria-hidden":`true`,style:{offsetPath:`path("${s.path}")`,width:8/i,height:8/i,margin:`${-4/i}px 0 0 ${-4/i}px`,animationDelay:`${-((e.charCodeAt(0)*131+e.length*47)%2800)}ms`}})}),t&&m!==``&&c&&(0,J.jsx)(hf,{children:(0,J.jsx)(`div`,{className:`map-relation-label nodrag nopan`,"data-kind":l,title:m,style:{transform:`translate(-50%, -50%) translate(${c.x}px, ${c.y}px) scale(${1/i})`},children:m??t})})]})}function Tm({open:e,info:t,zh:n,onChoose:r,readOnly:i=!1}){return(0,J.jsx)(R,{open:e,onClose:()=>r({mode:`off`}),label:n?`选择地图加载范围`:`Choose map history`,width:`max-w-lg`,children:(0,J.jsxs)(`div`,{className:`map-history-choice`,children:[(0,J.jsx)(`h2`,{children:n?`选择地图加载范围`:`Choose map history`}),(0,J.jsx)(`p`,{children:n?`本会话有 ${t.task_count} 个任务,历史记录约 ${(t.event_bytes/1024/1024).toFixed(1)} MB。`:`This session has ${t.task_count} tasks and about ${(t.event_bytes/1024/1024).toFixed(1)} MB of history.`}),(0,J.jsx)(`p`,{children:i?n?`只读模式只加载历史记录,不调用模型。较长历史需要一些加载时间。`:`Read-only mode loads records without model calls. Long histories take time to load.`:n?`加载较长历史需要一些时间。生成卡片摘要与关系说明会调用已配置的模型,并消耗额外 Token。已有摘要会优先复用。`:`Loading a long history takes time. Card summaries and relationship descriptions use your configured model and consume additional tokens. Existing summaries are reused.`}),(0,J.jsxs)(`div`,{className:`map-history-options`,children:[(0,J.jsxs)(`button`,{type:`button`,onClick:()=>r({mode:`current`,since:t.current_task_ts,eventSince:t.current_event_ts,taskId:t.current_task_id||void 0}),children:[(0,J.jsx)(`strong`,{children:n?`从当前进度加载`:`Start at current progress`}),(0,J.jsx)(`span`,{children:n?`推荐 · 加载当前任务及后续进度,保留相关连接`:`Recommended · Load current and future work with its connections`})]}),(0,J.jsxs)(`button`,{type:`button`,onClick:()=>r({mode:`full`}),children:[(0,J.jsx)(`strong`,{children:n?`从头加载`:`Load from the beginning`}),(0,J.jsx)(`span`,{children:n?`分批加载完整历史,再补齐需要的摘要`:`Load the complete history in pages, then prepare missing summaries`})]}),(0,J.jsxs)(`button`,{type:`button`,onClick:()=>r({mode:`off`}),children:[(0,J.jsx)(`strong`,{children:n?`不开启地图模式`:`Keep map mode off`}),(0,J.jsx)(`span`,{children:n?`不加载地图,也不生成摘要`:`Do not load the map or generate summaries`})]})]}),(0,J.jsx)(`small`,{children:n?`选择仅用于本会话,可随时更改加载范围。`:`This choice applies to this session and can be changed later.`})]})})}function Em(e){try{let t=JSON.parse(e||`null`);return!t||![`full`,`current`,`off`].includes(t.mode)||t.mode===`current`&&![t.since,t.eventSince].every(e=>typeof e==`number`&&Number.isFinite(e)&&e>=0)?null:t}catch{return null}}function Dm(e,t){if(!e||e.id!==t.id||t.reset_history)return t;let n=new Map((!t.incremental||t.tasks_complete?[]:e.tasks).map(e=>[e.id,e]));for(let e of t.tasks)n.set(e.id,e);for(let e of t.removed_task_ids||[])n.delete(e);let r=new Map(e.events.filter(e=>t.incremental&&!t.team_events_complete||e.type!==`team.task`).map(e=>[e.id,e]));for(let e of t.events)r.set(e.id,e);for(let e of t.removed_event_ids||[])r.delete(e);return i(e,{...e,...t,tasks:[...n.values()].sort((e,t)=>(e.ts||0)-(t.ts||0)||e.id.localeCompare(t.id)),events:[...r.values()].filter(e=>n.has(e.item_id))})}function Om(e,t,n){return e?t?.history_loading?400:!km(n)||t?.events.some(e=>e.type===`team.task`&&$f.has(e.status||``))?15e3:!1:!1}function km(e){return!e.daemon.alive||e.continuous?.enabled===!1&&/pause|stop/i.test(e.continuous.done_reason||``)?!0:e.daemon.health?.state===`stopped`}var Am=new Map;function jm(e){let t=Am.get(e);if(t)return t;try{let t=JSON.parse(ee(`argus.map.camera.v1:`+e)||`null`);if(t&&[t.viewport,t.overview].every(e=>e&&[e.x,e.y,e.zoom].every(Number.isFinite)&&e.zoom>=.035&&e.zoom<=3.5)&&(t.focusId===null||typeof t.focusId==`string`)&&typeof t.detailed==`boolean`)return{camera:t}}catch{}return{}}function Mm(e,t){for(Am.delete(e),Am.set(e,t);Am.size>8;)Am.delete(Am.keys().next().value);t.camera&&L(`argus.map.camera.v1:`+e,JSON.stringify(t.camera))}var Nm={task:Gp,branch:Zp},Pm={relation:wm},Fm={done:`#a8cfbb`,running:`#8fb6e4`,question:`#e2c78e`,failed:`#dfab97`,paused:`#d6c6a0`,superseded:`#c8bdd5`,aborted:`#c3c5cb`,skipped:`#c3c5cb`,missing:`#c3c5cb`};function Im({events:e,zh:t}){let n=[...new Map(e.filter(e=>e.type===`team.task`).map(e=>[e.id,e])).values()];if(!n.length)return null;let r=n.filter(e=>e.status===`done`).length,i=n.filter(e=>$f.has(e.status||``)).length,a=n.filter(e=>e.status===`failed`).length;return(0,J.jsxs)(`div`,{className:`map-team-progress`,role:`status`,"aria-label":t?`子任务进度`:`Subtask progress`,children:[(0,J.jsx)(`strong`,{children:t?`子任务`:`Subtasks`}),(0,J.jsxs)(`span`,{children:[(0,J.jsx)(T,{size:12}),(0,J.jsxs)(`b`,{children:[r,`/`,n.length]}),` `,t?`已完成`:`completed`]}),(0,J.jsxs)(`span`,{children:[(0,J.jsx)(`b`,{children:i}),` `,t?`进行中`:`running`]}),(0,J.jsxs)(`span`,{children:[(0,J.jsx)(`b`,{children:a}),` `,t?`失败`:`failed`]})]})}function Lm({data:e,zh:t,composer:n,activePhase:r,snapshot:s,events:c,pendingLabel:f,readOnly:m,sessionId:h,viewKey:g,paused:_,actions:v}){let[y,b]=(0,Y.useState)(!1),[x,S]=(0,Y.useState)(!1),[C,w]=(0,Y.useState)(null),O=(0,Y.useRef)(0),k=(0,Y.useRef)(!0);(0,Y.useEffect)(()=>(k.current=!0,()=>{k.current=!1}),[]);let j=(0,Y.useMemo)(()=>np(e.tasks),[e.tasks]),[N,P,I]=gf([]),L=(0,Y.useRef)(null),R=lm(L,!m),z=vf(),V=(0,Y.useRef)(!1),[ee,te]=(0,Y.useState)(!1),U=(0,Y.useRef)(null);U.current||=jm(g);let[W]=(0,Y.useState)(()=>new Set(U.current?.scene?.cards.map(e=>e.id))),G=N.find(e=>e.id===R.focusId),{copy:re,ready:ie}=um(e,G?.data.task.id||null,t,!m&&!e.history_loading,G?.data.layout.steps,h,_),ae=(0,Y.useMemo)(()=>sp(j,re?.relations||[],t),[j,re?.relations,t]),oe=(0,Y.useRef)(U.current.scene),q=(0,Y.useMemo)(()=>{let n=Pp(j,e.events,t,oe.current,ae);return oe.current=i(oe.current,n),oe.current},[j,e.events,t,ae]),de=(0,Y.useRef)(null),pe=(0,Y.useMemo)(()=>(de.current=i(de.current,op(j,e.events,t)),de.current),[j,e.events,t]),me=(0,Y.useRef)(null),X=(0,Y.useMemo)(()=>{let e=pe.tasks.filter(e=>e.branch);if(!e.length)return{links:q.links,positions:q.positions,frames:q.frames,structure:q.structure,branches:e,branchAnchor:new Map};let t=new Map;for(let e of q.cards)t.set(e.task.id,e.id);let n=new Map(e.map(e=>[e.id,t.get(e.parent_id)??e.parent_id])),r={...q.frames};for(let t of e)r[t.id]={...qp,scale:1};let i=[...q.links,...pe.links.filter(e=>e.kind===`fanout`||e.kind===`fanin`).map(e=>({...e,source:t.get(e.source)??e.source,target:t.get(e.target)??e.target}))],a=new Map;for(let t of e){let e=n.get(t.id);a.set(e,[...a.get(e)??[],t.id])}let o=q.cards.flatMap(e=>[e.id,...a.get(e.id)??[]]),s=JSON.stringify([o.map(e=>[e,r[e].width,r[e].height]),i.map(e=>[e.source,e.target,e.kind])]),c=me.current?.structure===s?me.current.positions:hp(o,i,r);return me.current={structure:s,positions:c},{links:i,positions:c,frames:r,structure:s,branches:e,branchAnchor:n}},[q,pe]),he=xe(q,!!e.history_loading),ge=(0,Y.useMemo)(()=>ap(e.events),[e.events]),ve=async(e,t=[])=>{let r=++O.current,i=L.current?.querySelector(`.map-composer`)?.getBoundingClientRect();w({id:r,text:A(e).text.replace(/\s+/g,` `).slice(0,180),origin:{x:i?.left??20,y:i?.top??innerHeight-100,width:i?.width??260,height:i?.height??56}});let a=!1,o=e=>{e.type===`task`&&(a=!0),k.current&&e.type===`settled`&&e.outcome===`message`&&!a&&(S(!0),b(!1)),k.current&&w(t=>t?.id===r?{...t,result:e}:t)};try{let r=await n.onSend(e,t,o);return r&&k.current&&A(e).refs.length>0&&(S(!0),b(!1)),r||o({type:`settled`,outcome:`error`}),r}catch(e){throw o({type:`settled`,outcome:`error`}),e}},be=()=>{w(e=>e?{...e,result:{type:`settled`,outcome:`cancelled`}}:null),n.onCancel()};(0,Y.useEffect)(()=>{if(!z||V.current||!ie||U.current?.camera&&e.history_loading)return;let t=requestAnimationFrame(()=>{V.current=!0,U.current?.camera?R.restore(U.current.camera):R.fit(),te(!0)});return()=>cancelAnimationFrame(t)},[z,R.fit,R.restore,e.history_loading,ie]),(0,Y.useEffect)(()=>{let e=()=>{V.current&&Mm(g,{scene:oe.current,camera:R.capture()})};return window.addEventListener(`pagehide`,e),()=>{e(),window.removeEventListener(`pagehide`,e)}},[g,R.capture]),(0,Y.useEffect)(()=>{if(!z)return;let e=requestAnimationFrame(R.fitUpdatedScene);return()=>cancelAnimationFrame(e)},[X.structure,z,R.fitUpdatedScene]);let Se=(0,Y.useRef)(n);Se.current=n;let Ce=(0,Y.useCallback)(e=>{if(m)return;let t=Se.current;t.onChange(F(e)+t.value),window.setTimeout(()=>document.querySelector(`.map-composer textarea`)?.focus(),0)},[m]),[we,Te]=(0,Y.useState)(null),Ee=a(),De=o({queryKey:[`map-notes`,h],queryFn:({signal:e})=>p.mapNotes(h,e),enabled:e.kind===`live`&&!m,staleTime:6e4}),Oe=(0,Y.useMemo)(()=>({notes:Kp(De.data?.notes??[])}),[De.data]),[ke,Ae]=(0,Y.useState)(null),[je,Me]=(0,Y.useState)(``),[Ne,Pe]=(0,Y.useState)(!1);(0,Y.useEffect)(()=>{if(!ke)return;let e=e=>{e.target.closest(`.map-note-editor`)||Ae(null)},t=e=>{e.key===`Escape`&&(e.stopPropagation(),Ae(null))};return window.addEventListener(`pointerdown`,e),document.addEventListener(`keydown`,t,!0),()=>{window.removeEventListener(`pointerdown`,e),document.removeEventListener(`keydown`,t,!0)}},[ke]);let Fe=async()=>{let e=ke,t=je.trim();if(!(!e||!t)){Pe(!1);try{await p.addMapNote(h,{node_id:e.ref.task_id,text:t}),await Ee.invalidateQueries({queryKey:[`map-notes`,h]}),Ae(null),Me(``)}catch{Pe(!0)}}},Ie=(0,Y.useCallback)((e,t)=>{m||Te({ref:e,x:Math.min(window.innerWidth-180,t.x),y:Math.min(window.innerHeight-140,t.y)})},[m]);(0,Y.useEffect)(()=>{if(!we)return;let e=e=>{e.target.closest(`.map-context-menu`)||Te(null)},t=e=>{e.key===`Escape`&&(e.stopPropagation(),Te(null))};return window.addEventListener(`pointerdown`,e),document.addEventListener(`keydown`,t,!0),()=>{window.removeEventListener(`pointerdown`,e),document.removeEventListener(`keydown`,t,!0)}},[we]);let[Le,Re]=(0,Y.useState)(``),ze=(0,Y.useCallback)(e=>`${e.task.title} ${e.task.objective??``} ${re?.cards[e.task.id]?.title||``} ${re?.cards[e.task.id]?.summary||``} ${e.part>1?t?`续篇 ${e.part-1}`:`Continued ${e.part-1}`:``}`.toLowerCase(),[re,t]),Be=(0,Y.useMemo)(()=>Le?q.cards.filter(e=>ze(e).includes(Le.toLowerCase())):[],[Le,q.cards,ze]),[Ve,He]=(0,Y.useState)(0);(0,Y.useEffect)(()=>He(0),[Le]);let[Ue,We]=(0,Y.useState)(j.tasks.length),[Ge,Ke]=(0,Y.useState)(!1),[qe,Je]=(0,Y.useState)(!1),[Ye,Xe]=(0,Y.useState)(``);(0,Y.useEffect)(()=>{P(n=>i(n,q.cards.map(n=>({id:n.id,type:`task`,position:X.positions[n.id]??q.positions[n.id],width:q.frames[n.id].width,height:q.frames[n.id].height,style:{width:q.frames[n.id].width,height:q.frames[n.id].height},data:{...n,zh:t,open:R.enter,readStep:R.readStep,menu:Ie,quote:Ce,source:e.id,readOnly:m,live:e.kind===`live`,paused:_,seenCards:W,restoring:!!U.current?.camera&&!V.current,layout:q.layouts[n.id],frame:q.frames[n.id],plannedWidth:ge.get(n.task.id),focused:!1,detailed:!1}}))))},[j,q,X,t,P,R.enter,R.readStep,Ie,Ce,e.id,e.kind,m,_,W,ge]),(0,Y.useEffect)(()=>{We(e=>Math.min(Math.max(e,1),j.tasks.length))},[j.tasks.length]),(0,Y.useEffect)(()=>{if(!Ge||R.detailed)return;let e=window.setInterval(()=>We(e=>e>=j.tasks.length?(Ke(!1),e):e+1),900);return()=>window.clearInterval(e)},[Ge,j.tasks.length,R.detailed]);let Ze=(0,Y.useMemo)(()=>{let t=new Set(q.cards.filter(t=>e.kind===`live`||t.ordinal<=Ue).map(e=>e.id));for(let[e,n]of X.branchAnchor)t.has(n)&&t.add(e);return t},[q.cards,Ue,e.kind,X.branchAnchor]),Qe=(0,Y.useRef)([]),$e=(0,Y.useMemo)(()=>{let e=N.map(e=>({...e,hidden:!Ze.has(e.id),data:{...e.data,copy:re?{cards:Object.fromEntries([e.data.task.id,...e.data.layout.steps.map(e=>e.id)].filter(e=>re.cards[e]).map(e=>[e,re.cards[e]]))}:void 0,focused:e.id===R.focusId,detailed:R.detailed&&e.id===R.focusId,canvasSize:R.canvasSize,growthDelay:he.cards[e.id],dispatchState:C?.result?.type===`task`&&C.result.taskId===e.data.task.id&&!n.historical?C.landed?`landed`:`receiving`:void 0,growingSteps:Object.fromEntries(e.data.layout.steps.flatMap(t=>{let n=he.steps[ye(e.id,t.id)];return n==null?[]:[[t.id,n]]})),growingLinks:Object.fromEntries(e.data.layout.links.flatMap(t=>{let n=he.links[ye(e.id,t.id)];return n==null?[]:[[t.id,n]]}))},style:{...e.style,opacity:Le&&!ze(e.data).includes(Le.toLowerCase())?.22:1}}));return Qe.current=i(Qe.current,e),Qe.current},[N,Ze,R.focusId,R.detailed,R.canvasSize,Le,ze,re,t,he,C,n.historical]),et=(0,Y.useRef)([]),tt=(0,Y.useMemo)(()=>{let e=new Map;for(let t of X.branches){let n=t.parent_id??``;e.set(n,(e.get(n)??0)+1)}let n=new Map,r=X.branches.map(r=>{let i=r.parent_id??``,a=(n.get(i)??0)+1;return n.set(i,a),{id:r.id,type:`branch`,position:X.positions[r.id]??{x:0,y:0},width:qp.width,height:qp.height,style:{width:qp.width,height:qp.height},hidden:!Ze.has(r.id),draggable:!1,selectable:!1,focusable:!1,data:{task:r,zh:t,parentCardId:X.branchAnchor.get(r.id),open:R.enter,fanIndex:a,fanCount:e.get(i)}}});return et.current=i(et.current,r),et.current},[X,Ze,t,R.enter]),nt=(0,Y.useMemo)(()=>tt.length?[...$e,...tt]:$e,[$e,tt]),rt=(0,Y.useMemo)(()=>{let n=X.links.filter(e=>Ze.has(e.source)&&Ze.has(e.target)&&(e.kind!==`replacement`||qe)),r=gp(n),i=new Map(q.cards.map(e=>[e.id,e.task])),a=new Set;if(e.kind===`live`&&!_){for(let e of q.cards)$f.has(e.task.status)&&a.add(e.id);for(let e of X.branches)$f.has(e.status)&&a.add(e.id)}return n.map((e,n)=>{let o=e.kind===`fanout`||e.kind===`fanin`;return{id:e.id,source:e.source,target:e.target,..._p({...X.positions[e.source],...X.frames[e.source]},{...X.positions[e.target],...X.frames[e.target]}),type:`relation`,data:{growthDelay:he.links[e.id],active:a.has(e.target),lane:r[n]},className:`map-edge-${e.kind}`,label:o?void 0:e.label||(e.kind===`replacement`?(i.get(e.source)?.superseded_reason||``).replace(/\s+/g,` `).slice(0,60)||(t?`转入新计划`:`New plan`):e.kind===`dependency`?t?`依赖`:`Dependency`:t?`同一研究`:`Related work`),labelStyle:{fontSize:30,fill:e.kind===`replacement`?`#95809f`:`#6685a4`},labelBgPadding:[12,6],labelBgBorderRadius:12,labelBgStyle:{fill:`var(--map-paper)`,fillOpacity:.96},style:{stroke:e.cycle?`#dc6648`:e.kind===`replacement`?`#a48caf`:e.kind===`dependency`?`#527fa7`:`#7594ad`,strokeWidth:e.kind===`dependency`?1.55:o?.95:1.3,vectorEffect:`non-scaling-stroke`,strokeDasharray:e.kind===`dependency`||o?void 0:e.kind===`context`?`3 10`:`4 5`},markerEnd:{type:go.ArrowClosed,color:e.kind===`replacement`?`#a48caf`:`#8aa5b8`,width:32,height:32},ariaLabel:e.evidence||(o?`Team branch: ${e.source} → ${e.target}`:e.kind===`dependency`?`Dependency: ${e.source} → ${e.target}`:`Plan replacement: ${e.source} → ${e.target_plan_id} (${e.target_count} tasks, representative ${e.target})`)}})},[X,Ze,qe,t,he,e.kind,_,q.cards]),it=j.links.filter(e=>e.kind===`replacement`).length,at=(0,Y.useMemo)(()=>{let t={done:0,running:0,question:0,failed:0,other:0};for(let n of e.tasks)n.status===`done`?t.done++:$f.has(n.status)?t.running++:n.pending_question?t.question++:n.status===`failed`?t.failed++:t.other++;return t},[e.tasks]),ot=at.done,st=at.question+at.failed,ct=e=>{We(t=>Math.max(t,q.cards.find(t=>t.id===e)?.ordinal||1)),R.enter(e)},lt=()=>{let n=e.tasks.find(e=>$f.has(e.status))??e.tasks.find(e=>e.pending_question)??e.tasks.find(e=>e.status===`pending`)??e.tasks.at(-1);n?(ct(q.cards.filter(e=>e.task.id===n.id).at(-1).id),Xe(``)):Xe(t?`发送一个目标,地图就会开始生长`:`Send a goal to start your map`)},ut=()=>{let t=e.tasks.find(e=>e.pending_question)??e.tasks.find(e=>e.status===`failed`);t&&ct(q.cards.filter(e=>e.task.id===t.id).at(-1).id)};(0,Y.useEffect)(()=>{let e=e=>{if(!(e.defaultPrevented||e.metaKey||e.ctrlKey||e.altKey||e.isComposing)&&!e.target?.closest(`input, textarea, select, [contenteditable]`)){if(e.key===`/`)e.preventDefault(),L.current?.querySelector(`.map-search input`)?.focus();else if(e.key===`f`||e.key===`F`)R.fit();else if((e.key===`ArrowRight`||e.key===`ArrowLeft`)&&R.detailed&&R.focusId){let t=q.cards.filter(e=>Ze.has(e.id)),n=t.findIndex(e=>e.id===R.focusId);if(n<0)return;let r=t[n+(e.key===`ArrowRight`?1:-1)];r&&(e.preventDefault(),R.enter(r.id))}}};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[R.fit,R.enter,R.detailed,R.focusId,q.cards,Ze]);let dt=(0,Y.useMemo)(()=>({artifacts:v.artifacts,onOpenArtifact:v.onOpenArtifact}),[v.artifacts,v.onOpenArtifact]);return(0,J.jsx)(zp.Provider,{value:Oe,children:(0,J.jsxs)(Bp.Provider,{value:dt,children:[(0,J.jsx)(`div`,{className:`map-progress-line`,role:`progressbar`,"aria-label":t?`已完成任务`:`Completed tasks`,"aria-valuemin":0,"aria-valuemax":e.tasks.length||1,"aria-valuenow":ot,children:(0,J.jsx)(`span`,{style:{width:`${e.tasks.length?ot/e.tasks.length*100:0}%`}})}),(0,J.jsxs)(`div`,{className:`map-summary`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`span`,{className:`map-summary-value`,title:q.cards.length>j.tasks.length?`${q.cards.length} ${t?`张卡片`:`cards`}`:void 0,children:e.tasks.length}),(0,J.jsx)(`span`,{children:t?`个任务`:`tasks`}),e.tasks.length>0&&(0,J.jsx)(`span`,{className:`map-progress-strip`,role:`img`,"aria-label":t?`已完成 ${at.done},进行中 ${at.running},值得关注 ${st}`:`${at.done} completed, ${at.running} running, ${st} need attention`,children:[`done`,`running`,`question`,`failed`,`other`].map(e=>at[e]>0&&(0,J.jsx)(`i`,{className:`seg-${e}`,style:{flexGrow:at[e]}},e))}),(0,J.jsxs)(`span`,{className:`map-count-chip is-done`,children:[(0,J.jsx)(T,{size:13}),(0,J.jsx)(`strong`,{children:ot}),(0,J.jsx)(`span`,{children:t?`已完成`:`completed`})]}),at.running>0&&(0,J.jsxs)(`span`,{className:`map-count-chip is-running`,children:[(0,J.jsx)(`strong`,{children:at.running}),(0,J.jsx)(`span`,{children:t?`进行中`:`running`})]}),st>0&&(0,J.jsxs)(`button`,{type:`button`,className:`map-count-chip map-attention-jump`,onClick:ut,title:t?`跳到需要你处理的任务`:`Jump to the task waiting on you`,children:[(0,J.jsx)(`span`,{className:`map-attention-dot`}),(0,J.jsx)(`strong`,{children:st}),(0,J.jsx)(`span`,{children:t?`值得关注`:`need attention`})]})]}),n.pending?(0,J.jsxs)(`span`,{className:`map-live-phase`,children:[(0,J.jsx)(`i`,{}),t?`正在处理消息`:`Processing your message`]}):_?(0,J.jsx)(`span`,{className:`map-paused-label`,children:e.tasks.length>0&&ot===e.tasks.length?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(T,{size:13}),t?`已完成`:`Completed`]}):e.tasks.some(e=>$f.has(e.status)||e.status===`pending`)?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(M,{size:13}),t?`已暂停`:`Paused`]}):t?`就绪`:`Ready`}):r&&(0,J.jsxs)(`span`,{className:`map-live-phase`,children:[(0,J.jsx)(`i`,{}),{planner:`Planner`,manager:`Manager`,engineer:`Engineer`,reviewer:`Reviewer`}[r]||r]}),(0,J.jsx)(`span`,{className:`map-summary-note`,children:t?`滚轮缩放 · 点击任务深入 · / 搜索 · F 全览`:`Scroll to zoom · click a task to explore · / search · F fit`})]}),(0,J.jsx)(Im,{events:e.events,zh:t}),e.kind===`live`&&(0,J.jsxs)(`div`,{className:`map-workspace-actions`,children:[(0,J.jsxs)(`button`,{type:`button`,"aria-expanded":x,onClick:()=>{S(e=>!e),b(!1)},children:[(0,J.jsx)(ce,{size:15}),t?`对话`:`Conversation`]}),(0,J.jsxs)(`button`,{type:`button`,"aria-expanded":y,onClick:()=>{b(e=>!e),S(!1)},children:[(0,J.jsx)(`i`,{"data-active":!!r||n.pending}),t?`Agent 动态`:`Agent activity`]}),(0,J.jsxs)(`button`,{type:`button`,className:`map-delivery-toggle`,disabled:!v.deliveryCount,onClick:v.onOpenDelivery,children:[(0,J.jsx)(E,{size:15}),t?`交付成果`:`Deliveries`,v.deliveryCount>0&&(0,J.jsx)(`span`,{children:v.deliveryCount})]})]}),e.kind===`live`&&!m&&(0,J.jsx)(D,{questions:s.pending_questions??[],backlog:s.backlog,onAnswer:v.onAnswer,onLocate:ut}),(0,J.jsx)(`div`,{className:`map-workspace`,children:(0,J.jsxs)(`div`,{ref:L,className:`map-canvas-wrap`,"data-focused":!!R.focusId,"data-detailed":R.detailed,"data-fitted":ee,children:[x&&(0,J.jsx)(fe,{events:v.conversationEvents,connected:v.connected,pending:n.pending,artifacts:v.artifacts,zh:t,onClose:()=>S(!1),onOpenArtifact:v.onOpenArtifact,onOpenDelivery:v.onOpenReceipt}),y&&e.kind===`live`&&(0,J.jsx)(`aside`,{className:`map-agent-drawer nowheel nodrag nopan`,children:(0,J.jsx)(B,{view:s.mission_view,roles:s.roles,events:c,taskId:G?.data.task.id||s.mission_view?.mission.id||void 0,paused:_&&!n.pending,onClose:()=>b(!1)})}),C&&!m&&(0,J.jsx)(_e,{flight:C,canvas:L,zh:t,historical:n.historical,onReveal:t=>{e.tasks.some(e=>e.id===t)&&R.fit()},onLand:e=>w(t=>t?.id===e?{...t,landed:!0}:t),onFinish:e=>w(t=>t?.id===e?null:t)}),(0,J.jsxs)(`div`,{className:`map-canvas-toolbar nowheel`,children:[(0,J.jsxs)(`label`,{className:`map-search`,children:[(0,J.jsx)(ue,{size:14}),(0,J.jsx)(`input`,{"aria-label":t?`搜索地图任务`:`Search map tasks`,placeholder:t?`搜索任务…`:`Find a task…`,title:t?`Enter 逐个跳转匹配`:`Enter jumps through matches`,value:Le,onChange:e=>Re(e.target.value),onKeyDown:e=>{e.key===`Enter`&&Be.length?(ct(Be[Ve%Be.length].id),He(e=>e+1)):e.key===`Escape`&&Le&&(e.stopPropagation(),Re(``))}}),Le&&(0,J.jsx)(`span`,{className:`map-search-count`,"aria-live":`polite`,children:Be.length?`${Ve%Be.length+1}/${Be.length}`:t?`无匹配`:`0 found`})]}),(0,J.jsxs)(`button`,{onClick:lt,title:t?`定位当前或最近任务`:`Locate current or latest task`,children:[(0,J.jsx)(se,{size:15}),(0,J.jsx)(`span`,{children:t?`定位当前`:`Locate current`})]}),(0,J.jsx)(`button`,{onClick:R.fit,title:t?`适配全图`:`Fit map`,"aria-label":`Fit map`,children:(0,J.jsx)(H,{size:15})}),R.detailed&&(0,J.jsxs)(`button`,{onClick:R.back,className:`map-back-button`,"aria-label":`Return to map`,children:[(0,J.jsx)(K,{size:14}),(0,J.jsx)(`span`,{children:t?`返回全图`:`Overview`})]})]}),Ye&&(0,J.jsx)(`div`,{className:`map-feedback`,role:`status`,children:Ye}),R.detailed&&G&&G.data.partCount>1&&(0,J.jsxs)(`nav`,{className:`map-part-switcher nowheel`,"aria-label":t?`切换任务部分`:`Switch task part`,children:[(0,J.jsx)(`button`,{"aria-label":t?`上一部分`:`Previous part`,disabled:!G.data.previousId,onClick:()=>G.data.previousId&&R.enter(G.data.previousId),children:(0,J.jsx)(ne,{size:15})}),(0,J.jsxs)(`span`,{children:[G.data.part,` / `,G.data.partCount]}),(0,J.jsx)(`button`,{"aria-label":t?`下一部分`:`Next part`,disabled:!G.data.nextId,onClick:()=>G.data.nextId&&R.enter(G.data.nextId),children:(0,J.jsx)(u,{size:15})})]}),j.tasks.length===0?(0,J.jsxs)(`div`,{className:`map-empty`,children:[(0,J.jsx)(l,{size:36}),(0,J.jsx)(`h3`,{children:t?`把一个目标,变成可见的成果`:`Turn a goal into a visible result`}),(0,J.jsx)(`p`,{children:m?t?`尚无任务记录。`:`No task records are available.`:t?`描述你想完成的事情,看 Argus 规划、执行、审查,最后在这里交付。`:`Describe your goal. Watch Argus plan, build, review, and deliver here.`}),!m&&(0,J.jsx)(`div`,{className:`map-starters`,children:(t?[[`交互实验`,`做一个交互式实验室,用动画展示 Dijkstra 和 A* 怎样寻找最短路径。让我能画障碍、单步播放、比较探索范围,并验证两个算法的结果一致。`],[`数据洞察`,`用一组可复现的模拟数据,做一个辛普森悖论交互演示。让我能切换整体和分组视角,看结论怎样反转,附上验证过程。`],[`产品原型`,`做一个精致的个人旅行规划网页。我能调整预算和出行天数,比较三种行程方案,并将选中的方案导出。让手机上也方便操作。`]]:[[`Interactive lab`,`Build an interactive Dijkstra vs A* pathfinding lab with editable obstacles, step-by-step animation, and correctness checks.`],[`Data insights`,`Create an interactive Simpson’s paradox demo using reproducible synthetic data, with aggregate and grouped views and validation.`],[`Product prototype`,`Build a polished travel planner. Let me adjust budget and duration, compare three itineraries, and export my choice. Make it easy to use on a phone.`]]).map(([e,t])=>(0,J.jsxs)(`button`,{type:`button`,onClick:()=>{n.onChange(t),requestAnimationFrame(()=>L.current?.querySelector(`textarea`)?.focus())},children:[e,` ↗`]},e))})]}):(0,J.jsxs)(pf,{nodes:nt,edges:rt,nodeTypes:Nm,edgeTypes:Pm,onNodesChange:I,onMove:R.onMove,defaultViewport:Qp,minZoom:.035,maxZoom:3.5,nodesDraggable:!1,nodesFocusable:!1,nodesConnectable:!1,edgesReconnectable:!1,zoomOnScroll:!1,zoomOnPinch:!0,zoomOnDoubleClick:!1,deleteKeyCode:null,selectionKeyCode:null,onlyRenderVisibleElements:!0,proOptions:{hideAttribution:!0},children:[(0,J.jsx)(Tf,{variant:xf.Dots,gap:88,size:3,color:`var(--map-dot)`}),(0,J.jsx)(Pf,{orientation:`horizontal`,showInteractive:!1,onFitView:R.fit,fitViewOptions:{padding:.16,maxZoom:.27,minZoom:.035,duration:R.reducedMotion?0:320}}),(0,J.jsx)(Yf,{nodeColor:e=>e.type===`branch`?`#c5d4e2`:Fm[ep(e.data.task)]??`#a7bfd9`,maskColor:`var(--map-minimap-mask)`,maskStrokeColor:`#85aacf`,maskStrokeWidth:2,onClick:(e,t)=>R.navigate(t),pannable:!0,zoomable:!0,ariaLabel:t?`地图导航预览`:`Map navigation preview`})]}),(0,J.jsxs)(`div`,{className:`map-legend nowheel`,children:[(0,J.jsxs)(`span`,{title:t?`同一会话中的时间归属,不是执行依赖`:`Chronological context, not execution dependencies`,children:[(0,J.jsx)(`b`,{className:`dashed`}),t?`内容关联`:`Related work`]}),(0,J.jsxs)(`span`,{children:[(0,J.jsx)(`b`,{}),t?`任务依赖`:`Dependency`]}),(0,J.jsxs)(`button`,{className:qe?``:`is-muted`,onClick:()=>Je(e=>!e),"aria-pressed":qe,disabled:it===0,"aria-label":`Toggle plan replacements`,children:[(0,J.jsx)(`b`,{className:`replacement`}),t?`计划替代`:`Plan changes`,it?` · ${it}`:``]})]}),!m&&(0,J.jsx)(dm,{...n,pendingLabel:f,dispatchStatus:C?.result?.type===`task`?C.landed||n.historical?`task`:`launching`:C?.result?.outcome,onSend:ve,onCancel:be,overview:!R.detailed}),we&&!m&&(0,J.jsxs)(`div`,{className:`map-context-menu`,role:`menu`,style:{left:we.x,top:we.y},children:[(0,J.jsx)(`button`,{role:`menuitem`,onClick:()=>{Ce(we.ref),Te(null)},children:t?`引用`:`Reference`}),e.kind===`live`&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`button`,{role:`menuitem`,onClick:()=>{Me(``),Ae({ref:we.ref,x:we.x,y:we.y}),Te(null)},children:t?`添加批注`:`Add a note`}),(0,J.jsx)(`button`,{role:`menuitem`,onClick:()=>{n.onRouteOverrideChange?.(`task`),Ce(we.ref),Te(null)},children:t?`从这里展开`:`Branch from here`})]})]}),ke&&!m&&(0,J.jsxs)(`div`,{className:`map-note-editor nodrag nopan`,style:{left:Math.min(window.innerWidth-320,ke.x),top:Math.min(window.innerHeight-240,ke.y)},children:[(0,J.jsx)(`small`,{children:t?`批注《${ke.ref.task_title}》`:`Note on “${ke.ref.task_title}”`}),(0,J.jsx)(`textarea`,{autoFocus:!0,maxLength:2e3,value:je,onChange:e=>Me(e.target.value),placeholder:t?`写下你的观察,Argus 在下个规划周期会读到`:`Your observation; Argus reads it next planning cycle`}),Ne&&(0,J.jsx)(`small`,{className:`map-note-error`,children:t?`没有保存上,稍后再试;草稿还在`:`Not saved; try again — the draft is kept`}),(0,J.jsxs)(`div`,{className:`map-note-actions`,children:[(0,J.jsx)(`button`,{onClick:()=>Ae(null),children:t?`取消`:`Cancel`}),(0,J.jsx)(`button`,{className:`is-primary`,disabled:!je.trim(),onClick:()=>void Fe(),children:t?`保存`:`Save`})]})]}),(j.cyclic||j.missing>0)&&(0,J.jsx)(`div`,{className:`map-graph-warning`,children:j.cyclic?t?`检测到循环引用,保留原始连线。`:`Cyclic references retained.`:`${j.missing} ${t?`个依赖不在当前记录范围内`:`dependencies outside the available history`}`})]})}),e.kind!==`live`&&(0,J.jsxs)(`div`,{className:`map-playback`,children:[(0,J.jsx)(`button`,{"aria-label":Ge?`Pause reveal`:`Play reveal`,onClick:()=>{Ue>=j.tasks.length&&We(1),Ke(e=>!e)},children:Ge?(0,J.jsx)(M,{size:14}):(0,J.jsx)(d,{size:14})}),(0,J.jsx)(`button`,{"aria-label":`Restart reveal`,onClick:()=>{Ke(!1),We(1),R.back()},children:(0,J.jsx)(le,{size:13})}),(0,J.jsx)(`span`,{children:t?`逐卡展开`:`Reveal cards`}),(0,J.jsx)(`input`,{"aria-label":`Visible task count`,type:`range`,min:Math.min(1,j.tasks.length),max:j.tasks.length,value:Ue,onChange:e=>{Ke(!1),We(Number(e.target.value))}}),(0,J.jsxs)(`span`,{className:`map-count`,children:[Ue,` / `,j.tasks.length]}),(0,J.jsx)(`button`,{"aria-label":`Reveal next card`,disabled:Ue>=j.tasks.length,onClick:()=>We(e=>Math.min(j.tasks.length,e+1)),children:(0,J.jsx)(u,{size:14})}),(0,J.jsx)(`small`,{children:t?`时间顺序`:`Chronological order`})]})]})})}var Rm=(0,Y.memo)(function({snapshot:e,events:t,managerSteps:n=[],draft:r,onDraftChange:i,onSend:s,pending:c,onCancel:u,focusSignal:d,readOnly:f=!1,onOpenSettings:m,routeOverride:h,onRouteOverrideChange:g,conversationEvents:_,connected:v,artifacts:y,deliveryCount:b,onOpenDelivery:x,onOpenReceipt:S,onOpenArtifact:C,onAnswer:w}){let{locale:T}=G(),E=T===`zh-CN`,[D,O]=(0,Y.useState)([]),k=(0,Y.useRef)(r);k.current=r;let A=(0,Y.useRef)(!0);(0,Y.useEffect)(()=>(A.current=!0,()=>{A.current=!1}),[]);let j=(0,Y.useCallback)(async(e,t=[],n)=>{let r=await s(e,t,r=>{A.current&&(r.type===`settled`&&r.outcome===`error`&&!k.current.trim()&&(i(e),O(e=>e.length?e:t)),n?.(r))});return r&&A.current&&(k.current===e&&i(``),O(e=>e.filter(e=>!t.includes(e)))),r},[s,i]),[M,N]=(0,Y.useState)(()=>new URLSearchParams(window.location.search).get(`dataset`)||ee(`argus.map.source.v1`)||`live`),P=o({queryKey:[`map-datasets`],queryFn:({signal:e})=>p.mapDatasets(e),staleTime:1/0}),F=o({queryKey:[`map-dataset`,M],queryFn:({signal:e})=>p.mapDataset(M,e),enabled:M!==`live`,staleTime:1/0,retry:!1}),I=a(),R=`argus.map.history.v1:`+e.session.id,[z,B]=(0,Y.useState)(()=>Em(ee(R))),[V,te]=(0,Y.useState)(!1),H=o({queryKey:[`map-info`,e.session.id],queryFn:({signal:t})=>p.mapInfo(e.session.id,t),enabled:M===`live`,staleTime:6e4}),U=z??(H.data&&!H.data.requires_choice?{mode:`full`}:null);(0,Y.useEffect)(()=>{if(!z&&H.data&&!H.data.requires_choice){let e={mode:`full`};B(e),L(R,JSON.stringify(e))}},[H.data,z,R]);let K=M!==`live`||!!U&&U.mode!==`off`&&!V,ne=[`map-live`,e.session.id,U?.mode,U?.since,U?.eventSince,U?.taskId],ie=JSON.stringify([M,e.session.id,T,U]),ae=e=>{B(e),L(R,JSON.stringify(e)),te(!1)},oe=o({queryKey:ne,queryFn:async({signal:t})=>{let n=I.getQueryData(ne),r=U?.mode===`full`?await p.mapHistory(e.session.id,t,n?.history_cursor,n?.cursor):await p.liveMap(e.session.id,t,n?.cursor,U||void 0);return Dm(I.getQueryData(ne),r)},enabled:M===`live`&&K,staleTime:1/0,gcTime:72e5,refetchOnMount:`always`,refetchInterval:t=>Om(K,t.state.data,e)}),se=M===`live`&&km(e),ce=t.filter(e=>e.run_label!==`map-summary`&&/^(life\.(mission\.|phase\.|planner\.task_added)|round\.|agent\.message|team\.|idea\.portfolio\.)/.test(String(e.type))).at(-1),le=JSON.stringify([ce?.ts,ce?.event_id||ce?.id,ce?.revision,ce?.updated_ts,ce?.status,e.backlog,se]),q=(0,Y.useRef)(null),ue=(0,Y.useRef)(0),fe=(0,Y.useRef)(null);(0,Y.useEffect)(()=>{let e=fe.current;if(!e)return;let t=()=>{ue.current=Date.now()+900},n=e=>{e.buttons&&t()};return e.addEventListener(`wheel`,t,{passive:!0}),e.addEventListener(`pointerdown`,t),e.addEventListener(`pointermove`,n),()=>{e.removeEventListener(`wheel`,t),e.removeEventListener(`pointerdown`,t),e.removeEventListener(`pointermove`,n)}},[]),(0,Y.useEffect)(()=>{if(M!==`live`||!K||q.current)return;let t=()=>{let n=ue.current-Date.now();if(n>0){q.current=setTimeout(t,n+120);return}q.current=null,I.invalidateQueries({queryKey:[`map-live`,e.session.id]})};q.current=setTimeout(t,650)},[le,M,e.session.id,I,K]),(0,Y.useEffect)(()=>()=>{q.current&&clearTimeout(q.current),q.current=null},[M,e.session.id,K]);let pe=M===`live`?oe.data:F.data,me=(0,Y.useMemo)(()=>({conversationEvents:_,connected:v,artifacts:y,deliveryCount:b,onOpenDelivery:x,onOpenReceipt:S,onOpenArtifact:C,onAnswer:w}),[_,v,y,b,x,S,C,w]),X=(0,Y.useMemo)(()=>({routeOverride:h,onRouteOverrideChange:g,value:r,onChange:i,onSend:j,attachments:D,onAttachmentsChange:O,pending:c,onCancel:u,focusSignal:d,sessionName:e.session.display_name||e.session.id,historical:M!==`live`,zh:E}),[h,g,r,i,j,D,c,u,d,e.session.display_name,e.session.id,M,E]),he=e=>{N(e),L(`argus.map.source.v1`,e);let t=new URL(window.location.href);t.searchParams.set(`dataset`,e),window.history.replaceState(null,``,t)};return(0,J.jsxs)(`section`,{ref:fe,className:`argus-map`,"aria-label":E?`研究进度地图`:`Research progress map`,children:[(0,J.jsxs)(`header`,{className:`map-header`,children:[(0,J.jsx)(`div`,{className:`map-heading-icon`,children:(0,J.jsx)(l,{size:20})}),(0,J.jsxs)(`div`,{className:`map-heading`,children:[(0,J.jsx)(`div`,{className:`map-eyebrow`,children:`ARGUS / RESEARCH MAP`}),(0,J.jsx)(`h1`,{children:E?`研究地图`:`Research map`})]}),(0,J.jsxs)(`div`,{className:`map-header-actions`,children:[!f&&m&&(0,J.jsx)(`button`,{type:`button`,onClick:m,className:`map-settings`,"aria-label":E?`地图模型设置`:`Map model settings`,title:E?`地图模型设置`:`Map model settings`,children:(0,J.jsx)(de,{size:16})}),M===`live`&&H.data&&(0,J.jsx)(`button`,{type:`button`,className:`map-scope-button`,onClick:()=>te(!0),children:E?`加载范围`:`History range`}),(0,J.jsxs)(`span`,{className:`map-source-badge`,children:[(0,J.jsx)(`span`,{}),M===`live`?E?`当前会话`:`Current session`:pe?.kind===`synthetic`?E?`人工示例`:`Synthetic example`:pe?.kind===`demo`?E?`历史演示`:`Recorded demo`:E?`历史记录`:`Historical records`]})]})]}),(0,J.jsxs)(`div`,{className:`map-dataset-bar`,children:[(0,J.jsx)(re,{size:15}),(0,J.jsxs)(`select`,{"aria-label":E?`地图数据来源`:`Map data source`,value:M,onChange:e=>he(e.target.value),children:[(0,J.jsxs)(`option`,{value:`live`,children:[E?`当前会话`:`Current session`,` ·`,` `,e.session.display_name]}),!P.data?.datasets.some(e=>e.id===M)&&M!==`live`&&(0,J.jsx)(`option`,{value:M,children:M}),P.data?.datasets.map(e=>(0,J.jsxs)(`option`,{value:e.id,children:[e.title,` · `,e.task_count]},e.id))]}),pe?.captured_at&&(0,J.jsxs)(`span`,{className:`map-capture`,children:[(0,J.jsx)(W,{size:12}),new Date(pe.captured_at).toLocaleDateString()]})]}),M===`live`&&H.data&&(0,J.jsx)(Tm,{open:V||!U&&H.data.requires_choice,info:H.data,zh:E,readOnly:f,onChoose:ae}),M===`live`&&H.isError&&(0,J.jsxs)(`div`,{className:`map-data-error`,children:[E?`暂时无法检查历史记录。`:`Could not check session history.`,(0,J.jsx)(`button`,{onClick:()=>void H.refetch(),children:E?`重试`:`Retry`})]}),K&&pe?.history_loading&&(0,J.jsxs)(`div`,{className:`map-history-progress`,role:`status`,children:[E?`正在分批加载历史记录`:`Loading history in pages`,pe.history_progress&&` · ${(pe.history_progress.loaded_bytes/1024/1024).toFixed(1)} / ${(pe.history_progress.total_bytes/1024/1024).toFixed(1)} MB`,(0,J.jsx)(`button`,{onClick:()=>te(!0),children:E?`更改范围`:`Change range`})]}),K&&pe&&(M===`live`?oe.isError:F.isError)&&(0,J.jsxs)(`div`,{className:`map-data-error`,role:`status`,children:[E?`暂时无法更新,已保留加载的地图。`:`Updates are unavailable. Your loaded map is preserved.`,(0,J.jsx)(`button`,{onClick:()=>void(M===`live`?oe.refetch():F.refetch()),children:E?`重试`:`Retry`})]}),P.isError&&(0,J.jsxs)(`div`,{className:`map-data-error`,children:[E?`历史记录列表暂时无法读取,可切换当前会话或重试。`:`Historical maps are unavailable. Open the current session or retry.`,(0,J.jsx)(`button`,{onClick:()=>void P.refetch(),children:E?`重试`:`Retry`})]}),K?(M===`live`?oe.isError:F.isError)&&!pe?(0,J.jsxs)(`div`,{className:`map-empty`,children:[(0,J.jsx)(`h3`,{children:E?`地图暂时无法读取`:`Map unavailable`}),(0,J.jsx)(`p`,{children:String(M===`live`?oe.error:F.error)}),(0,J.jsx)(`button`,{onClick:()=>void(M===`live`?oe.refetch():F.refetch()),children:E?`重试`:`Retry`})]}):pe?(0,J.jsx)(lf,{children:(0,J.jsx)(Lm,{data:pe,actions:me,snapshot:e,events:t,pendingLabel:n.at(-1)?.detail||n.at(-1)?.label,viewKey:ie,paused:se,sessionId:e.session.id,zh:E,readOnly:f,activePhase:M===`live`&&!se?e.roles.find(e=>e.active)?.role:void 0,composer:X})},ie):(0,J.jsxs)(`div`,{className:`map-empty is-loading`,"aria-busy":`true`,children:[(0,J.jsxs)(`div`,{className:`map-ghosts`,"aria-hidden":!0,children:[(0,J.jsx)(`i`,{}),(0,J.jsx)(`i`,{}),(0,J.jsx)(`i`,{})]}),E?`正在载入地图…`:`Loading map…`]}):(0,J.jsxs)(`div`,{className:`map-empty`,children:[(0,J.jsx)(`h3`,{children:E?`地图尚未开启`:`Map is not enabled`}),(0,J.jsx)(`p`,{children:H.isPending?E?`正在检查历史记录规模…`:`Checking history size…`:E?`选择加载范围后查看研究进度。`:`Choose a history range to view research progress.`}),H.data&&(0,J.jsx)(`button`,{onClick:()=>te(!0),children:E?`选择加载范围`:`Choose history range`})]})]})});export{Rm as MapPanel,Im as MapTeamProgress}; \ No newline at end of file diff --git a/frontend/web/dist/assets/ResearchWorkbenchPanel-DZNe62z_.js b/frontend/web/dist/assets/ResearchWorkbenchPanel-DZNe62z_.js new file mode 100644 index 000000000..e3d9a55bd --- /dev/null +++ b/frontend/web/dist/assets/ResearchWorkbenchPanel-DZNe62z_.js @@ -0,0 +1,10 @@ +import{r as e}from"./rolldown-runtime-hePW80VL.js";import{A as t,k as n}from"./icons-2gFhc0pq.js";import{i as r,n as i,t as a}from"./query-CGMsBv4s.js";import{n as o,r as s,t as c}from"./play-DT9RZkLC.js";import{C as l,D as u,H as d,O as f,T as p,U as m,V as h,W as g,f as _,g as v,h as y,i as b,m as x,n as S,p as C,t as w,w as T,x as E,y as D,z as O}from"./index-BmfdUynJ.js";var k=f(`ArrowRight`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`m12 5 7 7-7 7`,key:`xquz4c`}]]),A=f(`Circle`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),j=f(`CodeXml`,[[`path`,{d:`m18 16 4-4-4-4`,key:`1inbqp`}],[`path`,{d:`m6 8-4 4 4 4`,key:`15zrgr`}],[`path`,{d:`m14.5 4-5 16`,key:`e7oirm`}]]),M=f(`FileCode2`,[[`path`,{d:`M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4`,key:`1pf5j1`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`path`,{d:`m5 12-3 3 3 3`,key:`oke12k`}],[`path`,{d:`m9 18 3-3-3-3`,key:`112psh`}]]),N=f(`File`,[[`path`,{d:`M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z`,key:`1rqfz7`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}]]),ee=f(`Files`,[[`path`,{d:`M20 7h-3a2 2 0 0 1-2-2V2`,key:`x099mo`}],[`path`,{d:`M9 18a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h7l4 4v10a2 2 0 0 1-2 2Z`,key:`18t6ie`}],[`path`,{d:`M3 7.6v12.8A1.6 1.6 0 0 0 4.6 22h9.8`,key:`1nja0z`}]]),te=f(`FlaskConical`,[[`path`,{d:`M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2`,key:`18mbvz`}],[`path`,{d:`M6.453 15h11.094`,key:`3shlmq`}],[`path`,{d:`M8.5 2h7`,key:`csnxdl`}]]),P=f(`FolderKanban`,[[`path`,{d:`M4 20h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.93a2 2 0 0 1-1.66-.9l-.82-1.2A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13c0 1.1.9 2 2 2Z`,key:`1fr9dc`}],[`path`,{d:`M8 10v4`,key:`tgpxqk`}],[`path`,{d:`M12 10v2`,key:`hh53o1`}],[`path`,{d:`M16 10v6`,key:`1d6xys`}]]),ne=f(`Folder`,[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]),re=f(`Gauge`,[[`path`,{d:`m12 14 4-4`,key:`9kzdfg`}],[`path`,{d:`M3.34 19a10 10 0 1 1 17.32 0`,key:`19p75a`}]]),F=f(`Github`,[[`path`,{d:`M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4`,key:`tonef`}],[`path`,{d:`M9 18c-4.51 2-5-2-7-2`,key:`9comsn`}]]),ie=f(`LockKeyhole`,[[`circle`,{cx:`12`,cy:`16`,r:`1`,key:`1au0dj`}],[`rect`,{x:`3`,y:`10`,width:`18`,height:`12`,rx:`2`,key:`6s8ecr`}],[`path`,{d:`M7 10V7a5 5 0 0 1 10 0v3`,key:`1pqi11`}]]),ae=f(`Radio`,[[`path`,{d:`M4.9 19.1C1 15.2 1 8.8 4.9 4.9`,key:`1vaf9d`}],[`path`,{d:`M7.8 16.2c-2.3-2.3-2.3-6.1 0-8.5`,key:`u1ii0m`}],[`circle`,{cx:`12`,cy:`12`,r:`2`,key:`1c9p78`}],[`path`,{d:`M16.2 7.8c2.3 2.3 2.3 6.1 0 8.5`,key:`1j5fej`}],[`path`,{d:`M19.1 4.9C23 8.8 23 15.1 19.1 19`,key:`10b0cb`}]]),I=f(`Server`,[[`rect`,{width:`20`,height:`8`,x:`2`,y:`2`,rx:`2`,ry:`2`,key:`ngkwjq`}],[`rect`,{width:`20`,height:`8`,x:`2`,y:`14`,rx:`2`,ry:`2`,key:`iecqi9`}],[`line`,{x1:`6`,x2:`6.01`,y1:`6`,y2:`6`,key:`16zg32`}],[`line`,{x1:`6`,x2:`6.01`,y1:`18`,y2:`18`,key:`nzw8ys`}]]),oe=f(`SquareTerminal`,[[`path`,{d:`m7 11 2-2-2-2`,key:`1lz0vl`}],[`path`,{d:`M11 13h4`,key:`1p7l4v`}],[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}]]),se=f(`TimerReset`,[[`path`,{d:`M10 2h4`,key:`n1abiw`}],[`path`,{d:`M12 14v-4`,key:`1evpnu`}],[`path`,{d:`M4 13a8 8 0 0 1 8-7 8 8 0 1 1-5.3 14L4 17.6`,key:`1ts96g`}],[`path`,{d:`M9 17H4v5`,key:`8t5av`}]]),ce=f(`TriangleAlert`,[[`path`,{d:`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`,key:`wmoenq`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),le=f(`UserRound`,[[`circle`,{cx:`12`,cy:`8`,r:`5`,key:`1hypcn`}],[`path`,{d:`M20 21a8 8 0 0 0-16 0`,key:`rfgkzh`}]]),ue=f(`Workflow`,[[`rect`,{width:`8`,height:`8`,x:`3`,y:`3`,rx:`2`,key:`by2w9f`}],[`path`,{d:`M7 11v4a2 2 0 0 0 2 2h4`,key:`xkn7yn`}],[`rect`,{width:`8`,height:`8`,x:`13`,y:`13`,rx:`2`,key:`1cgmvn`}]]),L=e(t(),1),de=12e3;function R(e=!1){let t={...h()};return e&&(t[`Content-Type`]=`application/json`),t}async function z(e,t={}){await m();let n={...t,headers:{...R(!!t.body),...t.headers??{}},cache:`no-store`},r=String(t.method??`GET`).toUpperCase(),i=async n=>{if(!n.ok){let r=await n.text().catch(()=>``),i=r;try{i=JSON.parse(r).detail??r}catch{}throw Error(i||`${t.method??`GET`} ${e} failed (${n.status})`)}return await n.json()};return r===`GET`?g(e,n,de,i):i(await fetch(e,n))}var B=(e,t=``)=>`/api/projects/${encodeURIComponent(e)}${t}`,fe=()=>globalThis.crypto?.randomUUID?.()??`${Date.now()}-${Math.random()}`;function pe(e){let t=e.replaceAll(`\r +`,` +`).split(` + +`),n=t.pop()??``,r=[];return t.forEach(e=>{e.split(` +`).forEach(e=>{if(e.startsWith(`data:`))try{let t=JSON.parse(e.slice(5).trim());r.push(t)}catch{}})}),{frames:r,rest:n}}function me(e,t){let n=String(e.type??``);if(n===`phase`)t.onPhase?.(String(e.label??``),String(e.role??`manager`),String(e.detail??``),e.heartbeat===!0);else if(n===`delta`)t.onDelta?.(String(e.text??``),String(e.fragment_mode??`auto`));else if(n===`done`){let n=e.result??{};return t.onDone?.(n),n}else if(n===`error`)throw Error(String(e.error??`Manager stream failed`));return null}var V={projects:e=>z(`/api/projects`,{signal:e}),snapshot:(e,t)=>z(B(e,`/snapshot?events_limit=40&compact=false`),{signal:t}),status:(e,t)=>z(B(e,`/status`),{signal:t}),events:(e,t=180,n)=>z(B(e,`/events?limit=${t}&view=ui`),{signal:n}).then(e=>e.events),transcript:(e,t=100,n)=>z(B(e,`/transcript?n=${t}`),{signal:n}).then(e=>e.turns),journal:(e,t=80,n)=>z(B(e,`/journal?n=${t}`),{signal:n}).then(e=>e.journal),artifacts:(e,t)=>z(B(e,`/artifacts`),{signal:t}).then(e=>e.artifacts),counterexamples:(e,t)=>z(B(e,`/counterexamples`),{signal:t}),artifact:(e,t,n)=>z(B(e,`/artifact?${new URLSearchParams({path:t})}`),{signal:n}),artifactBlob:async(e,t,n=!1,r)=>{await m();let i=new URLSearchParams({path:t});n&&i.set(`download`,`true`);let a=B(e,`/artifact/raw?${i}`);return g(a,{headers:R(),signal:r,cache:`no-store`},de,async e=>{if(!e.ok)throw Error(`Artifact unavailable (${e.status})`);return e.blob()})},gitDiff:(e,t)=>z(B(e,`/git-diff`),{signal:t}),rewritePrompt:(e,t,n)=>z(B(e,`/prompt/rewrite`),{method:`POST`,body:JSON.stringify({text:t}),signal:n}),note:(e,t)=>z(B(e,`/note`),{method:`POST`,body:JSON.stringify({text:t})}),uploadAttachments:async(e,t,n)=>{await m();let r=new FormData;t.forEach(e=>r.append(`files`,e,e.name));let i=await fetch(B(e,`/attachments`),{method:`POST`,headers:R(),body:r,signal:n});if(!i.ok)throw Error(await i.text()||`attachment upload failed (${i.status})`);return await i.json()},createDaemon:(e,t=``,n=``)=>z(`/api/daemons`,{method:`POST`,body:JSON.stringify({objective:e,name:t,workdir:n,command_id:fe()})}),createFinalReview:(e,t)=>z(B(e,`/reviews/final`),{method:`POST`,body:JSON.stringify(t)}),startDaemon:(e,t)=>z(B(e,`/daemon/start`),{method:`POST`,body:JSON.stringify({command_id:fe(),expected_revision:t})}),stopDaemon:(e,t,n)=>z(B(e,`/daemon/stop`),{method:`POST`,body:JSON.stringify({drain:t,command_id:fe(),expected_revision:n})}),async messageStream(e,t,n={},r,i=[]){await m();let a=B(e,`/message/stream`),o=await fetch(a,{method:`POST`,headers:R(!0),body:JSON.stringify(i.length?{text:t,attachments:i}:{text:t}),signal:r});if(!o.ok){let e=await o.text().catch(()=>``);throw Error(e||`Manager request failed (${o.status})`)}if(!o.body)throw Error(`Manager returned an empty stream`);let s=o.body.getReader(),c=new TextDecoder,l=``,u={};for(;;){let e=await s.read();if(e.done)break;l+=c.decode(e.value,{stream:!0});let t=pe(l);l=t.rest,t.frames.forEach(e=>{let t=me(e,n);t&&(u=t)})}return pe(`${l}\n\n`).frames.forEach(e=>{let t=me(e,n);t&&(u=t)}),u}};function he(e,t,n){let r=!1,i=null,a,o=800,s=()=>{if(r)return;let c=window.location.protocol===`https:`?`wss:`:`ws:`,l=new URLSearchParams({replay:`40`,view:`ui`}),u=d();u&&l.set(`token`,u),i=new WebSocket(`${c}//${window.location.host}${B(e,`/stream`)}?${l}`),i.onopen=()=>{o=800,n(!0)},i.onmessage=e=>{try{t(JSON.parse(String(e.data)))}catch{}},i.onerror=()=>i?.close(),i.onclose=e=>{n(!1),!(r||e.code===4401||e.code===4404)&&(a=window.setTimeout(s,o),o=Math.min(o*1.7,8e3))}};return s(),{close:()=>{r=!0,a&&window.clearTimeout(a),i?.close()}}}var ge={active:[`进行中`,`In progress`],claimed:[`进行中`,`In progress`],in_progress:[`进行中`,`In progress`],running:[`进行中`,`In progress`],working:[`进行中`,`In progress`],pending:[`等待中`,`Waiting`],queued:[`等待中`,`Waiting`],waiting:[`等待中`,`Waiting`],idle:[`等待中`,`Waiting`],accepted:[`已完成`,`Completed`],complete:[`已完成`,`Completed`],completed:[`已完成`,`Completed`],done:[`已完成`,`Completed`],success:[`已完成`,`Completed`],blocked:[`已阻塞`,`Blocked`],failed:[`失败`,`Failed`],error:[`失败`,`Failed`],rejected:[`需要修改`,`Needs changes`],continue:[`需要修改`,`Needs changes`],replan:[`需要重新规划`,`Needs replanning`],skipped:[`已跳过`,`Skipped`],paused:[`已暂停`,`Paused`],stopped:[`已暂停`,`Paused`],cancelled:[`已暂停`,`Paused`],aborted:[`已暂停`,`Paused`],not_started:[`等待中`,`Waiting`],healthy:[`状态正常`,`Healthy`],degraded:[`部分受限`,`Limited`]},_e={manager:[`Manager`,`Manager`],planner:[`Planner`,`Planner`],engineer:[`Engineer`,`Engineer`],reviewer:[`Reviewer`,`Reviewer`],system:[`Argus`,`Argus`],operator:[`你`,`You`],stopped:[`已暂停`,`Paused`],idle:[`等待中`,`Waiting`]},ve={scope:[`研究定义`,`Scope`],research:[`文献与假设`,`Literature and hypotheses`],implementation:[`方法实现`,`Implementation`],experiment:[`实验验证`,`Experiments`],analysis:[`结果分析`,`Analysis`],writing:[`论文写作`,`Writing`],review:[`最终审核`,`Final review`],delivery:[`成果交付`,`Delivery`]},ye={certified:[`阶段已通过`,`Stage approved`],not_certified:[`阶段未通过`,`Stage not approved`],revoked:[`阶段批准已撤回`,`Stage approval revoked`],intentionally_skipped:[`无需阶段审核`,`Stage review not needed`],deferred:[`阶段审核待定`,`Stage review pending`],not_assessed:[`尚未审核阶段`,`Stage not reviewed`]};function be(e,t,n,r){let i=t[String(e??``).toLowerCase()]??n;return r(i[0],i[1])}function H(e,t){return be(e,ge,[`状态已更新`,`Status updated`],t)}function U(e,t){return be(e,_e,[`Argus`,`Argus`],t)}function xe(e,t){return be(e,ve,[`未分阶段`,`Unstaged`],t)}function Se(e,t){return be(e,ye,[`阶段状态已更新`,`Stage status updated`],t)}function W(){let{locale:e}=O();return{locale:e,text:(0,L.useCallback)((t,n)=>e===`zh-CN`?t:n,[e])}}function G(...e){return e.filter(Boolean).join(` `)}function K(e){let t=Math.max(0,Math.floor(Number(e??0)));if(t<60)return`${t}s`;let n=Math.floor(t/86400),r=Math.floor(t%86400/3600),i=Math.floor(t%3600/60);return n?`${n}d ${r}h`:r?`${r}h ${i}m`:`${i}m`}function Ce(e,t){return e?new Date(e*1e3).toLocaleTimeString(t,{hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hour12:!1}):`—`}function we(e){let t=String(e??``).toLowerCase();return/failed|error|blocked|rejected|stalled|dead|abort/.test(t)?`danger`:/warn|waiting|paused|hold|queued|pending|continue/.test(t)?`warn`:/done|complete|completed|accepted|healthy|success|passed/.test(t)?`success`:/run|active|work|claimed|progress|live/.test(t)?`live`:/research|plan|info|ready/.test(t)?`info`:`neutral`}function Te(e){let t=String(e.agent_layer??e.actor??``).toLowerCase();if(t===`main`||t.startsWith(`engineer`))return`engineer`;if(t.startsWith(`review`))return`reviewer`;if(t.startsWith(`plan`))return`planner`;if(t.startsWith(`manager`))return`manager`;let n=String(e.type??``);return/review/.test(n)?`reviewer`:/planner/.test(n)?`planner`:/manager/.test(n)?`manager`:/engineer|round/.test(n)?`engineer`:`system`}function q(e){let t=String(e.action_summary??``).trim();if(t)return t;let n=String(e.title??``).trim();if(n)return n;let r=String(e.kind??``).trim();return r?r.replaceAll(`_`,` `):String(e.type??`event`).split(`.`).slice(-2).join(` · `).replaceAll(`_`,` `)}function Ee(e,t=400){let n=String(e.text??e.reason??e.summary??e.detail??``).trim();return n?n.length>t?`${n.slice(0,t)}…`:n:``}var J=n();function Y({children:e,tone:t=`neutral`,dot:n=!1,className:r}){return(0,J.jsxs)(`span`,{className:G(`badge`,`badge--${t}`,r),children:[n?(0,J.jsx)(`span`,{className:G(`badge__dot`,t===`live`&&`is-pulsing`)}):null,e]})}function De({title:e,eyebrow:t,action:n,children:r,className:i,bodyClassName:a}){return(0,J.jsxs)(`section`,{className:G(`panel`,i),children:[e||t||n?(0,J.jsxs)(`header`,{className:`panel__header`,children:[(0,J.jsxs)(`div`,{className:`panel__heading`,children:[t?(0,J.jsx)(`div`,{className:`eyebrow`,children:t}):null,e?(0,J.jsx)(`div`,{className:`panel__title`,children:e}):null]}),n?(0,J.jsx)(`div`,{className:`panel__action`,children:n}):null]}):null,(0,J.jsx)(`div`,{className:G(`panel__body`,a),children:r})]})}function X({icon:e=N,title:t,description:n,action:r}){return(0,J.jsxs)(`div`,{className:`empty-state`,children:[(0,J.jsx)(`span`,{className:`empty-state__icon`,children:(0,J.jsx)(e,{size:19})}),(0,J.jsx)(`div`,{className:`empty-state__title`,children:t}),n?(0,J.jsx)(`p`,{children:n}):null,r?(0,J.jsx)(`div`,{className:`empty-state__action`,children:r}):null]})}function Oe({label:e}){let{text:t}=W();return(0,J.jsxs)(`span`,{className:`spinner`,role:`status`,children:[(0,J.jsx)(D,{size:15,className:`spin`}),` `,e||t(`加载中`,`Loading`)]})}function ke({events:e,limit:t=24,empty:n,dense:r=!1}){let{locale:i,text:a}=W(),o=e.slice(-t).reverse();return o.length?(0,J.jsx)(`div`,{className:G(`event-list`,r&&`event-list--dense`),children:o.map((e,t)=>{let n=Te(e),o=q(e),s=Ee(e,r?180:480),c=we(String(e.status??e.kind??e.type??``));return(0,J.jsxs)(`article`,{className:`event-row`,children:[(0,J.jsx)(`div`,{className:G(`event-row__marker`,`event-row__marker--${c}`)}),(0,J.jsxs)(`div`,{className:`event-row__content`,children:[(0,J.jsxs)(`div`,{className:`event-row__meta`,children:[(0,J.jsx)(`span`,{className:G(`role-label`,`role-label--${n}`),children:U(n,a)}),(0,J.jsx)(`time`,{children:Ce(e.ts,i)})]}),(0,J.jsx)(`div`,{className:`event-row__title`,children:o}),s?(0,J.jsx)(`div`,{className:`event-row__detail`,children:s}):null]})]},`${e.type}-${e.ts}-${e.message_id??t}`)})}):(0,J.jsx)(X,{icon:ae,title:n||a(`还没有可展示的实时动态`,`No activity to show yet`)})}var Ae=new Set([`done`,`completed`,`accepted`,`success`]),je=new Set([`running`,`in_progress`,`claimed`,`active`,`working`]);function Me(e){if(!e.length)return null;let t=[...e].sort((e,t)=>e-t),n=Math.floor(t.length/2);return t.length%2?t[n]:(t[n-1]+t[n])/2}function Ne(e){return[...e].reverse().find(e=>{let t=String(e.kind??``),n=String(e.type??``);return t!==`reasoning`&&!n.startsWith(`provider.`)&&![`ui.operator`,`ui.argus`].includes(n)})??null}function Pe(e){return e.backlog.find(e=>je.has(e.status))??e.backlog.find(e=>e.status===`pending`)??e.backlog.at(-1)??null}function Fe(e,t,n=Date.now()/1e3,r=`zh-CN`){let i=(e,t)=>r===`zh-CN`?e:t,a=e.mission_view,o=a?.dag?.length?a.dag:e.backlog,s=o.length,c=o.filter(e=>Ae.has(e.status)).length,l=o.filter(e=>/pending|queued|waiting/.test(e.status)).length,u=Pe(e),d=a?.active_role||e.roles.find(e=>e.active)?.role||``,f=u?.started_ts||a?.mission.started_at||e.daemon.uptime_seconds&&n-e.daemon.uptime_seconds||n,p=t.filter(e=>Number(e.ts??0)>=Number(f||0)),m=Ne(p),h=String(a?.mission.status??``).toLowerCase(),g=[`complete`,`completed`,`done`].includes(h),_=[`incomplete`,`failed`,`blocked`,`aborted`,`stopped`,`cancelled`].includes(h),v=g||!_&&!!(s&&c===s),y=!e.daemon.alive,b=u?.finished_ts||a?.mission.completed_at||(y?Number(m?.ts??f):null),x=Math.max(0,Number(b??n)-Number(f||n)),S=!!(u&&je.has(u.status)&&e.daemon.alive),C=p.filter(e=>String(e.kind??``)===`command_execution`).length,w=p.filter(e=>/^(read|write|edit):/i.test(Ee(e,80))||String(e.kind??``)===`file_change`).length,T=!!a?.role_work?.some(e=>e.role===`engineer`&&/handoff|main completed/i.test(`${e.kind} ${e.title}`)&&e.ts>=Number(f||0)),E=p.some(e=>/review.*started/i.test(String(e.type??``))),D=p.some(e=>/review.*completed/i.test(String(e.type??``))),O=!!(u&&/failed|blocked|error/.test(u.status)),k=!!(a?.review?.status&&/replan|blocked|rejected|continue/.test(a.review.status)),A=0;u&&Ae.has(u.status)?A=1:u&&je.has(u.status)&&e.daemon.alive&&(A=.14,(C||w)&&(A=Math.min(.58,.27+Math.log2(1+C+w)*.055)),T&&(A=.7),(E||d===`reviewer`)&&(A=.8),D&&(A=.93));let j=v?1:_&&s&&c===s?.95:s?c/s:0,M=u&&o.some(e=>e.id===u.id)&&S&&!k,N=v?1:k?j:s?Math.min(1,(c+(M?A:0))/s):null,ee=s?Math.max(.05,Math.min(.18,.45/s)):0,te=v?[1,1]:k?[j,j]:N==null?null:[Math.max(j,N-ee*.45),Math.min(.99,Math.max(N,N+ee))],P=e.backlog.map(e=>e.started_ts&&e.finished_ts?e.finished_ts-e.started_ts:0).filter(e=>e>=5&&e<=604800),ne=Me(P),re=null,F=``;if(v)F=i(`项目已完成,无需预计完成时间`,`Project complete; no finish-time estimate is needed`);else if(y)F=i(`Argus 已停止,预计完成时间暂停更新`,`Argus stopped; the expected finish time is paused`);else if(!S)F=i(`当前没有执行中的任务,暂时无法预计完成时间`,`No active task; the expected finish time is unavailable`);else if(k)F=i(`Reviewer 正在改变任务范围,暂时无法预计完成时间`,`The Reviewer is changing scope, so the expected finish time is unavailable`);else if(!ne)F=i(`同类已完成任务不足,正在建立时间基线`,`Not enough completed tasks to establish a time baseline`);else if(!s||N==null)F=i(`任务路线尚未稳定,暂不预计完成时间`,`The task route is not stable enough to estimate a finish time`);else{let e=Math.max(0,s-c-(M?A:0))*ne;re={minSeconds:Math.max(60,e*.68),maxSeconds:Math.max(180,e*(P.length>=3?1.45:1.75)),basis:i(`${P.length} 个已完成任务的中位耗时`,`Median duration of ${P.length} completed tasks`)}}let ie=s>=4&&P.length>=3?`high`:s>=2&&P.length>=1?`medium`:`low`,ae=e.roles.find(e=>e.role===`planner`)?.status===`done`||!!u,I=[{id:`plan`,label:i(`规划任务`,`Plan task`),detail:ae?i(`Planner 已形成当前任务`,`Planner created the current task`):i(`等待 Planner`,`Waiting for Planner`),status:ae?`done`:d===`planner`?`active`:`pending`},{id:`start`,label:i(`启动执行`,`Start execution`),detail:u?.started_ts?i(`任务已领取并启动`,`Task claimed and started`):i(`等待执行`,`Waiting to execute`),status:u?.started_ts?`done`:u?.status===`pending`?`pending`:O?`blocked`:`active`},{id:`work`,label:i(`运行与产出`,`Execution and outputs`),detail:i(`${C} 条命令 · ${w} 次文件动作`,`${C} commands · ${w} file actions`),status:T?`done`:C||w?`active`:O?`blocked`:`pending`},{id:`handoff`,label:i(`提交 Reviewer`,`Ready for review`),detail:T?i(`已提交 Reviewer`,`Submitted to Reviewer`):i(`等待可审读的结果`,`Waiting for results the Reviewer can read`),status:T||d===`reviewer`?`done`:`pending`},{id:`review`,label:i(`Reviewer 认证`,`Reviewer certification`),detail:D?i(`本轮审查已完成`,`Round review complete`):E||d===`reviewer`?i(`Reviewer 正在检查`,`Reviewer is checking`):i(`等待审查`,`Waiting for review`),status:D?`done`:E||d===`reviewer`?`active`:O?`blocked`:`pending`}];return v?I=I.map(e=>({...e,status:`done`,detail:e.status===`done`?e.detail:i(`项目已完成`,`Project complete`)})):k?I=I.map(e=>e.status===`done`?e:{...e,status:`blocked`,detail:i(`等待 Reviewer 重新规划任务范围`,`Waiting for Reviewer to replan scope`)}):y&&(I=I.map(e=>e.status===`active`?{...e,status:`blocked`,detail:i(`Argus 已停止`,`Argus stopped`)}:e)),{confirmed:j,estimate:N,range:te,confidence:ie,basis:k?i(`Reviewer 正在重新规划,仅显示确定完成部分`,`Reviewer is replanning; only confirmed completion is shown`):s?i(`根据任务状态和事件里程碑估算`,`Estimated from task status and event milestones`):i(`任务路线尚未建立`,`Task route not established`),currentTask:u?.title||a?.mission.title||i(`等待新任务`,`Waiting for a new task`),currentRole:y?`stopped`:d||Te(m??{})||`idle`,currentStep:v?i(`项目已完成`,`Project complete`):k?i(`Reviewer 要求重新规划 · ${H(a?.review?.status||`replan`,i)}`,`Reviewer requested replanning · ${H(a?.review?.status||`replan`,i)}`):y?i(`已停止 · 最后执行到 ${m?q(m):H(u?.status,i)}`,`Stopped · last step: ${m?q(m):H(u?.status,i)}`):m?q(m):u?.status?H(u.status,i):i(`等待动态`,`Waiting for activity`),currentDetail:m?Ee(m,700):u?.objective||``,elapsedSeconds:x,eta:re,etaUnavailableReason:F,checkpoints:I,completedTasks:c,totalTasks:s,pendingTasks:l,currentFraction:k?0:A}}var Ie=new Set([`done`,`completed`,`accepted`,`success`]),Le=new Set([`running`,`in_progress`,`claimed`,`active`,`working`]),Re=[`manager`,`planner`,`engineer`,`reviewer`],ze=[`scope`,`research`,`implementation`,`experiment`,`analysis`,`writing`,`review`];function Be(e){let t=e.toLowerCase();return/review|delivery/.test(t)?6:/writ|draft|paper/.test(t)?5:/analy|select/.test(t)?4:/experiment|pilot|run|eval/.test(t)?3:/implement|build|engineer/.test(t)?2:+!!/research|literature|idea/.test(t)}function Ve(e){return e==null?`—`:`${Math.round(e*100)}%`}function He(e,t,n,r){let i=t=>new Date((e+t)*1e3).toLocaleTimeString(r,{hour:`2-digit`,minute:`2-digit`,hour12:!1});return`${i(t)}–${i(n)}`}function Ue(e){let{locale:t,text:n}=W(),[r,i]=(0,L.useState)(()=>Date.now()/1e3),[a,o]=(0,L.useState)(``);(0,L.useEffect)(()=>{if(!e.active||!e.snapshot.daemon.alive)return;i(Date.now()/1e3);let t=window.setInterval(()=>i(Date.now()/1e3),1e3);return()=>clearInterval(t)},[e.active,e.snapshot.daemon.alive]);let l=(0,L.useMemo)(()=>Fe(e.snapshot,e.events,r,t),[t,r,e.events,e.snapshot]),d=e.snapshot.mission_view,f=d?.dag?.length?d.dag:e.snapshot.backlog.map(e=>({id:e.id,title:e.title,objective:e.objective,status:e.status,deps:e.deps??[],branch_id:e.id,parent_branch_id:``})),m=f.find(e=>Le.has(e.status))??f.find(e=>/pending|queued/.test(e.status))??f.at(-1),h=f.find(e=>e.id===a)??m,g=Be(d?.stage.id||d?.stage.label||`scope`),_=Math.round(l.confirmed*100),b=Math.round((l.range?.[0]??l.confirmed)*100),S=Math.round((l.range?.[1]??l.confirmed)*100),w=Math.round((l.estimate??l.confirmed)*100),T=e.snapshot.daemon.health?.state||(e.snapshot.daemon.alive?`active`:`stopped`),D=d?.review?.status&&!Ie.has(d.review.status)?d.review:null,O=e.events.filter(e=>String(e.kind??``)!==`reasoning`&&!String(e.type??``).startsWith(`provider.`)),k=async t=>{let r=t?n(`确认完成当前步骤后停止 Argus?`,`Stop Argus after the current step finishes?`):n(`确认立即停止 Argus?当前步骤可能被中断。`,`Stop Argus now? The current step may be interrupted.`);confirm(r)&&await e.controls.stop(t)};return(0,J.jsxs)(`div`,{className:`ros-page experiment-v3`,children:[(0,J.jsxs)(`header`,{className:`ros-page-header`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`div`,{className:`eyebrow`,children:`EXPERIMENT PROGRESS`}),(0,J.jsx)(`h1`,{children:n(`实验进程`,`Experiment progress`)}),(0,J.jsx)(`p`,{children:n(`查看当前步骤、预计进度范围、预计完成时间,以及估算的可信程度。`,`See the current step, estimated progress range, expected finish time, and how confident Argus is in the estimate.`)})]}),(0,J.jsxs)(`div`,{className:`experiment-header-actions`,children:[(0,J.jsxs)(`button`,{className:`button button--secondary`,type:`button`,onClick:()=>void e.refresh(),children:[(0,J.jsx)(y,{size:14}),n(`刷新`,`Refresh`)]}),e.snapshot.daemon.control_available===!1?null:e.snapshot.daemon.alive?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`button`,{className:`button button--secondary`,type:`button`,disabled:e.controls.busy,onClick:()=>void k(!0),children:[(0,J.jsx)(v,{size:14}),n(`当前步后停止`,`Stop after step`)]}),(0,J.jsxs)(`button`,{className:`button button--danger`,type:`button`,disabled:e.controls.busy,onClick:()=>void k(!1),children:[(0,J.jsx)(C,{size:13}),n(`立即停止`,`Stop now`)]})]}):(0,J.jsxs)(`button`,{className:`button button--primary`,type:`button`,disabled:e.controls.busy,onClick:()=>void e.controls.start(),children:[(0,J.jsx)(c,{size:14}),n(`继续运行`,`Resume`)]})]})]}),(0,J.jsxs)(`section`,{className:`experiment-progress-hero`,children:[(0,J.jsxs)(`div`,{className:`progress-hero-main`,children:[(0,J.jsxs)(`div`,{className:`progress-live-line`,children:[(0,J.jsx)(Y,{tone:e.snapshot.daemon.alive?`live`:`neutral`,dot:!0,children:e.snapshot.daemon.alive?n(`ARGUS 运行中`,`ARGUS RUNNING`):n(`ARGUS 已停止`,`ARGUS STOPPED`)}),(0,J.jsx)(`span`,{children:d?.stage.label||xe(d?.stage.id,n)}),(0,J.jsx)(`span`,{children:U(l.currentRole,n)})]}),(0,J.jsx)(`h2`,{children:l.currentTask}),(0,J.jsxs)(`div`,{className:`current-step-callout`,children:[(0,J.jsx)(`span`,{children:(0,J.jsx)(u,{size:17})}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`small`,{children:e.snapshot.daemon.alive?n(`当前正在进行`,`In progress`):n(`最后执行位置`,`Last execution point`)}),(0,J.jsx)(`strong`,{children:l.currentStep}),l.currentDetail?(0,J.jsx)(`code`,{children:l.currentDetail}):null]})]})]}),(0,J.jsxs)(`div`,{className:`progress-number`,children:[(0,J.jsx)(`span`,{children:n(`预计进度`,`Estimated progress`)}),(0,J.jsx)(`strong`,{children:Ve(l.estimate)}),(0,J.jsxs)(`small`,{children:[n(`预计范围`,`Likely range`),` `,b,`–`,S,`%`]})]}),(0,J.jsxs)(`div`,{className:`truthful-progress`,"aria-label":n(`预计完成 ${w}%`,`Estimated completion ${w}%`),children:[(0,J.jsxs)(`div`,{className:`truthful-progress__track`,children:[(0,J.jsx)(`span`,{className:`confirmed`,style:{width:`${_}%`}}),(0,J.jsx)(`span`,{className:`estimated-range`,style:{left:`${b}%`,width:`${Math.max(1,S-b)}%`}}),(0,J.jsx)(`i`,{style:{left:`${w}%`}})]}),(0,J.jsxs)(`div`,{className:`truthful-progress__legend`,children:[(0,J.jsxs)(`span`,{children:[(0,J.jsx)(`b`,{className:`confirmed-dot`}),n(`确定完成`,`Confirmed`),` `,_,`%`]}),(0,J.jsxs)(`span`,{children:[(0,J.jsx)(`b`,{className:`range-dot`}),n(`估计范围`,`Estimated range`),` `,b,`–`,S,`%`]}),(0,J.jsx)(`span`,{children:l.basis})]})]}),(0,J.jsxs)(`div`,{className:`progress-metrics`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsxs)(`span`,{children:[(0,J.jsx)(E,{size:15}),n(`当前任务已运行`,`Current task elapsed`)]}),(0,J.jsx)(`strong`,{children:K(l.elapsedSeconds)}),(0,J.jsx)(`small`,{children:n(`从任务领取开始`,`Since task claim`)})]}),(0,J.jsxs)(`div`,{children:[(0,J.jsxs)(`span`,{children:[(0,J.jsx)(se,{size:15}),n(`预计完成时间`,`Expected finish time`)]}),(0,J.jsx)(`strong`,{children:l.eta?`${K(l.eta.minSeconds)}–${K(l.eta.maxSeconds)}`:n(`暂不可用`,`Unavailable`)}),(0,J.jsx)(`small`,{children:l.eta?He(r,l.eta.minSeconds,l.eta.maxSeconds,t):l.etaUnavailableReason})]}),(0,J.jsxs)(`div`,{children:[(0,J.jsxs)(`span`,{children:[(0,J.jsx)(re,{size:15}),n(`估算置信度`,`Estimate confidence`)]}),(0,J.jsx)(`strong`,{className:`confidence-${l.confidence}`,children:l.confidence===`high`?n(`高`,`High`):l.confidence===`medium`?n(`中`,`Medium`):n(`低`,`Low`)}),(0,J.jsx)(`small`,{children:l.eta?.basis||n(`需要更多历史任务`,`More task history is needed`)})]}),(0,J.jsxs)(`div`,{children:[(0,J.jsxs)(`span`,{children:[(0,J.jsx)(ue,{size:15}),n(`任务路线`,`Task route`)]}),(0,J.jsxs)(`strong`,{children:[l.completedTasks,` / `,l.totalTasks||`—`]}),(0,J.jsxs)(`small`,{children:[n(`${l.pendingTasks} 项等待中`,`${l.pendingTasks} waiting`),` · `,n(`当前步骤`,`current step`),` `,Math.round(l.currentFraction*100),`%`]})]})]})]}),(0,J.jsx)(`section`,{className:`research-stage-rail`,children:ze.map((e,t)=>(0,J.jsxs)(`div`,{className:t(0,J.jsxs)(`button`,{type:`button`,className:h?.id===e.id?`is-active`:``,onClick:()=>o(e.id),children:[(0,J.jsx)(`span`,{className:`task-state task-state--${we(e.status)}`,children:Ie.has(e.status)?(0,J.jsx)(p,{size:12}):Le.has(e.status)?(0,J.jsx)(u,{size:12}):(0,J.jsx)(A,{size:9})}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`strong`,{children:e.title||e.objective||n(`未命名任务`,`Untitled task`)}),(0,J.jsxs)(`small`,{children:[H(e.status,n),e.deps.length?n(` · 需等待前置任务 ${e.deps.length} 项`,` · Starts after ${e.deps.length} earlier tasks`):``]})]})]},e.id)):(0,J.jsx)(X,{icon:ue,title:n(`尚无任务路线`,`No task route yet`)})})]}),(0,J.jsxs)(`main`,{className:`experiment-v3-center`,children:[(0,J.jsxs)(`section`,{className:`ros-card checkpoint-card`,children:[(0,J.jsxs)(`header`,{children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`span`,{children:`CURRENT CHECKPOINTS`}),(0,J.jsx)(`h2`,{children:n(`当前任务走到哪一步`,`Current task checkpoints`)})]}),(0,J.jsxs)(Y,{tone:`info`,children:[Math.round(l.currentFraction*100),`%`]})]}),(0,J.jsx)(`div`,{className:`checkpoint-list`,children:l.checkpoints.map((e,t)=>(0,J.jsxs)(`div`,{className:`checkpoint checkpoint--${e.status}`,children:[(0,J.jsx)(`span`,{children:e.status===`done`?(0,J.jsx)(p,{size:13}):e.status===`active`?(0,J.jsx)(u,{size:13}):e.status===`blocked`?(0,J.jsx)(ce,{size:13}):t+1}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`strong`,{children:e.label}),(0,J.jsx)(`p`,{children:e.detail})]}),t{let r=e.snapshot.roles.find(e=>e.role===t);return(0,J.jsxs)(`article`,{className:r?.active?`is-active`:``,children:[(0,J.jsx)(`span`,{"data-role-dot":t,className:`role-dot role-dot--${t}`,"aria-hidden":`true`}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`strong`,{children:U(t,n)}),(0,J.jsx)(`p`,{children:r?.label||H(`waiting`,n)}),(0,J.jsx)(`small`,{children:H(r?.status||`idle`,n)})]}),r?.active?(0,J.jsx)(Y,{tone:`live`,dot:!0,children:H(`active`,n)}):(0,J.jsx)(Y,{tone:we(r?.status),children:H(r?.status||`idle`,n)})]},t)})})]}),(0,J.jsxs)(`section`,{className:`ros-card estimate-note`,children:[(0,J.jsx)(`header`,{children:(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`span`,{children:`ESTIMATE HEALTH`}),(0,J.jsx)(`h2`,{children:n(`估算与风险`,`Estimate and risk`)})]})}),(0,J.jsxs)(`div`,{children:[(0,J.jsxs)(`p`,{children:[(0,J.jsx)(`strong`,{children:n(`估算说明`,`Estimate note`)}),n(`当前百分比根据任务状态和事件里程碑估算,可能随新进展调整。`,`The percentage is estimated from task state and event milestones and may change as work progresses.`)]}),D?(0,J.jsxs)(`div`,{className:`estimate-risk`,children:[(0,J.jsx)(ce,{size:15}),(0,J.jsxs)(`span`,{children:[(0,J.jsxs)(`strong`,{children:[U(`reviewer`,n),` · `,H(D.status,n)]}),D.reason||n(`任务范围可能变化,预计完成时间已暂停更新。`,`Scope may change, so the expected finish time is paused.`)]})]}):(0,J.jsxs)(`div`,{className:`estimate-ok`,children:[(0,J.jsx)(x,{size:15}),(0,J.jsxs)(`span`,{children:[(0,J.jsx)(`strong`,{children:n(`当前估算可用`,`Estimate available`)}),H(T,n),` · `,n(`最近进度`,`last progress`),` `,K(e.snapshot.daemon.health?.seconds_since_progress)]})]}),e.controls.error?(0,J.jsx)(`div`,{className:`inline-error`,children:e.controls.error}):null]})]})]})]})]})}async function Z(e,t,n){let r=new URLSearchParams(t),i=await fetch(`${e}?${r}`,{headers:R(),signal:n,cache:`no-store`});if(!i.ok){let t=await i.json().catch(()=>({}));throw Error(t.detail||t.error||`${e} failed (${i.status})`)}return i.json()}var Q=(e,t)=>({sid:e,workspace_id:t}),$={profiles:(e,t)=>Z(`/api/v2/workspaces`,{sid:e},t),tree:(e,t,n)=>Z(`/api/v2/workspace/tree`,Q(e,t),n),file:(e,t,n,r)=>Z(`/api/v2/workspace/file`,{...Q(e,t),path:n},r),git:(e,t,n)=>Z(`/api/v2/workspace/git`,Q(e,t),n),literature:(e,t,n)=>Z(`/api/v2/workspace/literature`,Q(e,t),n),rawUrl:(e,t,n)=>`/api/v2/workspace/raw?${new URLSearchParams({...Q(e,t),path:n})}`,rawBlob:async(e,t,n,r)=>{let i=await fetch(`/api/v2/workspace/raw?${new URLSearchParams({...Q(e,t),path:n})}`,{headers:R(),signal:r,cache:`no-store`});if(!i.ok){let e=await i.json().catch(()=>({}));throw Error(e.detail||`raw preview failed (${i.status})`)}return i.blob()}};function We(e){let t=new Map;e.forEach(e=>t.set(e.path,{...e,children:[]}));let n=[];t.forEach(e=>{let r=e.path.lastIndexOf(`/`),i=r>=0?e.path.slice(0,r):``,a=i?t.get(i):null;a?a.children.push(e):n.push(e)});let r=e=>{e.sort((e,t)=>e.type===t.type?e.name.localeCompare(t.name):e.type===`directory`?-1:1),e.forEach(e=>r(e.children))};return r(n),n}function Ge(e,t,n){let[r,i]=(0,L.useState)(``),[a,o]=(0,L.useState)(``);return(0,L.useEffect)(()=>{if(i(``),o(``),!e||!t||!n)return;let r=new AbortController,a=``;return $.rawBlob(e,t,n,r.signal).then(e=>{a=URL.createObjectURL(e),i(a)},e=>{r.signal.aborted||o(e.message)}),()=>{r.abort(),a&&URL.revokeObjectURL(a)}},[n,e,t]),{url:r,error:a}}function Ke(e,t,n=!0){let r=i({queryKey:[`workspace-profiles`,e],queryFn:({signal:t})=>$.profiles(e,t),staleTime:1e4,enabled:!!e&&n}),a=`argus-v2-workspace-profile:${t}:${e}`,[o,s]=(0,L.useState)(()=>w(a)||``),c=(0,L.useMemo)(()=>{let e=r.data?.profiles??[];return e.find(e=>e.id===o)??e.find(e=>e.id===r.data?.default_id)??e.find(e=>e.canonical)??e[0]??null},[r.data,o]);return(0,L.useEffect)(()=>{c&&c.id!==o&&s(c.id)},[c,o]),{profiles:r,active:c,workspaceId:c?.id??``,setWorkspaceId:e=>{s(e),S(a,e)}}}function qe({node:e,depth:t,selected:n,expanded:r,onToggle:i,onSelect:a}){let o=e.type===`directory`,c=r.has(e.path);return(0,J.jsxs)(`div`,{className:`workspace-node`,children:[(0,J.jsxs)(`button`,{type:`button`,className:n===e.path?`is-selected`:``,style:{paddingLeft:7+t*13},onClick:()=>o?i(e.path):a(e.path),children:[o?c?(0,J.jsx)(T,{size:13}):(0,J.jsx)(s,{size:13}):(0,J.jsx)(`span`,{className:`node-spacer`}),o?(0,J.jsx)(ne,{size:14}):(0,J.jsx)(M,{size:14}),(0,J.jsx)(`span`,{children:e.name}),e.skipped?(0,J.jsx)(`small`,{children:`restricted`}):null]}),o&&c?e.children.map(e=>(0,J.jsx)(qe,{node:e,depth:t+1,selected:n,expanded:r,onToggle:i,onSelect:a},e.path)):null]})}function Je({sid:e,workspaceId:t,path:n,active:r}){let{text:a}=W(),o=n.toLowerCase().slice(n.lastIndexOf(`.`)),s=[`.pdf`,`.png`,`.jpg`,`.jpeg`,`.webp`,`.svg`].includes(o),c=i({queryKey:[`workspace-file`,e,t,n],queryFn:({signal:r})=>$.file(e,t,n,r),enabled:!!(r&&n&&t&&!s),refetchInterval:5e3}),l=Ge(s?e:``,s?t:``,s?n:``);if(!n)return(0,J.jsx)(X,{icon:N,title:a(`打开一个文件开始阅读`,`Open a file to start reading`),description:a(`左侧文件树直接映射已批准的服务器工作区。`,`The file tree maps the approved server workspace.`)});if(s)return l.error?(0,J.jsx)(X,{icon:ie,title:`Preview unavailable`,description:l.error}):l.url?o===`.pdf`?(0,J.jsx)(b,{src:l.url,name:n.split(`/`).at(-1)||n,className:`workspace-pdf`}):(0,J.jsx)(`img`,{className:`workspace-image`,src:l.url,alt:n}):(0,J.jsx)(`div`,{className:`editor-loading`,children:`Loading preview…`});if(c.isLoading)return(0,J.jsxs)(`div`,{className:`editor-loading`,children:[`Opening `,n,`…`]});if(c.isError)return(0,J.jsx)(X,{icon:ie,title:`Preview unavailable`,description:c.error.message});let u=(c.data?.content??``).split(` +`);return(0,J.jsxs)(`div`,{className:`vscode-code`,tabIndex:0,"aria-label":a(`文件内容`,`File contents`),children:[(0,J.jsx)(`div`,{className:`vscode-line-numbers`,children:u.map((e,t)=>(0,J.jsx)(`span`,{children:t+1},t))}),(0,J.jsx)(`pre`,{children:(0,J.jsx)(`code`,{children:c.data?.content})})]})}function Ye(e){let{locale:t,text:n}=W(),r=Ke(e.sid,`ide`,e.active),a=r.workspaceId,c=r.active?.path||``,[u,d]=(0,L.useState)(``),[f,m]=(0,L.useState)(new Set),h=(0,L.useRef)(``),g=(0,L.useRef)(null),v=e=>{d(e);let t=g.current,n=t?.closest(`.vscode-shell`),r=t?.closest(`.ros-content`);t&&n&&r&&getComputedStyle(n).display===`flex`&&r.scrollTo({top:r.scrollTop+t.getBoundingClientRect().top-r.getBoundingClientRect().top-12,behavior:window.matchMedia(`(prefers-reduced-motion: reduce)`).matches?`auto`:`smooth`})},[b,x]=(0,L.useState)(`files`),[S,C]=(0,L.useState)(`repository`),w=i({queryKey:[`workspace-tree`,e.sid,a],queryFn:({signal:t})=>$.tree(e.sid,a,t),enabled:!!(e.active&&a),refetchInterval:8e3}),E=i({queryKey:[`workspace-git`,e.sid,a],queryFn:({signal:t})=>$.git(e.sid,a,t),enabled:!!(e.active&&a),refetchInterval:8e3}),D=(0,L.useMemo)(()=>We(w.data?.entries??[]),[w.data?.entries]);(0,L.useEffect)(()=>{d(``),m(new Set),h.current=``},[a]),(0,L.useEffect)(()=>{!a||!D.length||h.current===a||(h.current=a,m(new Set(D.filter(e=>e.type===`directory`).slice(0,5).map(e=>e.path))))},[D,a]);let O=e.events.filter(e=>[`command_execution`,`tool_use`,`tool_result`,`file_change`].includes(String(e.kind??``))).slice(-100),k=(E.data?.status??``).split(` +`).filter(Boolean),A=(E.data?.log??``).split(` +`).filter(Boolean).map(e=>{let[t,n,r,...i]=e.split(` `);return{hash:t,date:n,author:r,subject:i.join(` `)}}),M=E.data;return(0,J.jsxs)(`div`,{className:`ros-page ide-v3`,children:[(0,J.jsxs)(`header`,{className:`ros-page-header`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`div`,{className:`eyebrow`,children:`AI IDE`}),(0,J.jsx)(`h1`,{children:n(`服务器代码工作区`,`Server code workspace`)}),(0,J.jsx)(`p`,{children:n(`接近 VS Code 的只读工作台:文件浏览、源码阅读、Git/GitHub 就绪状态和 Argus 终端轨迹。`,`A read-only VS Code-style workspace for files, source, Git/GitHub readiness, and Argus terminal activity.`)})]}),(0,J.jsxs)(Y,{tone:`info`,children:[(0,J.jsx)(ie,{size:12}),n(`只读安全模式`,`Read-only safe mode`)]})]}),(0,J.jsxs)(`div`,{className:`ide-context-strip`,children:[(0,J.jsx)(I,{size:15}),(0,J.jsx)(`select`,{"aria-label":n(`选择已批准工作区`,`Select approved workspace`),value:a,onChange:e=>r.setWorkspaceId(e.target.value),children:r.profiles.data?.profiles.map(e=>(0,J.jsx)(`option`,{value:e.id,children:e.label},e.id))}),(0,J.jsx)(`code`,{children:c}),w.isError?(0,J.jsx)(Y,{tone:`danger`,children:n(`连接失败`,`Connection failed`)}):w.isFetching?(0,J.jsx)(Y,{tone:`live`,dot:!0,children:n(`同步中`,`Syncing`)}):(0,J.jsxs)(Y,{tone:`success`,children:[(0,J.jsx)(l,{size:11}),`Synced`]}),(0,J.jsxs)(`small`,{children:[w.data?.entries.length??0,` entries`]}),(0,J.jsx)(`button`,{type:`button`,onClick:()=>{w.refetch(),E.refetch()},"aria-label":n(`刷新工作区`,`Refresh workspace`),children:(0,J.jsx)(y,{size:14})})]}),(0,J.jsxs)(`div`,{className:`vscode-shell`,children:[(0,J.jsxs)(`nav`,{className:`vscode-activitybar`,children:[(0,J.jsx)(`button`,{type:`button`,className:b===`files`?`is-active`:``,onClick:()=>x(`files`),title:`Explorer`,"aria-label":`Explorer`,children:(0,J.jsx)(ee,{size:21})}),(0,J.jsxs)(`button`,{type:`button`,className:b===`git`?`is-active`:``,onClick:()=>x(`git`),title:`Source Control`,"aria-label":`Source Control`,children:[(0,J.jsx)(o,{size:21}),k.length?(0,J.jsx)(`i`,{children:k.length}):null]})]}),(0,J.jsxs)(`aside`,{className:`vscode-sidebar`,children:[(0,J.jsxs)(`header`,{children:[(0,J.jsx)(`span`,{children:b===`git`?`SOURCE CONTROL`:`EXPLORER`}),(0,J.jsx)(`button`,{type:`button`,onClick:()=>void w.refetch(),"aria-label":n(`刷新文件树`,`Refresh file tree`),children:(0,J.jsx)(y,{size:14})})]}),b===`files`?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`vscode-root`,children:[(0,J.jsx)(T,{size:13}),(0,J.jsx)(`strong`,{children:c.split(`/`).at(-1)||c})]}),(0,J.jsx)(`div`,{className:`workspace-tree`,children:w.isError?(0,J.jsx)(X,{icon:I,title:n(`目录连接失败`,`Directory connection failed`),description:w.error.message}):D.map(e=>(0,J.jsx)(qe,{node:e,depth:0,selected:u,expanded:f,onToggle:e=>m(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),onSelect:v},e.path))})]}):(0,J.jsx)(`div`,{className:`vscode-changes`,children:k.length?k.map(e=>(0,J.jsxs)(`button`,{type:`button`,onClick:()=>{let t=e.slice(3).trim(),n=t.includes(` -> `)?t.split(` -> `).at(-1):t;n.endsWith(`/`)||v(n)},children:[(0,J.jsx)(`b`,{children:e.slice(0,2).trim()||`?`}),(0,J.jsx)(`span`,{children:e.slice(3)})]},e)):(0,J.jsx)(`p`,{children:`No changes`})})]}),(0,J.jsxs)(`main`,{className:`vscode-editor`,ref:g,children:[(0,J.jsx)(`div`,{className:`vscode-tabs`,children:(0,J.jsxs)(`button`,{type:`button`,className:`is-active`,children:[(0,J.jsx)(j,{size:13}),u||`Welcome`]})}),(0,J.jsx)(`div`,{className:`vscode-breadcrumbs`,children:u?u.split(`/`).map((e,t)=>(0,J.jsxs)(`span`,{children:[e,tC(`changes`),children:`Changes`}),(0,J.jsx)(`button`,{type:`button`,className:S===`timeline`?`is-active`:``,onClick:()=>C(`timeline`),children:`Timeline`}),(0,J.jsx)(`button`,{type:`button`,className:S===`repository`?`is-active`:``,onClick:()=>C(`repository`),children:`Repository`})]}),(0,J.jsx)(`div`,{className:`vscode-git-content`,children:M?.available?S===`changes`?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`pre`,{className:`vscode-status`,children:M.status||`Working tree clean`}),M.diff?(0,J.jsx)(`pre`,{className:`vscode-diff`,children:M.diff}):null]}):S===`timeline`?(0,J.jsx)(`div`,{className:`vscode-commits`,children:A.map(e=>(0,J.jsxs)(`article`,{children:[(0,J.jsx)(o,{size:13}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`strong`,{children:e.subject}),(0,J.jsxs)(`small`,{children:[e.author,` · `,e.date?.slice(0,10)]})]})]},e.hash))}):(0,J.jsxs)(`div`,{className:`repository-readiness`,children:[(0,J.jsx)(`h3`,{children:`Repository readiness`}),(0,J.jsxs)(`dl`,{children:[(0,J.jsxs)(`div`,{children:[(0,J.jsxs)(`dt`,{children:[(0,J.jsx)(o,{size:13}),`Remote`]}),(0,J.jsx)(`dd`,{children:M.remotes.length?M.remotes.map(e=>`${e.name}: ${e.fetch}`).join(` +`):`Not configured`}),(0,J.jsx)(`i`,{className:M.remotes.length?`ok`:`missing`,children:M.remotes.length?(0,J.jsx)(p,{size:12}):(0,J.jsx)(_,{size:12})})]}),(0,J.jsxs)(`div`,{children:[(0,J.jsxs)(`dt`,{children:[(0,J.jsx)(o,{size:13}),`Upstream`]}),(0,J.jsxs)(`dd`,{children:[M.upstream||`Not configured`,M.upstream?` · ahead ${M.ahead}, behind ${M.behind}`:``]}),(0,J.jsx)(`i`,{className:M.upstream?`ok`:`missing`,children:M.upstream?(0,J.jsx)(p,{size:12}):(0,J.jsx)(_,{size:12})})]}),(0,J.jsxs)(`div`,{children:[(0,J.jsxs)(`dt`,{children:[(0,J.jsx)(le,{size:13}),`Commit identity`]}),(0,J.jsx)(`dd`,{children:M.identity.name&&M.identity.email?`${M.identity.name} <${M.identity.email}>`:`Not configured`}),(0,J.jsx)(`i`,{className:M.identity.valid?`ok`:`missing`,children:M.identity.valid?(0,J.jsx)(p,{size:12}):(0,J.jsx)(_,{size:12})})]}),(0,J.jsxs)(`div`,{children:[(0,J.jsxs)(`dt`,{children:[(0,J.jsx)(F,{size:13}),`GitHub CLI`]}),(0,J.jsx)(`dd`,{children:M.github.authenticated?`${M.github.login} · ${M.github.protocol}`:`Not authenticated`}),(0,J.jsx)(`i`,{className:M.github.authenticated?`ok`:`missing`,children:M.github.authenticated?(0,J.jsx)(p,{size:12}):(0,J.jsx)(_,{size:12})})]})]}),(0,J.jsx)(`p`,{children:M.publish_ready?`Repository is ready for an explicitly approved push.`:`Configure the missing items before publishing. No credentials are shown in this UI.`})]}):(0,J.jsx)(X,{icon:o,title:`Not a Git repository`})})]}),(0,J.jsxs)(`section`,{className:`vscode-terminal`,children:[(0,J.jsxs)(`header`,{children:[(0,J.jsx)(`strong`,{children:`ARGUS ACTIVITY`}),(0,J.jsxs)(`span`,{children:[(0,J.jsx)(oe,{size:13}),`read-only`]})]}),(0,J.jsx)(`div`,{children:O.length?O.map((e,n)=>(0,J.jsxs)(`article`,{children:[(0,J.jsx)(`time`,{children:Ce(e.ts,t)}),(0,J.jsx)(`b`,{className:`terminal-role terminal-role--${Te(e)}`,children:Te(e)}),(0,J.jsx)(`span`,{children:`›`}),(0,J.jsx)(`code`,{children:Ee(e,800)||q(e)})]},`${e.ts}-${n}`)):(0,J.jsx)(`p`,{children:`$ waiting for Argus activity`})})]}),(0,J.jsxs)(`footer`,{className:`vscode-statusbar`,children:[(0,J.jsxs)(`span`,{children:[(0,J.jsx)(o,{size:12}),M?.branch||`no branch`]}),(0,J.jsx)(`span`,{children:w.isError?`Workspace error`:w.isFetching?`Workspace syncing`:w.data?.truncated?`Tree truncated`:`Workspace synced`}),(0,J.jsx)(`span`,{children:M?.github.authenticated?`GitHub: ${M.github.login}`:`GitHub: offline`}),(0,J.jsx)(`span`,{children:`UTF-8`}),(0,J.jsx)(`span`,{children:u.split(`.`).at(-1)?.toUpperCase()||`Plain Text`})]})]})]})}var Xe=[{id:`experiments`,zh:`运行进程`,en:`Execution`,zhDesc:`查看当前步骤、任务路线和角色交接。`,enDesc:`Follow the current step, task route, and role handoffs.`,icon:te,color:`blue`},{id:`ide`,zh:`AI IDE`,en:`AI IDE`,zhDesc:`阅读项目文件,查看 Git 状态与 Argus 活动。`,enDesc:`Read project files, Git state, and Argus activity.`,icon:j,color:`emerald`}],Ze=[{id:`overview`,zh:`项目概览`,en:`Project overview`,icon:P},...Xe];function Qe(e){let{text:t}=W(),n=e.snapshot.mission_view,r=n?.routing.vertical===`research`,i=n?.active_role||e.status?.active_role||`idle`,a=[H(n?.mission.status||`idle`,t),n?.outcome.stage_certification?Se(n.outcome.stage_certification,t):``].filter(Boolean).join(` · `);return(0,J.jsxs)(`div`,{className:`overview-page`,children:[(0,J.jsxs)(`section`,{className:`overview-hero`,children:[(0,J.jsxs)(`div`,{className:`overview-hero__copy`,children:[(0,J.jsxs)(`div`,{className:`overview-hero__badges`,children:[(0,J.jsx)(Y,{tone:e.snapshot.daemon.alive?`live`:`neutral`,dot:!0,children:e.snapshot.daemon.alive?t(`Argus 正在运行`,`Argus running`):t(`Argus 已停止`,`Argus stopped`)}),(0,J.jsx)(Y,{tone:we(n?.stage.id),children:n?.stage.label||xe(n?.stage.id,t)})]}),(0,J.jsx)(`h1`,{children:e.snapshot.session.display_name||e.project.label}),(0,J.jsx)(`p`,{children:n?.mission.objective||e.status?.continuous?.objective||e.project.objective||t(`尚未设置目标。`,`No objective has been set.`)})]}),(0,J.jsxs)(`div`,{className:`overview-hero__stats`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`span`,{children:t(`当前角色`,`Active role`)}),(0,J.jsx)(`strong`,{children:U(i,t)}),(0,J.jsx)(`small`,{children:e.snapshot.roles.find(e=>e.active)?.label||H(`waiting`,t)})]}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`span`,{children:r?t(`研究阶段`,`Research stage`):t(`工作流阶段`,`Workflow stage`)}),(0,J.jsx)(`strong`,{children:n?.stage.label||xe(n?.stage.id,t)}),(0,J.jsx)(`small`,{children:a})]}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`span`,{children:t(`累计运行`,`Elapsed`)}),(0,J.jsx)(`strong`,{children:K(n?.mission.campaign_elapsed_seconds||e.snapshot.daemon.uptime_seconds)}),(0,J.jsx)(`small`,{children:n?.round.current?t(`第 ${n.round.current}/${n.round.max||`—`} 轮`,`Round ${n.round.current}/${n.round.max||`—`}`):t(`暂无轮次`,`No round`)})]})]})]}),(0,J.jsx)(`div`,{className:`overview-section-heading`,children:(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`h2`,{children:t(`项目工作区`,`Project workspace`)}),(0,J.jsx)(`p`,{children:t(`所有模块共享同一个 Argus 项目、项目文件和实时动态。`,`All modules share the same Argus project, project files, and live activity.`)})]})}),(0,J.jsx)(`section`,{className:`module-grid`,children:Xe.map(n=>{let r=n.icon;return(0,J.jsxs)(`button`,{className:`module-card`,type:`button`,onClick:()=>e.navigate(n.id),children:[(0,J.jsx)(`span`,{className:`module-card__icon module-card__icon--${n.color}`,children:(0,J.jsx)(r,{size:20})}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`h3`,{children:t(n.zh,n.en)}),(0,J.jsx)(`p`,{children:t(n.zhDesc,n.enDesc)})]}),(0,J.jsx)(k,{size:16})]},n.id)})}),(0,J.jsxs)(`section`,{className:`overview-lower`,children:[(0,J.jsx)(De,{eyebrow:`CURRENT MISSION`,title:t(`当前任务`,`Current mission`),children:(0,J.jsxs)(`div`,{className:`overview-mission`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(se,{size:18}),(0,J.jsx)(`span`,{children:H(n?.mission.status||`idle`,t)})]}),(0,J.jsx)(`h3`,{children:n?.mission.title||e.project.current_task||t(`等待新任务`,`Waiting for a new task`)}),(0,J.jsx)(`p`,{children:n?.mission.summary||n?.frontier.summary||n?.review.reason||t(`Argus 的下一步和 Reviewer 边界会在这里同步。`,`Argus next steps and reviewer boundaries appear here.`)}),(0,J.jsxs)(`button`,{className:`button button--secondary`,type:`button`,onClick:()=>e.navigate(`experiments`),children:[t(`查看完整实验进程`,`View experiment progress`),` `,(0,J.jsx)(k,{size:14})]})]})}),(0,J.jsx)(De,{eyebrow:`RECENT ACTIVITY`,title:t(`最近活动`,`Recent activity`),bodyClassName:`panel__body--flush`,children:(0,J.jsx)(ke,{events:e.events,limit:7,dense:!0})})]})]})}function $e(e){let t=String(e.event_id??e.id??``);if(t)return t;let n=String(e.message_id??``);return n?`${e.type??``}:${n}:${e.kind??``}`:[e.type??``,e.ts??``,e.agent_layer??e.actor??``,e.kind??``,String(e.text??e.title??e.reason??``).slice(0,160)].join(`|`)}function et(e,t){let n=[...e],r=new Map(n.map((e,t)=>[$e(e),t]));return t.forEach(e=>{let t=$e(e),i=r.get(t);i==null?(r.set(t,n.length),n.push(e)):n[i]={...n[i],...e}}),n.sort((e,t)=>Number(e.ts??0)-Number(t.ts??0)).slice(-600)}function tt(e=!0){return i({queryKey:[`v2-projects`],queryFn:({signal:e})=>V.projects(e),enabled:e,refetchInterval:1e4})}function nt(e,t=!0){let n=r(),[o,s]=(0,L.useState)([]),[c,l]=(0,L.useState)(!1),u=(0,L.useRef)(null),d=!!e&&t,f=i({queryKey:[`v2-snapshot`,e],queryFn:({signal:t})=>V.snapshot(e,t),enabled:d,refetchInterval:5e3}),p=i({queryKey:[`v2-status`,e],queryFn:({signal:t})=>V.status(e,t),enabled:d,refetchInterval:6e3}),m=i({queryKey:[`v2-events`,e],queryFn:({signal:t})=>V.events(e,220,t),enabled:d,refetchInterval:15e3});(0,L.useEffect)(()=>{s([]),l(!1)},[e]),(0,L.useEffect)(()=>{!e||!m.data||s(e=>et(e,m.data))},[m.data,e]),(0,L.useEffect)(()=>{if(!e||!t){l(!1);return}let r=he(e,t=>{s(e=>et(e,[t])),u.current??=window.setTimeout(()=>{u.current=null,n.invalidateQueries({queryKey:[`v2-snapshot`,e]}),n.invalidateQueries({queryKey:[`v2-status`,e]})},900)},l);return()=>{r.close(),l(!1),u.current!=null&&(window.clearTimeout(u.current),u.current=null)}},[t,n,e]);let h=async()=>{e&&await Promise.all([n.invalidateQueries({queryKey:[`v2-snapshot`,e]}),n.invalidateQueries({queryKey:[`v2-status`,e]}),n.invalidateQueries({queryKey:[`v2-events`,e]})])},g=a({mutationFn:()=>V.startDaemon(e,f.data?.daemon_commands?.revision),onSuccess:h}),_=a({mutationFn:t=>V.stopDaemon(e,t,f.data?.daemon_commands?.revision),onSuccess:h}),v=(0,L.useMemo)(()=>{let e=[f,p,m].find(e=>e.error);return e?.error instanceof Error?e.error:null},[m,f,p]);return{snapshot:f,status:p,events:o,connected:c,refresh:h,controls:{start:g,stop:_},error:v}}function rt({sid:e,active:t}){let{locale:n}=O(),[r,i]=(0,L.useState)(()=>{let e=new URLSearchParams(window.location.search).get(`module`);return Ze.find(t=>t.id===e)?.id??`overview`}),[a,o]=(0,L.useState)(()=>new Set([r])),s=(0,L.useCallback)(e=>{i(e),o(t=>t.has(e)?t:new Set([...t,e]))},[]),c=tt(t),l=c.data?.projects??[],u=(0,L.useMemo)(()=>l.find(t=>t.id===e)??null,[l,e]),d=nt(e,t),f=r,p=d.controls.start.error||d.controls.stop.error,m=u&&d.snapshot.data?{sid:e,active:t,project:u,snapshot:d.snapshot.data,status:d.status.data,events:d.events,connected:d.connected,snapshotUpdatedAt:d.snapshot.dataUpdatedAt,refresh:d.refresh,controls:{start:async()=>{try{return await d.controls.start.mutateAsync()}catch{return null}},stop:async e=>{try{return await d.controls.stop.mutateAsync(e)}catch{return null}},busy:d.controls.start.isPending||d.controls.stop.isPending,error:p instanceof Error?p.message:``},navigate:s}:null;return(0,J.jsxs)(`section`,{className:`integrated-workbench flex min-h-0 flex-1 flex-col bg-transparent text-ink`,children:[(0,J.jsx)(`nav`,{className:`workbench-module-tabs shrink-0 border-b border-line/60 px-3 py-2`,"aria-label":n===`zh-CN`?`工作台模块`:`Workbench modules`,children:(0,J.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:Ze.map(({id:e,zh:t,en:r,icon:i})=>(0,J.jsxs)(`button`,{type:`button`,className:`workbench-module-tab`,"data-module":e,"data-selected":f===e,"aria-pressed":f===e,onClick:()=>s(e),children:[(0,J.jsx)(i,{size:14}),(0,J.jsx)(`span`,{children:n===`zh-CN`?t:r})]},e))})}),c.isError&&!u||d.snapshot.isError&&!d.snapshot.data?(0,J.jsx)(X,{title:n===`zh-CN`?`工作台读取失败`:`Workbench unavailable`,description:`Argus API did not return the selected project.`}):m?Ze.filter(({id:e})=>a.has(e)).map(({id:n})=>(0,J.jsx)(`div`,{className:`ros-content min-h-0 flex-1 overflow-x-hidden overflow-y-auto ${f===n?``:`hidden`}`,"aria-hidden":f!==n,children:n===`overview`?(0,J.jsx)(Qe,{...m,active:t&&f===n}):n===`experiments`?(0,J.jsx)(Ue,{...m,active:t&&f===n}):(0,J.jsx)(Ye,{...m,active:t&&f===n})},`${e}:${n}`)):(0,J.jsx)(`div`,{className:`boot-state`,children:(0,J.jsx)(Oe,{label:n===`zh-CN`?`正在载入工作台`:`Loading workbench`})})]})}export{rt as ResearchWorkbenchPanel}; \ No newline at end of file diff --git a/frontend/web/dist/assets/index-BmfdUynJ.js b/frontend/web/dist/assets/index-BmfdUynJ.js new file mode 100644 index 000000000..8c86012a1 --- /dev/null +++ b/frontend/web/dist/assets/index-BmfdUynJ.js @@ -0,0 +1,32 @@ +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/motion-sqs9Ax-g.js","assets/rolldown-runtime-hePW80VL.js","assets/ResearchWorkbenchPanel-DZNe62z_.js","assets/icons-2gFhc0pq.js","assets/query-CGMsBv4s.js","assets/play-DT9RZkLC.js","assets/ResearchWorkbenchPanel-BXRghxPt.css","assets/MapPanel-DOAsDr5E.js","assets/markdown-BtnlLdzu.js","assets/markdown-B3MBJsZb.css","assets/MapPanel-7aVAJo-I.css"])))=>i.map(i=>d[i]); +import{r as e,t}from"./rolldown-runtime-hePW80VL.js";import{A as n,C as r,D as i,E as a,O as o,S as s,T as c,_ as l,a as u,b as d,c as f,d as p,f as m,g as h,h as g,i as _,k as v,l as y,m as b,n as x,o as S,p as C,r as w,s as T,t as E,u as D,v as ee,w as O,x as te,y as ne}from"./icons-2gFhc0pq.js";import{_ as k,a as re,b as A,c as j,d as ie,f as ae,h as M,i as oe,l as se,m as N,n as ce,o as le,p as ue,r as de,s as fe,t as P,u as F,v as pe,y as me}from"./query-CGMsBv4s.js";import{i as he,n as ge,r as _e,t as ve}from"./markdown-BtnlLdzu.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var ye=t((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0>>1,a=e[r];if(0>>1;ri(c,n))li(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(li(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=typeof setTimeout==`function`?setTimeout:null,_=typeof clearTimeout==`function`?clearTimeout:null,v=typeof setImmediate<`u`?setImmediate:null;typeof navigator<`u`&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function y(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function b(e){if(h=!1,y(e),!m){if(n(c)!==null)m=!0,k(x);else{var t=n(l);t!==null&&re(b,t.startTime-e)}}}function x(t,i){m=!1,h&&(h=!1,_(w),w=-1),p=!0;var a=f;try{for(y(i),d=n(c);d!==null&&(!(d.expirationTime>i)||t&&!D());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=i);i=e.unstable_now(),typeof s==`function`?d.callback=s:d===n(c)&&r(c),y(i)}else r(c);d=n(c)}if(d!==null)var u=!0;else{var g=n(l);g!==null&&re(b,g.startTime-i),u=!1}return u}finally{d=null,f=a,p=!1}}var S=!1,C=null,w=-1,T=5,E=-1;function D(){return!(e.unstable_now()-Ee||125o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(_(w),w=-1):h=!0,re(b,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,k(x))),r},e.unstable_shouldYield=D,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),be=t(((e,t)=>{t.exports=ye()})),xe=t((e=>{var t=n(),r=be();function i(e){for(var t=`https://reactjs.org/docs/error-decoder.html?invariant=`+e,n=1;n`u`||window.document===void 0||window.document.createElement===void 0),u=Object.prototype.hasOwnProperty,d=/^[: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]*$/,f={},p={};function m(e){return u.call(p,e)?!0:u.call(f,e)?!1:d.test(e)?p[e]=!0:(f[e]=!0,!1)}function h(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?(e=e.toLowerCase().slice(0,5),e!==`data-`&&e!==`aria-`):!n.acceptsBooleans;default:return!1}}function g(e,t,n,r){if(t==null||h(e,t,n,r))return!0;if(r)return!1;if(n!==null)switch(n.type){case 3:return!t;case 4:return!1===t;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}function _(e,t,n,r,i,a,o){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=r,this.attributeNamespace=i,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=a,this.removeEmptyString=o}var v={};`children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style`.split(` `).forEach(function(e){v[e]=new _(e,0,!1,e,null,!1,!1)}),[[`acceptCharset`,`accept-charset`],[`className`,`class`],[`htmlFor`,`for`],[`httpEquiv`,`http-equiv`]].forEach(function(e){var t=e[0];v[t]=new _(t,1,!1,e[1],null,!1,!1)}),[`contentEditable`,`draggable`,`spellCheck`,`value`].forEach(function(e){v[e]=new _(e,2,!1,e.toLowerCase(),null,!1,!1)}),[`autoReverse`,`externalResourcesRequired`,`focusable`,`preserveAlpha`].forEach(function(e){v[e]=new _(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){v[e]=new _(e,3,!1,e.toLowerCase(),null,!1,!1)}),[`checked`,`multiple`,`muted`,`selected`].forEach(function(e){v[e]=new _(e,3,!0,e,null,!1,!1)}),[`capture`,`download`].forEach(function(e){v[e]=new _(e,4,!1,e,null,!1,!1)}),[`cols`,`rows`,`size`,`span`].forEach(function(e){v[e]=new _(e,6,!1,e,null,!1,!1)}),[`rowSpan`,`start`].forEach(function(e){v[e]=new _(e,5,!1,e.toLowerCase(),null,!1,!1)});var y=/[\-:]([a-z])/g;function b(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(y,b);v[t]=new _(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(y,b);v[t]=new _(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(y,b);v[t]=new _(t,1,!1,e,`http://www.w3.org/XML/1998/namespace`,!1,!1)}),[`tabIndex`,`crossOrigin`].forEach(function(e){v[e]=new _(e,1,!1,e.toLowerCase(),null,!1,!1)}),v.xlinkHref=new _(`xlinkHref`,1,!1,`xlink:href`,`http://www.w3.org/1999/xlink`,!0,!1),[`src`,`href`,`action`,`formAction`].forEach(function(e){v[e]=new _(e,1,!1,e.toLowerCase(),null,!0,!0)});function x(e,t,n,r){var i=v.hasOwnProperty(t)?v[t]:null;(i===null?r||!(2s||i[o]!==a[s]){var c=` +`+i[o].replace(` at new `,` at `);return e.displayName&&c.includes(``)&&(c=c.replace(``,e.displayName)),c}while(1<=o&&0<=s);break}}}finally{N=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:``)?se(e):``}function le(e){switch(e.tag){case 5:return se(e.type);case 16:return se(`Lazy`);case 13:return se(`Suspense`);case 19:return se(`SuspenseList`);case 0:case 2:case 15:return e=ce(e.type,!1),e;case 11:return e=ce(e.type.render,!1),e;case 1:return e=ce(e.type,!0),e;default:return``}}function ue(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 T:return`Fragment`;case w:return`Portal`;case D:return`Profiler`;case E:return`StrictMode`;case ne:return`Suspense`;case k:return`SuspenseList`}if(typeof e==`object`)switch(e.$$typeof){case O:return(e.displayName||`Context`)+`.Consumer`;case ee:return(e._context.displayName||`Context`)+`.Provider`;case te:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case re:return t=e.displayName||null,t===null?ue(e.type)||`Memo`:t;case A:t=e._payload,e=e._init;try{return ue(e(t))}catch{}}return null}function de(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`:`ForwardRef(`+e+`)`);case 7:return`Fragment`;case 5:return t;case 4:return`Portal`;case 3:return`Root`;case 6:return`Text`;case 16:return ue(t);case 8:return t===E?`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 fe(e){switch(typeof e){case`boolean`:case`number`:case`string`:case`undefined`:return e;case`object`:return e;default:return``}}function P(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()===`input`&&(t===`checkbox`||t===`radio`)}function F(e){var t=P(e)?`checked`:`value`,n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=``+e[t];if(!e.hasOwnProperty(t)&&n!==void 0&&typeof n.get==`function`&&typeof n.set==`function`){var i=n.get,a=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return i.call(this)},set:function(e){r=``+e,a.call(this,e)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(e){r=``+e},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function pe(e){e._valueTracker||=F(e)}function me(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r=``;return e&&(r=P(e)?e.checked?`true`:`false`:e.value),e=r,e!==n&&(t.setValue(e),!0)}function he(e){if(e||=typeof document<`u`?document:void 0,e===void 0)return null;try{return e.activeElement||e.body}catch{return e.body}}function ge(e,t){var n=t.checked;return M({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function _e(e,t){var n=t.defaultValue==null?``:t.defaultValue,r=t.checked==null?t.defaultChecked:t.checked;n=fe(t.value==null?n:t.value),e._wrapperState={initialChecked:r,initialValue:n,controlled:t.type===`checkbox`||t.type===`radio`?t.checked!=null:t.value!=null}}function ve(e,t){t=t.checked,t!=null&&x(e,`checked`,t,!1)}function ye(e,t){ve(e,t);var n=fe(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`)?Se(e,t.type,n):t.hasOwnProperty(`defaultValue`)&&Se(e,t.type,fe(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function xe(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 Se(e,t,n){(t!==`number`||he(e.ownerDocument)!==e)&&(n==null?e.defaultValue=``+e._wrapperState.initialValue:e.defaultValue!==``+n&&(e.defaultValue=``+n))}var Ce=Array.isArray;function we(e,t,n,r){if(e=e.options,t){t={};for(var i=0;i`+t.valueOf().toString()+``,t=Ae.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function Me(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var Ne={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},Pe=[`Webkit`,`ms`,`Moz`,`O`];Object.keys(Ne).forEach(function(e){Pe.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),Ne[t]=Ne[e]})});function Fe(e,t,n){return t==null||typeof t==`boolean`||t===``?``:n||typeof t!=`number`||t===0||Ne.hasOwnProperty(e)&&Ne[e]?(``+t).trim():t+`px`}function Ie(e,t){for(var n in e=e.style,t)if(t.hasOwnProperty(n)){var r=n.indexOf(`--`)===0,i=Fe(n,t[n],r);n===`float`&&(n=`cssFloat`),r?e.setProperty(n,i):e[n]=i}}var Le=M({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 Re(e,t){if(t){if(Le[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(i(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(i(60));if(typeof t.dangerouslySetInnerHTML!=`object`||!(`__html`in t.dangerouslySetInnerHTML))throw Error(i(61))}if(t.style!=null&&typeof t.style!=`object`)throw Error(i(62))}}function ze(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 Be=null;function Ve(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var He=null,Ue=null,We=null;function Ge(e){if(e=ji(e)){if(typeof He!=`function`)throw Error(i(280));var t=e.stateNode;t&&(t=Ni(t),He(e.stateNode,e.type,t))}}function Ke(e){Ue?We?We.push(e):We=[e]:Ue=e}function qe(){if(Ue){var e=Ue,t=We;if(We=Ue=null,Ge(e),t)for(e=0;e>>=0,e===0?32:31-(xt(e)/St|0)|0}var wt=64,Tt=4194304;function Et(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 Dt(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,i=e.suspendedLanes,a=e.pingedLanes,o=n&268435455;if(o!==0){var s=o&~i;s===0?(a&=o,a!==0&&(r=Et(a))):r=Et(s)}else o=n&~i,o===0?a!==0&&(r=Et(a)):r=Et(o);if(r===0)return 0;if(t!==0&&t!==r&&(t&i)===0&&(i=r&-r,a=t&-t,i>=a||i===16&&a&4194240))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 Nt(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-bt(t),e[t]=n}function Pt(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=Jn),Zn=` `,J=!1;function Qn(e,t){switch(e){case`keyup`:return Kn.indexOf(t.keyCode)!==-1;case`keydown`:return t.keyCode!==229;case`keypress`:case`mousedown`:case`focusout`:return!0;default:return!1}}function Y(e){return e=e.detail,typeof e==`object`&&`data`in e?e.data:null}var $n=!1;function er(e,t){switch(e){case`compositionend`:return Y(t);case`keypress`:return t.which===32?(J=!0,Zn):null;case`textInput`:return e=t.data,e===Zn&&J?null:e;default:return null}}function tr(e,t){if($n)return e===`compositionend`||!qn&&Qn(e,t)?(e=_n(),gn=hn=mn=null,$n=!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}a:{for(;n;){if(n.nextSibling){n=n.nextSibling;break a}n=n.parentNode}n=void 0}n=Cr(n)}}function Tr(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Tr(e,t.parentNode):`contains`in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Er(){for(var e=window,t=he();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href==`string`}catch{n=!1}if(n)e=t.contentWindow;else break;t=he(e.document)}return t}function Dr(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 Or(e){var t=Er(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&Tr(n.ownerDocument.documentElement,n)){if(r!==null&&Dr(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 i=n.textContent.length,a=Math.min(r.start,i);r=r.end===void 0?a:Math.min(r.end,i),!e.extend&&a>r&&(i=r,r=a,a=i),i=wr(n,a);var o=wr(n,r);i&&o&&(e.rangeCount!==1||e.anchorNode!==i.node||e.anchorOffset!==i.offset||e.focusNode!==o.node||e.focusOffset!==o.offset)&&(t=t.createRange(),t.setStart(i.node,i.offset),e.removeAllRanges(),a>r?(e.addRange(t),e.extend(o.node,o.offset)):(t.setEnd(o.node,o.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,Ar=null,jr=null,Mr=null,Nr=!1;function Pr(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Nr||Ar==null||Ar!==he(r)||(r=Ar,`selectionStart`in r&&Dr(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}),Mr&&Sr(Mr,r)||(Mr=r,r=ii(jr,`onSelect`),0Fi||(e.current=Pi[Fi],Pi[Fi]=null,Fi--)}function Ri(e,t){Fi++,Pi[Fi]=e.current,e.current=t}var zi={},Bi=Ii(zi),Vi=Ii(!1),Hi=zi;function Ui(e,t){var n=e.type.contextTypes;if(!n)return zi;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var i={},a;for(a in n)i[a]=t[a];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=i),i}function Wi(e){return e=e.childContextTypes,e!=null}function Gi(){Li(Vi),Li(Bi)}function Ki(e,t,n){if(Bi.current!==zi)throw Error(i(168));Ri(Bi,t),Ri(Vi,n)}function qi(e,t,n){var r=e.stateNode;if(t=t.childContextTypes,typeof r.getChildContext!=`function`)return n;for(var a in r=r.getChildContext(),r)if(!(a in t))throw Error(i(108,de(e)||`Unknown`,a));return M({},n,r)}function Ji(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||zi,Hi=Bi.current,Ri(Bi,e),Ri(Vi,Vi.current),!0}function Yi(e,t,n){var r=e.stateNode;if(!r)throw Error(i(169));n?(e=qi(e,t,Hi),r.__reactInternalMemoizedMergedChildContext=e,Li(Vi),Li(Bi),Ri(Bi,e)):Li(Vi),Ri(Vi,n)}var Xi=null,Zi=!1,Qi=!1;function $i(e){Xi===null?Xi=[e]:Xi.push(e)}function ea(e){Zi=!0,$i(e)}function ta(){if(!Qi&&Xi!==null){Qi=!0;var e=0,t=K;try{var n=Xi;for(K=1;e>=o,i-=o,la=1<<32-bt(t)+i|n<h?(g=d,d=null):g=d.sibling;var _=p(i,d,s[h],c);if(_===null){d===null&&(d=g);break}e&&d&&_.alternate===null&&t(i,d),a=o(_,a,h),u===null?l=_:u.sibling=_,u=_,d=g}if(h===s.length)return n(i,d),_a&&da(i,h),l;if(d===null){for(;hg?(_=h,h=null):_=h.sibling;var y=p(a,h,v.value,l);if(y===null){h===null&&(h=_);break}e&&h&&y.alternate===null&&t(a,h),s=o(y,s,g),d===null?u=y:d.sibling=y,d=y,h=_}if(v.done)return n(a,h),_a&&da(a,g),u;if(h===null){for(;!v.done;g++,v=c.next())v=f(a,v.value,l),v!==null&&(s=o(v,s,g),d===null?u=v:d.sibling=v,d=v);return _a&&da(a,g),u}for(h=r(a,h);!v.done;g++,v=c.next())v=m(h,a,g,v.value,l),v!==null&&(e&&v.alternate!==null&&h.delete(v.key===null?g:v.key),s=o(v,s,g),d===null?u=v:d.sibling=v,d=v);return e&&h.forEach(function(e){return t(a,e)}),_a&&da(a,g),u}function _(e,r,i,o){if(typeof i==`object`&&i&&i.type===T&&i.key===null&&(i=i.props.children),typeof i==`object`&&i){switch(i.$$typeof){case C:a:{for(var c=i.key,l=r;l!==null;){if(l.key===c){if(c=i.type,c===T){if(l.tag===7){n(e,l.sibling),r=a(l,i.props.children),r.return=e,e=r;break a}}else if(l.elementType===c||typeof c==`object`&&c&&c.$$typeof===A&&ja(c)===l.type){n(e,l.sibling),r=a(l,i.props),r.ref=ka(e,l,i),r.return=e,e=r;break a}n(e,l);break}t(e,l),l=l.sibling}i.type===T?(r=Zl(i.props.children,e.mode,o,i.key),r.return=e,e=r):(o=Xl(i.type,i.key,i.props,null,e.mode,o),o.ref=ka(e,r,i),o.return=e,e=o)}return s(e);case w:a:{for(l=i.key;r!==null;){if(r.key===l){if(r.tag===4&&r.stateNode.containerInfo===i.containerInfo&&r.stateNode.implementation===i.implementation){n(e,r.sibling),r=a(r,i.children||[]),r.return=e,e=r;break a}n(e,r);break}t(e,r),r=r.sibling}r=eu(i,e.mode,o),r.return=e,e=r}return s(e);case A:return l=i._init,_(e,r,l(i._payload),o)}if(Ce(i))return h(e,r,i,o);if(ae(i))return g(e,r,i,o);Aa(e,i)}return typeof i==`string`&&i!==``||typeof i==`number`?(i=``+i,r!==null&&r.tag===6?(n(e,r.sibling),r=a(r,i),r.return=e,e=r):(n(e,r),r=$l(i,e.mode,o),r.return=e,e=r),s(e)):n(e,r)}return _}var Na=Ma(!0),Pa=Ma(!1),Fa=Ii(null),Ia=null,La=null,Ra=null;function za(){Ra=La=Ia=null}function Ba(e){var t=Fa.current;Li(Fa),e._currentValue=t}function Va(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)===t?r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t):(e.childLanes|=t,r!==null&&(r.childLanes|=t)),e===n)break;e=e.return}}function Ha(e,t){Ia=e,Ra=La=null,e=e.dependencies,e!==null&&e.firstContext!==null&&((e.lanes&t)!==0&&(Ms=!0),e.firstContext=null)}function Ua(e){var t=e._currentValue;if(Ra!==e){if(e={context:e,memoizedValue:t,next:null},La===null){if(Ia===null)throw Error(i(308));La=e,Ia.dependencies={lanes:0,firstContext:e}}else La=La.next=e}return t}var Wa=null;function Ga(e){Wa===null?Wa=[e]:Wa.push(e)}function Ka(e,t,n,r){var i=t.interleaved;return i===null?(n.next=n,Ga(t)):(n.next=i.next,i.next=n),t.interleaved=n,qa(e,r)}function qa(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 Ja=!1;function Ya(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Xa(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 Za(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function Qa(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,$&2){var i=r.pending;return i===null?t.next=t:(t.next=i.next,i.next=t),r.pending=t,qa(e,n)}return i=r.interleaved,i===null?(t.next=t,Ga(r)):(t.next=i.next,i.next=t),r.interleaved=t,qa(e,n)}function $a(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,n&4194240)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Ft(e,n)}}function eo(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var i=null,a=null;if(n=n.firstBaseUpdate,n!==null){do{var o={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};a===null?i=a=o:a=a.next=o,n=n.next}while(n!==null);a===null?i=a=t:a=a.next=t}else i=a=t;n={baseState:r.baseState,firstBaseUpdate:i,lastBaseUpdate:a,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 to(e,t,n,r){var i=e.updateQueue;Ja=!1;var a=i.firstBaseUpdate,o=i.lastBaseUpdate,s=i.shared.pending;if(s!==null){i.shared.pending=null;var c=s,l=c.next;c.next=null,o===null?a=l:o.next=l,o=c;var u=e.alternate;u!==null&&(u=u.updateQueue,s=u.lastBaseUpdate,s!==o&&(s===null?u.firstBaseUpdate=l:s.next=l,u.lastBaseUpdate=c))}if(a!==null){var d=i.baseState;o=0,u=l=c=null,s=a;do{var f=s.lane,p=s.eventTime;if((r&f)===f){u!==null&&(u=u.next={eventTime:p,lane:0,tag:s.tag,payload:s.payload,callback:s.callback,next:null});a:{var m=e,h=s;switch(f=t,p=n,h.tag){case 1:if(m=h.payload,typeof m==`function`){d=m.call(p,d,f);break a}d=m;break a;case 3:m.flags=m.flags&-65537|128;case 0:if(m=h.payload,f=typeof m==`function`?m.call(p,d,f):m,f==null)break a;d=M({},d,f);break a;case 2:Ja=!0}}s.callback!==null&&s.lane!==0&&(e.flags|=64,f=i.effects,f===null?i.effects=[s]:f.push(s))}else p={eventTime:p,lane:f,tag:s.tag,payload:s.payload,callback:s.callback,next:null},u===null?(l=u=p,c=d):u=u.next=p,o|=f;if(s=s.next,s===null){if(s=i.shared.pending,s===null)break;f=s,s=f.next,f.next=null,i.lastBaseUpdate=f,i.shared.pending=null}}while(1);if(u===null&&(c=d),i.baseState=c,i.firstBaseUpdate=l,i.lastBaseUpdate=u,t=i.shared.interleaved,t!==null){i=t;do o|=i.lane,i=i.next;while(i!==t)}else a===null&&(i.shared.lanes=0);Jc|=o,e.lanes=o,e.memoizedState=d}}function no(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;tn?n:4,e(!0);var r=vo.transition;vo.transition={};try{e(!1),t()}finally{K=n,vo.transition=r}}function as(){return Mo().memoizedState}function os(e,t,n){var r=pl(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},cs(e))ls(t,n);else if(n=Ka(e,t,n,r),n!==null){var i=fl();ml(n,e,r,i),us(n,t,r)}}function ss(e,t,n){var r=pl(e),i={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(cs(e))ls(t,i);else{var a=e.alternate;if(e.lanes===0&&(a===null||a.lanes===0)&&(a=t.lastRenderedReducer,a!==null))try{var o=t.lastRenderedState,s=a(o,n);if(i.hasEagerState=!0,i.eagerState=s,xr(s,o)){var c=t.interleaved;c===null?(i.next=i,Ga(t)):(i.next=c.next,c.next=i),t.interleaved=i;return}}catch{}n=Ka(e,t,i,r),n!==null&&(i=fl(),ml(n,e,r,i),us(n,t,r))}}function cs(e){var t=e.alternate;return e===bo||t!==null&&t===bo}function ls(e,t){wo=Co=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function us(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Ft(e,n)}}var ds={readContext:Ua,useCallback:Do,useContext:Do,useEffect:Do,useImperativeHandle:Do,useInsertionEffect:Do,useLayoutEffect:Do,useMemo:Do,useReducer:Do,useRef:Do,useState:Do,useDebugValue:Do,useDeferredValue:Do,useTransition:Do,useMutableSource:Do,useSyncExternalStore:Do,useId:Do,unstable_isNewReconciler:!1},fs={readContext:Ua,useCallback:function(e,t){return jo().memoizedState=[e,t===void 0?null:t],e},useContext:Ua,useEffect:Jo,useImperativeHandle:function(e,t,n){return n=n==null?null:n.concat([e]),Ko(4194308,4,Qo.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Ko(4194308,4,e,t)},useInsertionEffect:function(e,t){return Ko(4,2,e,t)},useMemo:function(e,t){var n=jo();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=jo();return t=n===void 0?t:n(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=os.bind(null,bo,e),[r.memoizedState,e]},useRef:function(e){var t=jo();return e={current:e},t.memoizedState=e},useState:Uo,useDebugValue:es,useDeferredValue:function(e){return jo().memoizedState=e},useTransition:function(){var e=Uo(!1),t=e[0];return e=is.bind(null,e[1]),jo().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=bo,a=jo();if(_a){if(n===void 0)throw Error(i(407));n=n()}else{if(n=t(),Vc===null)throw Error(i(349));yo&30||Ro(r,t,n)}a.memoizedState=n;var o={value:n,getSnapshot:t};return a.queue=o,Jo(Bo.bind(null,r,o,e),[e]),r.flags|=2048,Wo(9,zo.bind(null,r,o,n,t),void 0,null),n},useId:function(){var e=jo(),t=Vc.identifierPrefix;if(_a){var n=ua,r=la;n=(r&~(1<<32-bt(r)-1)).toString(32)+n,t=`:`+t+`R`+n,n=To++,0<\/script>`,e=e.removeChild(e.firstChild)):typeof r.is==`string`?e=c.createElement(n,{is:r.is}):(e=c.createElement(n),n===`select`&&(c=e,r.multiple?c.multiple=!0:r.size&&(c.size=r.size))):e=c.createElementNS(e,n),e[wi]=t,e[Ti]=r,nc(e,t,!1,!1),t.stateNode=e;a:{switch(c=ze(n,r),n){case`dialog`:Zr(`cancel`,e),Zr(`close`,e),a=r;break;case`iframe`:case`object`:case`embed`:Zr(`load`,e),a=r;break;case`video`:case`audio`:for(a=0;ael&&(t.flags|=128,r=!0,ac(s,!1),t.lanes=4194304)}}else{if(!r){if(e=mo(c),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),ac(s,!0),s.tail===null&&s.tailMode===`hidden`&&!c.alternate&&!_a)return oc(t),null}else 2*W()-s.renderingStartTime>el&&n!==1073741824&&(t.flags|=128,r=!0,ac(s,!1),t.lanes=4194304)}s.isBackwards?(c.sibling=t.child,t.child=c):(n=s.last,n===null?t.child=c:n.sibling=c,s.last=c)}return s.tail===null?(oc(t),null):(t=s.tail,s.rendering=t,s.tail=t.sibling,s.renderingStartTime=W(),t.sibling=null,n=po.current,Ri(po,r?n&1|2:n&1),t);case 22:case 23:return wl(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?Wc&1073741824&&(oc(t),t.subtreeFlags&6&&(t.flags|=8192)):oc(t),null;case 24:return null;case 25:return null}throw Error(i(156,t.tag))}function cc(e,t){switch(ma(t),t.tag){case 1:return Wi(t.type)&&Gi(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return lo(),Li(Vi),Li(Bi),go(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return fo(t),null;case 13:if(Li(po),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(i(340));Ea()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return Li(po),null;case 4:return lo(),null;case 10:return Ba(t.type._context),null;case 22:case 23:return wl(),null;case 24:return null;default:return null}}var lc=!1,uc=!1,dc=typeof WeakSet==`function`?WeakSet:Set,Q=null;function fc(e,t){var n=e.ref;if(n!==null){if(typeof n==`function`)try{n(null)}catch(n){Rl(e,t,n)}else n.current=null}}function pc(e,t,n){try{n()}catch(n){Rl(e,t,n)}}var mc=!1;function hc(e,t){if(fi=q,e=Er(),Dr(e)){if(`selectionStart`in e)var n={start:e.selectionStart,end:e.selectionEnd};else a:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var a=r.anchorOffset,o=r.focusNode;r=r.focusOffset;try{n.nodeType,o.nodeType}catch{n=null;break a}var s=0,c=-1,l=-1,u=0,d=0,f=e,p=null;b:for(;;){for(var m;f!==n||a!==0&&f.nodeType!==3||(c=s+a),f!==o||r!==0&&f.nodeType!==3||(l=s+r),f.nodeType===3&&(s+=f.nodeValue.length),(m=f.firstChild)!==null;)p=f,f=m;for(;;){if(f===e)break b;if(p===n&&++u===a&&(c=s),p===o&&++d===r&&(l=s),(m=f.nextSibling)!==null)break;f=p,p=f.parentNode}f=m}n=c===-1||l===-1?null:{start:c,end:l}}else n=null}n||={start:0,end:0}}else n=null;for(pi={focusedElem:e,selectionRange:n},q=!1,Q=t;Q!==null;)if(t=Q,e=t.child,t.subtreeFlags&1028&&e!==null)e.return=t,Q=e;else for(;Q!==null;){t=Q;try{var h=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(h!==null){var g=h.memoizedProps,_=h.memoizedState,v=t.stateNode;v.__reactInternalSnapshotBeforeUpdate=v.getSnapshotBeforeUpdate(t.elementType===t.type?g:hs(t.type,g),_)}break;case 3:var y=t.stateNode.containerInfo;y.nodeType===1?y.textContent=``:y.nodeType===9&&y.documentElement&&y.removeChild(y.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(i(163))}}catch(e){Rl(t,t.return,e)}if(e=t.sibling,e!==null){e.return=t.return,Q=e;break}Q=t.return}return h=mc,mc=!1,h}function gc(e,t,n){var r=t.updateQueue;if(r=r===null?null:r.lastEffect,r!==null){var i=r=r.next;do{if((i.tag&e)===e){var a=i.destroy;i.destroy=void 0,a!==void 0&&pc(t,n,a)}i=i.next}while(i!==r)}}function _c(e,t){if(t=t.updateQueue,t=t===null?null:t.lastEffect,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 vc(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 yc(e){var t=e.alternate;t!==null&&(e.alternate=null,yc(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[wi],delete t[Ti],delete t[Di],delete t[Oi],delete t[ki])),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 bc(e){return e.tag===5||e.tag===3||e.tag===4}function xc(e){a:for(;;){for(;e.sibling===null;){if(e.return===null||bc(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 a;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function Sc(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=di));else if(r!==4&&(e=e.child,e!==null))for(Sc(e,t,n),e=e.sibling;e!==null;)Sc(e,t,n),e=e.sibling}function Cc(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(Cc(e,t,n),e=e.sibling;e!==null;)Cc(e,t,n),e=e.sibling}var wc=null,Tc=!1;function Ec(e,t,n){for(n=n.child;n!==null;)Dc(e,t,n),n=n.sibling}function Dc(e,t,n){if(vt&&typeof vt.onCommitFiberUnmount==`function`)try{vt.onCommitFiberUnmount(G,n)}catch{}switch(n.tag){case 5:uc||fc(n,t);case 6:var r=wc,i=Tc;wc=null,Ec(e,t,n),wc=r,Tc=i,wc!==null&&(Tc?(e=wc,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):wc.removeChild(n.stateNode));break;case 18:wc!==null&&(Tc?(e=wc,n=n.stateNode,e.nodeType===8?bi(e.parentNode,n):e.nodeType===1&&bi(e,n),on(e)):bi(wc,n.stateNode));break;case 4:r=wc,i=Tc,wc=n.stateNode.containerInfo,Tc=!0,Ec(e,t,n),wc=r,Tc=i;break;case 0:case 11:case 14:case 15:if(!uc&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){i=r=r.next;do{var a=i,o=a.destroy;a=a.tag,o!==void 0&&(a&2||a&4)&&pc(n,t,o),i=i.next}while(i!==r)}Ec(e,t,n);break;case 1:if(!uc&&(fc(n,t),r=n.stateNode,typeof r.componentWillUnmount==`function`))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(e){Rl(n,t,e)}Ec(e,t,n);break;case 21:Ec(e,t,n);break;case 22:n.mode&1?(uc=(r=uc)||n.memoizedState!==null,Ec(e,t,n),uc=r):Ec(e,t,n);break;default:Ec(e,t,n)}}function Oc(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new dc),t.forEach(function(t){var r=Hl.bind(null,e,t);n.has(t)||(n.add(t),t.then(r,r))})}}function kc(e,t){var n=t.deletions;if(n!==null)for(var r=0;ra&&(a=s),r&=~o}if(r=a,r=W()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*Lc(r/1960))-r,10e?16:e,ol===null)var r=!1;else{if(e=ol,ol=null,sl=0,$&6)throw Error(i(331));var a=$;for($|=4,Q=e.current;Q!==null;){var o=Q,s=o.child;if(Q.flags&16){var c=o.deletions;if(c!==null){for(var l=0;lW()-$c?Tl(e,0):Xc|=n),hl(e,t)}function Bl(e,t){t===0&&(e.mode&1?(t=Tt,Tt<<=1,!(Tt&130023424)&&(Tt=4194304)):t=1);var n=fl();e=qa(e,t),e!==null&&(Nt(e,t,n),hl(e,n))}function Vl(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),Bl(e,n)}function Hl(e,t){var n=0;switch(e.tag){case 13:var r=e.stateNode,a=e.memoizedState;a!==null&&(n=a.retryLane);break;case 19:r=e.stateNode;break;default:throw Error(i(314))}r!==null&&r.delete(t),Bl(e,n)}var Ul=function(e,t,n){if(e!==null){if(e.memoizedProps!==t.pendingProps||Vi.current)Ms=!0;else{if((e.lanes&n)===0&&!(t.flags&128))return Ms=!1,tc(e,t,n);Ms=!!(e.flags&131072)}}else Ms=!1,_a&&t.flags&1048576&&fa(t,aa,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;$s(e,t),e=t.pendingProps;var a=Ui(t,Bi.current);Ha(t,n),a=ko(null,t,r,e,a,n);var o=Ao();return t.flags|=1,typeof a==`object`&&a&&typeof a.render==`function`&&a.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,Wi(r)?(o=!0,Ji(t)):o=!1,t.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,Ya(t),a.updater=_s,t.stateNode=a,a._reactInternals=t,xs(t,r,e,n),t=Vs(null,t,r,!0,o,n)):(t.tag=0,_a&&o&&pa(t),Ns(null,t,a,n),t=t.child),t;case 16:r=t.elementType;a:{switch($s(e,t),e=t.pendingProps,a=r._init,r=a(r._payload),t.type=r,a=t.tag=Jl(r),e=hs(r,e),a){case 0:t=zs(null,t,r,e,n);break a;case 1:t=Bs(null,t,r,e,n);break a;case 11:t=Ps(null,t,r,e,n);break a;case 14:t=Fs(null,t,r,hs(r.type,e),n);break a}throw Error(i(306,r,``))}return t;case 0:return r=t.type,a=t.pendingProps,a=t.elementType===r?a:hs(r,a),zs(e,t,r,a,n);case 1:return r=t.type,a=t.pendingProps,a=t.elementType===r?a:hs(r,a),Bs(e,t,r,a,n);case 3:a:{if(Hs(t),e===null)throw Error(i(387));r=t.pendingProps,o=t.memoizedState,a=o.element,Xa(e,t),to(t,r,null,n);var s=t.memoizedState;if(r=s.element,o.isDehydrated){if(o={element:r,isDehydrated:!1,cache:s.cache,pendingSuspenseBoundaries:s.pendingSuspenseBoundaries,transitions:s.transitions},t.updateQueue.baseState=o,t.memoizedState=o,t.flags&256){a=Ss(Error(i(423)),t),t=Us(e,t,r,n,a);break a}if(r!==a){a=Ss(Error(i(424)),t),t=Us(e,t,r,n,a);break a}for(ga=xi(t.stateNode.containerInfo.firstChild),ha=t,_a=!0,va=null,n=Pa(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling}else{if(Ea(),r===a){t=ec(e,t,n);break a}Ns(e,t,r,n)}t=t.child}return t;case 5:return uo(t),e===null&&Sa(t),r=t.type,a=t.pendingProps,o=e===null?null:e.memoizedProps,s=a.children,mi(r,a)?s=null:o!==null&&mi(r,o)&&(t.flags|=32),Rs(e,t),Ns(e,t,s,n),t.child;case 6:return e===null&&Sa(t),null;case 13:return Ks(e,t,n);case 4:return co(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=Na(t,null,r,n):Ns(e,t,r,n),t.child;case 11:return r=t.type,a=t.pendingProps,a=t.elementType===r?a:hs(r,a),Ps(e,t,r,a,n);case 7:return Ns(e,t,t.pendingProps,n),t.child;case 8:return Ns(e,t,t.pendingProps.children,n),t.child;case 12:return Ns(e,t,t.pendingProps.children,n),t.child;case 10:a:{if(r=t.type._context,a=t.pendingProps,o=t.memoizedProps,s=a.value,Ri(Fa,r._currentValue),r._currentValue=s,o!==null){if(xr(o.value,s)){if(o.children===a.children&&!Vi.current){t=ec(e,t,n);break a}}else for(o=t.child,o!==null&&(o.return=t);o!==null;){var c=o.dependencies;if(c!==null){s=o.child;for(var l=c.firstContext;l!==null;){if(l.context===r){if(o.tag===1){l=Za(-1,n&-n),l.tag=2;var u=o.updateQueue;if(u!==null){u=u.shared;var d=u.pending;d===null?l.next=l:(l.next=d.next,d.next=l),u.pending=l}}o.lanes|=n,l=o.alternate,l!==null&&(l.lanes|=n),Va(o.return,n,t),c.lanes|=n;break}l=l.next}}else if(o.tag===10)s=o.type===t.type?null:o.child;else if(o.tag===18){if(s=o.return,s===null)throw Error(i(341));s.lanes|=n,c=s.alternate,c!==null&&(c.lanes|=n),Va(s,n,t),s=o.sibling}else s=o.child;if(s!==null)s.return=o;else for(s=o;s!==null;){if(s===t){s=null;break}if(o=s.sibling,o!==null){o.return=s.return,s=o;break}s=s.return}o=s}}Ns(e,t,a.children,n),t=t.child}return t;case 9:return a=t.type,r=t.pendingProps.children,Ha(t,n),a=Ua(a),r=r(a),t.flags|=1,Ns(e,t,r,n),t.child;case 14:return r=t.type,a=hs(r,t.pendingProps),a=hs(r.type,a),Fs(e,t,r,a,n);case 15:return Is(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,a=t.pendingProps,a=t.elementType===r?a:hs(r,a),$s(e,t),t.tag=1,Wi(r)?(e=!0,Ji(t)):e=!1,Ha(t,n),ys(t,r,a),xs(t,r,a,n),Vs(null,t,r,!0,e,n);case 19:return Qs(e,t,n);case 22:return Ls(e,t,n)}throw Error(i(156,t.tag))};function Wl(e,t){return lt(e,t)}function Gl(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 Kl(e,t,n,r){return new Gl(e,t,n,r)}function ql(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Jl(e){if(typeof e==`function`)return+!!ql(e);if(e!=null){if(e=e.$$typeof,e===te)return 11;if(e===re)return 14}return 2}function Yl(e,t){var n=e.alternate;return n===null?(n=Kl(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 Xl(e,t,n,r,a,o){var s=2;if(r=e,typeof e==`function`)ql(e)&&(s=1);else if(typeof e==`string`)s=5;else a:switch(e){case T:return Zl(n.children,a,o,t);case E:s=8,a|=8;break;case D:return e=Kl(12,n,t,a|2),e.elementType=D,e.lanes=o,e;case ne:return e=Kl(13,n,t,a),e.elementType=ne,e.lanes=o,e;case k:return e=Kl(19,n,t,a),e.elementType=k,e.lanes=o,e;case j:return Ql(n,a,o,t);default:if(typeof e==`object`&&e)switch(e.$$typeof){case ee:s=10;break a;case O:s=9;break a;case te:s=11;break a;case re:s=14;break a;case A:s=16,r=null;break a}throw Error(i(130,e==null?e:typeof e,``))}return t=Kl(s,n,t,a),t.elementType=e,t.type=r,t.lanes=o,t}function Zl(e,t,n,r){return e=Kl(7,e,r,t),e.lanes=n,e}function Ql(e,t,n,r){return e=Kl(22,e,r,t),e.elementType=j,e.lanes=n,e.stateNode={isHidden:!1},e}function $l(e,t,n){return e=Kl(6,e,null,t),e.lanes=n,e}function eu(e,t,n){return t=Kl(4,e.children===null?[]:e.children,e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function tu(e,t,n,r,i){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=Mt(0),this.expirationTimes=Mt(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Mt(0),this.identifierPrefix=r,this.onRecoverableError=i,this.mutableSourceEagerHydrationData=null}function nu(e,t,n,r,i,a,o,s,c){return e=new tu(e,t,n,s,c),t===1?(t=1,!0===a&&(t|=8)):t=0,a=Kl(3,null,null,t),e.current=a,a.stateNode=e,a.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},Ya(a),e}function ru(e,t,n){var r=3{function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=`function`))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=xe()})),Ce=t((e=>{var t=Se();e.createRoot=t.createRoot,e.hydrateRoot=t.hydrateRoot})),we=class extends A{constructor(e={}){super(),this.config=e,this.#e=new Set,this.#t=new Map,this.#n=0}#e;#t;#n;build(e,t,n){let r=new re({client:e,mutationCache:this,mutationId:++this.#n,options:e.defaultMutationOptions(t),state:n});return this.add(r),r}add(e){this.#e.add(e);let t=Te(e);if(typeof t==`string`){let n=this.#t.get(t);n?n.push(e):this.#t.set(t,[e])}this.notify({type:`added`,mutation:e})}remove(e){if(this.#e.delete(e)){let t=Te(e);if(typeof t==`string`){let n=this.#t.get(t);if(n){if(n.length>1){let t=n.indexOf(e);t!==-1&&n.splice(t,1)}else n[0]===e&&this.#t.delete(t)}}}this.notify({type:`removed`,mutation:e})}canRun(e){let t=Te(e);if(typeof t==`string`){let n=this.#t.get(t)?.find(e=>e.state.status===`pending`);return!n||n===e}return!0}runNext(e){let t=Te(e);return typeof t==`string`?(this.#t.get(t)?.find(t=>t!==e&&t.state.isPaused))?.continue()??Promise.resolve():Promise.resolve()}clear(){j.batch(()=>{this.#e.forEach(e=>{this.notify({type:`removed`,mutation:e})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(e){let t={exact:!0,...e};return this.getAll().find(e=>ae(t,e))}findAll(e={}){return this.getAll().filter(t=>ae(e,t))}notify(e){j.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){let e=this.getAll().filter(e=>e.state.isPaused);return j.batch(()=>Promise.all(e.map(e=>e.continue().catch(N))))}};function Te(e){return e.options.scope?.id}var Ee=class extends A{constructor(e={}){super(),this.config=e,this.#e=new Map}#e;build(e,t,n){let r=t.queryKey,i=t.queryHash??ie(r,t),a=this.get(i);return a||(a=new le({client:e,queryKey:r,queryHash:i,options:e.defaultQueryOptions(t),state:n,defaultOptions:e.getQueryDefaults(r)}),this.add(a)),a}add(e){this.#e.has(e.queryHash)||(this.#e.set(e.queryHash,e),this.notify({type:`added`,query:e}))}remove(e){let t=this.#e.get(e.queryHash);t&&(e.destroy(),t===e&&this.#e.delete(e.queryHash),this.notify({type:`removed`,query:e}))}clear(){j.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#e.get(e)}getAll(){return[...this.#e.values()]}find(e){let t={exact:!0,...e};return this.getAll().find(e=>ue(t,e))}findAll(e={}){let t=this.getAll();return Object.keys(e).length>0?t.filter(t=>ue(e,t)):t}notify(e){j.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){j.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){j.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},De=class{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e={}){this.#e=e.queryCache||new Ee,this.#t=e.mutationCache||new we,this.#n=e.defaultOptions||{},this.#r=new Map,this.#i=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#o=me.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#s=fe.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#a--,this.#a===0&&(this.#o?.(),this.#o=void 0,this.#s?.(),this.#s=void 0)}isFetching(e){return this.#e.findAll({...e,fetchStatus:`fetching`}).length}isMutating(e){return this.#t.findAll({...e,status:`pending`}).length}getQueryData(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state.data}ensureQueryData(e){let t=this.defaultQueryOptions(e),n=this.#e.build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(k(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return this.#e.findAll(e).map(({queryKey:e,state:t})=>[e,t.data])}setQueryData(e,t,n){let r=this.defaultQueryOptions({queryKey:e}),i=this.#e.get(r.queryHash)?.state.data,a=se(t,i);if(a!==void 0)return this.#e.build(this,r).setData(a,{...n,manual:!0})}setQueriesData(e,t,n){return j.batch(()=>this.#e.findAll(e).map(({queryKey:e})=>[e,this.setQueryData(e,t,n)]))}getQueryState(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state}removeQueries(e){let t=this.#e;j.batch(()=>{t.findAll(e).forEach(e=>{t.remove(e)})})}resetQueries(e,t){let n=this.#e;return j.batch(()=>(n.findAll(e).forEach(e=>{e.reset()}),this.refetchQueries({type:`active`,...e},t)))}cancelQueries(e,t={}){let n={revert:!0,...t},r=j.batch(()=>this.#e.findAll(e).map(e=>e.cancel(n)));return Promise.all(r).then(N).catch(N)}invalidateQueries(e,t={}){return j.batch(()=>(this.#e.findAll(e).forEach(e=>{e.invalidate()}),e?.refetchType===`none`?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??`active`},t)))}refetchQueries(e,t={}){let n={...t,cancelRefetch:t.cancelRefetch??!0},r=j.batch(()=>this.#e.findAll(e).filter(e=>!e.isDisabled()&&!e.isStatic()).map(e=>{let t=e.fetch(void 0,n);return n.throwOnError||(t=t.catch(N)),e.state.fetchStatus===`paused`?Promise.resolve():t}));return Promise.all(r).then(N)}fetchQuery(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let n=this.#e.build(this,t);return n.isStaleByTime(k(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(N).catch(N)}fetchInfiniteQuery(e){return e._type=`infinite`,this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(N).catch(N)}ensureInfiniteQueryData(e){return e._type=`infinite`,this.ensureQueryData(e)}resumePausedMutations(){return fe.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#n}setDefaultOptions(e){this.#n=e}setQueryDefaults(e,t){this.#r.set(F(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){let t=[...this.#r.values()],n={};return t.forEach(t=>{M(e,t.queryKey)&&Object.assign(n,t.defaultOptions)}),n}setMutationDefaults(e,t){this.#i.set(F(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){let t=[...this.#i.values()],n={};return t.forEach(t=>{M(e,t.mutationKey)&&Object.assign(n,t.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;let t={...this.#n.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||=ie(t.queryKey,t),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!==`always`),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode=`offlineFirst`),t.queryFn===pe&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#n.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}},I=e(n(),1),Oe=e(Ce(),1),ke=class extends Error{status;method;path;constructor(e,t,n,r){super(e),this.name=`ApiError`,this.status=t,this.method=n,this.path=r}};function Ae(e){let t=e.replace(/\s+/g,` `).trim();if(!t)return``;try{let t=JSON.parse(e);for(let e of[`detail`,`error`,`message`]){let n=t[e];if(typeof n==`string`&&n.trim())return n.trim();if(Array.isArray(n)){let e=n.map(e=>e&&typeof e==`object`?String(e.msg??``):``).filter(Boolean);if(e.length)return e.join(`; `)}}}catch{}return t.startsWith(`typeof e==`string`):[],o=Re(r?.major),s=Re(r?.minor);if(!n||!r||!i)return{compatible:!1,reason:`malformed /api/meta response`};if(typeof i.source_root!=`string`||Re(i.pid)===null||typeof i.package_version!=`string`||typeof i.release_id!=`string`)return{compatible:!1,reason:`malformed /api/meta runtime identity`};if(n.service!==`argus-skill-webapi`)return{compatible:!1,reason:`unexpected service ${String(n.service||`unknown`)}`};let c=e;if(r.name!==Pe.name||o!==Pe.major)return{compatible:!1,reason:`protocol ${String(r.name||`unknown`)}/${String(o)} is incompatible with client ${Pe.name}/${Pe.major}`,meta:c};if(s===null||s!a.includes(e));if(l.length>0)return{compatible:!1,reason:`missing capabilities: ${l.join(`, `)}`,meta:c};if(i.source_root_matches_config===!1)return{compatible:!1,reason:`backend is running from a different installation than configured`,meta:c};if(i.release_id!==t.releaseId)return{compatible:!1,reason:`backend and client installations are out of sync; restart or reinstall Argus`,meta:c};if(t.sourceDigest){if(typeof i.runtime_source_digest!=`string`||!i.runtime_source_digest)return{compatible:!1,reason:`backend cannot verify this local installation; restart it from the current checkout`,meta:c};if(i.runtime_source_digest!==t.sourceDigest)return{compatible:!1,reason:`backend is running code from a different local installation; restart it`,meta:c}}return{compatible:!0,reason:``,warning:i.release_matches_source===!1?Fe:void 0,meta:c}}function Be(e,t){let n=ze(e);if(!n.compatible||!n.meta)throw Error(`incompatible Argus API: ${n.reason}`);return n.warning&&t?.(n.warning),n.meta}function Ve(e){let t=Le(e),n=Le(t?.daemon);if(!t||t.schema_version!==7)throw Error(`incompatible snapshot schema: expected 7, got ${String(t?.schema_version??`missing`)}`);if(!n)throw Error(`invalid snapshot: daemon section is missing`);let r=[`global_daily_cap_usd`,`read_status`,`read_error`,`protocol_compatible`,`protocol_error`].filter(e=>!Object.hasOwn(n,e));if(r.length>0)throw Error(`invalid snapshot: daemon fields missing: ${r.join(`, `)}`);let i=[`spend_usd`,`spend_status`,`usage_summary`,`request_usage`,`cost_control`,`daemon_commands`,`observability`,`mission_view`,`partial`,`diagnostics`].filter(e=>!Object.hasOwn(t,e));if(i.length>0)throw Error(`invalid snapshot: fields missing: ${i.join(`, `)}`);if(!Array.isArray(t.diagnostics))throw Error(`invalid snapshot: diagnostics must be an array`);return e}var He=`argus_web_token`,Ue=null;function We(){let e;try{e=new URLSearchParams(window.location.search)}catch{return}let t=e.get(`token`);if(t){Ue=t;try{localStorage.setItem(He,t)}catch{}try{e.delete(`token`);let t=e.toString();window.history.replaceState(null,``,`${window.location.pathname}${t?`?${t}`:``}${window.location.hash}`)}catch{}}}var Ge=()=>{if(Ue)return Ue;try{return new URLSearchParams(window.location.search).get(`token`)||localStorage.getItem(He)}catch{return null}};function Ke(){let e=Ge();return e?{Authorization:`Bearer ${e}`}:{}}function qe(){return Ge()??``}var Je=8e3,Ye=12e3,Xe=class extends Error{constructor(){super(`This browser is not paired with Argus. Reopen it from Argus Desktop or use a fresh pairing link.`),this.name=`PairingRequiredError`}},Ze=class extends Error{method;path;constructor(e,t,n=`could not reach the local Argus service`){super(`${e.toUpperCase()} ${t} ${n}. Make sure Argus Desktop is running, then retry.`),this.name=`LocalArgusUnavailableError`,this.method=e.toUpperCase(),this.path=t}};function L(e){return e instanceof Xe||!!(e&&typeof e==`object`&&Number(e.status)===401)}function Qe(e){return L(e)||e instanceof Ze}async function $e(e,t){try{return await fetch(e,t)}catch(n){throw t.signal?.aborted?n:new Ze(String(t.method??`GET`),e)}}async function et(e,t,n,r){let i=new AbortController,a=t.signal??void 0,o=!1,s=()=>{};if(a){let e=()=>i.abort(a.reason);a.aborted?e():(a.addEventListener(`abort`,e,{once:!0}),s=()=>a.removeEventListener(`abort`,e))}let c,l=(async()=>await r(await $e(e,{...t,signal:i.signal})))(),u=new Promise((e,t)=>{c=setTimeout(()=>{o=!0;let e=Error(`request timed out after ${n}ms`);i.abort(e),t(e)},n)});try{return await Promise.race([l,u])}catch(r){if(o){let r=Math.round(n/1e3);throw new Ze(String(t.method??`GET`),e,`timed out after ${r}s because the local Argus service did not respond`)}throw r}finally{c&&clearTimeout(c),s()}}async function R(e,t,n){return et(e,{headers:Ke(),signal:t},n??Ye,async t=>(await Me(t,`GET`,e),await t.json()))}async function z(e,t,n){let r=await fetch(e,{method:`POST`,headers:{"Content-Type":`application/json`,...Ke()},body:t===void 0?void 0:JSON.stringify(t),signal:n});return await Me(r,`POST`,e),await r.json()}async function tt(e,t,n){let r=await fetch(e,{method:`POST`,headers:Ke(),body:t,signal:n});return await Me(r,`POST`,e),await r.json()}function nt(e){let t=e&&typeof e==`object`?e:{},n=String(t.command_status??``);if(Number(t.rc??0)!==0||n===`failed`||n===`rejected`)throw Error(String(t.error||`daemon command ${n||`failed`}`));return e}async function rt(e,t,n){let r=await fetch(t,{method:e,headers:{"Content-Type":`application/json`,...Ke()},body:n===void 0?void 0:JSON.stringify(n)});return await Me(r,e,t),await r.json()}async function it(e,t){let n=await fetch(e,{headers:Ke(),signal:t});return await Me(n,`GET`,e),n.blob()}var B=(e,t=``)=>`/api/projects/${encodeURIComponent(e)}${t}`,at=()=>globalThis.crypto?.randomUUID?.()??`${Date.now()}-${Math.random()}`,ot;function st(e){return!!(e&&typeof e==`object`&&`aborted`in e&&typeof e.aborted==`boolean`)}function V(e,t,n){let r={text:e};return t?.length&&(r.attachments=t),n&&n!==`auto`&&(r.route_override=n),r}function H(){if(!ot){let e=(async()=>{let e=`/api/meta`,t=await et(e,{headers:Ke()},Je,async t=>{if(t.status===404)throw Error(`incompatible Argus API: service does not expose /api/meta`);return await Me(t,`GET`,e),Be(await t.json(),e=>console.warn(`Argus API compatibility warning: ${e}`))});if(t.authentication?.required&&!t.authentication.authenticated)throw new Xe;return t})();ot=e,e.catch(t=>{ot===e&&!(t instanceof Xe)&&(ot=void 0)})}return ot}function ct(e){let t=[],n;for(;(n=e.indexOf(` + +`))>=0;){let r=e.slice(0,n);e=e.slice(n+2);for(let e of r.split(` +`)){let n=e.trim();if(n.startsWith(`data:`))try{t.push(JSON.parse(n.slice(5).trim()))}catch{}}}return{frames:t,rest:e}}var lt=null,U={liveMap:(e,t,n,r)=>{let i=new URLSearchParams;return n&&i.set(`after`,n),r?.mode===`current`&&(i.set(`since`,String(r.since)),i.set(`event_since`,String(r.eventSince)),r.taskId&&i.set(`start_task`,r.taskId)),R(B(e,`/map`)+(i.size?`?${i}`:``),t)},mapInfo:(e,t)=>R(B(e,`/map-info`),t),mapHistory:(e,t,n,r)=>{let i=new URLSearchParams;return n&&i.set(`after`,n),r&&i.set(`task_after`,r),R(B(e,`/map-history`)+(i.size?`?${i}`:``),t)},mapCopy:(e,t,n,r,i)=>R(`/api/map-copy/${e}/${encodeURIComponent(t)}?locale=${n}${i?`&session_id=${encodeURIComponent(i)}`:``}`,r),generateMapCopy:(e,t,n,r,i)=>z(`/api/map-copy/${e}/${encodeURIComponent(t)}${i?`?session_id=${encodeURIComponent(i)}`:``}`,n,r),mapDatasets:e=>R(`/api/map-datasets`,e),mapDataset:(e,t)=>R(`/api/map-datasets/${encodeURIComponent(e)}`,t),meta:H,projectIndex:async()=>(await H(),R(`/api/projects`,void 0,Ye)),listProjects:async()=>(await H(),R(`/api/projects`,void 0,Ye).then(e=>e.projects)),projectCosts:async e=>(await H(),R(`/api/projects/costs`,e)),createDaemon:async(e,t=``,n=``,r)=>{let i=`/api/daemons`,a={objective:e,name:t,workdir:n,command_id:at(),expected_revision:r},o=()=>fetch(i,{method:`POST`,headers:{"Content-Type":`application/json`,...Ke()},body:JSON.stringify(a),cache:`no-store`}),s=await o();return s.status===400&&/Invalid HTTP request received/i.test(await s.clone().text())&&(s=await o()),await Me(s,`POST`,i),nt(await s.json())},updateProject:(e,t)=>rt(`PATCH`,B(e),{name:t}),deleteProject:e=>rt(`DELETE`,B(e)),snapshot:async(e,t,n=!1)=>(await H(),Ve(await R(B(e,`/snapshot?compact=true&events_limit=1${n?`&prewarm=true`:``}`),t,Ye))),activeSnapshot:async(e,t)=>{let n=lt!==e;n&&(lt=e);try{return await U.snapshot(e,t,n)}catch(t){throw n&<===e&&(lt=null),t}},prefetchSnapshot:(e,t)=>U.snapshot(e,t,!1),status:(e,t)=>R(B(e,`/status`),t),journal:(e,t=20,n)=>R(B(e,`/journal?n=${t}`),n).then(e=>e.journal),doctor:(e,t)=>R(B(e,`/doctor`),t),config:(e,t)=>R(B(e,`/config`),t),identity:(e,t)=>R(B(e,`/identity`),t).then(e=>e.identity),transcript:(e,t=30,n)=>R(B(e,`/transcript?n=${t}`),n).then(e=>e.turns),events:(e,t=80,n)=>R(B(e,`/events?limit=${t}&view=ui`),n).then(e=>e.events),backlogItem:(e,t,n)=>R(B(e,`/backlog/${encodeURIComponent(t)}`),n).then(e=>e.item),artifacts:(e,t)=>R(B(e,`/artifacts`),t).then(e=>e.artifacts),artifact:(e,t,n)=>R(B(e,`/artifact?${new URLSearchParams({path:t})}`),n),artifactPreview:(e,t,n)=>R(B(e,`/artifact/preview?${new URLSearchParams({path:t})}`),n),artifactBundle:(e,t,n)=>it(B(e,`/artifact/bundle?${new URLSearchParams({path:t})}`),n),artifactBlob:(e,t,n=!1,r)=>{let i=new URLSearchParams({path:t});return n&&i.set(`download`,`true`),it(B(e,`/artifact/raw?${i}`),r)},gitDiff:(e,t)=>R(B(e,`/git-diff`),t),metrics:e=>R(`/api/metrics`,e),sourceUpdateStatus:e=>R(`/api/runtime/source-update`,e),checkSourceUpdate:()=>z(`/api/runtime/source-update/check`),applySourceUpdate:()=>z(`/api/runtime/source-update/apply`),resources:e=>R(`/api/system/resources`,e),trash:(e=``,t=100,n=0,r)=>R(`/api/trash?${new URLSearchParams({query:e,limit:String(t),offset:String(n)})}`,r),restoreTrash:e=>z(`/api/trash/${encodeURIComponent(e)}/restore`),addTask:(e,t)=>z(B(e,`/tasks`),{text:t}).then(e=>e.item),abortMission:(e,t)=>z(B(e,`/mission/abort`),{reason:t}),mapNotes:(e,t)=>R(B(e,`/map-notes`),t),addMapNote:(e,t)=>z(B(e,`/map-notes`),t),answerPending:(e,t,n)=>z(B(e,`/backlog/${encodeURIComponent(t)}/answer`),{text:n}),resolveDecision:(e,t,n,r)=>z(B(e,`/decisions/${encodeURIComponent(t)}/resolve`),{option_id:n,note:r}),uploadAttachments:async(e,t,n)=>{await H();let r=new FormData;return t.forEach(e=>r.append(`files`,e,e.name)),tt(B(e,`/attachments`),r,n)},message:(e,t,n)=>{let r=st(n)?n:n?.signal,i=st(n)?void 0:n?.attachments,a=st(n)?void 0:n?.routeOverride;return z(B(e,`/message`),V(t,i,a),r)},messageStream:async(e,t,n,r)=>{let i=st(r)?r:r?.signal,a=st(r)?void 0:r?.attachments,o=st(r)?void 0:r?.routeOverride,s=await fetch(B(e,`/message/stream`),{method:`POST`,headers:{"Content-Type":`application/json`,...Ke()},body:JSON.stringify(V(t,a,o)),signal:i});if(await Me(s,`POST`,B(e,`/message/stream`)),!s.body)throw Error(`Manager stream returned no response body`);let c=!1,l=e=>{if(!i?.aborted){if(e.type===`phase`){let t=Number(e.quiet_s??0);n.onPhase?.(String(e.label??``),String(e.role??`manager`),{heartbeat:e.heartbeat===!0,quietS:Number.isFinite(t)?t:0,kind:String(e.kind??``),detail:String(e.detail??``)})}else e.type===`delta`?n.onDelta?.(String(e.text??``),String(e.message_id??``),String(e.fragment_mode??`auto`)):e.type===`done`?(c=!0,n.onDone?.(e.result??{})):e.type===`error`&&(c=!0,n.onError?.(Error(String(e.error??`stream error`))))}},u=s.body.getReader(),d=new TextDecoder,f=``;for(;;){let{done:e,value:t}=await u.read();if(e)break;f+=d.decode(t,{stream:!0});let n=ct(f);f=n.rest,n.frames.forEach(l)}if(!i?.aborted&&(ct(f+` + +`).frames.forEach(l),!c))throw Error(`Manager stream ended before a terminal event`)},nudge:(e,t)=>z(B(e,`/nudge`),{text:t}),note:(e,t)=>z(B(e,`/note`),{text:t}),previewPlan:(e,t)=>z(B(e,`/plan`),{text:t}),rewritePrompt:(e,t)=>z(B(e,`/prompt/rewrite`),{text:t}),setConfig:(e,t,n)=>z(B(e,`/config/set`),{name:t,value:n}),setBudgets:(e,t)=>z(B(e,`/config/budget`),{values:t}),setIdentity:(e,t)=>z(B(e,`/identity`),{text:t}),resetManager:e=>z(B(e,`/reset`)),skills:(e,t=`ls`)=>z(B(e,`/skills`),{args:t}).then(e=>e.text),setLaunchCwd:(e,t)=>z(B(e,`/launch-cwd`),{launch_cwd:t}),setWorkdir:(e,t)=>z(B(e,`/workdir`),{workdir:t}),disposeBacklog:(e,t,n)=>z(B(e,`/backlog/${encodeURIComponent(t)}/dispose`),{op:n}),stopBacklog:(e,t)=>z(B(e,`/backlog/${encodeURIComponent(t)}/stop`)),setContinuous:(e,t,n=``)=>z(B(e,`/continuous`),{enabled:t,objective:n}).then(e=>{if(!t)return e;if(!e.daemon)throw Error(`daemon start returned no result`);return nt(e.daemon),e}),startDaemon:(e,t)=>z(B(e,`/daemon/start`),{command_id:at(),expected_revision:t}).then(nt),stopDaemon:(e,t=!1,n,r=!1)=>z(B(e,`/daemon/stop`),{drain:t,force:r,command_id:at(),expected_revision:n}).then(nt),replaceDaemon:(e,t,n=!1,r)=>z(B(e,`/daemon/replace`),{victim_sid:t,resume_continuous:n,command_id:at(),expected_revision:r}).then(nt),upgradeDaemon:(e,t)=>z(B(e,`/daemon/upgrade`),{command_id:at(),expected_revision:t}).then(nt)},ut=new Set([4401,4404]);function dt(e,t,n={}){let r=window.location.protocol===`https:`?`wss:`:`ws:`,i=new URLSearchParams;n.replay!=null&&i.set(`replay`,String(n.replay)),i.set(`view`,`ui`);let a=Ge();a&&i.set(`token`,a);let o=`${r}//${window.location.host}${B(e,`/stream`)}?${i}`,s=null,c=!1,l,u=()=>{c||(s=new WebSocket(o),s.onopen=()=>n.onOpen?.(),s.onmessage=e=>{try{let n=JSON.parse(e.data);n&&typeof n==`object`&&t(n)}catch{}},s.onclose=e=>{let t=!ut.has(e.code);n.onClose?.({code:e.code,reason:e.reason,retryable:t}),!c&&t&&(l=setTimeout(u,1e3))},s.onerror=()=>s?.close())};return u(),()=>{c=!0,l&&clearTimeout(l),s?.close()}}var W={accent:`rgb(var(--blue))`,success:`rgb(var(--ok))`,error:`rgb(var(--err))`,warning:`rgb(var(--warn))`,info:`rgb(var(--blue))`,ink:`rgb(var(--ink))`,inkDim:`rgb(var(--ink-dim))`,inkFaint:`rgb(var(--ink-faint))`,role:{manager:`rgb(var(--role-manager))`,planner:`rgb(var(--role-planner))`,engineer:`rgb(var(--role-engineer))`,reviewer:`rgb(var(--role-reviewer))`}};function ft(e){switch(e){case`medium`:return W.inkDim;case`high`:return W.info;case`xhigh`:return W.accent;case`max`:return W.error;default:return W.inkFaint}}var pt=e=>String(e??``).trim(),mt=/^[a-z][a-z -]+ requires an operator-owned decision before continuing\.?$/i,ht=e=>{let t=pt(e);return mt.test(t)?``:t},gt=(e,t)=>{let n=/[\u3400-\u9fff]/.test(`${e}\n${t}`);return{id:`custom`,label:n?`自己输入`:`Write my own answer`,description:n?`直接告诉 Argus 你的决定。`:`Tell Argus your decision directly.`,requires_note:!0}};function _t(e,t){let n=[...e,...t],r=[],i=new Set;for(let e of n){let t=pt(e.id),n=e.operator_decision;if(n&&typeof n==`object`&&!Array.isArray(n)){let a=n,o=pt(a.id);if(!o||i.has(o)||pt(a.status)!==`pending`)continue;i.add(o);let s=pt(a.options_source)===`agent`&&Array.isArray(a.options)?a.options.filter(e=>!!pt(e?.id)&&!!pt(e?.label)).map(e=>({...e,requires_note:e.requires_note===!0})):[];s.push(gt(pt(a.title),pt(a.question))),r.push({id:o,item_id:pt(a.item_id)||t,revision:Number(a.revision??1),status:`pending`,title:pt(a.title)||pt(e.title)||`Decision required`,reason:ht(a.reason),question:pt(a.question)||pt(e.pending_question),evidence:Array.isArray(a.evidence)?a.evidence.filter(e=>pt(e?.label)!==`Acceptance check`):[],options:s,options_source:s.length?`agent`:`none`,selected_option:``,note:``});continue}let a=pt(e.pending_question??e.question??e.text);if(!t||!a)continue;let o=`legacy-${t}`;i.has(o)||(i.add(o),r.push({id:o,item_id:t,revision:1,status:`pending`,title:pt(e.title??e.objective)||`Blocked task`,reason:``,question:a,evidence:[],options:[gt(pt(e.title??e.objective),a)],options_source:`none`,selected_option:``,note:``,legacy:!0}))}return r}var G={AGENT_IO_START:`agent.io.start`,AGENT_IO_STREAM:`agent.io.stream`,AGENT_IO_COMPLETE:`agent.io.complete`,AGENT_IO_ERROR:`agent.io.error`,USAGE_RECORDED:`usage.recorded`,PROVIDER_REQUEST_STARTED:`provider.request.started`,PROVIDER_REQUEST_COMPLETED:`provider.request.completed`,PROVIDER_REQUEST_DENIED:`provider.request.denied`,CODEX_UTIL_COMPLETED:`codex.util.completed`,SKILL_COST_COMPLETED:`skill.cost.completed`,BUDGET_RESERVATION_CREATED:`budget.reservation.created`,BUDGET_RESERVATION_DENIED:`budget.reservation.denied`,BUDGET_RESERVATION_SETTLED:`budget.reservation.settled`,BUDGET_RESERVATION_RELEASED:`budget.reservation.released`,BUDGET_UNPRICED_BLOCKED:`budget.unpriced.blocked`,LOOP_START:`loop.start`,LOOP_DONE:`loop.done`,ROUND_START:`round.start`,ROUND_MAIN_COMPLETED:`round.main.completed`,ROUND_REVIEW_STARTED:`round.review.started`,ROUND_REVIEW_DEFERRED:`round.review.deferred`,ROUND_REVIEW_COMPLETED:`round.review.completed`,ROUND_CHECKPOINT_RECORDED:`round.checkpoint.recorded`,ROUND_CHECKPOINT_FAILED:`round.checkpoint.failed`,ROUND_SECRET_REDACTED:`round.secret_redacted`,ROUND_ESCALATED:`round.escalated`,ROUND_STALL:`round.stall`,ROUND_REVIEWER_BACKEND_FAILURE:`round.reviewer_backend_failure`,ROLE_SESSION_TURN:`role.session.turn`,ENGINEER_PROGRESS:`engineer.progress`,ENGINEER_SKILL_MAINTENANCE_COMPLETED:`engineer.skill_maintenance.completed`,LIFE_STATUS:`life.status`,LIFE_PHASE_STARTED:`life.phase.started`,LIFE_MISSION_STARTED:`life.mission.started`,LIFE_MISSION_COMPLETED:`life.mission.completed`,LIFE_MISSION_FAILED:`life.mission.failed`,LIFE_MISSION_SKIPPED:`life.mission.skipped`,LIFE_MISSION_ORPHANED:`life.mission.orphaned`,LIFE_MISSION_REQUEUED:`life.mission.requeued`,LIFE_MANAGER_INTENT_STARTED:`life.manager.intent.started`,LIFE_MANAGER_INTENT_COMPLETED:`life.manager.intent.completed`,LIFE_MANAGER_INTENT_FAILED:`life.manager.intent.failed`,LIFE_MANAGER_STAGE_DECISION:`life.manager.stage_decision`,LIFE_MANAGER_PLAN_CHALLENGE_DECIDED:`life.manager.plan_challenge.decided`,LIFE_VERTICAL_RESOLVED:`life.vertical.resolved`,LIFE_MANAGER_BACKEND_RESOLVED:`life.manager.backend_resolved`,LIFE_PLANNER_BACKEND_RESOLVED:`life.planner.backend_resolved`,LIFE_ENGINEER_BACKEND_RESOLVED:`life.engineer.backend_resolved`,LIFE_REVIEWER_BACKEND_RESOLVED:`life.reviewer.backend_resolved`,LIFE_CURATOR_BACKEND_RESOLVED:`life.curator.backend_resolved`,LIFE_PLANNER_START:`life.planner.start`,LIFE_PLANNER_NORMALIZED:`life.planner.normalized`,LIFE_PLANNER_TASK_ADDED:`life.planner.task_added`,LIFE_PLANNER_TASK_SKIPPED:`life.planner.task_skipped`,LIFE_PLANNER_VERDICT:`life.planner.verdict`,LIFE_PLANNER_WAITING:`life.planner.waiting`,LIFE_PLANNER_WAITING_WOKEN:`life.planner.waiting_woken`,LIFE_PLANNER_TERMINAL_IDLE:`life.planner.terminal_idle`,LIFE_PLANNER_VERIFICATION_PROBE:`life.planner.verification_probe`,LIFE_PLANNER_STALL_ESCALATION:`life.planner.stall_escalation`,LIFE_PLANNER_DEPENDENCY_DROPPED:`life.planner.dependency_dropped`,LIFE_PLANNER_PARALLEL_DROPPED:`life.planner.parallel_dropped`,LIFE_PLANNER_ERROR:`life.planner.error`,LIFE_RUNTIME_FAILURE_CIRCUIT_OPENED:`life.runtime_failure.circuit_opened`,LIFE_RUNTIME_FAILURE_CIRCUIT_BLOCKED:`life.runtime_failure.circuit_blocked`,LIFE_RUNTIME_FAILURE_CANARY_PASSED:`life.runtime_failure.canary_passed`,LIFE_PLAN_REVISION_PROPOSED:`life.plan.revision.proposed`,LIFE_PLAN_REVISION_REJECTED:`life.plan.revision.rejected`,LIFE_PLAN_REVISION_COMMITTED:`life.plan.revision.committed`,LIFE_PLAN_NODE_SUPERSEDED:`life.plan.node.superseded`,LIFE_RESEARCH_SECOND_READING:`life.research.second_reading`,LIFE_LETTER_WRITTEN:`life.letter.written`,LIFE_BUDGET_PAUSE:`life.budget.pause`,LIFE_LIFECYCLE_BLOCK:`life.lifecycle.block`,LIFE_LIFECYCLE_TRANSITION:`life.lifecycle.transition`,LIFE_INBOX_QUEUED:`life.inbox.queued`,LIFE_INBOX_DRAINED:`life.inbox.drained`,LIFE_OPERATOR_QUESTION_PENDING:`life.operator_question.pending`,LIFE_OPERATOR_QUESTION_ANSWERED:`life.operator_question.answered`,LIFE_DAEMON_IDLE_TIMEOUT:`life.daemon.idle_timeout`,PROJECT_COMPLETED:`project.completed`,PROJECT_COMPLETION_REFUSED:`project.completion_refused`,DAEMON_PARKED:`daemon.parked`,DAEMON_COMMAND_SUBMITTED:`daemon.command.submitted`,DAEMON_COMMAND_COMPLETED:`daemon.command.completed`,DAEMON_COMMAND_REJECTED:`daemon.command.rejected`,IDEA_SEARCH_STARTED:`idea.search.started`,IDEA_SEARCH_COMPLETED:`idea.search.completed`,IDEA_SEARCH_SKIPPED:`idea.search.skipped`,VENUE_RESEARCH_STARTED:`venue.research.started`,VENUE_RESEARCH_COMPLETED:`venue.research.completed`,RESEARCH_ACHIEVEMENT_CERTIFIED:`research.achievement.certified`,SKILL_LIBRARY_AVAILABLE:`skill.library.available`,SKILL_CREATED:`skill.created`,SKILL_UPDATED:`skill.updated`,SKILL_ARCHIVED:`skill.archived`,SKILL_TIDIED:`skill.tidied`,SKILL_HISTORY_COMPRESSED:`skill.history.compressed`,SKILL_EVOLUTION_COMPLETED:`skill.evolution.completed`,WIKI_INITIALIZED:`wiki.initialized`,WIKI_HOOK_WARNING:`wiki.hook.warning`,WIKI_CREATED:`wiki.created`,WIKI_UPDATED:`wiki.updated`,WIKI_RETIRED:`wiki.retired`,WIKI_PROMOTION_PROMOTED:`wiki.promotion.promoted`,WIKI_PROMOTION_DEMOTED:`wiki.promotion.demoted`,WIKI_RETIRED_COMPRESSED:`wiki.retired.compressed`,WIKI_EVOLUTION_COMPLETED:`wiki.evolution.completed`,OPERATOR_ALERT:`operator_alert`},vt={"loop.started":G.LOOP_START,"loop.completed":G.LOOP_DONE,"round.started":G.ROUND_START,"mission.started":G.LIFE_MISSION_STARTED,"mission.completed":G.LIFE_MISSION_COMPLETED,"mission.error":G.LIFE_MISSION_FAILED};G.LIFE_MANAGER_BACKEND_RESOLVED,G.LIFE_PLANNER_BACKEND_RESOLVED,G.LIFE_ENGINEER_BACKEND_RESOLVED,G.LIFE_REVIEWER_BACKEND_RESOLVED,G.LIFE_CURATOR_BACKEND_RESOLVED,G.LOOP_START,G.LOOP_DONE,G.ROUND_START,G.ROUND_MAIN_COMPLETED,G.ROUND_REVIEW_DEFERRED,G.ROUND_REVIEW_COMPLETED,G.ROUND_CHECKPOINT_RECORDED,G.ROUND_CHECKPOINT_FAILED,G.ROUND_SECRET_REDACTED,G.ROUND_ESCALATED,G.ROUND_STALL,G.ROUND_REVIEWER_BACKEND_FAILURE,G.ENGINEER_SKILL_MAINTENANCE_COMPLETED,G.SKILL_LIBRARY_AVAILABLE,G.SKILL_CREATED,G.SKILL_UPDATED,G.SKILL_ARCHIVED,G.SKILL_TIDIED,G.SKILL_HISTORY_COMPRESSED,G.SKILL_EVOLUTION_COMPLETED,G.WIKI_INITIALIZED,G.WIKI_HOOK_WARNING,G.WIKI_CREATED,G.WIKI_UPDATED,G.WIKI_RETIRED,G.WIKI_PROMOTION_PROMOTED,G.WIKI_PROMOTION_DEMOTED,G.WIKI_RETIRED_COMPRESSED,G.WIKI_EVOLUTION_COMPLETED,G.LIFE_MISSION_STARTED,G.LIFE_MISSION_COMPLETED,G.LIFE_MANAGER_INTENT_STARTED,G.LIFE_MANAGER_INTENT_COMPLETED,G.LIFE_MANAGER_INTENT_FAILED,G.LIFE_MANAGER_STAGE_DECISION,G.LIFE_MANAGER_PLAN_CHALLENGE_DECIDED,G.LIFE_VERTICAL_RESOLVED,G.LIFE_PLANNER_START,G.LIFE_PLANNER_TASK_ADDED,G.LIFE_PLANNER_TASK_SKIPPED,G.LIFE_PLANNER_DEPENDENCY_DROPPED,G.LIFE_PLANNER_PARALLEL_DROPPED,G.LIFE_PLANNER_VERDICT,G.LIFE_PLANNER_WAITING,G.LIFE_PLANNER_WAITING_WOKEN,G.LIFE_PLANNER_TERMINAL_IDLE,G.LIFE_PLANNER_VERIFICATION_PROBE,G.LIFE_PLANNER_STALL_ESCALATION,G.LIFE_RUNTIME_FAILURE_CIRCUIT_OPENED,G.LIFE_RUNTIME_FAILURE_CIRCUIT_BLOCKED,G.LIFE_RUNTIME_FAILURE_CANARY_PASSED,G.LIFE_PLAN_REVISION_PROPOSED,G.LIFE_PLAN_REVISION_REJECTED,G.LIFE_PLAN_REVISION_COMMITTED,G.LIFE_PLAN_NODE_SUPERSEDED,G.LIFE_RESEARCH_SECOND_READING,G.LIFE_LETTER_WRITTEN,G.LIFE_BUDGET_PAUSE,G.BUDGET_RESERVATION_DENIED,G.BUDGET_UNPRICED_BLOCKED,G.LIFE_LIFECYCLE_BLOCK,G.LIFE_LIFECYCLE_TRANSITION,G.PROVIDER_REQUEST_STARTED,G.PROVIDER_REQUEST_COMPLETED,G.PROVIDER_REQUEST_DENIED,G.LIFE_INBOX_QUEUED,G.LIFE_INBOX_DRAINED,G.LIFE_DAEMON_IDLE_TIMEOUT,G.PROJECT_COMPLETED,G.PROJECT_COMPLETION_REFUSED,G.DAEMON_PARKED,G.DAEMON_COMMAND_COMPLETED,G.DAEMON_COMMAND_REJECTED,G.IDEA_SEARCH_STARTED,G.IDEA_SEARCH_COMPLETED,G.IDEA_SEARCH_SKIPPED,G.VENUE_RESEARCH_STARTED,G.VENUE_RESEARCH_COMPLETED,G.RESEARCH_ACHIEVEMENT_CERTIFIED,G.OPERATOR_ALERT,G.AGENT_IO_START,G.AGENT_IO_COMPLETE,G.AGENT_IO_ERROR,G.PROVIDER_REQUEST_STARTED,G.PROVIDER_REQUEST_COMPLETED,G.PROVIDER_REQUEST_DENIED,G.USAGE_RECORDED;function yt(e){let t=String(e??``).trim();return vt[t]??t}function bt(e){if(typeof e!=`object`||!e)return JSON.stringify(e);if(Array.isArray(e))return`[${e.map(bt).join(`,`)}]`;let t=e;return`{${Object.keys(t).sort().map(e=>`${JSON.stringify(e)}:${bt(t[e])}`).join(`,`)}}`}function xt(e){let t=2166136261;for(let n=0;n>>0).toString(36)}function St(e){let t=e.event_id??e.id??e.seq??e._offset,n=String(e.type??`event`);return t!=null&&t!==``?`${n}-${String(t)}`:`${n}-${String(e.ts??e.time??``)}-${xt(bt(e))}`}function Ct(e){return e.type===G.ENGINEER_PROGRESS&&e.kind===`reasoning`}function wt(e){if(e.type!==G.ENGINEER_PROGRESS||![`assistant_message`,`agent_message`,`message`].includes(String(e.kind??``)))return!1;let t=String(e.agent_layer??e.actor??``);return String(e.text??``).trimStart().startsWith(`{`)?t===`reviewer`||t===`planner`:!1}var Tt=/^(?:[-*+]\s*)?[`*_]*(?:ARGUS_)?(?:MILESTONE_STATUS|NEXT_OWNER|OPERATOR_QUESTION|OPERATOR_OPTIONS|ROLE_DECISION)[`*_]*\s*[:=]|^(?:final\s+)?decision\s*:\s*$/i;function Et(e){return String(e??``).split(/\r?\n/).filter(e=>!Tt.test(e.trim())).join(` +`).trim()}function Dt(e){let t=String(e.fragment_mode??``);return t===`append`||t===`snapshot`?t:e.replace===!0?`snapshot`:`auto`}function Ot(e,t){let n=Math.min(e.length,t.length);for(let r=n;r>=8;--r)if(e.endsWith(t.slice(0,r)))return r;return 0}function kt(e,t,n=`auto`){let r=(e||``).trim(),i=(t||``).trim();if(!r)return i;if(!i)return r;if(n===`snapshot`)return i;if(r.includes(i))return r;if(n===`append`)return`${r}\n${i}`;if(i.includes(r))return i;let a=Ot(r,i);return a?`${r}${i.slice(a)}`:`${r}\n${i}`}var At=[`all`,`attention`,`milestones`,`messages`],jt=new Set([G.LIFE_MISSION_STARTED,G.LIFE_MISSION_COMPLETED,G.LIFE_MISSION_FAILED,G.LOOP_START,G.LOOP_DONE,G.LIFE_PLANNER_VERDICT,`final.report.ready`,`pptx.report.ready`,`plan.completed`,G.LIFE_BUDGET_PAUSE,G.LIFE_LIFECYCLE_BLOCK]);function Mt(e,t,n=`all`,r=``){let i=yt(e.canonical_type??e.type),a=String(e.kind??``);if(n===`attention`&&![`warn`,`err`].includes(String(t.tone??``))&&e.operator_alert!==!0||n===`milestones`&&!(t.rule&&!i.startsWith(`ui.`))&&!jt.has(i)||n===`messages`&&t.tone!==`bright`&&![`assistant_message`,`agent_message`,`message`].includes(a)&&![`ui.operator`,`ui.argus`].includes(i))return!1;let o=r.trim().toLocaleLowerCase();return!o||[i,a,t.role,t.label,t.text,e.title,e.objective,e.text,e.summary,e.reason,e.error,e.status,e.action_summary,e.command,e.path,Array.isArray(e.tags)?e.tags.join(` `):e.tags].some(e=>String(e??``).toLocaleLowerCase().includes(o))}var Nt=[{id:`status`,name:`/status`,argument:`none`,desc:`roles, queued work, journal, and health`,group:`Everyday`,kind:`panel`},{id:`roles`,name:`/roles`,argument:`none`,desc:`per-role backend / model / effort + live activity`,group:`Everyday`,kind:`panel`},{id:`journal`,name:`/journal`,arg:`[N]`,argument:`optional`,desc:`recent journal entries (default 10)`,group:`Everyday`,kind:`panel`},{id:`backlog`,name:`/backlog`,arg:`[all]`,argument:`optional`,desc:`pending tasks (all = incl. done/skipped)`,group:`Everyday`,kind:`panel`},{id:`artifacts`,name:`/artifacts`,argument:`none`,desc:`result files the Reviewer has checked (Enter previews)`,group:`Everyday`,kind:`panel`},{id:`artifact`,name:`/artifact`,arg:``,argument:`required`,desc:`preview one reviewed result file`,group:`Everyday`,kind:`panel`},{id:`events`,name:`/events`,arg:`[filter] [query]`,argument:`optional`,desc:`search feed: all / watch / milestones / messages`,group:`Everyday`,kind:`panel`},{id:`find`,name:`/find`,arg:``,argument:`required`,desc:`search the current event buffer`,group:`Everyday`,kind:`panel`},{id:`cancel`,name:`/cancel`,argument:`none`,desc:`stop waiting for the current Manager reply`,group:`Everyday`,kind:`local`},{id:`ask`,name:`/ask`,arg:``,argument:`required`,desc:`answer inline — no task queued, no Planner/Engineer/Reviewer`,aliases:[`/chat`],group:`Everyday`,kind:`action`},{id:`crystalpilot`,name:`/crystalpilot`,arg:`[status|off|use ]`,argument:`optional`,desc:`enable crystallography tools in this Argus conversation`,group:`Everyday`,kind:`action`},{id:`task`,name:`/task`,arg:``,argument:`required`,desc:`queue work directly`,aliases:[`/add`],group:`Task management`,kind:`action`},{id:`plan`,name:`/plan`,arg:``,argument:`required`,desc:`preview a Planner-authored execution plan`,group:`Task management`,kind:`action`},{id:`rewrite`,name:`/rewrite`,arg:`[text]`,argument:`optional`,desc:`let the Manager rewrite your prompt before sending`,aliases:[`/refine`],group:`Task management`,kind:`action`},{id:`nudge`,name:`/nudge`,arg:``,argument:`required`,desc:`inject guidance into the running mission`,aliases:[`/inject`,`/notify`],group:`Task management`,kind:`action`},{id:`abort`,name:`/abort`,argument:`none`,desc:`immediately stop the running mission`,group:`Task management`,kind:`action`},{id:`note`,name:`/note`,arg:``,argument:`required`,desc:`append a manual note to the timeline`,group:`Task management`,kind:`action`},{id:`done`,name:`/done`,arg:``,argument:`required`,desc:`mark a task done`,group:`Task management`,kind:`action`},{id:`skip`,name:`/skip`,arg:``,argument:`required`,desc:`skip a task`,aliases:[`/rm`],group:`Task management`,kind:`action`},{id:`stop`,name:`/stop`,arg:``,argument:`required`,desc:`stop a task's auto-iteration`,group:`Task management`,kind:`action`},{id:`item`,name:`/item`,arg:``,argument:`required`,desc:`inspect a full task contract`,group:`Task management`,kind:`panel`},{id:`run`,name:`/run`,argument:`none`,desc:`return to the always-live mission feed`,group:`Task management`,kind:`local`},{id:`new`,name:`/new`,arg:`[objective]`,argument:`optional`,desc:`review, create, and switch to a fresh conversation`,group:`Sessions & diagnostics`,kind:`action`},{id:`daemons`,name:`/daemons`,arg:`[query]`,argument:`optional`,desc:`find every session + switch or create`,group:`Sessions & diagnostics`,kind:`panel`},{id:`resume`,name:`/resume`,arg:`[list|]`,argument:`optional`,desc:`switch to another project/session`,group:`Sessions & diagnostics`,kind:`action`},{id:`attach`,name:`/attach`,arg:``,argument:`required`,desc:`follow another project (read the stream)`,group:`Sessions & diagnostics`,kind:`action`},{id:`rename`,name:`/rename`,arg:``,argument:`required`,desc:`rename the current conversation`,group:`Sessions & diagnostics`,kind:`action`},{id:`doctor`,name:`/doctor`,argument:`none`,desc:`diagnose 'why isn't anything running'`,group:`Sessions & diagnostics`,kind:`panel`},{id:`backend`,name:`/backend`,arg:`[codex|claude|copilot|cursor|opencode|pi|grok|qoder|dsh]`,argument:`optional`,desc:`view or change the shared runner backend`,group:`Configuration`,kind:`action`},{id:`config`,name:`/config`,arg:`[key=value …]`,argument:`optional`,desc:`view or change runtime settings`,group:`Configuration`,kind:`panel`},{id:`identity`,name:`/identity`,arg:`[set ]`,argument:`optional`,desc:`view or replace the operator identity card`,group:`Configuration`,kind:`panel`},{id:`reset`,name:`/reset`,argument:`none`,desc:`drop the warm Manager conversation context`,group:`Configuration`,kind:`action`},{id:`skills`,name:`/skills`,arg:`[ls|promote ]`,argument:`optional`,desc:`inspect or promote runtime skills`,group:`Configuration`,kind:`action`},{id:`clear`,name:`/clear`,argument:`none`,desc:`clear the event feed view`,group:`Other`,kind:`local`},{id:`reconnect`,name:`/reconnect`,argument:`none`,desc:`reconnect the live event stream`,group:`Other`,kind:`local`},{id:`help`,name:`/help`,argument:`none`,desc:`keys + full command reference`,aliases:[`/?`,`/commands`],group:`Other`,kind:`local`},{id:`quit`,name:`/quit`,argument:`none`,desc:`leave the cockpit (background work keeps running)`,aliases:[`/exit`,`/q`],group:`Other`,kind:`local`}];new Map(Nt.map(e=>[e.id,e]));var Pt=new Map;for(let e of Nt)for(let t of[e.name,...e.aliases??[]])Pt.set(t.toLowerCase(),e);function Ft(e){return e.argument===`required`}var K=/^\/[A-Za-z0-9_-]+$/;function It(e){if(!e.startsWith(`/`))return!1;let t=e.indexOf(` `),n=t===-1?e:e.slice(0,t);return K.test(n)}function Lt(e){return e.startsWith(`/`)&&!e.includes(` `)&&!e.slice(1).includes(`/`)}function Rt(e){if(!Lt(e))return[];let t=e.toLowerCase(),n=new Set,r=[];for(let e of Nt)[e.name,...e.aliases??[]].some(e=>e.toLowerCase().startsWith(t))&&!n.has(e.name)&&(n.add(e.name),r.push(e));return r.sort((e,n)=>Number(zt(n,t))-Number(zt(e,t)))}function zt(e,t){return[e.name,...e.aliases??[]].some(e=>e.toLowerCase()===t)}function Bt(e){return e.arg?`${e.name} `:e.name}function Vt(e){let t=e.trim();if(!t)return{filter:`all`,query:``};let[n,...r]=t.split(/\s+/);return n.toLowerCase()===`watch`?{filter:`attention`,query:r.join(` `)}:At.includes(n.toLowerCase())?{filter:n.toLowerCase(),query:r.join(` `)}:{filter:`all`,query:t}}function Ht(e){if(!It(e))return null;let t=e.indexOf(` `),n=(t===-1?e:e.slice(0,t)).toLowerCase(),r=t===-1?``:e.slice(t+1).trim(),i=Pt.get(n)??null;return{cmd:i,name:i?i.name:n,rest:r}}function Ut(e){let t=e.toLowerCase(),n=null,r=0;for(let e of Pt.keys()){let i=Wt(t,e);i>r&&(r=i,n=Pt.get(e).name)}return r>=.6?n:null}function Wt(e,t){return 1-Gt(e,t)/(Math.max(e.length,t.length)||1)}function Gt(e,t){let n=e.length,r=t.length,i=Array.from({length:n+1},(e,t)=>[t,...Array(r).fill(0)]);for(let e=0;e<=r;e+=1)i[0][e]=e;for(let a=1;a<=n;a+=1)for(let n=1;n<=r;n+=1)i[a][n]=Math.min(i[a-1][n]+1,i[a][n-1]+1,i[a-1][n-1]+(e[a-1]===t[n-1]?0:1));return i[n][r]}var Kt=new Set([`done`,`success`,`completed`]),qt=new Set([`research_incomplete`,`paused_no_breakthrough`,`exhausted_current_methods`]),Jt=new Set([`no_progress`,`max_rounds`]),Yt=new Set([`blocked`,`infra_blocked`]),Xt=new Set([`error`,`failed`,`supervisor_error`]),Zt={completed:{glyph:`🎉`,tone:`ok`,missionStatus:`complete`},incomplete:{glyph:`◌`,tone:`warn`,missionStatus:`incomplete`},stalled:{glyph:`⏸`,tone:`warn`,missionStatus:`stalled`},blocked:{glyph:`⛔`,tone:`err`,missionStatus:`blocked`},failed:{glyph:`💥`,tone:`err`,missionStatus:`failed`},ended:{glyph:`■`,tone:`info`,missionStatus:`ended`}},Qt={completed:`Task completed`,incomplete:`Mission incomplete`,stalled:`Mission stalled`,blocked:`Mission blocked`,failed:`Mission failed`,ended:`Mission ended`};function $t(e){return String(e??``).trim().toLowerCase()}function en(e){let t=$t(e);switch(t){case`completed`:case`incomplete`:case`stalled`:case`blocked`:case`failed`:case`ended`:return t;default:return null}}function tn(e){let t=$t(e.status);return e.success===!0||Kt.has(t)?`completed`:qt.has(t)?`incomplete`:Jt.has(t)?`stalled`:Yt.has(t)?`blocked`:Xt.has(t)?`failed`:`ended`}function nn(e){let t=e.outcome;if(t&&typeof t==`object`&&!Array.isArray(t)){let n=t;return{execution_status:$t(n.execution_status)||tn(e),review_status:$t(n.review_status)||`not_assessed`,stage_certification:$t(n.stage_certification)||`not_assessed`,interruption_kind:$t(n.interruption_kind)||`none`,resumable:n.resumable===!0}}return{execution_status:tn(e),review_status:`not_assessed`,stage_certification:`not_assessed`,interruption_kind:$t(e.stop_kind)||`none`,resumable:e.resumable===!0}}function rn(e){if(e.success===!0&&e.campaign_continues===!0)return{outcomeClass:`completed`,label:`Task continued`,glyph:`↻`,tone:`info`,missionStatus:`continued`};let t=en(e.outcome_class)??tn(e),n=String(e.status??``).trim(),r=Zt[t];return{outcomeClass:t,label:t===`completed`&&e.final_submission_certified===!0?`Submission certified`:t===`ended`&&n?`Mission ended · ${n}`:Qt[t],glyph:r.glyph,tone:r.tone,missionStatus:r.missionStatus}}var an=[`manager`,`planner`,`engineer`,`reviewer`],on=new Set([`planner`,`engineer`,`reviewer`]),sn=new Set([`running`,`in_progress`,`claimed`]),q=(e,t)=>String(e[t]??``).trim(),cn=(e,t)=>{let n=Number(e[t]);return Number.isFinite(n)?n:null};function ln(e){let t=[e.route?e.route.toUpperCase():``,e.vertical,e.workflow_mode?e.workflow_mode.toUpperCase():``].filter(Boolean);return e.lifetime===`standing`?t.push(`STANDING · OPEN-ENDED`):e.lifetime===`bounded_increment`?t.push(`BOUNDED INCREMENT`):e.lifetime===`bounded`&&e.continuous?t.push(`BOUNDED · FINITE CONTINUOUS`):e.lifetime&&t.push(e.lifetime.toUpperCase()),t.join(` · `)}function un(e){return JSON.parse(JSON.stringify(e))}function dn(){return{schema_version:6,bootstrapped:!1,mission:{id:``,title:``,objective:``,summary:``,final_output:``,status:`idle`,started_at:null,completed_at:null,elapsed_seconds:0,campaign_started_at:null,campaign_elapsed_seconds:0},stage:{id:``,label:``},routing:{route:``,vertical:``,workflow_mode:``,lifetime:``,continuous:!1,open_ended:!1},round:{current:0,max:0},active_role:``,roles:an.map(e=>({role:e,status:`waiting`,label:`Waiting`,updated_at:0})),role_work:[],dag:[],timeline:[],artifacts:[],learned_skills:[],learned_wiki_pages:[],storage:{project_skill_dir:``,global_skill_dir:``,project_skill_count:0,global_skill_count:0,skill_history_compressed:0,wiki_retired_compressed:0,skill_history_bytes_saved:0,wiki_retired_bytes_saved:0,wiki_paths:[]},achievement:null,review:{status:``,reason:``,rejected_attempts:0},frontier:{change:``,summary:``,updated_at:0},delivery:null,outcome:{},last_event_ts:0,updated_at:0}}function fn(e,t,n,r){if(n==null||n===``)return;let i=e.findIndex(e=>e[t]===n);i>=0?e[i]={...e[i],...r}:e.push(r)}function pn(e,t,n,r,i){if(!an.includes(t))return;n===`active`&&on.has(t)&&e.roles.forEach(e=>{on.has(e.role)&&e.role!==t&&e.status===`active`&&Object.assign(e,{status:`done`,label:`Handed off`,updated_at:i})});let a={role:t,status:n,label:r,updated_at:i};fn(e.roles,`role`,t,a),n===`active`?e.active_role=t:e.active_role===t&&(e.active_role=``)}function mn(e,t,n,r,i=``,a=`neutral`){let o=St(t);if(e.timeline.some(e=>e.id===o))return;let s={id:o,ts:Number(t.ts??Date.now()/1e3),type:yt(t.type),role:n,title:r.slice(0,180),detail:i.slice(0,500),tone:a};[`item_id`,`branch_id`].forEach(e=>{let n=q(t,e);n&&(s[e]=n)}),e.timeline=[...e.timeline,s].slice(-120)}function hn(e,t,n,r,i,a=``,o=``){if(!an.includes(n))return;let s=q(t,`message_id`),c=s?`${n}:${s}`:St(t),l=e.role_work.find(e=>e.id===c),u=l&&l.detail.length>a.length?l.detail:a,d={id:c,ts:Number(t.ts??Date.now()/1e3),role:n,kind:r,title:i.slice(0,240),detail:u.slice(0,4e3),status:o,item_id:q(t,`item_id`),mission_id:e.mission.id,mission_title:e.mission.title.slice(0,240),round_index:cn(t,`round_index`)},f=e.role_work.findIndex(e=>e.id===c);f>=0?e.role_work[f]=d:e.role_work.push(d);let p=new Set;an.forEach(t=>{e.role_work.filter(e=>e.role===t).slice(-40).forEach(e=>p.add(e.id))}),e.role_work=e.role_work.filter(e=>p.has(e.id))}function gn(e){return e===`ok`?`success`:e===`err`?`error`:`info`}var _n={agent_message:`Reporting progress`,assistant_message:`Reporting progress`,command_execution:`Running a command`,reasoning:`Reasoning`,tool_use:`Using a tool`,tool_result:`Inspecting tool output`,codex_idle:`Waiting for model output`};function vn(e,t){let n=yt(t.type),r=Number(t.ts??Date.now()/1e3);if(e.last_event_ts=Math.max(e.last_event_ts,r),n===G.LIFE_MANAGER_INTENT_STARTED)e.mission.id=q(t,`item_id`)||q(t,`intent_id`),e.mission.title=q(t,`objective`).slice(0,240),e.mission.objective=q(t,`objective`),e.mission.summary=``,e.mission.final_output=``,e.mission.started_at=null,e.mission.completed_at=null,e.mission.status=`grounding`,pn(e,`manager`,`active`,`Grounding project`,r),mn(e,t,`manager`,`Project grounding started`,q(t,`objective`)),hn(e,t,`manager`,`grounding`,`Grounding project`,q(t,`objective`),`active`);else if(n===G.LIFE_MANAGER_INTENT_COMPLETED){e.mission.id=q(t,`item_id`),e.mission.title=q(t,`objective`).slice(0,240),e.mission.objective=q(t,`objective`),e.mission.summary=``,e.mission.final_output=``,e.mission.started_at=null,e.mission.completed_at=null,e.mission.status=`framed`,e.routing.route=q(t,`route`)||e.routing.route||`team`,e.routing.vertical=q(t,`vertical`)||e.routing.vertical,e.routing.workflow_mode=q(t,`workflow_mode`)||e.routing.workflow_mode,e.routing.lifetime=q(t,`lifetime`)||e.routing.lifetime,`continuous`in t&&(e.routing.continuous=t.continuous===!0),`open_ended`in t&&(e.routing.open_ended=t.open_ended===!0);let n=q(t,`current_stage`),i=Array.isArray(t.stages)?t.stages:[];if(n)e.stage={id:n,label:n.replaceAll(`_`,` `)};else if(!e.stage.id&&i[0]){let t=String(i[0]);e.stage={id:t,label:t.replaceAll(`_`,` `)}}pn(e,`manager`,`done`,`Goal framed`,r),mn(e,t,`manager`,`Goal framed`,q(t,`reason`),`success`),hn(e,t,`manager`,`decision`,`Goal framed`,q(t,`reason`)||q(t,`execution_task`),`done`)}else if(n===G.LIFE_MANAGER_INTENT_FAILED)e.mission.status=`failed`,pn(e,`manager`,`error`,`Manager routing failed`,r),mn(e,t,`manager`,`Manager routing failed`,q(t,`error`)||q(t,`reason`),`error`),hn(e,t,`manager`,`grounding`,`Manager routing failed`,q(t,`error`)||q(t,`reason`),`error`);else if(n===G.LIFE_MANAGER_STAGE_DECISION){let n=q(t,`target_stage`)||q(t,`stage`)||q(t,`current_stage`);n&&(e.stage={id:n,label:n.replaceAll(`_`,` `)}),pn(e,`manager`,`done`,n?`Stage · ${n}`:`Stage reviewed`,r),mn(e,t,`manager`,n?`Stage → ${n}`:`Stage reviewed`,q(t,`reason`)),hn(e,t,`manager`,`stage_decision`,n?`Stage → ${n}`:`Stage reviewed`,q(t,`reason`),q(t,`action`))}else if(n===G.LIFE_PLANNER_START)pn(e,`planner`,`active`,`Planning next work`,r),hn(e,t,`planner`,`planning`,`Planning next work`,q(t,`objective`),`active`);else if(n===G.LIFE_PLANNER_TASK_ADDED){let n=q(t,`item_id`),i={id:n,title:q(t,`title`),objective:q(t,`objective`),status:`pending`,deps:Array.isArray(t.deps)?t.deps.map(String):[],branch_id:q(t,`branch_id`)||n,parent_branch_id:q(t,`parent_branch_id`)||null};fn(e.dag,`id`,n,i);let a=e.routing.vertical===`research`?`Research branch added`:`Task added`;pn(e,`planner`,`done`,a,r),mn(e,t,`planner`,a,i.title,`info`),hn(e,t,`planner`,`task`,i.title||`Task added`,i.objective,`pending`)}else if(n===G.LIFE_PLANNER_VERDICT){let n=!!t.project_done,i=n&&t.delivery&&typeof t.delivery==`object`&&!Array.isArray(t.delivery)?JSON.parse(JSON.stringify(t.delivery)):null,a=i?`Task completed`:n?`Project reviewed`:`Planning complete`;i&&(e.delivery=i,e.mission.status=`complete`,e.mission.summary=i.summary||``,e.mission.completed_at=r),pn(e,`planner`,`done`,a,r),mn(e,t,`planner`,a,q(t,`reason`),n?`success`:`neutral`),hn(e,t,`planner`,`verdict`,a,q(t,`reason`),n?`done`:`planned`)}else if(n===G.LIFE_PLANNER_WAITING){pn(e,`planner`,`waiting`,`Waiting on external work`,r);let n=q(t,`reason`)||q(t,`waiting_reason`);mn(e,t,`planner`,`Planner waiting`,n),hn(e,t,`planner`,`waiting`,`Planner waiting`,n,`waiting`)}else if(n===G.LIFE_MISSION_STARTED)e.review={status:``,reason:``,rejected_attempts:0},e.delivery=null,e.mission.campaign_started_at??=r,e.mission={...e.mission,id:q(t,`item_id`),title:q(t,`title`),objective:q(t,`objective`),summary:``,final_output:``,status:`working`,started_at:r,completed_at:null},pn(e,`reviewer`,`waiting`,`Waiting for the Engineer to finish`,r),pn(e,`engineer`,`active`,`Starting mission`,r),mn(e,t,`engineer`,`Mission started`,q(t,`title`),`info`),hn(e,t,`engineer`,`task`,q(t,`title`)||`Mission started`,q(t,`objective`),`active`);else if(n===G.ROUND_START)e.round={current:cn(t,`round_index`)??0,max:cn(t,`round_max`)??e.round.max},pn(e,`engineer`,`active`,`Running round ${e.round.current}`,r),mn(e,t,`engineer`,`Round ${e.round.current} started`);else if(n===G.ENGINEER_PROGRESS){let n=q(t,`agent_layer`)||q(t,`actor`)||`engineer`,i=n===`main`?`engineer`:n,a=q(t,`kind`),o=_n[a]??`Working`;pn(e,i,`active`,o,r),i===`engineer`&&[`assistant_message`,`agent_message`,`message`].includes(a)&&t.final_delivery===!0&&e.mission.started_at!=null&&e.mission.completed_at==null&&r>=e.mission.started_at&&(!t.item_id||q(t,`item_id`)===e.mission.id)&&(e.mission.final_output=Et(t.text));let s=q(t,`action_summary`)||q(t,`text`);s&&!Ct(t)&&!wt(t)&&hn(e,t,i,a||`progress`,o,s,`active`),[`reasoning`,`assistant_message`,`agent_message`].includes(a)||mn(e,t,i,o,q(t,`action_summary`)||q(t,`text`))}else if(n===G.ROUND_MAIN_COMPLETED)pn(e,`engineer`,`done`,`Work ready for review`,r),hn(e,t,`engineer`,`handoff`,`Work ready for review`,q(t,`text`)||q(t,`summary`),`done`);else if(n===G.ROUND_REVIEW_STARTED)e.review={status:``,reason:``,rejected_attempts:e.review.rejected_attempts},pn(e,`reviewer`,`active`,`Reviewing benchmark evidence`,r),hn(e,t,`reviewer`,`review`,`Review started`,``,`active`);else if(n===G.ROUND_REVIEW_DEFERRED){let n=q(t,`next_step`);pn(e,`engineer`,`active`,`Continuing before review`,r),pn(e,`reviewer`,`waiting`,`Review deferred for one round`,r),mn(e,t,`engineer`,`Continued before review`,n,`info`)}else if(n===G.ROUND_REVIEW_COMPLETED){let n=t.review_skipped===!0,i=n?`skipped`:q(t,`status`),a=q(t,`reason`);e.review={status:i,reason:a,rejected_attempts:e.review.rejected_attempts+ +!![`continue`,`blocked`].includes(i)};let o=q(t,`frontier_change`);o&&(e.frontier={change:o,summary:q(t,`frontier_summary`),updated_at:r});let s=n?`Review not performed`:i===`done`?`Evidence accepted`:`Attempt rejected`;pn(e,`reviewer`,n?`waiting`:i===`done`?`done`:`rejected`,n?s:i===`done`?`Accepted evidence`:`Requested another attempt`,r),mn(e,t,`reviewer`,s,a,n?`info`:i===`done`?`success`:`error`);let c=q(t,`next_action`);hn(e,t,`reviewer`,n?`review`:`verdict`,s,c?`${a}\n\nNext action: ${c}`:a,i)}else if([G.SKILL_CREATED,G.SKILL_UPDATED].includes(n)){let i=q(t,`skill_id`)||q(t,`name`);i&&(fn(e.learned_skills,`id`,i,{id:i,name:q(t,`name`),version:cn(t,`version`)??1,scope:q(t,`scope`),path:q(t,`path`),status:`active`,updated_at:r,mission_id:e.mission.id,mission_title:e.mission.title}),mn(e,t,`reviewer`,n===G.SKILL_CREATED?`Capability unlocked`:`Capability upgraded`,q(t,`name`),`skill`))}else if(n===G.SKILL_EVOLUTION_COMPLETED)e.storage.project_skill_dir=q(t,`project_skill_dir`)||e.storage.project_skill_dir,e.storage.global_skill_dir=q(t,`global_skill_dir`)||e.storage.global_skill_dir,e.storage.project_skill_count=cn(t,`project_skill_count`)??e.storage.project_skill_count,e.storage.global_skill_count=cn(t,`global_skill_count`)??e.storage.global_skill_count;else if(n===G.SKILL_HISTORY_COMPRESSED)e.storage.skill_history_compressed+=cn(t,`count`)??0,e.storage.skill_history_bytes_saved+=cn(t,`bytes_saved`)??0;else if(n===G.SKILL_TIDIED){let n=q(t,`name`);if(n){let i=e.learned_skills.find(e=>e.name===n),a={source_path:q(t,`path`),source_placement:q(t,`placement`),source_vertical:q(t,`vertical`),updated_at:r};i?Object.assign(i,a):fn(e.learned_skills,`id`,n,{id:n,name:n,version:1,scope:``,path:``,status:`active`,...a}),mn(e,t,`manager`,`Capability promoted to source`,n,`skill`)}}else if([G.WIKI_INITIALIZED,G.WIKI_EVOLUTION_COMPLETED].includes(n)){let n=[...(Array.isArray(t.paths)?t.paths:[]).map(e=>String(e)),q(t,`path`)].filter(Boolean);e.storage.wiki_paths=[...new Set([...e.storage.wiki_paths,...n])]}else if(n===G.WIKI_RETIRED_COMPRESSED)e.storage.wiki_retired_compressed+=cn(t,`count`)??0,e.storage.wiki_retired_bytes_saved+=cn(t,`bytes_saved`)??0;else if([G.WIKI_CREATED,G.WIKI_UPDATED].includes(n)){let i=q(t,`page_id`);i&&(fn(e.learned_wiki_pages,`id`,i,{id:i,title:q(t,`title`)||i,card_type:q(t,`card_type`),status:q(t,`status`)||`scratch`,path:q(t,`path`),updated_at:r}),mn(e,t,`reviewer`,n===G.WIKI_CREATED?`Knowledge captured`:`Knowledge refined`,q(t,`title`)||i,`skill`))}else if(n===G.WIKI_RETIRED){let n=q(t,`page_id`);if(n){let i=e.learned_wiki_pages.find(e=>e.id===n);i?Object.assign(i,{status:`retired`,updated_at:r}):fn(e.learned_wiki_pages,`id`,n,{id:n,title:n,card_type:q(t,`card_type`),status:`retired`,path:``,updated_at:r}),mn(e,t,`reviewer`,`Knowledge retired`,n,`error`)}}else if([G.WIKI_PROMOTION_PROMOTED,G.WIKI_PROMOTION_DEMOTED].includes(n)){let i=q(t,`page_id`);if(i){let a=e.learned_wiki_pages.find(e=>e.id===i);a?Object.assign(a,{status:q(t,`to_status`),updated_at:r}):fn(e.learned_wiki_pages,`id`,i,{id:i,title:i,card_type:q(t,`card_type`),status:q(t,`to_status`),path:``,updated_at:r});let o=n===G.WIKI_PROMOTION_PROMOTED;mn(e,t,`reviewer`,o?`Knowledge promoted`:`Knowledge demoted`,`${i} → ${q(t,`to_status`)}`,o?`success`:`neutral`)}}else if(n===G.RESEARCH_ACHIEVEMENT_CERTIFIED)e.achievement={id:q(t,`achievement_id`),title:q(t,`title`),goal:q(t,`goal`),summary:q(t,`summary`),rejected_attempts:e.review.rejected_attempts,skills_learned:e.learned_skills.filter(e=>e.status===`active`).length,artifacts:e.artifacts.length,elapsed_seconds:e.mission.elapsed_seconds,evidence:Array.isArray(t.evidence)?t.evidence.map(String):[],reviewer_certified:!0,certified_at:r};else if([G.LIFE_MISSION_COMPLETED,G.LIFE_MISSION_FAILED].includes(n)){let i=n===G.LIFE_MISSION_FAILED?rn({...t,outcome_class:`failed`,status:q(t,`status`)||`failed`,success:!1}):rn(t),a=`final_output`in t?q(t,`final_output`):q(t,`item_id`)===e.mission.id&&e.mission.started_at!=null&&(e.mission.completed_at==null||e.mission.completed_at===r)&&e.mission.final_output||``;e.mission.id=q(t,`item_id`)||e.mission.id,e.mission.title=q(t,`title`)||e.mission.title,e.mission.objective=q(t,`objective`)||e.mission.objective,e.mission.summary=q(t,`summary`),e.mission.final_output=a,e.mission.status=i.missionStatus,e.mission.completed_at=r;let o=t.delivery;t.success===!0&&o&&typeof o==`object`&&!Array.isArray(o)?e.delivery=JSON.parse(JSON.stringify(o)):t.success!==!0&&(e.delivery=null),e.outcome=nn(t),pn(e,`engineer`,i.missionStatus===`complete`?`done`:i.missionStatus,i.label,r),mn(e,t,`engineer`,i.label,q(t,`summary`)||q(t,`title`)||q(t,`status`),gn(i.tone)),hn(e,t,`engineer`,`completion`,i.label,q(t,`summary`)||q(t,`title`)||q(t,`status`),i.missionStatus)}return e.updated_at=Date.now()/1e3,e}function yn(e,t,n){let r=t.backlog.find(e=>sn.has(e.status)),i=t.backlog.find(e=>e.status===`pending`),a=t.backlog.find(t=>t.id===e.mission.id),o=r??a,s=!!(r||i||t.continuous?.enabled||t.continuous?.done_reason||t.continuous?.done_at||e.mission.id||![``,`idle`].includes(e.mission.status));t.continuous?.enabled&&(e.routing.route=e.routing.route||`team`,e.routing.continuous=!0,e.routing.open_ended=t.continuous.open_ended===!0,e.routing.lifetime=e.routing.open_ended?`standing`:e.routing.lifetime||`bounded`);let c=o?.objective||o?.title||(t.continuous?.enabled?t.continuous.objective:``)||t.session.objective||(e.mission.id?``:i?.objective)||(e.mission.id?``:i?.title)||e.mission.objective;c&&(e.mission.objective=c,o?e.mission.title=(o.title||c.split(` +`)[0]).slice(0,240):e.mission.title||(e.mission.title=c.split(` +`)[0].slice(0,240))),r?((r.id!==e.mission.id||r.started_ts!=null&&r.started_ts!==e.mission.started_at||e.mission.completed_at!=null)&&(e.mission.summary=``,e.mission.final_output=``,e.mission.started_at=r.started_ts??null,e.mission.completed_at=null),e.mission.id=r.id,e.mission.status=`working`,e.mission.started_at=e.mission.started_at??r.started_ts??null):a?a.status===`pending`&&(e.mission.status=`queued`):t.continuous?.done_reason||t.continuous?.done_at?e.mission.status=`complete`:i||t.continuous?.enabled?e.mission.status=`queued`:t.daemon.alive&&(e.mission.status=`idle`),t.roles.forEach(t=>{t.active?pn(e,t.role,`active`,t.label||t.status||`Working`,Date.now()/1e3-(t.age_s??0)):s||pn(e,t.role,`waiting`,`Waiting`,Date.now()/1e3);let n=e.roles.find(e=>e.role===t.role);n&&Object.assign(n,{backend:t.backend,model:t.model,effort:t.effort})});let l=t.roles.filter(e=>e.active);l.length?e.active_role=l[l.length-1].role:s||(e.active_role=``),t.backlog.forEach(t=>{let n={id:t.id,title:t.title,objective:t.objective,status:t.status,deps:t.deps??[],branch_id:t.id,parent_branch_id:t.deps?.[0]??null,acceptance_check:t.acceptance_check??``,plan_hypothesis:t.plan_hypothesis??``,goal_contribution:t.goal_contribution??``,expected_regressions:t.expected_regressions??``,decision_rule:t.decision_rule??``,non_goals:t.non_goals??[]};fn(e.dag,`id`,n.id,n)});let u=o?.outcome?.execution_status?o.outcome:e.mission.id?void 0:[...t.backlog].filter(e=>e.outcome?.execution_status).sort((e,t)=>Number(e.finished_ts??0)-Number(t.finished_ts??0)).at(-1)?.outcome;return!r&&u&&(e.outcome=nn({outcome:u,status:`done`,success:!0})),n.forEach(t=>{fn(e.artifacts,`path`,t.path,{id:t.path,path:t.path,title:t.name,kind:t.kind,why:t.why,exists:t.exists,storage_path:t.storage_path,source:t.source})}),s}function bn(e,t,n,r){r||(t.roles.forEach(t=>{t.active||pn(e,t.role,`waiting`,`Waiting`,Date.now()/1e3)}),e.active_role=``);let i=Date.now()/1e3,a=e.mission.campaign_started_at??t.session.created??e.mission.started_at;a&&(e.mission.campaign_started_at=a,e.mission.campaign_elapsed_seconds=Math.max(0,i-a)),e.mission.started_at&&e.mission.status===`working`?e.mission.elapsed_seconds=Math.max(0,i-e.mission.started_at):e.mission.started_at&&e.mission.completed_at&&(e.mission.elapsed_seconds=Math.max(0,e.mission.completed_at-e.mission.started_at)),e.achievement?.reviewer_certified&&(e.achievement.elapsed_seconds=e.mission.elapsed_seconds,e.achievement.rejected_attempts=e.review.rejected_attempts,e.achievement.skills_learned=e.learned_skills.filter(e=>e.status===`active`).length,e.achievement.artifacts=n.filter(e=>e.exists).length)}function xn(e,t=[],n=[]){let r=e.mission_view?un(e.mission_view):dn();r.storage??=dn().storage,r.storage.skill_history_compressed??=0,r.storage.wiki_retired_compressed??=0,r.storage.skill_history_bytes_saved??=0,r.storage.wiki_retired_bytes_saved??=0,r.learned_wiki_pages??=[],r.role_work??=[],r.delivery??=null,r.outcome??={};let i=r.last_event_ts,a=yn(r,e,n),o=[...t].sort((e,t)=>Number(e.ts??0)-Number(t.ts??0));return o.filter(e=>e.ts==null||Number(e.ts)>i).forEach(e=>vn(r,e)),r.mission.final_output||(r.mission.final_output=Sn(o,r.mission)),bn(r,e,n,a),r}function Sn(e,t){if(!t.id||[`working`,`queued`,`grounding`,`framed`].includes(t.status))return``;let n=e.reduce(vn,dn()).mission;return n.id!==t.id||n.started_at==null||n.completed_at==null||t.started_at!=null&&n.started_at!==t.started_at||t.completed_at!=null&&n.completed_at!==t.completed_at?``:n.final_output||``}function Cn(e){return String(e||``).replace(/\\([*_`~])/g,`$1`).replace(/\\\\(?=[A-Za-z])/g,`\\`)}function wn(e){let t=Math.max(0,Math.floor(e)),n=Math.floor(t/3600),r=Math.floor(t%3600/60);return n?`${n}h ${r}m`:r?`${r}m`:`${t}s`}function Tn(e){let t=Math.ceil(e);return t<60?`${t}s`:t<3600?`${Math.floor(t/60)}m ${t%60}s`:t<86400?`${Math.floor(t/3600)}h ${Math.floor(t%3600/60)}m`:`${Math.floor(t/86400)}d ${Math.floor(t%86400/3600)}h`}function En(e){let t=(e.label||e.display_name||``).trim();return!!(t&&t!==e.id)}function Dn(e){return[...e].sort((e,t)=>{if(e.daemon_alive!==t.daemon_alive)return e.daemon_alive?-1:1;let n=En(e);return n===En(t)?(t.last_active||0)-(e.last_active||0):n?-1:1})}function On(e){return Dn(e)[0]}function kn(e,t){let n=t?.trim()||null;return n&&e.some(e=>e.id===n)?{id:n,requested:n,recovered:!1}:{id:On(e)?.id??null,requested:n,recovered:!!n}}function An(e,t,n){if(n){let e=t?.trim()||null;return{id:e,requested:e,recovered:!1}}return kn(e,t)}function jn(e,t){let n=t.trim().toLowerCase().split(/\s+/).filter(Boolean);if(!n.length)return!0;let r=e.daemon_alive?`live running`:`stopped idle`,i=[e.id,e.label,e.display_name,e.objective,r].filter(Boolean).join(` `).toLowerCase();return n.every(e=>i.includes(e))}function Mn(e,t){return e.filter(e=>jn(e,t))}var Nn={[G.LIFE_LIFECYCLE_BLOCK]:`block`,[G.ROUND_REVIEWER_BACKEND_FAILURE]:`block`,[G.LIFE_BUDGET_PAUSE]:`warn`,[G.ROUND_STALL]:`warn`,[G.ROUND_ESCALATED]:`warn`,[G.LIFE_PLANNER_STALL_ESCALATION]:`warn`},Pn=new Set([G.BUDGET_RESERVATION_DENIED,G.BUDGET_UNPRICED_BLOCKED]),Fn=new Set([G.LIFE_MISSION_STARTED,G.ROUND_MAIN_COMPLETED,G.LIFE_MISSION_COMPLETED,G.LOOP_DONE,G.ROUND_START,`ui.operator`]),In=new Set([G.BUDGET_RESERVATION_CREATED,G.PROVIDER_REQUEST_STARTED]);function Ln(e){let t=yt(e.canonical_type??e.type);if(e.event_validation?.status===`invalid`)return t===G.ROLE_SESSION_TURN?null:{tone:`warn`,kind:`validation`,text:`invalid event ${t||`unknown`}: ${e.event_validation.errors.join(`; `)}`};if(Pn.has(t))return{tone:`block`,kind:`budget`,text:`Budget exhausted or blocked — ${String(e.reason??e.text??t).trim()}`};let n=e.operator_alert===!0?`block`:Nn[t];return n?{tone:n,text:String(e.text??e.reason??t).trim()}:null}function Rn(e){let t=null;for(let n of e){let e=yt(n.canonical_type??n.type),r=Ln(n);r?t=r:(t?.kind===`validation`||t?.kind===`budget`&&In.has(e)||t&&t.kind!==`budget`&&Fn.has(e))&&(t=null)}return t}var zn=new Set([`done`,`completed`,`failed`,`skipped`]);function Bn(e){return zn.has(e.status)}function Vn(e,t){return e.filter(e=>Bn(e)===t)}Math.max(...[` ╭───────────────────────────────────────────────────────────────────────────────────╮╮`,` │ ││`,` │ ◉ argus-skill · Autonomous Work Lab ││`,` │ ││`,` ╰───────────────────────────────────────────────────────────────────────────────────╯│`,` │`].map(e=>[...e].length));var Hn=[`⠋`,`⠙`,`⠹`,`⠸`,`⠼`,`⠴`,`⠦`,`⠧`,`⠇`,`⠏`];function Un(e){return Hn[e%Hn.length]}var Wn=()=>Date.now()/1e3;function Gn(e){return e.trim().replace(/[.…]+$/u,``).toLowerCase()}function Kn(e,t,n=Wn()){let r=(t.label??``).trim();if(!r)return e;let i=t.heartbeat===!0,a=e.slice(),o=a[a.length-1];if(o&&!o.endedTs){if(Gn(o.label)===Gn(r)||i&&o.heartbeat)return a[a.length-1]={...o,label:r,detail:t.detail||o.detail,kind:t.kind||o.kind,heartbeat:i,endedTs:0},a;a[a.length-1]={...o,endedTs:n}}return a.push({id:`${a.length}:${r}:${n}`,role:(t.role||`manager`).trim()||`manager`,label:r,detail:(t.detail||``).trim(),kind:(t.kind||``).trim(),startedTs:n,endedTs:0,heartbeat:i}),a}function qn(e,t=Wn()){if(e.length===0)return[];let n=e.slice(),r=n[n.length-1];return r&&!r.endedTs&&(n[n.length-1]={...r,endedTs:t}),n}function Jn(e,t=6){let n=Math.max(1,t);return e.length<=n?e:e.slice(e.length-n)}function Yn(e,t=Wn()){let n=e.endedTs||t;return Math.max(0,n-e.startedTs)}function Xn(e){if(!Number.isFinite(e)||e<1)return``;if(e<60)return`${Math.floor(e)}s`;let t=Math.floor(e/60),n=Math.floor(e%60);return n?`${t}m${n}s`:`${t}m`}function Zn(e,t=!1,n=!1){return(t||n)&&e.toLowerCase()===`r`}function J(e,t){let n=(e||``).replace(/```[a-z]*\n?/gi,``).replace(/\[([^\]]+)\]\([^)]+\)/g,`[$1]`).trim();return n.length<=t?n:n.slice(0,t-1).trimEnd()+`…`}var Qn=e=>String(e??``).split(` +`)[0]?.trim()??``,Y=(e,t)=>String(e[t]??``);function $n(e,t){let n=(e,n)=>t===`zh-CN`?n:e,r=Y(e,`phase`),i=Y(e,`cause`)||Y(e,`backend_error`),a=Y(e,`error`);if(!r||!i)return`${n(`routing failed`,`分流失败`)} ${J(a,140)}`;let o={backend:n(`backend`,`后端`),parse:n(`parse`,`解析`),contract:n(`contract:`,`契约:`),timeout:n(`timeout`,`超时`)},s=Number(e.attempts||0),c=s>1?n(` (attempt ${s})`,` (第${s}次尝试)`):``,l=`${n(`routing failed`,`分流失败`)} · ${o[r]||r} ${i}${c}`;return a?`${l} · ${n(`raw`,`原始错误`)}: ${a}`:l}var er=e=>{let t=e,n=t.round_index??t.round;return typeof n==`string`||typeof n==`number`?n:`?`},tr={manager:`Manager`,planner:`Planner`,engineer:`Engineer`,reviewer:`Reviewer`,critic:`Critic`,system:`Argus`},nr={manager:`Manager`,planner:`Planner`,engineer:`Engineer`,reviewer:`Reviewer`,critic:`Critic`,system:`Argus`},rr=e=>({bright:W.ink,dim:W.inkDim,accent:W.accent,ok:W.success,warn:W.warning,err:W.error,info:W.info})[e];function ir(e,t=`en`){let n=Y(e,`type`),r=(e,n)=>t===`zh-CN`?n:e,i=e=>(t===`zh-CN`?nr:tr)[e]||e;if(n===`ui.operator`){let t=Et(Y(e,`text`));return t?{role:`operator`,label:r(`You`,`你`),glyph:`›`,text:t,tone:`bright`,rule:!0}:null}if(n===`ui.argus`){let t=Y(e,`text`);return t?{role:`manager`,label:`Argus`,glyph:`◆`,text:t,tone:`bright`,rule:!0}:null}if(n===`engineer.progress`){let t=Y(e,`kind`),n=Y(e,`agent_layer`)||`engineer`,a=Qn(e.text??e.action_summary);if(t===`reasoning`){let t=J(Y(e,`text`),280);return t?{role:n,label:i(n),glyph:`∴`,text:t,tone:`dim`,reasoning:!0}:null}if(t===`assistant_message`||t===`agent_message`||t===`message`){if(wt(e))return null;let t=Et(Y(e,`text`));return t?{role:n,label:i(n),glyph:`▌`,text:t,tone:`bright`}:null}if(t===`command_execution`){let t=Y(e,`text`)||Y(e,`command`)||Y(e,`action_summary`);return t?{role:n,label:i(n),glyph:`▸ $`,text:t,tone:`dim`}:null}if(t===`file_change`){let t=Y(e,`text`)||Y(e,`action_summary`);return{role:n,label:i(n),glyph:`✎`,text:t||r(`(file change)`,`(文件变更)`),tone:`dim`}}if(t===`tool_use`){let t=Y(e,`text`)||Y(e,`action_summary`);return{role:n,label:i(n),glyph:`⚙`,text:t||r(`(tool)`,`(工具)`),tone:`dim`}}return a?{role:n,label:i(n),glyph:`▸`,text:J(a,160),tone:`dim`}:null}if(n===`life.manager.intent.started`)return{role:`manager`,label:`Manager`,glyph:`🧭`,text:r(`classifying request…`,`判断任务归属…`),tone:`info`};if(n===`life.manager.intent.completed`)return{role:`manager`,label:`Manager`,glyph:`🧭`,text:`→ ${ln({route:Y(e,`route`)||`team`,vertical:Y(e,`vertical`),workflow_mode:Y(e,`workflow_mode`),lifetime:Y(e,`lifetime`),continuous:e.continuous===!0,open_ended:e.open_ended===!0})||Y(e,`kind`)||r(`resolved`,`已确定`)}`,tone:`info`};if(n===`life.manager.intent.failed`)return{role:`manager`,label:`Manager`,glyph:`⚠`,text:$n(e,t),tone:`err`};if(n===`life.manager.stage_decision`){let t=Y(e,`target_stage`)||Y(e,`stage`)||Y(e,`current_stage`);return{role:`manager`,label:`Manager`,glyph:`🧭`,text:`${Y(e,`action`)}${t?` → ${t}`:``} ${J(Y(e,`reason`),120)}`,tone:`info`}}if(n===`life.research.second_reading`){let t=Y(e,`agent_layer`)||`manager`,n=J(Y(e,`supported`),160),a=r(`reread the evidence and reworked the plan`,`重读了证据并重排了计划`);return{role:t,label:i(t),glyph:`📖`,text:n?`${a} · ${n}`:a,tone:`info`}}if(n===`life.letter.written`){let t=Y(e,`agent_layer`)||`manager`;return{role:t,label:i(t),glyph:`✉`,text:r(`wrote you a letter`,`给你写了一封信`),tone:`accent`}}if(n===`life.planner.start`)return{role:`planner`,label:`Planner`,glyph:`📋`,text:`${r(`planning`,`正在规划`)} ${J(Y(e,`objective`),140)}`,tone:`accent`};if(n===`life.planner.verdict`)return Y(e,`status`)===`done`||e.project_done===!0?{role:`planner`,label:`Planner`,glyph:`🏁`,text:r(`project done`,`项目已完成`),tone:`ok`}:{role:`planner`,label:`Planner`,glyph:`📋`,text:r(`queued ${Y(e,`queued`)||Y(e,`n`)||`next`} task(s)`,`已加入 ${Y(e,`queued`)||Y(e,`n`)||`下一`} 个任务`),tone:`accent`};if(n===`life.planner.task_added`)return{role:`planner`,label:`Planner`,glyph:`+`,text:`${r(`added`,`已添加`)} ${J(Y(e,`title`)||Y(e,`objective`),140)}`,tone:`accent`};if(n===`life.planner.task_skipped`)return{role:`planner`,label:`Planner`,glyph:`⏭`,text:`${r(`skipped duplicate`,`已跳过重复任务`)} ${J(Y(e,`title`),120)}`,tone:`dim`};if(n===`life.planner.error`)return{role:`planner`,label:`Planner`,glyph:`⚠`,text:`${r(`planner error`,`Planner 错误`)} ${J(Y(e,`error`)||Y(e,`text`),140)}`,tone:`err`};if(n===`life.mission.started`||n===`mission.started`)return{role:`engineer`,label:`Engineer`,glyph:`🚀`,text:J(Y(e,`title`)||Y(e,`objective`)||Y(e,`text`)||r(`mission started`,`任务已开始`),160),tone:`info`,rule:!0};if(n===`round.started`||n===`round.start`)return{role:`engineer`,label:`Engineer`,glyph:`──`,text:r(`round ${er(e)}`,`第 ${er(e)} 轮`),tone:`dim`,rule:!0};if(n===`life.phase.started`){let t=Y(e,`label`)||Y(e,`phase`);if(!t)return null;let n=Y(e,`agent_layer`)||`engineer`;return{role:n,label:i(n),glyph:`🔄`,text:r(`entering ${t}`,`进入 ${t}`),tone:`info`}}if(n===`round.review.started`)return{role:`reviewer`,label:`Reviewer`,glyph:`🔄`,text:r(`review round ${er(e)}`,`审核第 ${er(e)} 轮`),tone:`info`};if(n===`round.review.deferred`)return{role:`engineer`,label:`Engineer`,glyph:`↪`,text:r(`continues before review · ${J(Y(e,`next_step`),160)}`,`审核前继续执行 · ${J(Y(e,`next_step`),160)}`),tone:`info`};if(n===`round.main.completed`)return{role:`engineer`,label:`Engineer`,glyph:`✅`,text:r(`round ${er(e)} completed`,`第 ${er(e)} 轮已完成`),tone:`info`};if(n===`round.review.completed`){if(e.review_skipped===!0)return{role:`reviewer`,label:`Reviewer`,glyph:`↪`,text:`${r(`review not performed`,`审查未执行`)} · ${J(Y(e,`reason`),160)}`,tone:`info`};let t=Y(e,`status`),n=t===`done`?`ok`:t===`blocked`||t===`no_progress`?`err`:`warn`;return{role:`reviewer`,label:`Reviewer`,glyph:t===`done`?`✅`:t===`blocked`||t===`no_progress`?`⛔`:`↻`,text:`${t||`?`} · ${J(Y(e,`reason`),160)}`,tone:n}}if(n===`life.iteration.critic`)return{role:`critic`,label:`Critic`,glyph:`👔`,text:`${Y(e,`decision`)||``} ${J(Y(e,`reason`),140)}`,tone:`info`};if(n===`life.iteration.continued`)return{role:`critic`,label:`Critic`,glyph:`🔁`,text:r(`queued next iteration`,`已加入下一轮迭代`),tone:`dim`};if(n===`life.mission.completed`||n===`mission.completed`||n===`loop.completed`){let t=rn(e),n=J(Y(e,`summary`),240);return{role:`engineer`,label:`Engineer`,glyph:t.glyph,text:n?`${t.label} · ${n}`:t.label,tone:t.tone,rule:!0}}if(n===`life.mission.failed`||n===`mission.error`)return{role:`engineer`,label:`Engineer`,glyph:`❌`,text:`${r(`mission failed`,`任务失败`)} ${J(Y(e,`reason`)||Y(e,`error`),140)}`,tone:`err`,rule:!0};if(n===`loop.start`)return{role:`engineer`,label:`Engineer`,glyph:`▶`,text:J(Y(e,`text`)||Y(e,`objective`),160),tone:`info`};if(n===`loop.done`)return{role:`engineer`,label:`Engineer`,glyph:`🏁`,text:`${r(`loop done`,`循环完成`)} ${J(Y(e,`text`),120)}`,tone:`dim`};if(n===`life.inbox.queued`)return{role:`system`,label:r(`You`,`你`),glyph:`📥`,text:`${r(`nudge`,`追加指导`)} · ${J(Y(e,`text`),160)}`,tone:`accent`};if(n===`final.report.ready`||n===`pptx.report.ready`)return{role:`system`,label:`Argus`,glyph:`📄`,text:r(`report ready`,`报告已就绪`),tone:`accent`};if(n===`plan.completed`)return{role:`planner`,label:`Planner`,glyph:`📋`,text:r(`plan completed`,`计划已完成`),tone:`accent`};if(n===`daemon.stopping`)return{role:`system`,label:`Argus`,glyph:`🛑`,text:r(`stopping`,`正在停止`),tone:`err`};if(n===`round.reviewer_backend_failure`)return{role:`system`,label:r(`Notice`,`通知`),glyph:`!`,text:r(`reviewer backend down — holding · ${J(Y(e,`text`),150)}`,`Reviewer 后端不可用 — 已暂停 · ${J(Y(e,`text`),150)}`),tone:`err`,rule:!0};if(n===`round.stall`)return{role:`system`,label:r(`Notice`,`通知`),glyph:`!`,text:J(Y(e,`text`)||r(`no forward progress`,`没有取得进展`),170),tone:`warn`};if(n===`round.escalated`)return{role:`system`,label:r(`Notice`,`通知`),glyph:`!`,text:J(Y(e,`text`)||r(`soft round limit — escalating external blockers`,`达到软轮次上限 — 正在升级外部阻塞`),170),tone:`warn`};if(n===`life.planner.stall_escalation`)return{role:`system`,label:r(`Notice`,`通知`),glyph:`!`,text:`${r(`planner stalled`,`Planner 停滞`)} — ${J(Y(e,`reason`)||Y(e,`text`),150)}`,tone:`warn`};if(n===`life.budget.pause`)return{role:`system`,label:r(`Watch`,`监控`),glyph:`⏸`,text:r(`budget cap reached — paused · ${J(Y(e,`text`)||Y(e,`reason`),140)}`,`已达到预算上限 — 已暂停 · ${J(Y(e,`text`)||Y(e,`reason`),140)}`),tone:`warn`};if(n===`budget.reservation.denied`)return{role:`system`,label:r(`Budget`,`预算`),glyph:`$`,text:`${r(`budget denied`,`预算申请被拒绝`)} — ${J(Y(e,`reason`)||Y(e,`text`),150)}`,tone:`err`,rule:!0};if(n===`budget.unpriced.blocked`)return{role:`system`,label:r(`Budget`,`预算`),glyph:`$`,text:`${r(`budget blocked by unresolved cost`,`预算因成本未确定而阻塞`)} — ${J(Y(e,`reason`)||Y(e,`text`),150)}`,tone:`err`,rule:!0};if(n===`life.lifecycle.block`)return null;if(n===`life.daemon.idle_timeout`)return{role:`system`,label:r(`Watch`,`监控`),glyph:`🟦`,text:J(Y(e,`text`)||r(`idle timeout — standing by`,`空闲超时 — 正在待命`),150),tone:`dim`};if(n===`round.watchdog.restart_requested`)return{role:`system`,label:r(`Watch`,`监控`),glyph:`🔄`,text:r(`stall caught — restarting the round · ${J(Y(e,`reason`),160)}`,`检测到停滞 — 正在重启本轮 · ${J(Y(e,`reason`),160)}`),tone:`warn`};if(n===`engineer.failure_nudge`)return{role:`engineer`,label:`Engineer`,glyph:`⚠`,text:`${r(`repeated tool failure`,`工具重复失败`)} — ${J(Y(e,`text`)||Y(e,`reason`),160)}`,tone:`warn`};if(n===`mission.idle`)return{role:`system`,label:`Argus`,glyph:`🟦`,text:J(Y(e,`text`)||r(`idle — awaiting the next mission`,`空闲 — 正在等待下一个任务`),160),tone:`dim`};if(e.operator_alert===!0){let t=J(Y(e,`text`)||Y(e,`reason`)||n,170);if(t)return{role:`system`,label:r(`Notice`,`通知`),glyph:`!`,text:t,tone:`err`,rule:!0}}return null}function ar(e,t){return St(e)}function or(e,t,n){e.setQueryData([`snapshot`,t],e=>e&&{...e,session:{...e.session,display_name:n}}),e.setQueryData([`projects`],e=>e&&{...e,projects:e.projects.map(e=>e.id===t?{...e,display_name:n,label:n||e.objective||e.id}:e)})}var sr=15e3,cr=5e3,lr=8e3,ur=2e3,dr=1e4,fr=1e4;function pr(e,t){return!L(t)&&e<1}function mr(e){return!L(e)&&cr}function hr(e){return e?.projects.some(e=>e.daemon_alive)?ur:sr}function gr(e){return e?.daemon.alive?ur:lr}var _r=()=>ce({queryKey:[`projects`],queryFn:U.projectIndex,refetchInterval:e=>hr(e.state.data)}),vr=()=>ce({queryKey:[`project-costs`],queryFn:({signal:e})=>U.projectCosts(e),retry:pr,refetchInterval:e=>mr(e.state.error),refetchIntervalInBackground:!1}),yr=e=>ce({queryKey:[`snapshot`,e],queryFn:({signal:t})=>U.activeSnapshot(e,t),enabled:!!e,refetchInterval:e=>gr(e.state.data)}),br=(e,t=30,n=!0)=>ce({queryKey:[`journal`,e,t],queryFn:({signal:n})=>U.journal(e,t,n),enabled:!!e&&n,refetchInterval:n?8e3:!1}),xr=(e,t)=>ce({queryKey:[`doctor`,e],queryFn:({signal:t})=>U.doctor(e,t),enabled:!!e&&t}),Sr=(e,t)=>ce({queryKey:[`config`,e],queryFn:({signal:t})=>U.config(e,t),enabled:!!e&&t}),Cr=(e,t)=>ce({queryKey:[`identity`,e],queryFn:({signal:t})=>U.identity(e,t),enabled:!!e&&t}),wr=(e,t,n=30)=>ce({queryKey:[`transcript`,e,n],queryFn:({signal:t})=>U.transcript(e,n,t),enabled:!!e&&t}),Tr=(e,t=!0)=>ce({queryKey:[`artifacts`,e],queryFn:({signal:t})=>U.artifacts(e,t),enabled:!!e&&t,refetchInterval:t?dr:!1}),Er=(e,t,n=null)=>ce({queryKey:[`artifact`,e,t,n],queryFn:({signal:n})=>U.artifact(e,t,n),enabled:!!e&&!!t,refetchInterval:e=>t&&/(?:^|[\\/])REVIEW\.md$/i.test(t)&&!L(e.state.error)?2e3:!1}),Dr=(e,t=!0)=>ce({queryKey:[`git-diff`,e],queryFn:({signal:t})=>U.gitDiff(e,t),enabled:!!e&&t,refetchInterval:t?fr:!1}),Or=(e,t)=>ce({queryKey:[`backlog-item`,e,t],queryFn:({signal:n})=>U.backlogItem(e,t,n),enabled:!!e&&!!t});function kr(e,t){let n=oe(),r=e=>{n.invalidateQueries({queryKey:[`snapshot`,e]}),n.invalidateQueries({queryKey:[`status`,e]}),n.invalidateQueries({queryKey:[`projects`]}),n.invalidateQueries({queryKey:[`backlog-item`,e]})},i=()=>r(e);return{addTask:P({mutationFn:t=>U.addTask(e,t),onSuccess:i}),nudge:P({mutationFn:t=>U.nudge(e,t)}),note:P({mutationFn:t=>U.note(e,t)}),startDaemon:P({mutationFn:()=>U.startDaemon(e,t),onSuccess:i}),stopDaemon:P({mutationFn:n=>U.stopDaemon(e,n,t),onSuccess:i}),forceStopDaemon:P({mutationFn:()=>U.stopDaemon(e,!1,t,!0),onSuccess:i}),updateProject:P({mutationFn:e=>U.updateProject(e.sid,e.name),onSuccess:e=>{or(n,e.sid,e.name),r(e.sid)}}),deleteProject:P({mutationFn:()=>U.deleteProject(e),onSuccess:async()=>{let t=e;if(t){let e=e=>e.queryKey.some(e=>e===t);await n.cancelQueries({predicate:e}),n.removeQueries({predicate:e})}await n.invalidateQueries({queryKey:[`projects`]})}}),disposeBacklog:P({mutationFn:t=>U.disposeBacklog(e,t.id,t.op),onSuccess:i}),stopBacklog:P({mutationFn:t=>U.stopBacklog(e,t),onSuccess:i}),setContinuous:P({mutationFn:t=>U.setContinuous(e,t.enabled,t.objective??``),onSuccess:i})}}var Ar=2e3;function jr(e,t){if(t.kind===`reset`)return{sid:t.sid,events:[],seen:new Set};if(t.sid!==e.sid)return e;if(t.kind===`seed`){let n=new Set,r=[];[...t.events,...e.events].forEach((e,t)=>{let i=ar(e,t);n.has(i)||(n.add(i),r.push(e))});let i=r.slice(-2e3);return{sid:e.sid,events:i,seen:new Set(i.map((e,t)=>ar(e,t)))}}let n=t.kind===`push`?[t.ev]:t.events,r=null,i=null;for(let t of n){let n=r??e.events,a=i??e.seen,o=ar(t,n.length);a.has(o)||((!r||!i)&&(r=[...e.events],i=new Set(e.seen)),i.add(o),r.push(t))}return!r||!i?e:(r.length>Ar&&r.splice(0,r.length-Ar).forEach((e,t)=>i.delete(ar(e,t))),{sid:e.sid,events:r,seen:i})}var Mr=new Set([`manager.live_view.updated`,`round.review.completed`,`life.mission.completed`]);function Nr(e){for(let t=e.length-1;t>=0;--t){let n=e[t],r=String(n.type??``);if(Mr.has(r)||r===`engineer.progress`&&n.kind===`file_change`)return ar(n,t)}return``}var Pr=new Set([`life.operator_question.pending`,`life.operator_question.answered`,`life.planner.task_added`,`life.planner.verdict`,`life.mission.started`,`life.mission.completed`,`life.mission.failed`,`round.review.completed`]);function Fr(e){for(let t=e.length-1;t>=0;--t){let n=e[t];if(Pr.has(String(n.type??``)))return ar(n,t)}return``}function Ir(e,t=0){let[n,r]=(0,I.useReducer)(jr,{sid:null,events:[],seen:new Set}),[i,a]=(0,I.useState)({sid:null,connected:!1}),o=(0,I.useRef)(e);return o.current=e,(0,I.useEffect)(()=>{if(r({kind:`reset`,sid:e}),a({sid:e,connected:!1}),!e)return;let t=!1,n=new AbortController,i=[],s,c=()=>{if(s=void 0,t||o.current!==e||i.length===0){i=[];return}let n=i;i=[],r({kind:`push-many`,sid:e,events:n})};U.events(e,120,n.signal).then(n=>{!t&&o.current===e&&r({kind:`seed`,sid:e,events:n})}).catch(()=>{});let l=dt(e,n=>{!t&&o.current===e&&(i.push(n),s===void 0&&(s=window.setTimeout(c,40)))},{replay:40,onOpen:()=>{!t&&o.current===e&&a({sid:e,connected:!0})},onClose:()=>{!t&&o.current===e&&a({sid:e,connected:!1})}});return()=>{t=!0,n.abort(),s!==void 0&&window.clearTimeout(s),i=[],l()}},[e,t]),{events:n.sid===e?n.events:[],connected:i.sid===e&&i.connected}}var Lr=`argus.message.route.v2`;function Rr(){try{let e=localStorage.getItem(Lr);if(e===`auto`||e===`chat`||e===`task`)return e}catch{}return`auto`}var X=v();function zr(e){return!Number.isFinite(e)||e<=0?`$0.00`:e>=100?`$${e.toFixed(0)}`:e>=10?`$${e.toFixed(1)}`:e>=1?`$${e.toFixed(2)}`:`$${e.toFixed(3)}`}function Br({settledUsd:e,knownUsd:t=0,status:n=`empty`}){let r=typeof e==`number`&&Number.isFinite(e)?e:t,i=n===`partial`||n===`unpriced`;return`${zr(Math.max(0,r||0))}${i?`+`:``}`}function Vr({settledUsd:e,knownUsd:t,status:n,calls:r=0,premiumRequests:i=0,live:a=!1,compact:o=!1}){let s=Br({settledUsd:e,knownUsd:t,status:n}),c=[`Cumulative settled project spend`,`${r} model call${r===1?``:`s`}`,i>0?`${i.toFixed(1)} premium requests`:``,n&&n!==`empty`?`pricing: ${n}`:``].filter(Boolean).join(` · `);return(0,X.jsxs)(`span`,{title:c,"aria-label":`Project spend ${s}`,className:`inline-flex shrink-0 items-center rounded-full border border-gold/25 bg-gold/8 font-mono tabular-nums text-gold ${o?`h-6 gap-1 px-2 text-[10px]`:`h-5 gap-1 px-1.5 text-[9px]`}`,children:[a?(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`h-1.5 w-1.5 animate-pulse rounded-full bg-gold/80`}):null,(0,X.jsx)(`span`,{children:s})]})}var Hr=`argus.locale`,Ur={"language.english":`English`,"handshake.connecting":`Getting Argus ready`,"handshake.service":`Service`,"handshake.project":`Project`,"handshake.ready":`Ready`,"handshake.title":`Getting Argus ready`,"handshake.detail":`Reopening your workspace…`,"splash.starting":`Argus starting`,"rail.workbench":`Workbench`,"rail.sessionsShortcut":`Sessions · Ctrl/⌘ P`,"panel.backlog":`Backlog`,"panel.activity":`Activity`,"panel.journal":`Journal`,"panel.roles":`Roles`,"panel.project":`Project`,"panel.liveView":`Manager live project view`,"stream.jumpToLatest":`Jump to latest`,"stream.toggleReasoning":`Show or hide agent reasoning (⌘T)`,"stream.reasoning":`Reasoning`,"stream.noLogs":`No activity yet`,"stream.system":`Argus updates`,"stream.autonomous":`Background activity`,"stream.backgroundWork":`Argus is working in the background`,"stream.ready":`Argus is ready. Ask a question or assign work.`,"newDaemon.workdirPlaceholder":`Blank → ~/.argus-skill/workspaces/`,"operations.resetManager":`Reset Manager context`,"language.chinese":`中文`,"language.switchTo":`Switch to {language}`,"common.loading":`Loading…`,"common.retry":`Retry`,"common.save":`Save`,"common.cancel":`Cancel`,"common.close":`Close`,"common.settings":`Settings`,"common.ready":`Ready`,"common.live":`Live`,"common.reconnecting":`Reconnecting`,"common.stale":`Snapshot stale`,"common.degraded":`Snapshot degraded`,"common.external":`External`,"common.pause":`Pause`,"common.run":`Run`,"common.local":`Local`,"common.all":`All`,"common.unassigned":`Unassigned`,"common.closeSessions":`Close sessions`,"common.resizeSessions":`Resize sessions`,"common.resizePreview":`Resize preview`,"common.expandPreview":`Expand preview`,"time.justNow":`just now`,"time.minutesAgo":`{count}m ago`,"time.hoursAgo":`{count}h ago`,"time.yesterdayAt":`Yesterday at {time}`,"connection.pairingTitle":`This browser is not paired with Argus`,"connection.pairingDetail":`Close this tab and reopen the workbench from Argus Desktop, or open a fresh pairing link.`,"connection.pairAgain":`Pair again`,"connection.pairingInput":`Pairing link or token`,"connection.pairingPlaceholder":`Paste a fresh pairing link or token`,"connection.pairingInvalid":`Enter a valid pairing link or token.`,"connection.connect":`Connect`,"connection.unreachableTitle":`The local Argus service is unavailable`,"connection.unreachableDetail":`Keep Argus Desktop running, wait for the local service to become ready, then retry.`,"sidebar.collapse":`Collapse sessions`,"sidebar.expand":`Expand sessions`,"sidebar.create":`Create session`,"sidebar.find":`Find a session`,"sidebar.clearSearch":`Clear search`,"sidebar.refreshFailed":`Refresh failed · retry`,"sidebar.noSessions":`No sessions`,"sidebar.noMatches":`No sessions matching "{query}"`,"sidebar.unnamedSession":`Unnamed session`,"sidebar.daemonAlive":`Argus running`,"sidebar.updateRequired":`Update required`,"sidebar.updateAvailable":`Update available`,"sidebar.updateAvailableHint":`The executor is still running with a different release from this page.`,"sidebar.stopped":`stopped`,"sidebar.runningFor":`running · {uptime}`,"sidebar.manage":`Manage {name}`,"sidebar.manageHint":`Rename, pause, or delete`,"sidebar.resume":`Resume`,"sidebar.resumeHint":`Resume work in {workdir}`,"sidebar.resumeSuccess":`Session resumed.`,"sidebar.resumeFailed":`Could not resume session: {error}`,"sidebar.modelLoading":`Loading backend and model…`,"sidebar.modelUnavailable":`Backend and model unavailable`,"sidebar.defaultModel":`default model`,"sidebar.openSettings":`Open settings`,"sidebar.theme":`{current} theme; switch to {next}`,"landing.selectOrCreate":`Select a session from the sidebar, or create a new one.`,"landing.noSessions":`No sessions yet. Create one to begin.`,"landing.select":`Select session`,"landing.new":`New session`,"topbar.openSessions":`Open sessions`,"topbar.externallyManaged":`Externally managed`,"topbar.pauseDaemon":`Pause Argus`,"topbar.runDaemon":`Run Argus`,"topbar.roleActive":`{role} is active`,"topbar.roleIdle":`{role} is idle`,"topbar.externalDaemonHint":`Argus is managed outside this app and must be controlled there.`,"topbar.manageSession":`Manage session`,"topbar.showPreview":`Show preview`,"topbar.showActivity":`Show activity`,"mobile.views":`Views`,"mobile.sessions":`Sessions`,"mobile.mission":`Mission`,"mobile.activity":`Activity`,"mobile.workbench":`Workbench`,"mobile.map":`Map`,"mobile.preview":`Preview`,"chat.working":`Argus is working on your message`,"chat.workingQuiet":`Argus is working on your message · Still working; no new update for {quiet}s`,"chat.stopWaitingHint":`Esc stop waiting`,"chat.messageArgus":`message Argus`,"chat.selectSession":`Select a session…`,"chat.placeholder":`Ask a question or assign work`,"chat.routeLabel":`message category`,"chat.routeHint":`Task skips category classification but still uses Manager → Planner → Engineer → Reviewer`,"chat.routeTask":`Task`,"chat.routeAuto":`Auto`,"chat.routeChat":`Chat`,"chat.attach":`attach files`,"chat.attachHint":`PNG, JPEG, WebP, PDF, Markdown/text, JSON, CSV · up to {count} files, {perFile} each, {total} total`,"chat.attachDrop":`Drop files to attach`,"chat.attachRemove":`remove attachment {name}`,"chat.attachUnsupported":`{name} is not supported. Use PNG, JPEG, WebP, PDF, Markdown/text, JSON, or CSV.`,"chat.attachTooLarge":`{name} exceeds the {size} per-file limit.`,"chat.attachTooMany":`You can attach up to {count} files per message.`,"chat.attachTotalTooLarge":`Attachments exceed the {size} total limit.`,"chat.attachmentUploadFailed":`Attachment upload failed: {error}`,"chat.uploadingAttachments":`Uploading attachments`,"chat.rewriteHint":`Let the Manager rewrite this prompt into a brief the team can act on. Nothing is sent — the rewrite lands back in this box for you to edit.`,"chat.rewriteLabel":`rewrite prompt with the Manager`,"chat.rewriting":`rewriting`,"chat.rewrite":`✦ Rewrite`,"chat.stopWaiting":`stop waiting`,"chat.stopWaitingTitle":`stop waiting for this reply; server-side work may continue`,"chat.send":`send message`,"copy.message":`Copy`,"copy.code":`Copy code`,"copy.copied":`Copied`,"help.title":`Keyboard shortcuts`,"help.commands":`Commands`,"help.palette":`command palette`,"help.sessions":`toggle sessions`,"help.managerChat":`focus Manager chat`,"help.rewrite":`rewrite the current prompt before sending`,"help.reasoning":`toggle agent reasoning`,"help.kiosk":`toggle kiosk (read-only) mode`,"help.composer":`focus the composer`,"help.send":`send message`,"help.newline":`insert newline`,"help.thisHelp":`this help`,"help.escape":`close overlay / stop waiting in composer`,"palette.placeholder":`Type a command or search…`,"palette.noMatches":`no matching commands`,"palette.navigate":`↑↓ navigate`,"palette.run":`↵ run`,"palette.close":`esc close`,"palette.view":`View`,"palette.action":`Action`,"palette.project":`Project`,"palette.newDaemon":`New session`,"palette.openTranscript":`Open Transcript`,"palette.openProject":`Open Project`,"palette.projectHint":`work · memory · agents`,"palette.openOperations":`Open Operations`,"palette.operationsHint":`session controls`,"palette.hideReasoning":`Hide reasoning`,"palette.showReasoning":`Show reasoning`,"palette.exitKiosk":`Exit kiosk mode`,"palette.enterKiosk":`Enter kiosk mode`,"palette.messageArgus":`Message Argus…`,"palette.stopWaiting":`Stop waiting for Manager reply`,"palette.stopContinuous":`Stop continuous campaign`,"palette.startContinuous":`Start continuous campaign`,"palette.stopDaemon":`Pause Argus`,"palette.startDaemon":`Run Argus`,"slash.suggestions":`Slash command suggestions`,"mission.roleActive":`{role} active`,"mission.overview":`mission overview`,"mission.operations":`Operations`,"role.manager":`Manager`,"role.planner":`Planner`,"role.engineer":`Engineer`,"role.reviewer":`Reviewer`,"role.critic":`Critic`,"role.system":`Argus`,"role.operator":`You`,"doctor.title":`Doctor`,"doctor.subtitle":`Argus status checks + recommended root-cause fix`,"doctor.recommended":`recommended fix`,"doctor.loadError":`Couldn’t load diagnostics.`,"doctor.empty":`No diagnostic data available`,"doctor.daemonLog":`Daemon log`,"settings.subtitle":`effective roles, budgets, and essential controls`,"settings.loadError":`Couldn’t load configuration.`,"settings.empty":`No configuration found`,"settings.quickConfig":`Quick Config`,"settings.appearance":`Appearance`,"settings.appearanceHint":`Choose the interface colour treatment. Logos and icons always remain monochrome.`,"settings.themeStyle":`Theme colour`,"settings.themeStyle.standard":`Standard`,"settings.themeStyle.standardHint":`Quiet black, white, grey, and blue.`,"settings.themeStyle.gradient":`Gradient`,"settings.themeStyle.gradientHint":`The classic Argus blue-to-gold background.`,"settings.backend":`Backend`,"settings.backendLabel.copilot":`GitHub Copilot`,"settings.backendLabel.codex":`Codex`,"settings.backendLabel.claude":`Claude`,"settings.backendLabel.cursor":`Cursor`,"settings.backendLabel.opencode":`OpenCode`,"settings.backendLabel.pi":`Pi`,"settings.backendLabel.grok":`Grok`,"settings.backendLabel.qoder":`Qoder`,"settings.backendLabel.dsh":`DSH`,"settings.backendSwitched":`Backend saved as {backend}. Restart Argus to apply.`,"settings.backendUnsupported":`Unsupported backend ({backend})`,"settings.backendUnavailable":`Backend unavailable`,"settings.model":`Model`,"settings.applyModel":`Apply`,"settings.modelPlaceholder":`auto (backend default)`,"settings.connection":`Connection`,"settings.webApi":`Web + REST API`,"settings.eventStream":`Live updates`,"settings.taskDaemon":`Background work`,"settings.taskDaemonValue":`Local process · events.jsonl · no TCP port`,"settings.budgetTitle":`Budget and quota limits`,"settings.budgetHint":`Set 0 for an uncapped provider-call limit where supported.`,"settings.saveBudgets":`Save budget limits`,"settings.budget.global":`Host-global daily`,"settings.budget.codex":`Codex calls / day`,"settings.budget.copilot":`Copilot calls / day`,"settings.budget.premium":`Copilot premium / day`,"settings.required":`{field} is required`,"settings.budgetSaved":`Budget limits saved. Restart active sessions to apply their limits.`,"settings.unit.usd":`USD`,"settings.unit.calls":`calls`,"settings.unit.requests":`requests`,"settings.advanced":`Advanced`,"settings.advancedHint":`Connection details, environment overrides, and effective raw configuration`,"settings.overrideTitle":`Environment override`,"settings.overrideHint":`Set a specific config alias or environment-variable key.`,"settings.namePlaceholder":`name or alias, e.g. manager_model`,"settings.valuePlaceholder":`value`,"settings.applyAdvanced":`Apply environment override`,"settings.applied":`Applied. Restart affected sessions to use the new settings.`,"settings.rolesTitle":`Effective roles`,"settings.rawConfig":`Raw configuration`,"settings.group.limits":`Limits`,"settings.group.safety":`Safety`,"settings.group.interface":`Interface`,"settings.knob.activeDaemons":`Active session limit`,"settings.knob.activeDaemonsDoc":`Maximum background sessions running on this host.`,"settings.knob.unpricedCalls":`Calls without pricing`,"settings.knob.unpricedCallsDoc":`Whether calls with unresolved pricing are blocked or allowed.`,"settings.knob.safeMode":`Safe mode`,"settings.knob.safeModeDoc":`Enable extra-conservative runtime guardrails.`,"settings.knob.telegram":`Telegram`,"settings.knob.telegramDoc":`Enable the Telegram notification bridge.`,"settings.knob.showReasoning":`Show reasoning`,"settings.knob.showReasoningDoc":`Stream role reasoning into the activity view.`,"settings.source.notApplicable":`Not applicable for this model`,"settings.source.vaultDefault":`Capability vault / default`,"settings.source.default":`Default`,"settings.source.saved":`Saved override`,"settings.source.environment":`Environment variable`,"settings.source.hostConfig":`Host configuration`,"settings.source.other":`Resolved configuration`,"settings.value.block":`Block calls`,"settings.value.allow":`Allow calls`,"settings.value.enabled":`Enabled`,"settings.value.disabled":`Disabled`,"settings.effort.low":`Low effort`,"settings.effort.medium":`Medium effort`,"settings.effort.high":`High effort`,"settings.effort.xhigh":`Extra-high effort`,"settings.role.curator":`Curator`,"settings.role.managerDoc":`Routes conversations and tasks, and approves reusable skills.`,"settings.role.plannerDoc":`Queues new work and decides when the project is ready to finish.`,"settings.role.engineerDoc":`Writes code and runs commands.`,"settings.role.reviewerDoc":`Reads completed work and decides whether it holds.`,"settings.role.curatorDoc":`Maintains and distills the reusable skill pool.`,"settings.footer":`Human-readable labels are shown with raw keys. The full registry remains available via`,"identity.title":`Identity`,"identity.subtitle":`who argus is working for on this project`,"identity.placeholder":`Describe who Argus is working for and durable preferences…`,"identity.save":`Save identity`,"identity.saved":`Identity saved.`,"transcript.title":`Transcript`,"transcript.subtitle":`recent operator ↔ argus turns · reply from the composer`,"transcript.empty":`no conversation turns yet`,"transcript.operator":`operator`,"new.createDaemon":`Create session`,"new.subtitle":`Creates an isolated timeline and Manager context.`,"new.close":`close create session`,"new.name":`Name`,"new.optional":`(optional)`,"new.namePlaceholder":`e.g. AAAI embodiment paper`,"new.workdir":`Output workdir`,"new.workdirHint":`Agents write code, papers, reports, and experiment outputs here. Internal memory stays under the session state directory.`,"new.objective":`Objective`,"new.objectivePlaceholder":`Leave blank to start with a conversation, or describe a campaign to start immediately.`,"new.startsAfterCreate":`Campaign starts after session creation`,"new.idleUntilMessage":`Idle until the first message`,"new.startsHint":`The session opens immediately while Argus prepares the work in the background.`,"new.idleHint":`Background work starts after your first message, when needed.`,"new.shortcut":`Ctrl/⌘+Enter to create`,"new.creating":`Creating…`,"new.createAndStart":`Create and start`,"manage.daemon":`Manage session`,"manage.displayName":`Display name`,"manage.executor":`Background work`,"manage.running":`Running`,"manage.runningExternally":`Running externally`,"manage.paused":`Stopped`,"manage.pauseHint":`Interrupt the current operation and keep progress resumable.`,"manage.stopNow":`Stop now`,"manage.stopNowHint":`Immediately interrupt this verified daemon so the session can be deleted.`,"manage.externalHint":`This session is managed outside this app.`,"manage.resumeHint":`Resume queued research work.`,"manage.working":`Working…`,"manage.resume":`Resume`,"manage.deleteSession":`Delete session`,"manage.deleteHint":`Deleted sessions move to the trash and remain recoverable. Stop background work first.`,"manage.delete":`Delete…`,"manage.confirmQuestion":`Move this session to trash?`,"manage.confirmDelete":`Confirm delete`,"decision.operator":`Operator decision`,"decision.required":`Decision required`,"decision.whyBlocked":`Why work is blocked`,"decision.evidence":`Evidence`,"decision.notePlaceholder":`Add the guidance the Manager should apply…`,"decision.resumeHint":`The Manager applies your choice before work resumes.`,"decision.later":`Later`,"decision.applying":`Applying…`,"decision.stopCampaign":`Stop campaign`,"decision.useOption":`Use this option`,"decision.sendAnswer":`Send answer`,"decision.noteRequired":`Add the required details before sending this choice.`,"artifact.preview":`Result preview`,"artifact.title":`Result`,"artifact.approvedEvidence":`evidence the Reviewer has checked`,"artifact.downloading":`Downloading…`,"artifact.download":`Download`,"artifact.open":`Open`,"artifact.close":`close result preview`,"artifact.unavailable":`preview unavailable`,"artifact.empty":`(empty file)`,"artifact.truncated":`preview truncated · download to inspect the complete file`,"artifact.htmlTooLarge":`HTML preview is too large to render safely. Download the complete file.`,"artifact.pdfDisabled":`Inline PDF preview is disabled by this browser.`,"artifact.openPdf":`Open PDF`,"artifact.noPreview":`This file type has no safe inline preview.`,"artifact.downloadHint":`Download it to inspect with a local application.`,"task.details":`Task details`,"task.stopLoop":`stop loop`,"task.done":`done`,"task.skip":`skip`,"task.close":`close task details`,"task.waitingOnYou":`Waiting on you`,"task.objective":`Objective`,"task.noObjective":`(no objective recorded)`,"task.untitled":`Untitled task`,"task.priority":`priority`,"task.started":`started`,"task.finished":`finished`,"task.outcome":`Outcome`,"task.iteration":`Iteration`,"task.mode":`mode`,"task.autoIterate":`auto-iterate`,"task.singlePass":`single pass`,"task.cycles":`cycles`,"task.cost":`cost`,"task.lastError":`Last error`,"task.notes":`Notes`,"task.dependsOn":`depends on`,"task.dependsOnCount":`Depends on {count} earlier tasks`,"pending.reviewRespond":`Review and respond`,"pending.showOnMap":`Show on map`,"backlog.active":`Active · {count}`,"backlog.history":`History · {count}`,"backlog.noHistory":`No completed work yet`,"backlog.empty":`Nothing queued. Argus is ready for new work.`,"backlog.viewDetails":`View full task details`,"backlog.iterating":`Repeating`,"backlog.stopIterating":`Stop repeating`,"backlog.stop":`Stop`,"backlog.markDone":`Mark done`,"backlog.remove":`Remove`,"mission.achievement":`Argus achievement`,"mission.elapsed":`Elapsed`,"mission.rejectedAttempts":`{count} rejected attempts`,"mission.skillsLearned":`{count} skills learned`,"mission.artifacts":`{count} files produced`,"mission.waiting":`Waiting for a mission`,"mission.statusActive":`{role} — {work}`,"mission.statusWaiting":`Ready when you are — assign a mission to begin.`,"mission.statusDone":`{outcome} — finished in {elapsed}.`,"mission.continuousDone":`Continuous run finished`,"mission.resumeContinuous":`Resume`,"mission.control":`Mission control`,"mission.attentionHealth":`System error — health is degraded.`,"mission.attentionFailed":`Mission failed — check the task below.`,"mission.deliveryFailed":`Task failed at delivery — execution could not start or finish.`,"mission.attentionStepFailed":`A step failed — check the task below.`,"mission.attentionPaused":`Mission is paused — waiting for your input.`,"mission.showObjective":`Show full objective`,"mission.showFullOutput":`View full output`,"mission.stage":`Stage`,"mission.campaign":`Campaign`,"mission.totalElapsed":`Total elapsed`,"mission.round":`Round`,"mission.mode":`Mode`,"mission.summary":`Mission summary`,"mission.deliveryCertified":`Delivery approved`,"mission.taskCompleted":`Task completed`,"mission.openResult":`Open result`,"mission.viewTask":`View task`,"mission.taskPlan":`Task plan`,"mission.team":`AI research team`,"mission.waitingShort":`Waiting`,"mission.roleWork":`Role work`,"mission.showMore":`Show more`,"mission.showLess":`Show less`,"mission.done":`Done`,"mission.inProgress":`In progress`,"mission.failed":`Failed`,"mission.bannerPaused":`Mission is paused — waiting for your input.`,"mission.bannerError":`System error — health is degraded.`,"mission.bannerStepFailed":`A step failed: {step}`,"mission.elapsedAgo":`{elapsed} ago`,"mission.filteredBy":`filtered by {task} · clear`,"mission.allVisible":`all visible missions`,"mission.roundNumber":`round {count}`,"mission.noRoleWork":`No persisted {role} work for this selection yet.`,"mission.researchDag":`Task route`,"mission.active":`active`,"mission.noDag":`The Planner has not added tasks to the route yet.`,"mission.workingHypothesis":`Working hypothesis · can be revised`,"mission.goalContribution":`How this supports the goal`,"mission.temporaryRegressions":`Expected temporary tradeoffs`,"mission.decisionRule":`When to revise, split, or stop`,"mission.acceptance":`What counts as done`,"mission.nonGoals":`Non-goals`,"mission.capabilities":`Capabilities`,"mission.capabilitiesUnlocked":`Capabilities unlocked`,"mission.learnedCapability":`Learned capability`,"mission.learnedDuring":`Learned during {mission}`,"mission.skillUnavailable":`Skill content is not available in this snapshot.`,"mission.contentTruncated":`Content preview truncated`,"mission.knowledgeRetained":`Knowledge retained`,"mission.selfEvolution":`Saved project knowledge`,"mission.knowledgeSaved":`Argus saved these capabilities and notes for future work on this project.`,"mission.noCapabilities":`No capabilities learned yet.`,"mission.replay":`Mission replay`,"mission.replayTimeline":`Replay mission timeline`,"mission.roleFailed":`{role} failed`,"mission.showingLatestEvent":`Showing latest event`,"mission.showingLastEvents":`Showing last {count} events`,"mission.waitingEvents":`Waiting for structured research events.`,"mission.startsAfter":`Starts after {count} earlier tasks`,"mission.hiddenTasks":`{count} earlier tasks hidden · {failed} blocked or failed · {skipped} skipped`,"mission.projectFilesChanged":`Project files changed`,"mission.reviewInIde":`Open the IDE to review the diff`,"research.currentWork":`Current work`,"research.dagProgress":`Task route progress`,"research.verifiedOutputs":`Verified outputs`,"research.recentMilestones":`Recent milestones`,"research.liveProgress":`Live progress`,"research.artifact":`Research result`,"research.canvas":`Manager live research canvas`,"research.previewArtifact":`Preview the result`,"research.openLarge":`Open large preview`,"research.collapse":`Collapse preview`,"research.unavailable":`Manager live view is temporarily unavailable.`,"research.noPreview":`No preview`,"research.waiting":`Waiting…`,"research.updating":`Updating…`,"research.fileUnavailable":`Preview unavailable for this file.`,"research.eventSourced":`event-sourced mission state`,"research.downloadFailed":`download failed`,"operations.title":`Operations`,"operations.work":`Work`,"operations.runtime":`Runtime`,"operations.system":`System`,"operations.recovery":`Recovery`,"operations.workInput":`Work input`,"operations.workHint":`Queue work, guide the active task, save a note, or preview a plan without dispatching it.`,"operations.action.task":`Task`,"operations.action.nudge":`Guide`,"operations.action.note":`Note`,"operations.action.plan":`Plan`,"operations.planPlaceholder":`Objective to preview; preview never queues work`,"operations.actionPlaceholder":`{action} text`,"operations.previewPlan":`Preview plan`,"operations.submitAction":`Submit {action}`,"operations.runtimeHint":`Change where this session runs, reset Manager context, or safely restart the session.`,"operations.workdir":`Working directory`,"operations.workdirUpdated":`Working directory updated.`,"operations.applyWorkdir":`Apply working directory`,"operations.replaceSlot":`Replace an active session`,"operations.sourceUpdate":`Argus source version`,"operations.pullLatest":`Pull latest version`,"operations.updateChecking":`Checking published branch…`,"operations.updateRunning":`Updating…`,"operations.updateAvailable":`Update available`,"operations.updateCurrent":`Up to date`,"operations.updateUnavailable":`This checkout cannot be updated safely.`,"operations.currentRevision":`Current`,"operations.latestRevision":`Latest`,"operations.updatePhase":`Phase`,"operations.updateRestart":`Source updated. Restart the cockpit, then use the reload button to move active daemons to the new release at a safe task boundary.`,"operations.skills":`Skills`,"operations.runSkill":`Run skill command`,"operations.metrics":`System metrics`,"operations.trash":`Recoverable trash`,"operations.searchTrash":`Search trash`,"operations.trashEmpty":`Trash is empty.`,"resource.title":`Resources`,"resource.loading":`Loading resource status…`,"resource.devices":`Devices: {count}`,"resource.inUse":`In use · {count}`,"resource.queue":`Queue · {count}`,"resource.none":`None`,"resource.timeLeft":`{ttl} left`,"resource.noIntent":`No purpose recorded`,"resource.yieldRequest":`Resource release requested · {reason}`,"resource.queuePosition":`Queue position {position}`,"label.status.inProgress":`In progress`,"label.status.waiting":`Waiting`,"label.status.completed":`Completed`,"label.status.blocked":`Blocked`,"label.status.failed":`Failed`,"label.status.needsChanges":`Needs changes`,"label.status.skipped":`Skipped`,"label.status.paused":`Paused`,"label.status.available":`Available`,"label.status.unavailable":`Unavailable`,"label.status.inaccessible":`Not accessible`,"label.status.limited":`Limited`,"label.status.healthy":`Healthy`,"label.status.updated":`Status updated`,"label.role.manager":`Manager`,"label.role.planner":`Planner`,"label.role.engineer":`Engineer`,"label.role.reviewer":`Reviewer`,"label.role.argus":`Argus`,"label.role.you":`You`,"label.work.task":`Task`,"label.work.action":`Work step`,"label.work.handoff":`Notes for the next step`,"label.work.review":`Review`,"label.work.planning":`Planning`,"label.work.update":`Update`,"label.stage.scope":`Scope`,"label.stage.research":`Research`,"label.stage.implementation":`Implementation`,"label.stage.experiment":`Experiments`,"label.stage.analysis":`Analysis`,"label.stage.writing":`Writing`,"label.stage.review":`Final review`,"label.stage.delivery":`Delivery`,"label.stage.unstaged":`Unstaged`,"label.frontier.reopened":`An earlier task was reopened`,"label.frontier.added":`A new task was added`,"label.frontier.completed":`A task path was completed`,"label.frontier.revised":`The task plan was revised`,"label.frontier.narrowed":`The task scope was narrowed`,"label.frontier.expanded":`The task scope was expanded`,"label.frontier.updated":`The task plan was updated`,"label.priority":`Priority {priority}`,"label.outcome.workCompleted":`Work completed`,"label.outcome.workPaused":`Work paused`,"label.outcome.workBlocked":`Work blocked`,"label.outcome.workFailed":`Work failed`,"label.outcome.workEnded":`Work ended`,"label.outcome.workIncomplete":`Work incomplete`,"label.outcome.workStalled":`Work stalled`,"label.outcome.workUpdated":`Work status updated`,"label.outcome.reviewPassed":`Review passed`,"label.outcome.reviewNeedsChanges":`Review requested changes`,"label.outcome.reviewBlocked":`Review blocked`,"label.outcome.reviewOutdated":`Review is out of date`,"label.outcome.reviewPending":`Review pending`,"label.outcome.stageApproved":`Stage approved`,"label.outcome.stageNotApproved":`Stage not approved`,"label.outcome.stageRevoked":`Stage approval revoked`,"label.outcome.stageNotNeeded":`Stage decision not needed`,"label.outcome.stagePending":`Stage decision pending`,"label.outcome.budgetPaused":`Paused by budget limit`,"label.outcome.waitingForYou":`Waiting for your response`,"label.outcome.stoppedByYou":`Stopped by you`,"label.outcome.pausedByYou":`Paused by you`,"label.outcome.sessionPaused":`Session paused`,"label.outcome.serviceUnavailable":`Service unavailable`,"label.outcome.serviceCoolingDown":`Service temporarily paused`,"label.outcome.temporaryIssue":`Paused by a temporary issue`,"label.outcome.serviceError":`Stopped by a service error`,"label.outcome.needsPlan":`A new plan is needed`,"label.outcome.canResume":`Can resume`,"label.routing.team":`Team workflow`,"label.routing.individual":`Individual workflow`,"label.routing.research":`Research`,"label.routing.software":`Software work`,"label.routing.staged":`Step by step`,"label.routing.flexible":`Flexible workflow`,"label.routing.ongoing":`Ongoing`,"label.routing.defined":`Defined scope`,"label.resource.nvidiaGpu":`NVIDIA GPU`,"label.resource.amdGpu":`AMD GPU`,"label.resource.appleGpu":`Apple GPU`,"label.resource.cpu":`CPU`,"label.resource.accelerator":`Accelerator`,"label.resource.enforced":`Limits enforced`,"label.resource.advisory":`Recommendations only`,"label.resource.released":`Resources released`,"label.resource.kept":`Resources kept`},Wr={"language.english":`English`,"handshake.connecting":`正在准备 Argus`,"handshake.service":`服务`,"handshake.project":`项目`,"handshake.ready":`就绪`,"handshake.title":`正在准备 Argus`,"handshake.detail":`正在恢复你的工作区…`,"splash.starting":`Argus 启动中`,"rail.workbench":`工作台`,"rail.sessionsShortcut":`会话 · Ctrl/⌘ P`,"panel.backlog":`待办`,"panel.activity":`动态`,"panel.journal":`日志`,"panel.roles":`角色`,"panel.project":`项目`,"panel.liveView":`Manager 实时项目视图`,"stream.jumpToLatest":`跳到最新`,"stream.toggleReasoning":`显示或隐藏 Agent 推理(⌘T)`,"stream.reasoning":`推理`,"stream.noLogs":`暂无活动`,"stream.system":`Argus 动态`,"stream.autonomous":`后台活动`,"stream.backgroundWork":`Argus 正在后台工作`,"stream.ready":`Argus 已就绪。你可以提问或安排下一项工作。`,"newDaemon.workdirPlaceholder":`留空 → ~/.argus-skill/workspaces/`,"operations.resetManager":`重置 Manager 上下文`,"language.chinese":`中文`,"language.switchTo":`切换到{language}`,"common.loading":`加载中…`,"common.retry":`重试`,"common.save":`保存`,"common.cancel":`取消`,"common.close":`关闭`,"common.settings":`设置`,"common.ready":`就绪`,"common.live":`实时`,"common.reconnecting":`正在重连`,"common.stale":`快照已过期`,"common.degraded":`快照异常`,"common.external":`外部`,"common.pause":`暂停`,"common.run":`运行`,"common.local":`本地`,"common.all":`全部`,"common.unassigned":`未分配`,"common.closeSessions":`关闭会话列表`,"common.resizeSessions":`调整会话列表宽度`,"common.resizePreview":`调整预览区域宽度`,"common.expandPreview":`展开预览`,"time.justNow":`刚刚`,"time.minutesAgo":`{count}分钟前`,"time.hoursAgo":`{count}小时前`,"time.yesterdayAt":`昨天 {time}`,"connection.pairingTitle":`此浏览器尚未与 Argus 配对`,"connection.pairingDetail":`请关闭此标签页,然后从 Argus Desktop 重新打开工作台,或使用新的配对链接。`,"connection.pairAgain":`重新配对`,"connection.pairingInput":`配对链接或令牌`,"connection.pairingPlaceholder":`粘贴新的配对链接或令牌`,"connection.pairingInvalid":`请输入有效的配对链接或令牌。`,"connection.connect":`连接`,"connection.unreachableTitle":`Argus 本地服务当前不可达`,"connection.unreachableDetail":`请保持 Argus Desktop 运行,等待本地服务就绪后再重试。`,"sidebar.collapse":`收起会话`,"sidebar.expand":`展开会话`,"sidebar.create":`创建会话`,"sidebar.find":`查找会话`,"sidebar.clearSearch":`清除搜索`,"sidebar.refreshFailed":`刷新失败 · 重试`,"sidebar.noSessions":`暂无会话`,"sidebar.noMatches":`没有匹配"{query}"的会话`,"sidebar.unnamedSession":`未命名会话`,"sidebar.daemonAlive":`Argus 运行中`,"sidebar.updateRequired":`需要更新`,"sidebar.updateAvailable":`可更新`,"sidebar.updateAvailableHint":`后台仍在运行,执行器与网页版本不同。`,"sidebar.stopped":`已停止`,"sidebar.runningFor":`运行中 · {uptime}`,"sidebar.manage":`管理 {name}`,"sidebar.manageHint":`重命名、暂停或删除`,"sidebar.resume":`继续`,"sidebar.resumeHint":`在 {workdir} 中继续工作`,"sidebar.resumeSuccess":`会话已恢复。`,"sidebar.resumeFailed":`无法恢复会话:{error}`,"sidebar.modelLoading":`正在加载后端和模型…`,"sidebar.modelUnavailable":`后端和模型信息不可用`,"sidebar.defaultModel":`默认模型`,"sidebar.openSettings":`打开设置`,"sidebar.theme":`{current}主题;切换到{next}主题`,"landing.selectOrCreate":`从侧边栏选择一个会话,或创建新会话。`,"landing.noSessions":`还没有会话。创建一个即可开始。`,"landing.select":`选择会话`,"landing.new":`新建会话`,"topbar.openSessions":`打开会话列表`,"topbar.externallyManaged":`由外部管理`,"topbar.pauseDaemon":`暂停 Argus`,"topbar.runDaemon":`运行 Argus`,"topbar.roleActive":`{role} 活跃中`,"topbar.roleIdle":`{role} 空闲`,"topbar.externalDaemonHint":`Argus 由此应用之外的服务管理,请前往相应位置控制。`,"topbar.manageSession":`管理会话`,"topbar.showPreview":`显示预览`,"topbar.showActivity":`显示动态`,"mobile.views":`视图`,"mobile.sessions":`会话`,"mobile.mission":`任务`,"mobile.activity":`动态`,"mobile.workbench":`工作台`,"mobile.map":`地图`,"mobile.preview":`预览`,"chat.working":`Argus 正在处理你的消息`,"chat.workingQuiet":`Argus 正在处理你的消息 · 仍在处理中,{quiet} 秒暂无新进展`,"chat.stopWaitingHint":`按 Esc 停止等待`,"chat.messageArgus":`向 Argus 发送消息`,"chat.selectSession":`请选择会话…`,"chat.placeholder":`提问或安排工作`,"chat.routeLabel":`消息类型`,"chat.routeHint":`任务模式跳过消息分类,但仍严格经过 Manager → Planner → Engineer → Reviewer`,"chat.routeTask":`任务`,"chat.routeAuto":`自动`,"chat.routeChat":`对话`,"chat.attach":`添加文件`,"chat.attachHint":`支持 PNG、JPEG、WebP、PDF、Markdown/文本、JSON、CSV · 每条消息最多 {count} 个文件,单个 {perFile},总计 {total}`,"chat.attachDrop":`拖放文件以添加附件`,"chat.attachRemove":`移除附件 {name}`,"chat.attachUnsupported":`{name} 不受支持。请使用 PNG、JPEG、WebP、PDF、Markdown/文本、JSON 或 CSV。`,"chat.attachTooLarge":`{name} 超过单文件大小限制 {size}。`,"chat.attachTooMany":`每条消息最多只能附带 {count} 个文件。`,"chat.attachTotalTooLarge":`附件总大小超过 {size} 限制。`,"chat.attachmentUploadFailed":`附件上传失败:{error}`,"chat.uploadingAttachments":`正在上传附件`,"chat.rewriteHint":`让 Manager 将提示词改写为团队可执行的任务说明。不会直接发送,改写结果会回到输入框供你编辑。`,"chat.rewriteLabel":`使用 Manager 改写提示词`,"chat.rewriting":`正在改写`,"chat.rewrite":`✦ 改写`,"chat.stopWaiting":`停止等待`,"chat.stopWaitingTitle":`停止等待此回复;服务端工作可能仍会继续`,"chat.send":`发送消息`,"copy.message":`复制`,"copy.code":`复制代码`,"copy.copied":`已复制`,"help.title":`键盘快捷键`,"help.commands":`命令`,"help.palette":`打开命令面板`,"help.sessions":`展开或收起会话`,"help.managerChat":`聚焦 Manager 对话框`,"help.rewrite":`发送前改写当前提示词`,"help.reasoning":`显示或隐藏 Agent 推理`,"help.kiosk":`切换只读展示模式`,"help.composer":`聚焦输入框`,"help.send":`发送消息`,"help.newline":`插入换行`,"help.thisHelp":`打开此帮助`,"help.escape":`关闭浮层或停止等待`,"palette.placeholder":`输入命令或搜索…`,"palette.noMatches":`没有匹配的命令`,"palette.navigate":`↑↓ 导航`,"palette.run":`↵ 执行`,"palette.close":`Esc 关闭`,"palette.view":`视图`,"palette.action":`操作`,"palette.project":`项目`,"palette.newDaemon":`新建会话`,"palette.openTranscript":`打开对话记录`,"palette.openProject":`打开项目`,"palette.projectHint":`工作 · 记忆 · Agent`,"palette.openOperations":`打开运行控制`,"palette.operationsHint":`会话控制`,"palette.hideReasoning":`隐藏推理`,"palette.showReasoning":`显示推理`,"palette.exitKiosk":`退出展示模式`,"palette.enterKiosk":`进入展示模式`,"palette.messageArgus":`向 Argus 发送消息…`,"palette.stopWaiting":`停止等待 Manager 回复`,"palette.stopContinuous":`停止持续任务`,"palette.startContinuous":`启动持续任务`,"palette.stopDaemon":`暂停 Argus`,"palette.startDaemon":`运行 Argus`,"slash.suggestions":`Slash 命令建议`,"mission.roleActive":`{role} 正在工作`,"mission.overview":`任务概览`,"mission.operations":`运行控制`,"role.manager":`Manager`,"role.planner":`Planner`,"role.engineer":`Engineer`,"role.reviewer":`Reviewer`,"role.critic":`Critic`,"role.system":`Argus`,"role.operator":`你`,"doctor.title":`诊断`,"doctor.subtitle":`Argus 状态检查与推荐的根因修复方案`,"doctor.recommended":`推荐修复`,"doctor.loadError":`无法加载诊断数据。`,"doctor.empty":`诊断暂无数据`,"doctor.daemonLog":`后台进程日志`,"settings.subtitle":`生效中的角色、预算和关键控制项`,"settings.loadError":`无法加载配置。`,"settings.empty":`未找到配置`,"settings.quickConfig":`快速配置`,"settings.appearance":`外观`,"settings.appearanceHint":`选择界面主题色。Logo 与图标始终保持黑白,不参与渐变。`,"settings.themeStyle":`主题色`,"settings.themeStyle.standard":`标准`,"settings.themeStyle.standardHint":`克制的黑、白、灰与蓝色。`,"settings.themeStyle.gradient":`渐变`,"settings.themeStyle.gradientHint":`经典 Argus 蓝金渐变背景。`,"settings.backend":`后端`,"settings.backendLabel.copilot":`GitHub Copilot`,"settings.backendLabel.codex":`Codex`,"settings.backendLabel.claude":`Claude`,"settings.backendLabel.cursor":`Cursor`,"settings.backendLabel.opencode":`OpenCode`,"settings.backendLabel.pi":`Pi`,"settings.backendLabel.grok":`Grok`,"settings.backendLabel.qoder":`Qoder`,"settings.backendLabel.dsh":`DSH`,"settings.backendSwitched":`后端已保存为{backend}。重启 Argus 后生效。`,"settings.backendUnsupported":`不支持的后端({backend})`,"settings.backendUnavailable":`后端信息不可用`,"settings.model":`模型`,"settings.applyModel":`应用`,"settings.modelPlaceholder":`auto(后端默认模型)`,"settings.connection":`连接`,"settings.webApi":`Web + REST API`,"settings.eventStream":`实时动态`,"settings.taskDaemon":`后台工作`,"settings.taskDaemonValue":`本地进程 · events.jsonl · 无 TCP 端口`,"settings.budgetTitle":`预算和配额限制`,"settings.budgetHint":`支持时,将调用限制设为 0 表示不设上限。`,"settings.saveBudgets":`保存预算限制`,"settings.budget.global":`主机全局每日预算`,"settings.budget.codex":`Codex 每日调用`,"settings.budget.copilot":`Copilot 每日调用`,"settings.budget.premium":`Copilot 每日 Premium 请求`,"settings.required":`必须填写{field}`,"settings.budgetSaved":`预算限制已保存。请重启活动会话以应用限制。`,"settings.unit.usd":`美元`,"settings.unit.calls":`次调用`,"settings.unit.requests":`次请求`,"settings.advanced":`高级设置`,"settings.advancedHint":`连接详情、环境变量覆盖和生效中的原始配置`,"settings.overrideTitle":`环境变量覆盖`,"settings.overrideHint":`设置特定的配置别名或环境变量键。`,"settings.namePlaceholder":`名称或别名,例如 manager_model`,"settings.valuePlaceholder":`值`,"settings.applyAdvanced":`应用环境变量覆盖`,"settings.applied":`设置已应用。请重启受影响的会话以使用新设置。`,"settings.rolesTitle":`生效中的角色`,"settings.rawConfig":`原始配置`,"settings.group.limits":`限制`,"settings.group.safety":`安全`,"settings.group.interface":`界面`,"settings.knob.activeDaemons":`活动会话上限`,"settings.knob.activeDaemonsDoc":`此主机上可同时运行的后台会话数量上限。`,"settings.knob.unpricedCalls":`未定价调用`,"settings.knob.unpricedCallsDoc":`未能确定价格的调用是阻止还是允许。`,"settings.knob.safeMode":`安全模式`,"settings.knob.safeModeDoc":`启用更保守的运行时保护措施。`,"settings.knob.telegram":`Telegram`,"settings.knob.telegramDoc":`启用 Telegram 通知桥接。`,"settings.knob.showReasoning":`显示推理`,"settings.knob.showReasoningDoc":`在活动视图中显示角色推理过程。`,"settings.source.notApplicable":`不适用于此模型`,"settings.source.vaultDefault":`能力库 / 默认值`,"settings.source.default":`默认值`,"settings.source.saved":`已保存的覆盖值`,"settings.source.environment":`环境变量`,"settings.source.hostConfig":`主机配置`,"settings.source.other":`解析后的配置`,"settings.value.block":`阻止调用`,"settings.value.allow":`允许调用`,"settings.value.enabled":`已启用`,"settings.value.disabled":`已停用`,"settings.effort.low":`低推理强度`,"settings.effort.medium":`中等推理强度`,"settings.effort.high":`高推理强度`,"settings.effort.xhigh":`超高推理强度`,"settings.role.curator":`知识维护`,"settings.role.managerDoc":`分流对话和任务,并批准可复用技能。`,"settings.role.plannerDoc":`安排后续工作,并判断项目何时可以收尾。`,"settings.role.engineerDoc":`编写代码并运行命令。`,"settings.role.reviewerDoc":`审读已完成的工作,判断其是否成立。`,"settings.role.curatorDoc":`维护并提炼可复用技能库。`,"settings.footer":`配置项同时显示易读标签和原始键。完整配置仍可通过以下命令查看:`,"identity.title":`身份`,"identity.subtitle":`本项目中 Argus 服务的对象`,"identity.placeholder":`描述 Argus 正在为谁工作,以及需要长期遵循的偏好…`,"identity.save":`保存身份`,"identity.saved":`身份已保存。`,"transcript.title":`对话记录`,"transcript.subtitle":`近期操作者 ↔ Argus 对话 · 请从输入框继续回复`,"transcript.empty":`暂无对话记录`,"transcript.operator":`操作者`,"new.createDaemon":`创建会话`,"new.subtitle":`创建隔离的时间线和 Manager 上下文。`,"new.close":`关闭创建会话窗口`,"new.name":`名称`,"new.optional":`(可选)`,"new.namePlaceholder":`例如:AAAI 具身智能论文`,"new.workdir":`输出工作目录`,"new.workdirHint":`Agent 会在这里写入代码、论文、报告和实验结果。内部记忆仍保存在会话状态目录中。`,"new.objective":`目标`,"new.objectivePlaceholder":`留空则从对话开始,也可以填写一个立即启动的持续任务。`,"new.startsAfterCreate":`创建会话后立即启动任务`,"new.idleUntilMessage":`收到第一条消息前保持空闲`,"new.startsHint":`会话会立即打开,Argus 将在后台准备相关工作。`,"new.idleHint":`收到第一条消息后,Argus 会按需启动后台工作。`,"new.shortcut":`按 Ctrl/⌘+Enter 创建`,"new.creating":`正在创建…`,"new.createAndStart":`创建并启动`,"manage.daemon":`管理会话`,"manage.displayName":`显示名称`,"manage.executor":`后台工作`,"manage.running":`运行中`,"manage.runningExternally":`由外部运行`,"manage.paused":`未运行`,"manage.pauseHint":`中断当前操作并保留可恢复的进度。`,"manage.stopNow":`立即停止`,"manage.stopNowHint":`立即中断这个已验证的 daemon,停止后即可删除会话。`,"manage.externalHint":`此会话由此应用之外的服务管理。`,"manage.resumeHint":`继续执行队列中的研究工作。`,"manage.working":`处理中…`,"manage.resume":`继续`,"manage.deleteSession":`删除会话`,"manage.deleteHint":`删除的会话会移入回收站,之后仍可恢复。请先停止后台工作。`,"manage.delete":`删除…`,"manage.confirmQuestion":`将此会话移入回收站?`,"manage.confirmDelete":`确认删除`,"decision.operator":`操作者决策`,"decision.required":`需要你的决策`,"decision.whyBlocked":`工作被阻塞的原因`,"decision.evidence":`证据`,"decision.notePlaceholder":`添加 Manager 应采用的指导…`,"decision.resumeHint":`Manager 会在恢复工作前应用你的选择。`,"decision.later":`稍后处理`,"decision.applying":`正在应用…`,"decision.stopCampaign":`停止持续任务`,"decision.useOption":`使用此选项`,"decision.sendAnswer":`发送回答`,"decision.noteRequired":`这个选项需要补充说明后才能提交。`,"artifact.preview":`结果预览`,"artifact.title":`结果`,"artifact.approvedEvidence":`Reviewer 已核实的证据`,"artifact.downloading":`正在下载…`,"artifact.download":`下载`,"artifact.open":`打开`,"artifact.close":`关闭结果预览`,"artifact.unavailable":`无法预览`,"artifact.empty":`(空文件)`,"artifact.truncated":`预览已截断 · 请下载完整文件查看`,"artifact.htmlTooLarge":`HTML 文件过大,无法安全预览。请下载完整文件。`,"artifact.pdfDisabled":`此浏览器已禁用内嵌 PDF 预览。`,"artifact.openPdf":`打开 PDF`,"artifact.noPreview":`此文件类型无法安全地在线预览。`,"artifact.downloadHint":`请下载后使用本地应用查看。`,"task.details":`任务详情`,"task.stopLoop":`停止循环`,"task.done":`完成`,"task.skip":`跳过`,"task.close":`关闭任务详情`,"task.waitingOnYou":`等待你的回复`,"task.objective":`目标`,"task.noObjective":`(未记录目标)`,"task.untitled":`未命名任务`,"task.priority":`优先级`,"task.started":`开始时间`,"task.finished":`完成时间`,"task.outcome":`结果`,"task.iteration":`迭代`,"task.mode":`模式`,"task.autoIterate":`自动迭代`,"task.singlePass":`单次执行`,"task.cycles":`轮次`,"task.cost":`成本`,"task.lastError":`最近错误`,"task.notes":`备注`,"task.dependsOn":`依赖`,"task.dependsOnCount":`依赖前置任务 {count} 项`,"pending.reviewRespond":`查看并回复`,"pending.showOnMap":`在地图上查看`,"backlog.active":`进行中 · {count}`,"backlog.history":`历史记录 · {count}`,"backlog.noHistory":`暂无已完成工作`,"backlog.empty":`队列中没有工作。Argus 已准备好接收新任务。`,"backlog.viewDetails":`查看完整任务详情`,"backlog.iterating":`重复执行中`,"backlog.stopIterating":`停止重复执行`,"backlog.stop":`停止`,"backlog.markDone":`标记为完成`,"backlog.remove":`移除`,"mission.achievement":`Argus 成果`,"mission.elapsed":`耗时`,"mission.rejectedAttempts":`{count} 次方案被拒绝`,"mission.skillsLearned":`学习了 {count} 个 Skill`,"mission.artifacts":`产出 {count} 个文件`,"mission.waiting":`等待任务`,"mission.statusActive":`{role} — {work}`,"mission.statusWaiting":`已准备就绪,请分配一个任务开始工作。`,"mission.statusDone":`{outcome} — 用时 {elapsed}。`,"mission.continuousDone":`连续运行已完成`,"mission.resumeContinuous":`恢复`,"mission.control":`任务控制`,"mission.attentionHealth":`系统出错——运行状态异常。`,"mission.attentionFailed":`任务失败——请查看下方详情。`,"mission.deliveryFailed":`任务在交付阶段失败——执行未能启动或完成。`,"mission.attentionStepFailed":`有一个步骤失败——请查看下方任务。`,"mission.attentionPaused":`任务已暂停——正在等待你的输入。`,"mission.showObjective":`显示完整目标`,"mission.showFullOutput":`查看完整输出`,"mission.stage":`阶段`,"mission.campaign":`持续任务`,"mission.totalElapsed":`总耗时`,"mission.round":`轮次`,"mission.mode":`模式`,"mission.summary":`本次完成`,"mission.deliveryCertified":`交付成果已通过审核`,"mission.taskCompleted":`任务已完成`,"mission.openResult":`打开成果`,"mission.viewTask":`查看任务`,"mission.taskPlan":`任务计划`,"mission.team":`AI 研究团队`,"mission.waitingShort":`等待中`,"mission.roleWork":`角色工作`,"mission.showMore":`显示更多`,"mission.showLess":`收起`,"mission.done":`已完成`,"mission.inProgress":`进行中`,"mission.failed":`失败`,"mission.bannerPaused":`任务已暂停 — 等待你的操作。`,"mission.bannerError":`系统异常 — 健康状态已降级。`,"mission.bannerStepFailed":`某步骤失败:{step}`,"mission.elapsedAgo":`{elapsed} 前`,"mission.filteredBy":`按 {task} 筛选 · 清除`,"mission.allVisible":`全部可见任务`,"mission.roundNumber":`第 {count} 轮`,"mission.noRoleWork":`当前筛选下还没有持久化的 {role} 工作记录。`,"mission.researchDag":`任务路线`,"mission.active":`进行中`,"mission.noDag":`Planner 尚未向路线中添加任务。`,"mission.workingHypothesis":`当前假设 · 可随证据调整`,"mission.goalContribution":`对目标的作用`,"mission.temporaryRegressions":`预期的暂时取舍`,"mission.decisionRule":`何时调整、拆分或停止`,"mission.acceptance":`完成的标准`,"mission.nonGoals":`非目标`,"mission.capabilities":`能力`,"mission.capabilitiesUnlocked":`已解锁能力`,"mission.learnedCapability":`已学习能力`,"mission.learnedDuring":`在“{mission}”期间学习`,"mission.skillUnavailable":`当前快照中没有此 Skill 的内容。`,"mission.contentTruncated":`内容预览已截断`,"mission.knowledgeRetained":`已保留知识`,"mission.selfEvolution":`已保存的项目知识`,"mission.knowledgeSaved":`Argus 已保存这些能力和笔记,供本项目后续工作使用。`,"mission.noCapabilities":`尚未学习新能力。`,"mission.replay":`任务回放`,"mission.replayTimeline":`回放任务时间线`,"mission.roleFailed":`{role} 执行失败`,"mission.showingLatestEvent":`显示最近一条事件`,"mission.showingLastEvents":`显示最近 {count} 条事件`,"mission.waitingEvents":`等待结构化研究事件。`,"mission.startsAfter":`需等待前置任务 {count} 项`,"mission.hiddenTasks":`已隐藏前序任务 {count} 项 · 阻塞或失败 {failed} 项 · 已跳过 {skipped} 项`,"mission.projectFilesChanged":`项目文件有变更`,"mission.reviewInIde":`可打开 IDE 查看差异`,"research.currentWork":`当前工作`,"research.dagProgress":`任务路线进度`,"research.verifiedOutputs":`已验证输出`,"research.recentMilestones":`近期里程碑`,"research.liveProgress":`实时进度`,"research.artifact":`研究成果`,"research.canvas":`Manager 实时研究面板`,"research.previewArtifact":`预览成果`,"research.openLarge":`打开大尺寸预览`,"research.collapse":`收起预览`,"research.unavailable":`Manager 实时视图暂时不可用。`,"research.noPreview":`暂无预览`,"research.waiting":`等待中…`,"research.updating":`正在更新…`,"research.fileUnavailable":`此文件无法预览。`,"research.eventSourced":`基于事件的任务状态`,"research.downloadFailed":`下载失败`,"operations.title":`运行控制`,"operations.work":`工作`,"operations.runtime":`运行时`,"operations.system":`系统`,"operations.recovery":`恢复`,"operations.workInput":`工作输入`,"operations.workHint":`加入工作、指导当前任务、保存备注,或仅预览计划而不分派。`,"operations.action.task":`任务`,"operations.action.nudge":`指导`,"operations.action.note":`备注`,"operations.action.plan":`计划`,"operations.planPlaceholder":`要预览的目标;预览不会加入任务队列`,"operations.actionPlaceholder":`输入 {action} 内容`,"operations.previewPlan":`预览计划`,"operations.submitAction":`提交 {action}`,"operations.runtimeHint":`更改会话运行位置、重置 Manager 上下文,或安全重启会话。`,"operations.workdir":`工作目录`,"operations.workdirUpdated":`工作目录已更新。`,"operations.applyWorkdir":`应用工作目录`,"operations.replaceSlot":`替换活动会话`,"operations.sourceUpdate":`Argus 源码版本`,"operations.pullLatest":`拉取最新版本`,"operations.updateChecking":`正在检查已发布分支…`,"operations.updateRunning":`正在更新…`,"operations.updateAvailable":`有可用更新`,"operations.updateCurrent":`已是最新`,"operations.updateUnavailable":`当前工作树无法安全更新。`,"operations.currentRevision":`当前`,"operations.latestRevision":`最新`,"operations.updatePhase":`阶段`,"operations.updateRestart":`源码已更新。请重启工作台,再使用重载按钮让活动 daemon 在安全任务边界切换到新版本。`,"operations.skills":`Skills`,"operations.runSkill":`运行 Skill 命令`,"operations.metrics":`系统指标`,"operations.trash":`可恢复的回收站`,"operations.searchTrash":`搜索回收站`,"operations.trashEmpty":`回收站为空。`,"resource.title":`资源`,"resource.loading":`正在加载资源状态…`,"resource.devices":`设备:{count}`,"resource.inUse":`使用中 · {count}`,"resource.queue":`等待队列 · {count}`,"resource.none":`无`,"resource.timeLeft":`剩余 {ttl}`,"resource.noIntent":`未记录用途`,"resource.yieldRequest":`收到释放资源请求 · {reason}`,"resource.queuePosition":`队列第 {position} 位`,"label.status.inProgress":`进行中`,"label.status.waiting":`等待中`,"label.status.completed":`已完成`,"label.status.blocked":`已阻塞`,"label.status.failed":`失败`,"label.status.needsChanges":`需要修改`,"label.status.skipped":`已跳过`,"label.status.paused":`已暂停`,"label.status.available":`可用`,"label.status.unavailable":`不可用`,"label.status.inaccessible":`无法访问`,"label.status.limited":`部分受限`,"label.status.healthy":`状态正常`,"label.status.updated":`状态已更新`,"label.role.manager":`Manager`,"label.role.planner":`Planner`,"label.role.engineer":`Engineer`,"label.role.reviewer":`Reviewer`,"label.role.argus":`Argus`,"label.role.you":`你`,"label.work.task":`任务`,"label.work.action":`工作步骤`,"label.work.handoff":`给下一步的说明`,"label.work.review":`审核`,"label.work.planning":`规划`,"label.work.update":`动态`,"label.stage.scope":`范围定义`,"label.stage.research":`研究`,"label.stage.implementation":`方法实现`,"label.stage.experiment":`实验验证`,"label.stage.analysis":`结果分析`,"label.stage.writing":`论文写作`,"label.stage.review":`最终审核`,"label.stage.delivery":`成果交付`,"label.stage.unstaged":`未分阶段`,"label.frontier.reopened":`已重新开启一项前序任务`,"label.frontier.added":`已添加一项新任务`,"label.frontier.completed":`已完成一条任务路径`,"label.frontier.revised":`已调整任务计划`,"label.frontier.narrowed":`已缩小任务范围`,"label.frontier.expanded":`已扩大任务范围`,"label.frontier.updated":`任务计划已更新`,"label.priority":`优先级 {priority}`,"label.outcome.workCompleted":`工作已完成`,"label.outcome.workPaused":`工作已暂停`,"label.outcome.workBlocked":`工作被阻塞`,"label.outcome.workFailed":`工作失败`,"label.outcome.workEnded":`工作已结束`,"label.outcome.workIncomplete":`工作尚未完成`,"label.outcome.workStalled":`工作停滞`,"label.outcome.workUpdated":`工作状态已更新`,"label.outcome.reviewPassed":`审核通过`,"label.outcome.reviewNeedsChanges":`审核要求修改`,"label.outcome.reviewBlocked":`审核被阻塞`,"label.outcome.reviewOutdated":`审核结果已过期`,"label.outcome.reviewPending":`等待审核`,"label.outcome.stageApproved":`阶段已通过`,"label.outcome.stageNotApproved":`阶段未通过`,"label.outcome.stageRevoked":`阶段批准已撤回`,"label.outcome.stageNotNeeded":`无需阶段审核`,"label.outcome.stagePending":`阶段审核待定`,"label.outcome.budgetPaused":`因预算上限暂停`,"label.outcome.waitingForYou":`正在等待你的回复`,"label.outcome.stoppedByYou":`已由你停止`,"label.outcome.pausedByYou":`已由你暂停`,"label.outcome.sessionPaused":`会话已暂停`,"label.outcome.serviceUnavailable":`服务暂不可用`,"label.outcome.serviceCoolingDown":`服务暂时暂停`,"label.outcome.temporaryIssue":`因临时问题暂停`,"label.outcome.serviceError":`因服务错误停止`,"label.outcome.needsPlan":`需要制定新计划`,"label.outcome.canResume":`可以继续`,"label.routing.team":`团队协作`,"label.routing.individual":`单独执行`,"label.routing.research":`研究任务`,"label.routing.software":`软件工作`,"label.routing.staged":`分步执行`,"label.routing.flexible":`灵活流程`,"label.routing.ongoing":`持续进行`,"label.routing.defined":`范围明确`,"label.resource.nvidiaGpu":`NVIDIA GPU`,"label.resource.amdGpu":`AMD GPU`,"label.resource.appleGpu":`Apple GPU`,"label.resource.cpu":`CPU`,"label.resource.accelerator":`加速设备`,"label.resource.enforced":`强制执行限制`,"label.resource.advisory":`仅提供建议`,"label.resource.released":`已释放资源`,"label.resource.kept":`继续占用资源`};function Gr(){try{let e=localStorage.getItem(Hr);if(e===`en`||e===`zh-CN`)return e}catch{}return navigator.language.toLowerCase().startsWith(`zh`)?`zh-CN`:`en`}function Kr(e,t={},n=Gr()){return((n===`zh-CN`?Wr[e]:Ur[e])??e).replace(/\{(\w+)\}/g,(e,n)=>String(t[n]??`{${n}}`))}var qr=(0,I.createContext)({locale:`en`,setLocale:()=>void 0,t:(e,t)=>Kr(e,t,`en`)});function Jr({children:e}){let[t,n]=(0,I.useState)(Gr),r=e=>{try{localStorage.setItem(Hr,e)}catch{}n(e)};(0,I.useEffect)(()=>{document.documentElement.lang=t},[t]);let i=(0,I.useMemo)(()=>({locale:t,setLocale:r,t:(e,n)=>Kr(e,n,t)}),[t]);return(0,X.jsx)(qr.Provider,{value:i,children:e})}function Z(){return(0,I.useContext)(qr)}var Yr=new Set([`running`,`in_progress`,`claimed`]);function Xr(e){return e.find(e=>e.active)??e.find(e=>e.role===`manager`)}function Zr({snap:e,streamOk:t,onStart:n,onStop:i,onManage:a,onOpenSessions:c,mobileView:l,onToggleMobileView:u,busy:d,snapshotStale:f=!1,readOnly:p=!1,missionView:m}){let{t:h}=Z(),g=Xr(e.roles),_=[`complete`,`completed`,`done`,`success`].includes(String(m?.mission.status||``).toLowerCase()),v=e.daemon.alive&&!_?m?.roles.find(e=>e.role===m.active_role):void 0,y=v?.role||g?.role||`manager`,b=e.daemon.alive&&(v?v.status===`active`:!!g?.active),x=e.backlog.find(e=>Yr.has(e.status)),S=v?.label||x?.title||x?.objective||(_?m?.mission.summary||m?.mission.title:``)||e.session.objective||h(`common.ready`),C=!!(e.partial||e.observability?.slo.status===`degraded`),w=e.daemon.alive&&e.daemon.control_available===!1,T=w?h(`topbar.externallyManaged`):e.daemon.alive?h(`topbar.pauseDaemon`):h(`topbar.runDaemon`),E=C?[...(e.diagnostics??[]).map(e=>`${e.section}: ${e.message}`),...e.observability?.slo.violations??[]].join(` +`)||h(`common.degraded`):h(f?`common.stale`:t?`common.live`:`common.reconnecting`);return(0,X.jsxs)(`header`,{className:`chrome-seam-surface glass-panel glass-panel--raised flex h-12 min-w-0 shrink-0 items-center gap-2 border-b px-3 sm:gap-3 sm:px-4`,children:[c?(0,X.jsx)(`button`,{type:`button`,onClick:c,"aria-label":h(`topbar.openSessions`),className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-md text-ink-faint hover:bg-bg hover:text-ink lg:hidden`,children:(0,X.jsx)(`svg`,{viewBox:`0 0 16 16`,"aria-hidden":`true`,className:`h-4 w-4`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.25`,children:(0,X.jsx)(`path`,{d:`M2.5 4h11M2.5 8h11M2.5 12h11`})})}):null,(0,X.jsx)(`div`,{className:`hidden min-w-0 max-w-28 truncate text-sm font-semibold text-ink sm:block`,children:e.session.display_name||e.session.id}),(0,X.jsx)(`span`,{className:`hidden h-4 w-px shrink-0 bg-line/40 sm:block`}),(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[(0,X.jsx)(`span`,{"data-role-dot":y,"aria-label":h(b?`topbar.roleActive`:`topbar.roleIdle`,{role:y}),className:`h-2 w-2 shrink-0 rounded-full ${b?`animate-pulse motion-reduce:animate-none`:``}`,style:{background:W.role[y]||`rgb(var(--ink-faint))`}}),(0,X.jsx)(`span`,{className:`hidden shrink-0 text-xs font-semibold capitalize text-ink-dim sm:inline`,children:y}),(0,X.jsx)(`span`,{className:`truncate text-xs text-ink-faint`,children:S})]}),(0,X.jsx)(`span`,{title:E,className:`h-2 w-2 shrink-0 rounded-full transition-shadow duration-150 ${C||f?`bg-err ring-1 ring-err/30 ring-offset-1 ring-offset-panel`:t?`bg-ok ring-1 ring-ok/30 ring-offset-1 ring-offset-panel`:`bg-ink-faint/50`}`,children:(0,X.jsx)(`span`,{className:`sr-only`,children:E})}),(0,X.jsx)(Vr,{settledUsd:e.spend_usd,knownUsd:e.usage_summary?.known_cost_usd,status:e.spend_status,calls:e.usage_summary?.call_count,premiumRequests:e.usage_summary?.premium_requests,live:e.daemon.alive,compact:!0}),u?(0,X.jsx)(`button`,{type:`button`,onClick:u,"aria-label":h(l===`activity`?`topbar.showPreview`:`topbar.showActivity`),title:h(l===`activity`?`topbar.showPreview`:`topbar.showActivity`),className:`icon-control flex h-8 w-8 shrink-0 items-center justify-center lg:hidden`,children:(0,X.jsx)(`svg`,{viewBox:`0 0 16 16`,"aria-hidden":`true`,className:`h-4 w-4`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.25`,children:l===`activity`?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`rect`,{x:`2`,y:`2.5`,width:`12`,height:`11`,rx:`1.5`}),(0,X.jsx)(`path`,{d:`M9.5 2.75v10.5`})]}):(0,X.jsx)(`path`,{d:`M3 4h10M3 8h10M3 12h7`})})}):null,p?null:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`button`,{type:`button`,disabled:d||w,onClick:e.daemon.alive?i:n,"aria-label":T,title:w?h(`topbar.externalDaemonHint`):T,className:`compact-control flex h-8 shrink-0 items-center gap-1 px-2 disabled:opacity-40`,children:[(0,X.jsx)(o,{icon:e.daemon.alive?s:r,className:`h-3 w-3`}),(0,X.jsx)(`span`,{className:`hidden sm:inline`,children:w?h(`common.external`):e.daemon.alive?h(`common.pause`):h(`common.run`)})]}),(0,X.jsx)(`button`,{type:`button`,"aria-label":h(`topbar.manageSession`),title:h(`topbar.manageSession`),onClick:a,className:`icon-control flex h-8 w-8 shrink-0 items-center justify-center text-sm tracking-widest`,children:`···`})]})]})}function Qr(e){let t=new Set;return[e.primary_target,...e.targets].filter(e=>!e?.path||t.has(e.path)?!1:(t.add(e.path),!0))}function $r(e,t){if(t===`research`)for(let t of e){let e=Qr(t).find(e=>/(?:^|\/)paper\/main\.pdf$/i.test(e.path.replace(/\\/g,`/`)));if(e)return{receipt:t,path:e.path}}let n=e[0];return n?{receipt:n,path:Qr(n)[0]?.path||null}:null}function ei(e){return e.replace(/\s*\bRESULT\s*=\s*/g,` + +`).replace(/\s*\b(?:STATUS|REVIEW_STATUS)\s*=\s*\S+/g,``).trim()}function ti(e,t,n){let r=n.reduce((e,t)=>t.type===`ui.operator`?Math.max(e,Number(t.ts)||0):e,0),i=t&&(e===void 0||t.delivered_at>r)?t:null;return e?i&&i.delivered_at>e.delivered_at?i:e:i}function ni(e,t){if(!t)return!1;let n=new Set([t]),r=[t];for(let t=0;te.id!==t&&n.has(e.id)&&[`pending`,`running`,`in_progress`,`claimed`].includes(e.status))}var ri=`modulepreload`,ii=function(e){return`/`+e},ai={},oi=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?import.meta.resolve(e):new URL(e,import.meta.url).href}r=o(t.map(t=>{if(t=ii(t,n),t=s(t),t in ai)return;ai[t]=!0;let r=t.endsWith(`.css`);for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}let i=document.createElement(`link`);if(i.rel=r?`stylesheet`:ri,r||(i.as=`script`),i.crossOrigin=``,i.href=t,a&&i.setAttribute(`nonce`,a),document.head.appendChild(i),r)return new Promise((e,n)=>{i.addEventListener(`load`,e),i.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},si={all:`(min-width: 0px)`,reduceMotion:`(prefers-reduced-motion: reduce)`};function ci(e,t,n=[]){let r=(0,I.useRef)(t);r.current=t,(0,I.useEffect)(()=>{let t=!1,n=null;return oi(()=>import(`./motion-sqs9Ax-g.js`).then(e=>e.t).then(i=>{if(t||!e.current)return;let a=i.gsap;n=a.matchMedia(),n.add(si,e=>r.current(a,!!e.conditions?.reduceMotion),e.current)}),__vite__mapDeps([0,1])),()=>{t=!0,n?.revert()}},n)}function li(e){if(!e)return`—`;let t=Date.now()/1e3,n=Math.max(0,t-e);return n<5?`just now`:n<60?`${Math.floor(n)}s ago`:n<3600?`${Math.floor(n/60)}m ago`:n<86400?`${Math.floor(n/3600)}h ago`:`${Math.floor(n/86400)}d ago`}function ui(e){if(e==null||e<0)return`—`;let t=Math.floor(e/86400),n=Math.floor(e%86400/3600),r=Math.floor(e%3600/60);return t?`${t}d ${n}h`:n?`${n}h ${r}m`:r?`${r}m`:`${Math.floor(e)}s`}function di(e,t=2){return e==null||!isFinite(e)?`$0.00`:`$${e.toFixed(t)}`}function fi(e){if(!Number.isFinite(e)||e<=0)return`0 B`;let t=[`B`,`KB`,`MB`,`GB`],n=Math.min(Math.floor(Math.log(e)/Math.log(1024)),t.length-1),r=e/1024**n;return`${r>=10||n===0?r.toFixed(0):r.toFixed(1)} ${t[n]}`}function pi(e){let t=e.ts??e.time,n=null;if(typeof t==`number`)n=t>0xe8d4a51000?t:t*1e3;else if(typeof t==`string`){let e=Date.parse(t);isNaN(e)||(n=e)}if(n==null)return``;let r=new Date(n),i=e=>String(e).padStart(2,`0`);return`${i(r.getHours())}:${i(r.getMinutes())}:${i(r.getSeconds())}`}function mi(e){return e instanceof Error?e.message:String(e||`Unknown error`)}function hi(e,t){let n=mi(e);return t?`Reply interrupted after a partial response: ${n}`:`Message failed before a response was received: ${n}`}function gi({ok:e,pulse:t=!1,title:n}){return(0,X.jsx)(`span`,{title:n,className:`inline-block h-1.5 w-1.5 rounded-full transition-shadow duration-150 ${e?`bg-ok ring-1 ring-ok/30 ring-offset-1 ring-offset-panel`:`bg-ink-faint/50`}`,"data-live":e&&t?`true`:void 0})}function _i({children:e,color:t,className:n=``}){return(0,X.jsx)(`span`,{className:`chip text-ink-dim ${n}`,style:t?{color:t,borderColor:`${t}44`}:void 0,children:e})}function vi({children:e,onClick:t,variant:n=`ghost`,disabled:r,title:i,className:a=``}){return(0,X.jsx)(`button`,{type:`button`,title:i,disabled:r,onClick:t,className:`brand-button ${{ghost:`brand-button-ghost`,primary:`brand-button-primary`,danger:`brand-button-danger`}[n]} ${a}`,children:e})}function yi({title:e,right:t}){return(0,X.jsxs)(`div`,{className:`panel-header flex min-h-11 items-center justify-between border-b px-4`,children:[(0,X.jsx)(`span`,{className:`text-sm font-medium text-ink-dim`,children:e}),t]})}function bi(){return(0,X.jsx)(`span`,{className:`inline-block h-3 w-3 animate-spin rounded-full border-2 border-line border-t-blue`})}function xi({children:e}){return(0,X.jsx)(`div`,{className:`px-3 py-6 text-center text-xs text-ink-faint`,children:e})}async function Si(e){try{if(navigator.clipboard?.writeText)return await navigator.clipboard.writeText(e),!0}catch{}try{let t=document.createElement(`textarea`);t.value=e,t.setAttribute(`readonly`,``),t.style.position=`fixed`,t.style.opacity=`0`,document.body.appendChild(t),t.select();let n=document.execCommand(`copy`);return t.remove(),n}catch{return!1}}function Ci({text:e,label:t,copiedLabel:n,className:r=``}){let[i,a]=(0,I.useState)(!1),o=(0,I.useRef)();(0,I.useEffect)(()=>()=>{o.current&&clearTimeout(o.current)},[]);let s=async()=>{await Si(e)&&(a(!0),o.current&&clearTimeout(o.current),o.current=setTimeout(()=>a(!1),1600))};return(0,X.jsxs)(`button`,{type:`button`,onClick:()=>void s(),"aria-label":i?n:t,title:i?n:t,className:`inline-flex h-7 items-center gap-1 rounded-md border border-line/60 bg-panel/85 px-2 text-[10px] text-ink-faint shadow-sm backdrop-blur transition hover:border-blue/45 hover:text-blue focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue/50 ${r}`,children:[i?(0,X.jsx)(`svg`,{viewBox:`0 0 16 16`,"aria-hidden":`true`,className:`h-3.5 w-3.5`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.7`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,X.jsx)(`path`,{d:`m3.5 8.5 2.7 2.7 6.3-6.4`})}):(0,X.jsxs)(`svg`,{viewBox:`0 0 16 16`,"aria-hidden":`true`,className:`h-3.5 w-3.5`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.4`,children:[(0,X.jsx)(`rect`,{x:`5.2`,y:`5.2`,width:`7.2`,height:`7.2`,rx:`1.2`}),(0,X.jsx)(`path`,{d:`M10.8 5.2V3.8a1.2 1.2 0 0 0-1.2-1.2H3.8a1.2 1.2 0 0 0-1.2 1.2v5.8a1.2 1.2 0 0 0 1.2 1.2h1.4`})]}),(0,X.jsx)(`span`,{children:i?n:t})]})}function wi(e){return typeof e==`string`||typeof e==`number`?String(e):Array.isArray(e)?e.map(wi).join(``):(0,I.isValidElement)(e)?wi(e.props.children):``}function Ti(e){let t=String(e||``).trim();try{t=decodeURIComponent(t)}catch{}if(/^file:/i.test(t))try{let e=new URL(t);if(e.hostname&&e.hostname!==`localhost`)return``;t=e.pathname}catch{return``}else if(/^[a-z][a-z0-9+.-]*:/i.test(t)&&!/^[a-z]:[\\/]/i.test(t))return``;for(t=t.split(`#`,1)[0].split(`?`,1)[0].replaceAll(`\\`,`/`),/^\/[a-z]:\//i.test(t)&&(t=t.slice(1));t.startsWith(`./`);)t=t.slice(2);return t.replace(/\/{2,}/g,`/`)}function Ei(e,t){return!e||!t?!1:/^[a-z]:\//i.test(e)||/^[a-z]:\//i.test(t)?e.toLowerCase()===t.toLowerCase():e===t}function Di(e,t=[]){let n=Ti(e||``);if(!n)return null;for(let e of t){let t=Ti(e.path),r=Ti(e.storage_path||``);if(Ei(n,t)||Ei(n.replace(/^\//,``),t)||Ei(n,r))return e.path}return null}function Oi({src:e,alt:t}){let[n,r]=(0,I.useState)(!1);return n||!e?(0,X.jsxs)(`span`,{className:`text-xs text-ink-faint`,children:[`Image unavailable`,t?` · ${t}`:``]}):(0,X.jsx)(`img`,{src:e,alt:t||``,loading:`lazy`,decoding:`async`,onError:()=>r(!0),className:`my-2 h-auto max-w-full rounded-lg`})}function ki({children:e,artifacts:t=[],onOpenArtifact:n}){let{t:r}=Z();return(0,X.jsx)(he,{remarkPlugins:[_e,[ge,{backslashDelimiters:!0,singleDollarTextMath:!1}]],rehypePlugins:[ve],components:{h1:({children:e})=>(0,X.jsx)(`h1`,{className:`mb-2 mt-3 text-base font-semibold text-ink first:mt-0`,children:e}),h2:({children:e})=>(0,X.jsx)(`h2`,{className:`mb-1.5 mt-3 text-sm font-semibold text-ink first:mt-0`,children:e}),h3:({children:e})=>(0,X.jsx)(`h3`,{className:`mb-1 mt-2 text-sm font-medium text-ink first:mt-0`,children:e}),p:({children:e})=>(0,X.jsx)(`p`,{className:`my-1.5 whitespace-pre-wrap break-words leading-[1.625] first:mt-0 last:mb-0`,children:e}),ul:({children:e})=>(0,X.jsx)(`ul`,{className:`my-2 list-disc space-y-1 pl-5`,children:e}),ol:({children:e})=>(0,X.jsx)(`ol`,{className:`my-2 list-decimal space-y-1 pl-5`,children:e}),li:({children:e})=>(0,X.jsx)(`li`,{className:`pl-0.5`,children:e}),blockquote:({children:e})=>(0,X.jsx)(`blockquote`,{className:`my-2 border-l border-blue/50 pl-3 text-ink-dim`,children:e}),hr:()=>(0,X.jsx)(`hr`,{className:`my-3 border-line/60`}),a:({href:e,title:r,children:i})=>{let a=Di(e,t),o=a?t.find(e=>e.path===a):void 0;return a&&n?(0,X.jsx)(`a`,{href:e,"data-artifact-path":a,title:o?.storage_path||a,onClick:e=>{e.preventDefault(),n(a)},className:`cursor-pointer text-blue underline decoration-blue/35 underline-offset-2 hover:decoration-blue`,children:i}):(0,X.jsx)(`a`,{href:e,title:r,target:`_blank`,rel:`noreferrer`,className:`text-blue underline decoration-blue/35 underline-offset-2 hover:decoration-blue`,children:i})},code:({className:e,children:t,...n})=>{let r=!!e||String(t).includes(` +`);return(0,X.jsx)(`code`,{...n,className:r?`block min-w-0 whitespace-pre-wrap break-words font-mono text-xs text-ink ${e??``}`:`break-all rounded bg-bg px-1.5 py-0.5 font-mono text-xs text-ink`,children:t})},pre:({children:e})=>(0,X.jsxs)(`pre`,{className:`group/code relative my-2 max-w-full overflow-x-hidden whitespace-pre-wrap break-words rounded-lg border border-line/50 bg-bg px-3 pb-3 pt-10`,children:[(0,X.jsx)(Ci,{text:I.Children.toArray(e).map(wi).join(``),label:r(`copy.code`),copiedLabel:r(`copy.copied`),className:`absolute right-2 top-2`}),e]}),table:({children:e})=>(0,X.jsx)(`table`,{className:`my-2 w-full table-fixed border-collapse text-left text-xs`,children:e}),th:({children:e})=>(0,X.jsx)(`th`,{className:`break-words border border-line/60 bg-bg px-2 py-1.5 font-semibold text-ink`,children:e}),td:({children:e})=>(0,X.jsx)(`td`,{className:`break-words border border-line/60 px-2 py-1.5 align-top`,children:e}),strong:({children:e})=>(0,X.jsx)(`strong`,{className:`font-semibold text-ink`,children:e}),img:({src:e,alt:t})=>(0,X.jsx)(Oi,{src:e,alt:t})},children:e})}function Ai({size:e,className:t=`text-ink`}){return(0,X.jsxs)(`svg`,{"data-logo":`rounded-mark`,viewBox:`0 0 512 512`,role:`img`,"aria-label":`Argus`,style:{width:e,height:e},className:`argus-brand-mark shrink-0 ${t}`,children:[(0,X.jsx)(`path`,{d:`M352 112q0-30 30-30h28q30 0 30 30v320h-88v-52q-46 62-129 62Q66 442 66 266T228 88q80 0 124 56v-32ZM140 266q46-80 102-80t110 80q-54 80-110 80t-102-80Z`,fill:`rgb(var(--brand-body))`,fillRule:`evenodd`}),(0,X.jsx)(`path`,{d:`M140 266q46-80 102-80t110 80q-54 80-110 80t-102-80Z`,fill:`rgb(var(--brand-eye))`}),(0,X.jsxs)(`g`,{className:`argus-mark-eye`,children:[(0,X.jsx)(`circle`,{cx:`244`,cy:`266`,r:`42`,fill:`rgb(var(--brand-pupil))`}),(0,X.jsx)(`circle`,{cx:`262`,cy:`248`,r:`12`,fill:`rgb(var(--brand-highlight))`})]})]})}function ji({size:e}){return(0,X.jsxs)(`svg`,{"data-logo":`rounded-horizontal`,viewBox:`150 40 1160 390`,role:`img`,"aria-label":`Argus`,style:{width:e*2.75,height:e},className:`shrink-0 text-ink`,children:[(0,X.jsxs)(`g`,{className:`argus-brand-mark`,transform:`translate(180 92) scale(.54)`,children:[(0,X.jsx)(`path`,{d:`M352 112q0-30 30-30h28q30 0 30 30v320h-88v-52q-46 62-129 62Q66 442 66 266T228 88q80 0 124 56v-32ZM140 266q46-80 102-80t110 80q-54 80-110 80t-102-80Z`,fill:`rgb(var(--brand-body))`,fillRule:`evenodd`}),(0,X.jsx)(`path`,{d:`M140 266q46-80 102-80t110 80q-54 80-110 80t-102-80Z`,fill:`rgb(var(--brand-eye))`}),(0,X.jsx)(`circle`,{cx:`244`,cy:`266`,r:`42`,fill:`rgb(var(--brand-pupil))`}),(0,X.jsx)(`circle`,{cx:`262`,cy:`248`,r:`12`,fill:`rgb(var(--brand-highlight))`})]}),(0,X.jsxs)(`g`,{fill:`rgb(var(--brand-body))`,children:[(0,X.jsx)(`path`,{d:`M383 556Q394 556 409 555Q424 554 433 552L422 412Q415 414 401.5 415.5Q388 417 378 417Q340 417 305 403.5Q270 390 248.5 360Q227 330 227 278V0H78V546H191L213 454H220Q244 496 286 526Q328 556 383 556Z`,transform:`translate(444 334) scale(.36 -.36)`}),(0,X.jsx)(`path`,{d:`M255 556Q356 556 413 476H417L429 546H555V-1Q555-118 486-179Q417-240 282-240Q224-240 174.5-233Q125-226 78-208V-89Q179-131 291-131Q406-131 406-7V4Q406 21 407.5 39Q409 57 410 71H406Q378 28 339 9Q300-10 251-10Q154-10 99.5 64.5Q45 139 45 272Q45 406 101 481Q157 556 255 556ZM302 435Q197 435 197 270Q197 107 304 107Q361 107 388.5 139.5Q416 172 416 253V271Q416 359 389 397Q362 435 302 435Z`,transform:`translate(617.52 334) scale(.36 -.36)`}),(0,X.jsx)(`path`,{d:`M579 546V0H465L445 70H437Q411 28 365.5 9Q320-10 269-10Q181-10 128 37.5Q75 85 75 190V546H224V227Q224 169 245 139Q266 109 312 109Q380 109 405 155.5Q430 202 430 289V546Z`,transform:`translate(855.48 334) scale(.36 -.36)`}),(0,X.jsx)(`path`,{d:`M459 162Q459 79 400.5 34.5Q342-10 226-10Q169-10 128-2.5Q87 5 46 22V145Q90 125 141 112Q192 99 231 99Q275 99 293.5 112Q312 125 312 146Q312 160 304.5 171Q297 182 272 196Q247 210 194 232Q143 254 110 275.5Q77 297 61 327.5Q45 358 45 404Q45 480 104 518Q163 556 261 556Q312 556 358 546Q404 536 453 513L408 406Q368 423 332 434.5Q296 446 259 446Q193 446 193 410Q193 397 201.5 386.5Q210 376 234.5 364Q259 352 307 332Q354 313 388 292.5Q422 272 440.5 241.5Q459 211 459 162Z`,transform:`translate(1102.08 334) scale(.36 -.36)`})]})]})}function Mi({size:e=20,tag:t,compact:n=!1}){return(0,X.jsxs)(`span`,{className:`inline-flex select-none items-center gap-2.5`,children:[n?(0,X.jsx)(Ai,{size:e}):(0,X.jsx)(ji,{size:e}),t&&!n?(0,X.jsx)(`span`,{className:`text-xs font-medium uppercase tracking-[0.08em] text-ink-faint`,children:t}):null]})}var Ni={active:`label.status.inProgress`,claimed:`label.status.inProgress`,in_progress:`label.status.inProgress`,running:`label.status.inProgress`,working:`label.status.inProgress`,pending:`label.status.waiting`,queued:`label.status.waiting`,waiting:`label.status.waiting`,idle:`label.status.waiting`,accepted:`label.status.completed`,complete:`label.status.completed`,completed:`label.status.completed`,done:`label.status.completed`,success:`label.status.completed`,blocked:`label.status.blocked`,failed:`label.status.failed`,error:`label.status.failed`,rejected:`label.status.needsChanges`,continue:`label.status.needsChanges`,skipped:`label.status.skipped`,paused:`label.status.paused`,stopped:`label.status.paused`,cancelled:`label.status.paused`,aborted:`label.status.paused`,not_started:`label.status.waiting`,available:`label.status.available`,absent:`label.status.unavailable`,inaccessible:`label.status.inaccessible`,degraded:`label.status.limited`,healthy:`label.status.healthy`},Pi={manager:`label.role.manager`,planner:`label.role.planner`,engineer:`label.role.engineer`,reviewer:`label.role.reviewer`,system:`label.role.argus`,operator:`label.role.you`},Fi={completed:`label.outcome.workCompleted`,done:`label.outcome.workCompleted`,success:`label.outcome.workCompleted`,paused:`label.outcome.workPaused`,blocked:`label.outcome.workBlocked`,failed:`label.outcome.workFailed`,error:`label.outcome.workFailed`,aborted:`label.outcome.workEnded`,ended:`label.outcome.workEnded`,incomplete:`label.outcome.workIncomplete`,research_incomplete:`label.outcome.workIncomplete`,paused_no_breakthrough:`label.outcome.workIncomplete`,exhausted_current_methods:`label.outcome.workIncomplete`,stalled:`label.outcome.workStalled`,no_progress:`label.outcome.workStalled`,max_rounds:`label.outcome.workStalled`,infra_blocked:`label.outcome.workBlocked`,supervisor_error:`label.outcome.workFailed`},Ii={accepted:`label.outcome.reviewPassed`,done:`label.outcome.reviewPassed`,passed:`label.outcome.reviewPassed`,continue:`label.outcome.reviewNeedsChanges`,rejected:`label.outcome.reviewNeedsChanges`,blocked:`label.outcome.reviewBlocked`,stale:`label.outcome.reviewOutdated`,pending:`label.outcome.reviewPending`,pending_review:`label.outcome.reviewPending`},Li={certified:`label.outcome.stageApproved`,not_certified:`label.outcome.stageNotApproved`,revoked:`label.outcome.stageRevoked`,intentionally_skipped:`label.outcome.stageNotNeeded`,deferred:`label.outcome.stagePending`},Ri={budget_exhausted:`label.outcome.budgetPaused`,budget_pause:`label.outcome.budgetPaused`,operator_input_required:`label.outcome.waitingForYou`,operator_abort:`label.outcome.stoppedByYou`,operator_pause:`label.outcome.pausedByYou`,daemon_shutdown:`label.outcome.sessionPaused`,backend_unavailable:`label.outcome.serviceUnavailable`,provider_cooldown:`label.outcome.serviceCoolingDown`,provider_fence:`label.outcome.serviceUnavailable`,transient_error:`label.outcome.temporaryIssue`,permanent_error:`label.outcome.serviceError`,planner_empty_plan:`label.outcome.needsPlan`},zi={cuda:`label.resource.nvidiaGpu`,rocm:`label.resource.amdGpu`,mps:`label.resource.appleGpu`,cpu:`label.resource.cpu`};function Bi(e,t){return t(Ni[String(e??``).toLowerCase()]??`label.status.updated`)}function Vi(e,t){return t(Pi[String(e??``).toLowerCase()]??`label.role.argus`)}function Hi(e,t){return t(`label.priority`,{priority:e})}function Ui(e,t){if(!e?.execution_status)return[];let n=[t(Fi[e.execution_status.toLowerCase()]??`label.outcome.workUpdated`)],r=Ii[String(e.review_status??``).toLowerCase()],i=Li[String(e.stage_certification??``).toLowerCase()],a=Ri[String(e.interruption_kind??``).toLowerCase()];return r&&n.push(t(r)),i&&n.push(t(i)),a&&n.push(t(a)),e.resumable&&n.push(t(`label.outcome.canResume`)),n}function Wi(e,t){return t(zi[e.toLowerCase()]??`label.resource.accelerator`)}function Gi(e,t){return t(e===`strict`?`label.resource.enforced`:`label.resource.advisory`)}function Ki(e,t){return t(e===`yield`?`label.resource.released`:`label.resource.kept`)}var qi=[`manager`,`planner`,`engineer`,`reviewer`],Ji=/Info: (?:Operation cancelled by user|Response was interrupted due to a server error\. Retrying\.\.\.)/gi;function Yi(e){let t=new Map;return e.forEach(e=>{let n=String(e.type??``);if(n===`life.mission.completed`||n===`mission.completed`){t.clear();return}let r=String(e.call_id??``);r&&(n===`provider.request.started`?t.set(r,e):(n===`provider.request.completed`||n===`provider.request.denied`)&&t.delete(r))}),Array.from(t.values()).at(-1)??null}function Xi({ev:e,r:t,first:n,last:r}){let i=W.role[t.role]??W.inkFaint,a=rr(t.tone);return(0,X.jsxs)(`div`,{className:`event-activity-row group relative grid grid-cols-[16px_minmax(0,1fr)] gap-3 px-4 py-3 transition-colors hover:bg-bg/70 ${r?`animate-appear`:``} ${t.reasoning?`opacity-60`:``}`,style:t.rule?{marginTop:4}:void 0,children:[(0,X.jsxs)(`div`,{className:`relative flex justify-center`,children:[n?null:(0,X.jsx)(`span`,{className:`absolute -top-2.5 h-4 w-px bg-line/60`}),r?null:(0,X.jsx)(`span`,{className:`absolute -bottom-2.5 top-2 w-px bg-line/60`}),(0,X.jsx)(`span`,{className:`relative z-10 mt-1.5 h-2 w-2 rounded-full border-2 border-panel`,style:{backgroundColor:i,boxShadow:`0 0 0 1px ${i}55`}})]}),(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(`span`,{className:`truncate text-xs font-semibold uppercase tracking-[0.06em]`,style:{color:i},title:t.label,children:t.label}),(0,X.jsx)(`span`,{className:`text-xs`,style:{color:a},children:t.glyph}),(0,X.jsx)(`time`,{className:`ml-auto font-mono text-xs tabular-nums text-ink-faint opacity-0 transition-opacity group-hover:opacity-100`,children:pi(e)})]}),(0,X.jsx)(`div`,{className:`mt-0.5 whitespace-pre-wrap break-words text-sm leading-5 ${t.reasoning?`italic`:``}`,style:{color:a},children:t.text})]})]})}function Zi({ev:e,r:t,artifacts:n,onOpenArtifact:r}){let{t:i}=Z(),a=String(e.type)===`ui.operator`,o=Number(e.response_latency_ms??0),s=!a&&o>=100?` · ${(o/1e3).toFixed(1)}s`:``,c=(0,I.useRef)(null);return ci(c,(e,t)=>{c.current&&(t||e.fromTo(c.current,{autoAlpha:0,x:a?12:0,y:a?0:8},{autoAlpha:1,x:0,y:0,duration:.28,ease:`power2.out`,clearProps:`transform,opacity,visibility`}))}),(0,X.jsx)(`article`,{ref:c,className:`conversation-row group mx-auto w-full max-w-full px-4 py-3 sm:px-6 lg:max-w-[61.8vw]`,children:a?(0,X.jsxs)(`div`,{className:`flex items-end justify-end gap-2`,children:[(0,X.jsx)(Ci,{text:t.text,label:i(`copy.message`),copiedLabel:i(`copy.copied`),className:`opacity-60 sm:opacity-0 sm:group-hover:opacity-100`}),(0,X.jsx)(`time`,{className:`shrink-0 pb-1 font-mono text-[10px] tabular-nums text-ink-faint`,children:pi(e)}),(0,X.jsx)(`div`,{className:`max-w-[calc(100%_-_3rem)] rounded-[18px] bg-conversation-user px-4 py-2.5 text-[15px] leading-relaxed text-ink ring-1 ring-line/35 sm:max-w-[82%]`,children:(0,X.jsx)(ki,{artifacts:n,onOpenArtifact:r,children:t.text})})]}):(0,X.jsxs)(`div`,{className:`flex gap-3`,children:[(0,X.jsx)(`span`,{className:`mt-0.5 flex h-7 w-7 shrink-0 items-center justify-center`,children:(0,X.jsx)(Ai,{size:26,className:`text-ink`})}),(0,X.jsxs)(`div`,{className:`relative min-w-0 flex-1 text-[15px] leading-relaxed text-ink`,children:[(0,X.jsxs)(`div`,{className:`mb-1 flex items-center gap-2`,children:[(0,X.jsx)(`span`,{className:`text-xs font-semibold text-blue`,children:`Argus`}),(0,X.jsx)(Ci,{text:t.text,label:i(`copy.message`),copiedLabel:i(`copy.copied`),className:`ml-auto opacity-60 sm:opacity-0 sm:group-hover:opacity-100`}),(0,X.jsxs)(`time`,{className:`font-mono text-[10px] tabular-nums text-ink-faint`,children:[pi(e),s]})]}),(0,X.jsx)(ki,{artifacts:n,onOpenArtifact:r,children:t.text})]})]})})}function Qi({role:e,rows:t,open:n,active:r,onToggle:i}){let{t:a}=Z(),o=W.role[e],s=(0,I.useRef)(null),c=t[t.length-1]?.r.text.length??0;return(0,I.useEffect)(()=>{if(!n)return;let e=window.requestAnimationFrame(()=>{s.current&&s.current.scrollHeight>s.current.clientHeight&&(s.current.scrollTop=s.current.scrollHeight)});return()=>window.cancelAnimationFrame(e)},[n,t.length,c]),(0,X.jsxs)(`section`,{className:`role-log-group border-b border-line/50`,"data-role":e,"data-open":n?`true`:`false`,"data-active":r?`true`:`false`,children:[(0,X.jsxs)(`button`,{type:`button`,onClick:i,"aria-expanded":n,className:`group flex h-11 w-full items-center gap-2 px-4 text-left transition-colors hover:bg-bg/60`,children:[(0,X.jsx)(`span`,{"data-role-dot":e,"aria-hidden":`true`,className:`h-2 w-2 shrink-0 rounded-full ${r?`animate-pulse motion-reduce:animate-none`:``}`,style:{background:o}}),(0,X.jsx)(`span`,{className:`text-xs font-semibold text-ink-dim`,children:Vi(e,a)}),(0,X.jsx)(`span`,{className:`font-mono text-xs text-ink-faint`,children:t.length}),t.length>0?(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-ink-faint`,children:t[t.length-1].r.text}):(0,X.jsx)(`span`,{className:`flex-1`}),(0,X.jsx)(`svg`,{viewBox:`0 0 16 16`,"aria-hidden":`true`,className:`h-4 w-4 shrink-0 text-ink-faint transition-transform duration-panel ease-panel ${n?`rotate-90`:``}`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,children:(0,X.jsx)(`path`,{d:`m6 3.5 4.5 4.5L6 12.5`})})]}),n?(0,X.jsx)(`div`,{className:`grid grid-rows-[1fr]`,children:(0,X.jsx)(`div`,{className:`min-h-0 overflow-hidden`,children:(0,X.jsx)(`div`,{ref:s,className:`max-h-72 overflow-x-hidden overflow-y-auto border-t border-line/40 scroll-thin`,children:t.length>0?t.map(({ev:e,r:n,key:r},i)=>(0,X.jsx)(Xi,{ev:e,r:n,first:i===0,last:i===t.length-1},r)):(0,X.jsx)(`div`,{className:`px-4 py-3 text-xs text-ink-faint`,children:a(`stream.noLogs`)})})})}):null]})}function $i(e){let t={manager:[],planner:[],engineer:[],reviewer:[]},n=[];return e.forEach(e=>{qi.includes(e.r.role)?t[e.r.role].push(e):n.push(e)}),{roleRows:t,systemRows:n,lastRole:[...e].reverse().find(e=>qi.includes(e.r.role))?.r.role??``}}function ea({rows:e}){let{t}=Z(),[n,r]=(0,I.useState)(!1);return(0,X.jsxs)(`section`,{className:`border-b border-line/50`,"data-system-open":n?`true`:`false`,children:[(0,X.jsxs)(`button`,{type:`button`,"aria-expanded":n,onClick:()=>r(e=>!e),className:`flex h-10 w-full items-center gap-2 px-4 text-left text-xs text-ink-faint hover:bg-bg/60`,children:[(0,X.jsx)(`span`,{children:t(`stream.system`)}),(0,X.jsx)(`span`,{className:`font-mono`,children:e.length}),(0,X.jsx)(`span`,{className:`flex-1`}),(0,X.jsx)(`svg`,{viewBox:`0 0 16 16`,"aria-hidden":`true`,className:`h-4 w-4 shrink-0 transition-transform duration-panel ease-panel ${n?`rotate-90`:``}`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,children:(0,X.jsx)(`path`,{d:`m6 3.5 4.5 4.5L6 12.5`})})]}),n?(0,X.jsx)(`div`,{className:`border-t border-line/40`,children:e.map(({ev:t,r:n,key:r},i)=>(0,X.jsx)(Xi,{ev:t,r:n,first:i===0,last:i===e.length-1},r))}):null]})}function ta({rows:e,live:t}){let{roleRows:n,systemRows:r,lastRole:i}=(0,I.useMemo)(()=>$i(e),[e]),[a,o]=(0,I.useState)(()=>new Set(t&&i?[i]:[])),s=(0,I.useRef)(!1);return(0,I.useEffect)(()=>{!t||!i||s.current||o(new Set([i]))},[i,t]),(0,X.jsxs)(`div`,{className:`bg-bg/25`,children:[qi.map(e=>(0,X.jsx)(Qi,{role:e,rows:n[e],open:a.has(e),active:i===e,onToggle:()=>{s.current=!0,o(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}},e)),r.length>0?(0,X.jsx)(ea,{rows:r}):null]})}function na(e){let t=e.delivery;if(!t||typeof t!=`object`||Array.isArray(t))return null;let n=t;return typeof n.delivery_id!=`string`||!n.delivery_id.trim()?null:n}function ra(e){for(let t=e.length-1;t>=0;--t){let n=e[t];if(n.type===`ui.operator`)return null;let r=na(n);if(r)return r}}function ia({delivery:e,onOpen:t}){let{t:n}=Z(),r=e.kind===`submission_certified`;return(0,X.jsxs)(`aside`,{className:`mx-auto my-3 flex w-full max-w-full gap-3 rounded-lg border border-ok/35 bg-ok/5 px-4 py-3 lg:max-w-[61.8vw]`,children:[(0,X.jsx)(`span`,{className:`flex h-7 w-7 shrink-0 items-center justify-center rounded-full bg-ok/15 font-semibold text-ok`,children:`✓`}),(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-[0.14em] text-ok`,children:n(r?`mission.deliveryCertified`:`mission.taskCompleted`)}),(0,X.jsx)(`div`,{className:`mt-1 truncate text-sm font-semibold text-ink`,title:e.title,children:e.title}),e.summary?(0,X.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-ink-dim`,children:ei(e.summary)}):null,t?(0,X.jsx)(`button`,{type:`button`,onClick:()=>t(e),className:`mt-2 rounded border border-ok/40 px-2 py-1 font-mono text-[10px] text-ok hover:border-ok hover:bg-ok/10`,children:n(e.primary_target?`mission.openResult`:`mission.viewTask`)}):null]})]})}function aa({group:e,latest:t,artifacts:n,onOpenArtifact:r,onOpenDelivery:i}){let a=e=>e.ev.type===`ui.argus`&&/^(info:|operation cancelled|cancelled\b)/i.test(e.r.text.trim()),o=e.rows.filter(e=>e.ev.type===`ui.argus`).map(e=>{let t=e.r.text.match(Ji)??[],n=e.r.text.replace(Ji,``).trim();return{reply:n&&!a(e)?{...e,r:{...e.r,text:n}}:null,messages:a(e)&&t.length===0?[e.r.text]:t}}),s=o.flatMap(e=>e.reply?[e.reply]:[]),c=o.flatMap(e=>e.messages),l=e.rows.filter(({ev:e})=>e.type!==`ui.argus`),u=(()=>{let t=new Set;return e.rows.flatMap(e=>{let n=na(e.ev);return!n||t.has(n.delivery_id)?[]:(t.add(n.delivery_id),[n])})})();return(0,X.jsxs)(`section`,{className:`conversation-thread border-b border-line/60`,children:[(0,X.jsx)(Zi,{ev:e.operator.ev,r:e.operator.r,artifacts:n,onOpenArtifact:r}),s.map(e=>(0,X.jsx)(Zi,{ev:e.ev,r:e.r,artifacts:n,onOpenArtifact:r},e.key)),c.map((t,n)=>(0,X.jsx)(`div`,{className:`mx-auto w-full max-w-full px-6 py-1.5 text-center text-xs text-ink-faint lg:max-w-[61.8vw]`,children:t},`${e.key}-system-${n}`)),u.map(e=>(0,X.jsx)(ia,{delivery:e,onOpen:i},e.delivery_id)),l.length>0?(0,X.jsx)(`div`,{className:`mx-auto w-full max-w-full border-t border-line/40 lg:max-w-[61.8vw]`,children:(0,X.jsx)(ta,{rows:l,live:t})}):null]})}function oa({events:e,connected:t,showReasoning:n,onToggleReasoning:r,embedded:i=!1,showHeader:a=!0,filter:o=`all`,query:s=``,skipFirst:c=0,artifacts:l,onOpenArtifact:u,onOpenDelivery:d}){let{locale:f,t:p}=Z(),[m,h]=(0,I.useState)(!0),[g,_]=(0,I.useState)(()=>Date.now()),v=(0,I.useRef)(null),y=(0,I.useDeferredValue)(e),b=(0,I.useMemo)(()=>Yi(y),[y]);(0,I.useEffect)(()=>{if(!b)return;_(Date.now());let e=window.setInterval(()=>_(Date.now()),1e3);return()=>window.clearInterval(e)},[b]);let x=b?Math.max(0,Math.floor((g-Number(b.ts??0)*1e3)/1e3)):0,S=(0,I.useMemo)(()=>{let e=[],t=new Map,r=0;return(c>0?y.slice(c):y).forEach((i,a)=>{let c=ir(i,f);if(!c)return;if(c.reasoning&&!n){r++;return}if(!Mt(i,c,o,s))return;let l=i,u=String(l.message_id??``),d=!!u&&String(l.type)===`engineer.progress`&&[`assistant_message`,`agent_message`,`message`].includes(String(l.kind));if(d&&t.has(u)){let n=t.get(u);e[n]={...e[n],ev:{...e[n].ev,...i},r:{...e[n].r,...c,text:kt(e[n].r.text,c.text,Dt(i))}};return}let p={ev:i,r:c,key:ar(i,a)};d&&t.set(u,e.length),e.push(p)}),{list:e,hiddenReasoning:r}},[y,n,o,s,c,f]),C=(0,I.useMemo)(()=>{let e=[],t=[],n=null;return S.list.forEach(r=>{r.ev.type===`ui.operator`?(n={key:r.key,operator:r,rows:[]},e.push(n)):n?n.rows.push(r):t.push(r)}),{groups:e,earlier:t}},[S.list]),w=(0,I.useMemo)(()=>y.filter(Ct).length,[y]),T=(0,I.useMemo)(()=>S.list.slice(-20).reduce((e,t)=>e+t.r.text.length,0),[S.list]);return(0,I.useEffect)(()=>{if(!m)return;let e=window.requestAnimationFrame(()=>{v.current&&(v.current.scrollTop=v.current.scrollHeight)});return()=>window.cancelAnimationFrame(e)},[S.list.length,T,m]),(0,I.useEffect)(()=>{let e=v.current;if(!e)return;let t=()=>h(e.scrollHeight-e.scrollTop-e.clientHeight<40);return e.addEventListener(`scroll`,t,{passive:!0}),()=>e.removeEventListener(`scroll`,t)},[]),(0,X.jsxs)(`section`,{className:`relative flex min-h-0 flex-1 flex-col overflow-hidden bg-panel ${i?``:`rounded-lg border border-line/80`}`,children:[a&&(0,X.jsx)(yi,{title:p(`panel.activity`),right:(0,X.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,X.jsxs)(`button`,{onClick:r,className:`rounded px-1.5 py-0.5 text-xs transition-colors ${n?`text-blue-sky`:`text-ink-faint hover:text-ink-dim`}`,title:p(`stream.toggleReasoning`),children:[p(`stream.reasoning`),w?` ·${w}`:``]}),(0,X.jsx)(`span`,{className:`text-xs ${t?`text-ok`:`text-ink-faint`}`,children:t?`● ${p(`common.live`)}`:`○ ${p(`common.reconnecting`)}`})]})}),b?(0,X.jsxs)(`div`,{className:`flex h-9 shrink-0 items-center gap-2 border-b border-line/60 bg-blue-deep/5 px-4 text-xs text-ink-dim`,children:[(0,X.jsx)(`span`,{className:`h-2 w-2 animate-pulse rounded-full bg-blue-sky`}),(0,X.jsx)(`span`,{className:`truncate`,children:p(`stream.backgroundWork`)}),(0,X.jsxs)(`span`,{className:`ml-auto shrink-0 font-mono tabular-nums text-ink-faint`,children:[x,`s`]})]}):null,(0,X.jsx)(`div`,{ref:v,className:`min-h-0 flex-1 overflow-x-hidden overflow-y-auto pb-6 pt-1.5 scroll-thin`,children:S.list.length===0?(0,X.jsx)(xi,{children:p(`stream.ready`)}):(0,X.jsxs)(X.Fragment,{children:[C.earlier.length>0?(0,X.jsxs)(`section`,{className:`mx-auto w-full max-w-full border-b border-line/60 lg:max-w-[61.8vw]`,children:[(0,X.jsxs)(`div`,{className:`flex h-10 items-center gap-2 border-b border-line/40 px-4 text-[10px] font-semibold uppercase tracking-[0.12em] text-ink-faint`,children:[p(`stream.autonomous`),(0,X.jsx)(`span`,{className:`font-mono font-normal tracking-normal`,children:C.earlier.length})]}),(0,X.jsx)(ta,{rows:C.earlier,live:C.groups.length===0})]}):null,C.groups.map((e,t)=>(0,X.jsx)(aa,{group:e,latest:t===C.groups.length-1,artifacts:l,onOpenArtifact:u,onOpenDelivery:d},e.key))]})}),!m&&(0,X.jsx)(`button`,{onClick:()=>{h(!0),v.current?.scrollTo({top:v.current.scrollHeight,behavior:`smooth`})},"aria-label":p(`stream.jumpToLatest`),title:p(`stream.jumpToLatest`),className:`absolute bottom-4 left-1/2 flex h-8 w-8 -translate-x-1/2 items-center justify-center rounded-full border border-line/60 bg-panel text-sm text-ink-dim shadow-glow transition-all duration-200 hover:border-ink-faint hover:text-ink`,children:`↓`})]})}function sa(e){return e.nativeEvent.isComposing||e.keyCode===229}var ca=`operator console`,la={Everyday:`常用`,"Task management":`任务管理`,"Sessions & diagnostics":`会话与诊断`,Configuration:`配置`,Other:`其他`},ua={crystalpilot:`在当前 Argus 会话启用晶体学工具,保持原生界面`,status:`查看角色、队列、日志和健康状态`,roles:`查看各角色的后端、模型、推理强度和实时活动`,journal:`查看近期日志(默认 10 条)`,backlog:`查看待处理任务(all 包含已完成和已跳过)`,artifacts:`查看 Reviewer 批准的结果文件(按 Enter 预览)`,artifact:`预览一个已批准的结果文件`,events:`搜索动态:all / watch / milestones / messages`,find:`搜索当前事件缓冲区`,cancel:`停止等待当前 Manager 回复`,ask:`直接回答,不排任务、不走 Planner/Engineer/Reviewer`,task:`直接加入任务队列`,plan:`预览 Planner 编写的执行计划`,rewrite:`让 Manager 在发送前改写提示词`,nudge:`向正在运行的任务注入指导`,abort:`立即终止正在运行的任务`,note:`向时间线添加手动备注`,done:`将任务标记为完成`,skip:`跳过任务`,stop:`停止任务的自动迭代`,item:`查看完整任务契约`,run:`返回持续更新的任务动态`,new:`检查、创建并切换到新会话`,daemons:`查找全部会话并切换或创建`,resume:`切换到其他项目或会话`,attach:`跟随其他项目并读取其动态`,rename:`重命名当前会话`,doctor:`诊断为什么没有任务运行`,backend:`查看或更改共享 Runner 后端`,config:`查看或更改运行时设置`,identity:`查看或替换操作者身份卡`,reset:`清除 Manager 的热会话上下文`,skills:`查看或提升运行时 Skill`,clear:`清空事件动态视图`,reconnect:`重新连接实时动态`,help:`查看快捷键和完整命令参考`,quit:`离开控制台(后台工作继续运行)`};function da(e,t){return t===`zh-CN`?ua[e.id]:e.id===`reconnect`?`reconnect live activity`:e.desc}function fa(e,t){return t===`zh-CN`?la[e.group]:e.group}function pa(e,t){let n=new Map;for(let r of e){let e=fa(r,t),i=r.aliases?.length?` (= ${r.aliases.join(`, `)})`:``,a=`${r.name}${r.arg?` ${r.arg}`:``}${i}`;n.has(e)||n.set(e,[]),n.get(e).push({label:a,desc:da(r,t)})}return[...n.entries()].map(([e,t])=>({group:e,rows:t}))}var ma=`slash-completion-listbox`;function ha(e,t){return t<=0?0:Math.max(0,Math.min(e,t-1))}function ga(e){return`slash-completion-option-${e}`}function _a({query:e,selected:t,onSelect:n}){let{locale:r,t:i}=Z(),a=Rt(e);if(a.length===0)return null;let o=a.slice(0,8),s=ha(t,o.length);return(0,X.jsx)(`div`,{id:ma,role:`listbox`,"aria-label":i(`slash.suggestions`),className:`slash-completion-menu scroll-thin border-b border-line/40`,children:o.map((e,t)=>(0,X.jsxs)(`button`,{id:ga(e.id),type:`button`,role:`option`,"aria-selected":t===s,onPointerDown:e=>{e.preventDefault(),n(t)},className:`flex w-full items-baseline gap-2 px-3 py-1.5 text-left text-sm transition-colors ${t===s?`bg-blue/10 text-ink`:`text-ink-dim hover:bg-line/20`}`,children:[(0,X.jsx)(`span`,{className:`shrink-0 font-mono text-blue`,children:e.name}),e.arg?(0,X.jsx)(`span`,{className:`shrink-0 font-mono text-xs text-ink-faint`,children:e.arg}):null,(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-ink-faint`,children:da(e,r)})]},e.id))})}var va=10485760,ya=26214400,ba=[`.png`,`.jpg`,`.jpeg`,`.webp`,`.pdf`,`.md`,`.markdown`,`.txt`,`.json`,`.csv`].join(`,`),xa={".png":`image/png`,".jpg":`image/jpeg`,".jpeg":`image/jpeg`,".webp":`image/webp`,".pdf":`application/pdf`,".md":`text/markdown`,".markdown":`text/markdown`,".txt":`text/plain`,".json":`application/json`,".csv":`text/csv`};function Sa(e){let t=String(e||``).trim().toLowerCase(),n=t.lastIndexOf(`.`);return n>=0?t.slice(n):``}function Ca(e){return xa[Sa(e.name)]||String(e.type||``).split(`;`,1)[0].trim()||`application/octet-stream`}function wa(e){return Object.hasOwn(xa,Sa(e.name))}function Ta(e){return Ca(e).startsWith(`image/`)}function Ea(e){return[e.name,String(e.size),Ca(e),String(e.lastModified??``)].join(`::`)}function Da(e,t){let n=[],r=[],i=new Set(e.map(Ea)),a=e.reduce((e,t)=>e+Math.max(0,t.size||0),0),o=e.length;for(let e of t){let t=Ea(e);if(!i.has(t)){if(i.add(t),!wa(e)){r.push({code:`unsupported`,fileName:e.name});continue}if(o>=5){r.push({code:`too-many`,limitCount:5});continue}if(e.size>10485760){r.push({code:`too-large`,fileName:e.name,limitBytes:va});continue}if(a+e.size>26214400){r.push({code:`too-large-total`,limitBytes:ya});continue}n.push(e),a+=e.size,o+=1}}return{accepted:n,issues:r}}function Oa(e){return e?Array.from(e):[]}function ka(e){return Oa(e?.types).map(e=>String(e)).includes(`Files`)||Aa(e).length>0}function Aa(e){let t=Oa(e?.files).filter(e=>e instanceof File);if(t.length)return t;let n=[];for(let t of Oa(e?.items)){if(String(t?.kind||``)!==`file`||typeof t?.getAsFile!=`function`)continue;let e=t.getAsFile();e instanceof File&&n.push(e)}return n}function ja({file:e,removeLabel:t,onRemove:n,disabled:r=!1}){let[i,a]=(0,I.useState)(``);return(0,I.useEffect)(()=>{if(!Ta(e)||typeof URL>`u`||typeof URL.createObjectURL!=`function`){a(``);return}let t=URL.createObjectURL(e);return a(t),()=>URL.revokeObjectURL(t)},[e]),(0,X.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 rounded-2xl border border-line/50 bg-panel/80 px-2.5 py-2 text-xs shadow-[0_10px_24px_-20px_rgb(0_0_0/0.2)]`,children:[i?(0,X.jsx)(`img`,{src:i,alt:``,className:`h-10 w-10 shrink-0 rounded-xl border border-line/40 object-cover`}):null,(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`div`,{className:`truncate font-medium text-ink`,title:e.name,children:e.name}),(0,X.jsxs)(`div`,{className:`truncate text-ink-faint`,children:[fi(e.size),` · `,Ca(e)]})]}),(0,X.jsx)(`button`,{type:`button`,onClick:n,disabled:r,"aria-label":t,title:t,className:`send-control h-8 w-8 shrink-0 rounded-full border-line/60 text-ink-faint hover:border-err/50 hover:bg-err/10 hover:text-err`,children:`×`})]})}var Ma=e=>e.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase(),Na=(...e)=>e.filter((e,t,n)=>!!e&&e.trim()!==``&&n.indexOf(e)===t).join(` `).trim(),Pa={xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`},Fa=(0,I.forwardRef)(({color:e=`currentColor`,size:t=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:i=``,children:a,iconNode:o,...s},c)=>(0,I.createElement)(`svg`,{ref:c,...Pa,width:t,height:t,stroke:e,strokeWidth:r?Number(n)*24/Number(t):n,className:Na(`lucide`,i),...s},[...o.map(([e,t])=>(0,I.createElement)(e,t)),...Array.isArray(a)?a:[a]])),Ia=(e,t)=>{let n=(0,I.forwardRef)(({className:n,...r},i)=>(0,I.createElement)(Fa,{ref:i,iconNode:t,className:Na(`lucide-${Ma(e)}`,n),...r}));return n.displayName=`${e}`,n},La=Ia(`Activity`,[[`path`,{d:`M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2`,key:`169zse`}]]),Ra=Ia(`ArrowUpRight`,[[`path`,{d:`M7 7h10v10`,key:`1tivn9`}],[`path`,{d:`M7 17 17 7`,key:`1vkiza`}]]),za=Ia(`ArrowUp`,[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]),Ba=Ia(`Boxes`,[[`path`,{d:`M2.97 12.92A2 2 0 0 0 2 14.63v3.24a2 2 0 0 0 .97 1.71l3 1.8a2 2 0 0 0 2.06 0L12 19v-5.5l-5-3-4.03 2.42Z`,key:`lc1i9w`}],[`path`,{d:`m7 16.5-4.74-2.85`,key:`1o9zyk`}],[`path`,{d:`m7 16.5 5-3`,key:`va8pkn`}],[`path`,{d:`M7 16.5v5.17`,key:`jnp8gn`}],[`path`,{d:`M12 13.5V19l3.97 2.38a2 2 0 0 0 2.06 0l3-1.8a2 2 0 0 0 .97-1.71v-3.24a2 2 0 0 0-.97-1.71L17 10.5l-5 3Z`,key:`8zsnat`}],[`path`,{d:`m17 16.5-5-3`,key:`8arw3v`}],[`path`,{d:`m17 16.5 4.74-2.85`,key:`8rfmw`}],[`path`,{d:`M17 16.5v5.17`,key:`k6z78m`}],[`path`,{d:`M7.97 4.42A2 2 0 0 0 7 6.13v4.37l5 3 5-3V6.13a2 2 0 0 0-.97-1.71l-3-1.8a2 2 0 0 0-2.06 0l-3 1.8Z`,key:`1xygjf`}],[`path`,{d:`M12 8 7.26 5.15`,key:`1vbdud`}],[`path`,{d:`m12 8 4.74-2.85`,key:`3rx089`}],[`path`,{d:`M12 13.5V8`,key:`1io7kd`}]]),Va=Ia(`Check`,[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]),Ha=Ia(`ChevronDown`,[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]),Ua=Ia(`CircleCheck`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),Wa=Ia(`CircleHelp`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`,key:`1u773s`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),Ga=Ia(`Clock3`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`polyline`,{points:`12 6 12 12 16.5 12`,key:`1aq6pp`}]]),Ka=Ia(`Diamond`,[[`path`,{d:`M2.7 10.3a2.41 2.41 0 0 0 0 3.41l7.59 7.59a2.41 2.41 0 0 0 3.41 0l7.59-7.59a2.41 2.41 0 0 0 0-3.41l-7.59-7.59a2.41 2.41 0 0 0-3.41 0Z`,key:`1f1r0c`}]]),qa=Ia(`Download`,[[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}],[`polyline`,{points:`7 10 12 15 17 10`,key:`2ggqvy`}],[`line`,{x1:`12`,x2:`12`,y1:`15`,y2:`3`,key:`1vk2je`}]]),Ja=Ia(`ExternalLink`,[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`M10 14 21 3`,key:`gplh6r`}],[`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`,key:`a6xqqp`}]]),Ya=Ia(`FileText`,[[`path`,{d:`M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z`,key:`1rqfz7`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`path`,{d:`M10 9H8`,key:`b1mrlr`}],[`path`,{d:`M16 13H8`,key:`t4e002`}],[`path`,{d:`M16 17H8`,key:`z1uh3a`}]]),Xa=Ia(`KeyRound`,[[`path`,{d:`M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z`,key:`1s6t7t`}],[`circle`,{cx:`16.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`w0ekpg`}]]),Za=Ia(`LoaderCircle`,[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`,key:`13zald`}]]),Qa=Ia(`Maximize2`,[[`polyline`,{points:`15 3 21 3 21 9`,key:`mznyad`}],[`polyline`,{points:`9 21 3 21 3 15`,key:`1avn1i`}],[`line`,{x1:`21`,x2:`14`,y1:`3`,y2:`10`,key:`ota7mn`}],[`line`,{x1:`3`,x2:`10`,y1:`21`,y2:`14`,key:`1atl0r`}]]),$a=Ia(`Minimize2`,[[`polyline`,{points:`4 14 10 14 10 20`,key:`11kfnr`}],[`polyline`,{points:`20 10 14 10 14 4`,key:`rlmsce`}],[`line`,{x1:`14`,x2:`21`,y1:`10`,y2:`3`,key:`o5lafz`}],[`line`,{x1:`3`,x2:`10`,y1:`21`,y2:`14`,key:`1atl0r`}]]),eo=Ia(`PackageCheck`,[[`path`,{d:`m16 16 2 2 4-4`,key:`gfu2re`}],[`path`,{d:`M21 10V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l2-1.14`,key:`e7tb2h`}],[`path`,{d:`m7.5 4.27 9 5.15`,key:`1c824w`}],[`polyline`,{points:`3.29 7 12 12 20.71 7`,key:`ousv84`}],[`line`,{x1:`12`,x2:`12`,y1:`22`,y2:`12`,key:`a4e8g8`}]]),to=Ia(`Pause`,[[`rect`,{x:`14`,y:`4`,width:`4`,height:`16`,rx:`1`,key:`zuxfzm`}],[`rect`,{x:`6`,y:`4`,width:`4`,height:`16`,rx:`1`,key:`1okwgv`}]]),no=Ia(`RefreshCw`,[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`,key:`v9h5vc`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`,key:`3uifl3`}],[`path`,{d:`M8 16H3v5`,key:`1cv678`}]]),ro=Ia(`ShieldCheck`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),io=Ia(`Square`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]),ao=Ia(`Terminal`,[[`polyline`,{points:`4 17 10 11 4 5`,key:`akl6gq`}],[`line`,{x1:`12`,x2:`20`,y1:`19`,y2:`19`,key:`q2wloq`}]]),oo=Ia(`X`,[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]);function so(e,t,n){let r=e?.model_revision&&e.model_revision!==n,i={...e?.cards};for(let[n,a]of Object.entries(t.cards)){if(r&&i[n]?.model_revision===e.model_revision)continue;let t=i[n];(!t||(a.copy_revision??0)>(t.copy_revision??0)||(a.copy_revision??0)===(t.copy_revision??0)&&(a.generated_at>t.generated_at||a.generated_at===t.generated_at&&!t.input_revision))&&(i[n]=a)}let a=(t.cache_revision??0)<(e?.cache_revision??0);return{...e,...t,cards:i,cache_revision:Math.max(t.cache_revision??0,e?.cache_revision??0),relations:(r||a)&&e?e.relations:t.relations,available:t.available??!0,...r?{model_revision:e.model_revision,available:e.available}:{}}}function co(e,t,n){let r=n?.cards[e.key],i=t.tasks.find(t=>t.id===e.task_id);if(!r||!i)return!0;let a=[i.id,i.id+`:active`,i.id+`:outcome`].includes(e.key);if(a||!r.task_content_revision||!i.content_revision){if(i.revision&&r.task_revision!==i.revision||a&&r.task_status!==i.status)return!0}else if(r.task_content_revision!==i.content_revision)return!0;let o=r.event_ids||[];return e.event_ids.some(e=>{let n=o.indexOf(e),i=t.events.find(t=>t.id===e);return n<0||r.event_revisions&&i?.revision&&r.event_revisions[n]!==i.revision})||!a&&JSON.stringify(e.event_ids)!==JSON.stringify(o)}var lo=e=>`[[Argus引用 ${JSON.stringify(e)}]]\n`;function uo(e){let t=[];return{refs:t,text:e.split(` +`).filter(e=>{if(e.startsWith(`[[Argus引用 `)&&e.endsWith(`]]`))try{let n=JSON.parse(e.slice(10,-2));if(typeof n.task_id==`string`&&typeof n.source==`string`&&typeof n.task_title==`string`&&(n.part===void 0||Number.isInteger(n.part)&&n.part>0)&&(n.step_title===void 0||typeof n.step_title==`string`)&&(n.step_id===void 0||typeof n.step_id==`string`)&&(n.team_id===void 0||typeof n.team_id==`string`)&&(n.team_task_id===void 0||typeof n.team_task_id==`string`)&&(n.lang===void 0||typeof n.lang==`string`)&&Array.isArray(n.event_ids)&&n.event_ids.every(e=>typeof e==`string`))return t.push(n),!1}catch{}return!0}).join(` +`).replace(/^\n+/,``)}}function fo(e,t,n){let r=e.tasks.find(e=>e.id===n),i=r?[r,...e.tasks.filter(e=>e.id!==n)]:e.tasks,a=(t,n=1/0)=>{let r=Math.max(-1/0,...e.events.filter(e=>e.item_id===t&&e.type===`life.mission.started`&&e.ts<=n).map(e=>e.ts));return e.events.filter(e=>e.item_id===t&&e.ts>=r&&e.ts<=n&&[`round.main.completed`,`round.review.completed`].includes(e.type)).slice(-2).map(e=>e.id)},o=i.map(t=>({key:t.id,task_id:t.id,kind:`task`,event_ids:[...new Set([...a(t.id),...e.events.filter(e=>e.item_id===t.id).slice(-2).map(e=>e.id)])]})),s=r?t.map(e=>({key:e.id,task_id:r.id,kind:e.kind,event_ids:[...new Set([...e.kind===`result`?a(r.id,e.ts):[],...e.eventIds])].slice(-16)})):[];return[...o.slice(0,1),...s,...o.slice(1)]}function po({value:e,onChange:t,inputRef:n,fileInputRef:r,onFiles:i,inputProps:a,onSend:o,onCancel:s,pending:c,disabled:l=!1,controls:u}){let{t:d,locale:f}=Z(),p=f===`zh-CN`,{refs:m,text:h}=uo(e);return(0,I.useEffect)(()=>{let e=n.current;if(!e)return;let t=()=>{e.getClientRects().length&&(e.style.height=`0px`,e.style.height=`${Math.min(132,Math.max(28,e.scrollHeight))}px`)};t();let r=e.clientWidth,i=new ResizeObserver(()=>{e.clientWidth!==r&&(r=e.clientWidth,t())});return i.observe(e),()=>i.disconnect()},[n,h]),(0,X.jsxs)(`div`,{className:`composer-surface`,"data-pending":c,children:[m.length>0&&(0,X.jsx)(`div`,{className:`map-reference-chips`,children:m.map((e,n)=>(0,X.jsxs)(`span`,{children:[(0,X.jsxs)(`span`,{children:[p?`引用`:`Reference`,` · `,e.step_title||e.task_title]}),(0,X.jsx)(`button`,{type:`button`,"aria-label":p?`移除引用`:`Remove reference`,onClick:()=>t(m.filter((e,t)=>t!==n).map(lo).join(``)+h),children:(0,X.jsx)(oo,{size:12})})]},`${e.task_id}:${e.step_id}:${n}`))}),(0,X.jsxs)(`form`,{className:`map-composer`,onSubmit:e=>{e.preventDefault(),!c&&!l&&o()},children:[(0,X.jsx)(`input`,{ref:r,type:`file`,multiple:!0,accept:ba,hidden:!0,disabled:l||c,onChange:i}),(0,X.jsx)(`button`,{type:`button`,className:`map-composer-brand map-attach`,"aria-label":d(`chat.attach`),title:d(`chat.attach`),disabled:l||c,onClick:()=>r.current?.click(),children:(0,X.jsx)(Ai,{size:24})}),(0,X.jsx)(`textarea`,{...a,ref:n,rows:1,value:h,disabled:l,onChange:e=>t(m.map(lo).join(``)+e.target.value),onKeyDown:e=>{a.onKeyDown?.(e),!(e.defaultPrevented||sa(e))&&e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),!c&&!l&&o())}}),(0,X.jsx)(`button`,{type:c?`button`:`submit`,onClick:c?s:void 0,disabled:l||!c&&!h.trim(),"aria-label":c?p?`停止等待`:`Stop waiting`:p?`发送消息`:`Send message`,className:`map-send ${c?`is-pending`:``}`,children:c?(0,X.jsx)(io,{size:15}):(0,X.jsx)(za,{size:20})})]}),u?(0,X.jsx)(`div`,{className:`composer-controls`,children:u}):null]})}function mo(e,t){if(!t.onRewrite||!Zn(e.key,e.ctrlKey,e.metaKey))return!1;e.preventDefault();let n=t.value.trim();return n&&!t.disabled&&!t.pending&&!t.rewriting&&t.onRewrite(n),!0}function ho({value:e,onChange:t,onSend:n,onCancel:r,disabled:i,pending:a,focusSignal:o,attachments:s,onAttachmentsChange:c,steps:l=[],onRewrite:u,rewriting:d=!1,slashSelection:f,onSlashSelectionChange:p,routeOverride:m=`auto`,onRouteOverrideChange:h}){let{t:g}=Z(),_=(0,I.useRef)(null),v=(0,I.useRef)(null),y=(0,I.useRef)(!1),[b,x]=(0,I.useState)(0),[S,C]=(0,I.useState)(!1),[w,T]=(0,I.useState)(``),[E,D]=(0,I.useState)(0),[ee,O]=(0,I.useState)(!1);(0,I.useEffect)(()=>{if(!a&&!d)return;let e=setInterval(()=>x(e=>e+1),1e3);return()=>clearInterval(e)},[a,d]),(0,I.useEffect)(()=>{o&&!i&&_.current?.focus()},[o,i]);let te=Jn(l),ne=Date.now()/1e3,k=Rt(e).slice(0,8),re=k.length>0&&!S,A=re?ha(f,k.length):0,j=re?k[A]:void 0,ie=e=>{let n=k[e];n&&(t(Bt(n)),n.argument===`none`&&C(!0),p(0),_.current?.focus())},ae=async()=>{if(!(!e.trim()||a||i||d||y.current)){y.current=!0;try{await n(e.trim(),s)&&(p(0),C(!1),T(``))}finally{y.current=!1}}},M=e=>{if(!e.length||i||a||y.current)return;let{accepted:t,issues:n}=Da(s,e);t.length&&c([...s,...t]),T(n.map(e=>e.code===`unsupported`?g(`chat.attachUnsupported`,{name:e.fileName}):e.code===`too-large`?g(`chat.attachTooLarge`,{name:e.fileName,size:fi(e.limitBytes)}):e.code===`too-many`?g(`chat.attachTooMany`,{count:e.limitCount}):g(`chat.attachTotalTooLarge`,{size:fi(e.limitBytes)})).join(` `))},oe=(e,t)=>{ka(e.dataTransfer)&&(e.preventDefault(),D(e=>Math.max(0,e+t)))};return(0,X.jsxs)(`div`,{className:`conversation-composer flex flex-col ${E>0?`rounded-3xl ring-2 ring-manager/60`:``}`,"data-compact":!ee&&!e.trim()&&!s.length&&!a&&!d&&!w&&!E,onFocusCapture:()=>O(!0),onBlurCapture:e=>O(e.currentTarget.contains(e.relatedTarget)),onDragEnter:e=>oe(e,1),onDragOver:e=>oe(e,0),onDragLeave:e=>oe(e,-1),onDrop:e=>{ka(e.dataTransfer)&&(e.preventDefault(),D(0),M(Aa(e.dataTransfer)))},children:[a?(0,X.jsxs)(`div`,{className:`px-3 py-2`,children:[te.length?(0,X.jsx)(`ol`,{className:`mt-1.5 space-y-0.5`,children:te.map((e,t)=>{let n=t===te.length-1&&!e.endedTs,r=Xn(Yn(e,ne));return(0,X.jsxs)(`li`,{className:`flex min-w-0 items-baseline gap-2 text-xs`,children:[(0,X.jsx)(`span`,{className:`shrink-0 font-mono ${n?`text-manager`:`text-ok`}`,children:n?Un(b):`✓`}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono ${n?`text-ink`:`text-ink-faint`}`,title:e.detail||e.label,children:e.label}),r?(0,X.jsx)(`span`,{className:`shrink-0 font-mono tabular-nums text-ink-faint`,children:r}):null]},e.id)})}):null,(0,X.jsx)(`div`,{className:`mt-1 text-xs text-ink-faint`,children:g(`chat.stopWaitingHint`)})]}):null,re?(0,X.jsx)(_a,{query:e,selected:A,onSelect:ie}):null,s.length||w||E>0?(0,X.jsxs)(`div`,{className:`px-3 py-2`,children:[E>0?(0,X.jsx)(`div`,{className:`mb-2 text-xs text-manager`,children:g(`chat.attachDrop`)}):null,(0,X.jsx)(`div`,{className:`map-attachment-tray`,children:s.map((e,t)=>(0,X.jsx)(ja,{file:e,removeLabel:g(`chat.attachRemove`,{name:e.name}),onRemove:()=>{c(s.filter(t=>t!==e)),T(``)}},`${e.name}:${e.lastModified}:${t}`))}),(0,X.jsx)(`div`,{className:`text-xs ${w?`text-err`:`text-ink-faint`}`,children:w||g(`chat.attachHint`,{count:5,perFile:fi(10485760),total:fi(26214400)})})]}):null,(0,X.jsx)(po,{value:e,onChange:e=>{t(e),p(0),C(!1)},inputRef:_,fileInputRef:v,onFiles:e=>{M(Array.from(e.target.files??[])),e.target.value=``},onSend:()=>void ae(),onCancel:r,pending:a,disabled:i,inputProps:{onPaste:e=>{let t=Aa(e.clipboardData);t.length&&(e.preventDefault(),M(t))},onKeyDown:t=>{sa(t)||mo(t,{value:e,disabled:i,pending:a,rewriting:d,onRewrite:u})||(re?t.key===`ArrowDown`||t.key===`ArrowUp`?(t.preventDefault(),p(ha(A+(t.key===`ArrowDown`?1:-1),k.length))):t.key===`Tab`||t.key===`Enter`&&!t.shiftKey?(t.preventDefault(),ie(A)):t.key===`Escape`&&(t.preventDefault(),C(!0)):t.key===`Escape`&&a?(t.preventDefault(),r()):t.key===`Enter`&&!t.shiftKey&&(t.preventDefault(),ae()))},"aria-label":g(`chat.messageArgus`),"aria-keyshortcuts":`Control+R Meta+R`,"aria-controls":re?ma:void 0,"aria-expanded":re,"aria-activedescendant":j?ga(j.id):void 0,placeholder:g(i?`chat.selectSession`:`chat.placeholder`)},controls:(0,X.jsxs)(X.Fragment,{children:[h?(0,X.jsxs)(`select`,{value:m,onChange:e=>h(e.target.value),disabled:i||a,title:g(`chat.routeHint`),"aria-label":g(`chat.routeLabel`),children:[(0,X.jsx)(`option`,{value:`task`,children:g(`chat.routeTask`)}),(0,X.jsx)(`option`,{value:`auto`,children:g(`chat.routeAuto`)}),(0,X.jsx)(`option`,{value:`chat`,children:g(`chat.routeChat`)})]}):null,u?(0,X.jsx)(`button`,{type:`button`,onClick:()=>u(e.trim()),disabled:i||a||d||!e.trim(),title:`Ctrl/⌘+R · ${g(`chat.rewriteHint`)}`,"aria-label":g(`chat.rewriteLabel`),"aria-keyshortcuts":`Control+R Meta+R`,children:d?`${Un(b)} ${g(`chat.rewriting`)}`:g(`chat.rewrite`)}):null]})})]})}function go({open:e,onClose:t,children:n,label:r,width:i=`max-w-2xl`,align:a=`center`,viewport:o=!1,showClose:s=!0,style:c}){let{t:l}=Z(),u=(0,I.useRef)(null),d=(0,I.useRef)(null),f=(0,I.useRef)(t);return f.current=t,ci(u,(t,n)=>{if(!(!e||!u.current||!d.current)){if(n){t.set([d.current,u.current],{clearProps:`all`});return}t.timeline({defaults:{overwrite:`auto`}}).fromTo(d.current,{autoAlpha:0},{autoAlpha:1,duration:.14,ease:`power1.out`},0).fromTo(u.current,{autoAlpha:0,y:a===`top`?-6:8,scale:.992},{autoAlpha:1,y:0,scale:1,duration:.2,ease:`power3.out`,clearProps:`transform,opacity,visibility`},.03)}},[e,a]),(0,I.useEffect)(()=>{if(!e)return;let t=document.activeElement instanceof HTMLElement?document.activeElement:null,n=window.requestAnimationFrame(()=>{(u.current?.querySelector(`[data-autofocus]`)??u.current?.querySelector(`input:not([disabled]), textarea:not([disabled]), select:not([disabled]), button:not([disabled]), [href], [tabindex]:not([tabindex="-1"])`)??u.current)?.focus()}),r=e=>{if(e.key===`Escape`){e.preventDefault(),f.current();return}if(e.key!==`Tab`||!u.current)return;let t=Array.from(u.current.querySelectorAll(`input:not([disabled]), textarea:not([disabled]), select:not([disabled]), button:not([disabled]), [href], [tabindex]:not([tabindex="-1"])`)).filter(e=>e.getAttribute(`aria-hidden`)!==`true`);if(t.length===0){e.preventDefault(),u.current.focus();return}let n=t[0],r=t[t.length-1];e.shiftKey&&(document.activeElement===n||!u.current.contains(document.activeElement))?(e.preventDefault(),r.focus()):!e.shiftKey&&document.activeElement===r&&(e.preventDefault(),n.focus())};return window.addEventListener(`keydown`,r),()=>{window.cancelAnimationFrame(n),window.removeEventListener(`keydown`,r),t?.isConnected&&t.focus()}},[e]),e?(0,X.jsxs)(`div`,{className:`fixed inset-0 z-50 flex ${a===`top`?`items-start pt-3 sm:pt-14`:`items-center`} justify-center ${o?`p-0`:`p-3 sm:p-4`}`,onPointerDown:t,children:[(0,X.jsx)(`div`,{ref:d,className:`modal-scrim absolute inset-0`}),(0,X.jsxs)(`div`,{ref:u,role:`dialog`,"aria-modal":`true`,"aria-label":r,tabIndex:-1,style:c,className:`brand-modal glass-panel glass-panel--raised relative z-10 w-full overscroll-contain ${i} scroll-thin ${o?`flex h-[100dvh] max-h-[100dvh] flex-col overflow-hidden rounded-none`:`max-h-[calc(100dvh-1.5rem)] overflow-x-hidden overflow-y-auto rounded-2xl sm:max-h-[88dvh]`}`,onPointerDown:e=>e.stopPropagation(),children:[!o&&s?(0,X.jsx)(`button`,{type:`button`,"data-modal-close":!0,onClick:t,"aria-label":l(`common.close`),className:`modal-close`,children:(0,X.jsx)(`svg`,{viewBox:`0 0 16 16`,"aria-hidden":`true`,children:(0,X.jsx)(`path`,{d:`m4 4 8 8m0-8-8 8`})})}):null,n]})]}):null}function _o({title:e,sub:t}){return(0,X.jsxs)(`div`,{className:`px-6 pb-3 pr-14 pt-5`,children:[(0,X.jsx)(`h2`,{className:`text-base font-semibold tracking-[-0.01em] text-ink`,children:e}),t&&(0,X.jsx)(`p`,{className:`mt-1 text-sm text-ink-faint`,children:t})]})}function vo(e,t,n,r=`en`){return e.map(e=>({id:`command-${e.id}`,label:da(e,r),hint:`${e.name}${e.arg?` ${e.arg}`:``}`,group:fa(e,r),keywords:[e.name,...e.aliases??[]].join(` `),run:()=>Ft(e)?n(`${e.name} `):t(e.name)}))}function yo(e,t){let n=t.trim().toLowerCase().split(/\s+/).filter(Boolean);return n.length?e.filter(e=>{let t=`${e.label} ${e.group} ${e.hint??``} ${e.keywords??``}`.toLowerCase();return n.every(e=>t.includes(e))}):e}function bo({open:e,onClose:t,items:n}){let{t:r}=Z(),[i,a]=(0,I.useState)(``),[o,s]=(0,I.useState)(0),c=(0,I.useRef)(null),l=(0,I.useRef)(null);(0,I.useEffect)(()=>{e&&(a(``),s(0),setTimeout(()=>c.current?.focus(),0))},[e]);let u=(0,I.useMemo)(()=>yo(n,i),[i,n]);(0,I.useEffect)(()=>{o>=u.length&&s(Math.max(0,u.length-1))},[u.length,o]),(0,I.useEffect)(()=>{l.current?.scrollIntoView({block:`nearest`})},[e,i,o]);let d=e=>{e&&(t(),e.run())},f=e=>{sa(e)||(e.key===`ArrowDown`?(e.preventDefault(),u.length&&s(e=>Math.min(u.length-1,e+1))):e.key===`ArrowUp`?(e.preventDefault(),s(e=>Math.max(0,e-1))):e.key===`Enter`&&(e.preventDefault(),d(u[o])))},p=[];for(let e of u){let t=p.find(t=>t.name===e.group);t||(t={name:e.group,items:[]},p.push(t)),t.items.push(e)}let m=-1;return(0,X.jsxs)(go,{open:e,onClose:t,label:r(`help.palette`),width:`max-w-xl`,align:`top`,children:[(0,X.jsx)(`div`,{className:`border-b border-line px-4 py-3`,children:(0,X.jsx)(`input`,{ref:c,value:i,onChange:e=>a(e.target.value),onKeyDown:f,placeholder:r(`palette.placeholder`),role:`combobox`,"aria-expanded":e,"aria-autocomplete":`list`,"aria-controls":`command-palette-results`,"aria-activedescendant":u[o]?`palette-${u[o].id}`:void 0,className:`w-full bg-transparent font-mono text-sm text-ink outline-none placeholder:text-ink-faint`})}),(0,X.jsxs)(`div`,{id:`command-palette-results`,role:`listbox`,className:`max-h-[52vh] overflow-y-auto scroll-thin py-1.5`,children:[u.length===0&&(0,X.jsx)(`div`,{className:`px-4 py-6 text-center text-xs text-ink-faint`,children:r(`palette.noMatches`)}),p.map(e=>(0,X.jsxs)(`div`,{className:`mb-1`,children:[(0,X.jsx)(`div`,{className:`px-4 py-1 text-[10px] font-semibold uppercase tracking-wider text-ink-faint`,children:e.name}),e.items.map(e=>{m++;let t=m===o;return(0,X.jsxs)(`button`,{id:`palette-${e.id}`,ref:t?l:void 0,role:`option`,"aria-selected":t,onMouseEnter:()=>s(u.indexOf(e)),onClick:()=>d(e),className:`flex w-full items-center justify-between px-4 py-1.5 text-left text-sm transition-colors ${t?`bg-blue-deep/20 text-ink`:`text-ink-dim hover:bg-panel/60`}`,children:[(0,X.jsx)(`span`,{children:e.label}),e.hint&&(0,X.jsx)(`span`,{className:`font-mono text-[11px] text-ink-faint`,children:e.hint})]},e.id)})]},e.name))]}),(0,X.jsxs)(`div`,{className:`flex items-center gap-3 border-t border-line px-4 py-1.5 text-[10px] text-ink-faint`,children:[(0,X.jsx)(`span`,{children:r(`palette.navigate`)}),(0,X.jsx)(`span`,{children:r(`palette.run`)}),(0,X.jsx)(`span`,{children:r(`palette.close`)})]})]})}var xo=[{keys:`⌘K / Ctrl+K`,desc:`help.palette`},{keys:`⌘B / Ctrl+B`,desc:`help.sessions`},{keys:`⌘J / Ctrl+J`,desc:`help.managerChat`},{keys:`⌘R / Ctrl+R`,desc:`help.rewrite`},{keys:`⌘T / Ctrl+T`,desc:`help.reasoning`},{keys:`⌘. / Ctrl+.`,desc:`help.kiosk`},{keys:`/`,desc:`help.composer`},{keys:`↵ Enter`,desc:`help.send`},{keys:`Shift+Enter`,desc:`help.newline`},{keys:`?`,desc:`help.thisHelp`},{keys:`Esc`,desc:`help.escape`}];function So({open:e,onClose:t}){let{locale:n,t:r}=Z(),i=pa(Nt,n);return(0,X.jsxs)(go,{open:e,onClose:t,label:r(`help.title`),width:`max-w-2xl`,children:[(0,X.jsx)(_o,{title:r(`help.title`)}),(0,X.jsxs)(`div`,{className:`max-h-[70dvh] overflow-y-auto scroll-thin`,children:[(0,X.jsx)(`div`,{className:`p-4`,children:xo.map(e=>(0,X.jsxs)(`div`,{className:`flex items-center justify-between py-1.5`,children:[(0,X.jsx)(`span`,{className:`text-sm text-ink-dim`,children:r(e.desc)}),(0,X.jsx)(`kbd`,{className:`rounded border border-line bg-surface px-2 py-0.5 font-mono text-[11px] text-ink`,children:e.keys})]},e.keys))}),(0,X.jsxs)(`div`,{className:`border-t border-line px-4 pb-4 pt-3`,children:[(0,X.jsx)(`p`,{className:`mb-3 text-xs font-semibold uppercase tracking-wider text-ink-faint`,children:r(`help.commands`)}),i.map(e=>(0,X.jsxs)(`div`,{className:`mb-4`,children:[(0,X.jsx)(`p`,{className:`mb-1 text-[10px] font-semibold uppercase tracking-wider text-ink-faint`,children:e.group}),e.rows.map(e=>(0,X.jsxs)(`div`,{className:`flex items-start justify-between gap-4 py-1`,children:[(0,X.jsx)(`code`,{className:`shrink-0 font-mono text-xs text-ink`,children:e.label}),(0,X.jsx)(`span`,{className:`text-right text-xs text-ink-dim`,children:e.desc})]},e.label))]},e.group))]})]})]})}function Co({sid:e,config:t,onSaved:n}){let{locale:r}=Z(),i=r===`zh-CN`,a=t.roles.find(e=>e.role===`engineer`),o=new Map(t.operator_knobs.map(e=>[e.name,e.value])),s=o.get(`ARGUS_SKILL_MAP_MODEL`)||`auto`,c=o.get(`ARGUS_SKILL_MAP_REASONING_EFFORT`)||`auto`,[l,u]=(0,I.useState)(s===`auto`?``:s),[d,f]=(0,I.useState)(!1),[p,m]=(0,I.useState)(``);(0,I.useEffect)(()=>u(s===`auto`?``:s),[s]);let h=async(t,r)=>{if(!d){f(!0),m(``);try{await U.setConfig(e,t,r),await n()}catch(e){m(e instanceof Error?e.message:String(e))}finally{f(!1)}}},g=i?`跟随科研设置`:`Follow research settings`;return(0,X.jsxs)(`section`,{className:`map-model-settings rounded-lg border border-line glass-card p-3`,"aria-label":i?`地图模型`:`Map model`,children:[(0,X.jsx)(`div`,{className:`text-xs font-semibold text-ink`,children:i?`地图模型`:`Map model`}),(0,X.jsx)(`p`,{className:`mt-1 text-xs text-ink-dim`,children:i?`沿用科研 Engineer 的接入与账号。留空即可跟随 Engineer 模型。`:`Uses the research Engineer's runner and account. Leave the model blank to follow Engineer settings.`}),(0,X.jsxs)(`p`,{className:`mt-1 text-xs text-ink-faint`,children:[a?.backend_label,` · `,a?.model||(i?`接入默认模型`:`Runner default model`)]}),(0,X.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-end gap-2`,children:[(0,X.jsxs)(`label`,{className:`min-w-0 flex-1 text-xs text-ink-dim`,children:[i?`摘要模型`:`Summary model`,(0,X.jsx)(`input`,{value:l,onChange:e=>u(e.target.value),disabled:d,placeholder:g,className:`mt-1 h-9 w-full rounded border border-line bg-bg px-2 text-xs text-ink outline-none focus:border-blue`})]}),(0,X.jsx)(`button`,{type:`button`,disabled:d,onClick:()=>void h(`ARGUS_SKILL_MAP_MODEL`,l.trim()||`auto`),className:`h-9 rounded border border-line px-3 text-xs text-ink-dim hover:border-blue disabled:opacity-40`,children:i?`应用`:`Apply`}),s!==`auto`&&(0,X.jsx)(`button`,{type:`button`,disabled:d,onClick:()=>void h(`ARGUS_SKILL_MAP_MODEL`,`auto`),className:`h-9 rounded border border-line px-3 text-xs text-ink-dim hover:border-blue disabled:opacity-40`,children:g})]}),(0,X.jsxs)(`label`,{className:`mt-3 flex items-center gap-3 text-xs text-ink-dim`,children:[i?`思考强度`:`Reasoning effort`,(0,X.jsxs)(`select`,{value:c,disabled:d,onChange:e=>void h(`ARGUS_SKILL_MAP_REASONING_EFFORT`,e.target.value),className:`h-9 rounded border border-line bg-bg px-2 text-xs text-ink outline-none focus:border-blue`,children:[(0,X.jsx)(`option`,{value:`auto`,children:g}),[[`low`,`低`],[`medium`,`中`],[`high`,`高`],[`xhigh`,`很高`],[`max`,`最高`]].map(([e,t])=>(0,X.jsx)(`option`,{value:e,children:i?t:e},e))]})]}),p&&(0,X.jsx)(`p`,{role:`alert`,className:`mt-2 text-xs text-err`,children:p})]})}var wo=[{name:`ARGUS_SKILL_MAX_ACTIVE_DAEMONS`,group:`Limits`,label:`Active daemon limit`,description:`Maximum background sessions running on this host.`},{name:`ARGUS_SKILL_UNPRICED_COST_POLICY`,group:`Safety`,label:`Unpriced calls`,description:`Whether calls with unresolved pricing are blocked or allowed.`},{name:`ARGUS_SKILL_SAFE_MODE`,group:`Safety`,label:`Safe mode`,description:`Enable extra-conservative runtime guardrails.`},{name:`ARGUS_SKILL_ENABLE_TELEGRAM`,group:`Interface`,label:`Telegram`,description:`Enable the Telegram notification bridge.`},{name:`ARGUS_SKILL_SHOW_REASONING`,group:`Interface`,label:`Show reasoning`,description:`Stream role reasoning into the cockpit activity view.`}];function To(e){let t=new Map(e.map(e=>[e.name,e]));return wo.flatMap(e=>{let n=t.get(e.name);return n?[{...n,group:e.group,label:e.label,doc:e.description}]:[]})}function Eo(e,t){let n=new URL(e),r=n.protocol===`https:`?`wss:`:`ws:`,i=encodeURIComponent(t);return{webApi:`${n.origin}/api`,eventStream:`${r}//${n.host}/api/projects/${i}/stream`,daemon:`local process · events.jsonl · no TCP port`}}var Do=[{value:`copilot`,label:`settings.backendLabel.copilot`},{value:`codex`,label:`settings.backendLabel.codex`},{value:`claude`,label:`settings.backendLabel.claude`},{value:`cursor`,label:`settings.backendLabel.cursor`},{value:`opencode`,label:`settings.backendLabel.opencode`},{value:`pi`,label:`settings.backendLabel.pi`},{value:`grok`,label:`settings.backendLabel.grok`},{value:`qoder`,label:`settings.backendLabel.qoder`},{value:`dsh`,label:`settings.backendLabel.dsh`}],Oo={copilot:`copilot`,codex:`codex`,claude:`claude`,cursor:`cursor`,opencode:`opencode`,pi:`pi`,grok:`grok`,qoder:`qoder`,dsh:`dsh`};function ko(e){return Oo[e]??``}function Ao(e,t){let n=ko(e);return n?t(`settings.backendLabel.${n}`):e}function jo(e){return e?.operator_knobs.find(e=>e.name===`ARGUS_SKILL_RUNNER_BACKEND`)?.value??e?.roles[0]?.backend??``}var Mo=[{alias:`global_daily_cap`,env:`ARGUS_SKILL_GLOBAL_DAILY_CAP_USD`,label:`settings.budget.global`,unit:`settings.unit.usd`,step:`0.1`},{alias:`codex_daily_requests`,env:`ARGUS_SKILL_CODEX_DAILY_CALL_CAP`,label:`settings.budget.codex`,unit:`settings.unit.calls`,step:`1`},{alias:`copilot_daily_requests`,env:`ARGUS_SKILL_COPILOT_DAILY_CALL_CAP`,label:`settings.budget.copilot`,unit:`settings.unit.calls`,step:`1`},{alias:`copilot_daily_premium`,env:`ARGUS_SKILL_COPILOT_DAILY_PREMIUM_CAP`,label:`settings.budget.premium`,unit:`settings.unit.requests`,step:`1`}],No={ARGUS_SKILL_MAX_ACTIVE_DAEMONS:{label:`settings.knob.activeDaemons`,doc:`settings.knob.activeDaemonsDoc`},ARGUS_SKILL_UNPRICED_COST_POLICY:{label:`settings.knob.unpricedCalls`,doc:`settings.knob.unpricedCallsDoc`},ARGUS_SKILL_SAFE_MODE:{label:`settings.knob.safeMode`,doc:`settings.knob.safeModeDoc`},ARGUS_SKILL_ENABLE_TELEGRAM:{label:`settings.knob.telegram`,doc:`settings.knob.telegramDoc`},ARGUS_SKILL_SHOW_REASONING:{label:`settings.knob.showReasoning`,doc:`settings.knob.showReasoningDoc`}},Po={Limits:`settings.group.limits`,Safety:`settings.group.safety`,Interface:`settings.group.interface`},Fo={manager:`settings.role.managerDoc`,planner:`settings.role.plannerDoc`,engineer:`settings.role.engineerDoc`,reviewer:`settings.role.reviewerDoc`,curator:`settings.role.curatorDoc`};function Io(e,t){let n=e.trim();return n===`not applicable for this model`?t(`settings.source.notApplicable`):n.startsWith(`capability vault`)?t(`settings.source.vaultDefault`):n.startsWith(`default`)?t(`settings.source.default`):n.startsWith(`persisted:`)||n===`persisted`?t(`settings.source.saved`):n.startsWith(`ARGUS_SKILL_`)||n===`env`?t(`settings.source.environment`):n.startsWith(`global:`)?t(`settings.source.hostConfig`):t(`settings.source.other`)}function Lo(e,t){let n=e.value.trim().toLowerCase();if(e.name===`ARGUS_SKILL_UNPRICED_COST_POLICY`){if(n===`block`)return t(`settings.value.block`);if(n===`allow`)return t(`settings.value.allow`)}return[`ARGUS_SKILL_SAFE_MODE`,`ARGUS_SKILL_ENABLE_TELEGRAM`,`ARGUS_SKILL_SHOW_REASONING`].includes(e.name)?t([`1`,`true`,`on`,`yes`].includes(n)?`settings.value.enabled`:`settings.value.disabled`):e.value}function Ro(e,t){let n={low:`low`,medium:`medium`,high:`high`,xhigh:`xhigh`}[e.toLowerCase()];return n?t(`settings.effort.${n}`):e}function zo({message:e,retrying:t,onRetry:n,t:r}){return(0,X.jsxs)(`div`,{role:`alert`,className:`flex flex-col items-center gap-3 px-4 py-8 text-center`,children:[(0,X.jsx)(`p`,{className:`text-sm text-err`,children:e}),(0,X.jsx)(`button`,{type:`button`,onClick:n,disabled:t,className:`rounded-md border border-err/40 px-3 py-1.5 text-xs font-medium text-err hover:bg-err/10 disabled:opacity-40`,children:r(t?`common.loading`:`common.retry`)})]})}function Bo({sid:e,open:t,onClose:n}){let{t:r}=Z(),{data:i,isLoading:a,isError:o,isFetching:s,refetch:c}=xr(e,t),l=!!(i&&(i.recommended||i.checks.length||i.log_tail.trim()));return(0,X.jsxs)(go,{open:t,onClose:n,label:r(`doctor.title`),width:`max-w-3xl`,children:[(0,X.jsx)(_o,{title:r(`doctor.title`),sub:r(`doctor.subtitle`)}),(0,X.jsxs)(`div`,{className:`p-4`,children:[a&&(0,X.jsx)(`div`,{className:`flex justify-center py-8`,children:(0,X.jsx)(bi,{})}),!a&&o&&(0,X.jsx)(zo,{message:r(`doctor.loadError`),retrying:s,onRetry:()=>void c(),t:r}),!a&&!o&&!l&&(0,X.jsx)(xi,{children:r(`doctor.empty`)}),!a&&!o&&i?.recommended&&(0,X.jsxs)(`div`,{className:`mb-4 rounded-lg border border-gold/40 bg-gold/5 p-3`,children:[(0,X.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-wide text-gold`,children:r(`doctor.recommended`)}),(0,X.jsx)(`div`,{className:`mt-1 text-sm text-ink`,children:i.recommended.name}),(0,X.jsx)(`div`,{className:`mt-0.5 text-xs text-ink-dim`,children:i.recommended.detail}),i.recommended.fix&&(0,X.jsx)(`pre`,{className:`mt-2 whitespace-pre-wrap break-words rounded bg-bg p-2 font-mono text-xs text-blue-sky`,children:i.recommended.fix})]}),!a&&!o&&(0,X.jsx)(`div`,{className:`space-y-1.5`,children:(i?.checks??[]).map((e,t)=>(0,X.jsxs)(`div`,{className:`flex items-start gap-2 rounded-md border border-line/60 px-3 py-2`,children:[(0,X.jsx)(`span`,{className:e.ok?`text-ok`:`text-err`,children:e.ok?`✓`:`✗`}),(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsx)(`div`,{className:`text-xs font-medium text-ink`,children:e.name}),e.detail&&(0,X.jsx)(`div`,{className:`mt-0.5 text-[11px] text-ink-dim`,children:e.detail}),!e.ok&&e.fix&&(0,X.jsx)(`pre`,{className:`mt-1 whitespace-pre-wrap break-words rounded bg-bg p-1.5 font-mono text-xs text-ink-dim`,children:e.fix})]})]},t))}),!a&&!o&&i?.log_tail&&(0,X.jsxs)(`div`,{className:`mt-4`,children:[(0,X.jsx)(`div`,{className:`mb-1 text-[10px] font-semibold uppercase tracking-wide text-ink-faint`,children:r(`doctor.daemonLog`)}),(0,X.jsx)(`pre`,{className:`max-h-48 overflow-x-hidden overflow-y-auto whitespace-pre-wrap break-words rounded-lg bg-bg p-3 font-mono text-xs leading-relaxed text-ink-dim scroll-thin`,children:i.log_tail})]})]})]})}function Vo({sid:e,open:t,onClose:n}){let{t:r}=Z(),i=oe(),{data:a,isLoading:s,isError:c,isFetching:l,refetch:u}=Sr(e,t),[d,f]=(0,I.useState)(!1),[p,h]=(0,I.useState)(``),[g,_]=(0,I.useState)(!1),[v,y]=(0,I.useState)(``),[b,x]=(0,I.useState)(!1),[C,w]=(0,I.useState)(``),[E,D]=(0,I.useState)(``),[ee,O]=(0,I.useState)(!1),[te,ne]=(0,I.useState)(``),[k,re]=(0,I.useState)(!1),[A,j]=(0,I.useState)(``),[ie,ae]=(0,I.useState)({});(0,I.useEffect)(()=>{t||f(!1)},[t]),(0,I.useEffect)(()=>{if(!t||!a)return;h(a.operator_knobs.find(e=>e.name===`ARGUS_SKILL_MODEL`)?.value??``);let e=new Map(a.operator_knobs.map(e=>[e.name,e.value]));ae(Object.fromEntries(Mo.map(t=>[t.alias,e.get(t.env)??``])))},[a,t]);let M=async()=>{await u(),await i.invalidateQueries({queryKey:[`map-copy`]})},se=jo(a),N=async t=>{if(!g){_(!0),y(``),x(!1);try{await U.setConfig(e,`ARGUS_SKILL_RUNNER_BACKEND`,t),await M(),y(r(`settings.backendSwitched`,{backend:Ao(t,r)}))}catch(e){x(!0),y(e instanceof Error?e.message:String(e))}finally{_(!1)}}},ce=async()=>{if(!g){_(!0),y(``),x(!1);try{await U.setConfig(e,`ARGUS_SKILL_MODEL`,p.trim()||`auto`),await M(),y(r(`settings.applied`))}catch(e){x(!0),y(e instanceof Error?e.message:String(e))}finally{_(!1)}}},le=async()=>{if(!k){re(!0),j(``);try{let t=Object.fromEntries(Mo.map(e=>{let t=String(ie[e.alias]??``).trim();if(!t)throw Error(r(`settings.required`,{field:r(e.label)}));return[e.alias,t]}));await U.setBudgets(e,t),await M(),j(r(`settings.budgetSaved`))}catch(e){j(e instanceof Error?e.message:String(e))}finally{re(!1)}}},ue=async t=>{if(t.preventDefault(),!(!C.trim()||!E.trim()||ee)){O(!0),ne(``);try{await U.setConfig(e,C.trim(),E.trim()),await M(),ne(r(`settings.applied`))}catch(e){ne(e instanceof Error?e.message:String(e))}finally{O(!1)}}},de=To(a?.operator_knobs??[]).reduce((e,t)=>((e[t.group]??=[]).push(t),e),{}),fe=Eo(window.location.origin,e),P=!!(a&&(a.roles.length||a.operator_knobs.length));return(0,X.jsxs)(go,{open:t,onClose:n,label:r(`common.settings`),width:`max-w-4xl`,children:[(0,X.jsx)(_o,{title:r(`common.settings`),sub:r(`settings.subtitle`)}),(0,X.jsxs)(`div`,{className:`p-4`,children:[s&&(0,X.jsx)(`div`,{className:`flex justify-center py-8`,children:(0,X.jsx)(bi,{})}),!s&&c&&(0,X.jsx)(zo,{message:r(`settings.loadError`),retrying:l,onRetry:()=>void u(),t:r}),!s&&!c&&!P&&(0,X.jsx)(xi,{children:r(`settings.empty`)}),!s&&!c&&P&&a&&(0,X.jsxs)(`div`,{className:`space-y-4`,children:[(0,X.jsxs)(`section`,{className:`rounded-lg border border-line glass-card p-3`,children:[(0,X.jsx)(`div`,{className:`mb-2 text-[10px] font-semibold uppercase tracking-wide text-ink-faint`,children:r(`settings.quickConfig`)}),(0,X.jsxs)(`label`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(`span`,{className:`w-12 shrink-0 text-[10px] text-ink-faint`,children:r(`settings.backend`)}),(0,X.jsxs)(`select`,{value:ko(se),disabled:g,onChange:e=>void N(e.target.value),className:`h-8 min-w-44 rounded border border-line bg-bg px-2 text-xs text-ink outline-none focus:border-blue disabled:opacity-40`,children:[ko(se)?null:(0,X.jsx)(`option`,{value:``,disabled:!0,children:se?r(`settings.backendUnsupported`,{backend:se}):r(`settings.backendUnavailable`)}),Do.map(e=>(0,X.jsx)(`option`,{value:e.value,children:r(e.label)},e.value))]})]}),(0,X.jsxs)(`div`,{className:`mt-2 flex items-center gap-2`,children:[(0,X.jsx)(`span`,{className:`w-12 shrink-0 text-[10px] text-ink-faint`,children:r(`settings.model`)}),(0,X.jsx)(`input`,{value:p,onChange:e=>h(e.target.value),placeholder:r(`settings.modelPlaceholder`),className:`h-8 min-w-0 flex-1 rounded border border-line bg-bg px-2 font-mono text-xs text-ink outline-none focus:border-blue`}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>void ce(),disabled:g,className:`h-8 shrink-0 rounded border border-line/70 px-2.5 text-xs font-medium text-ink-dim hover:border-blue/50 disabled:opacity-40`,children:r(`settings.applyModel`)})]}),v&&(0,X.jsx)(`div`,{role:b?`alert`:`status`,className:`mt-1.5 text-[10px] ${b?`text-err`:`text-ink-dim`}`,children:v})]}),(0,X.jsx)(Co,{sid:e,config:a,onSaved:M}),(0,X.jsxs)(`section`,{className:`rounded-lg border border-gold/40 bg-gold/5 p-3`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-wide text-gold`,children:r(`settings.budgetTitle`)}),(0,X.jsx)(`p`,{className:`mt-0.5 text-[10px] text-ink-faint`,children:r(`settings.budgetHint`)})]}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>void le(),disabled:k,title:r(`settings.saveBudgets`),"aria-label":r(`settings.saveBudgets`),className:`flex h-9 w-9 items-center justify-center rounded border border-blue/35 bg-blue/8 text-xs font-semibold text-blue hover:border-blue-deep hover:bg-blue-deep hover:text-white disabled:opacity-40`,children:k?`…`:(0,X.jsx)(o,{icon:m})})]}),(0,X.jsx)(`div`,{className:`mt-3 grid gap-2 sm:grid-cols-2 lg:grid-cols-3`,children:Mo.map(e=>(0,X.jsxs)(`label`,{className:`rounded border border-line/70 bg-bg/60 p-2`,children:[(0,X.jsx)(`span`,{className:`block text-[10px] text-ink-faint`,children:r(e.label)}),(0,X.jsxs)(`div`,{className:`mt-1 flex items-center gap-2`,children:[(0,X.jsx)(`input`,{type:`number`,min:`0`,step:e.step,value:ie[e.alias]??``,onChange:t=>ae(n=>({...n,[e.alias]:t.target.value})),className:`h-8 min-w-0 flex-1 bg-transparent font-mono text-sm text-ink outline-none`}),(0,X.jsx)(`span`,{className:`text-[9px] text-ink-faint`,children:r(e.unit)})]})]},e.alias))}),A?(0,X.jsx)(`div`,{className:`mt-2 text-xs text-ink-dim`,children:A}):null]}),(0,X.jsxs)(`section`,{className:`overflow-hidden rounded-lg border border-line bg-surface/50`,children:[(0,X.jsxs)(`button`,{type:`button`,"aria-expanded":d,"aria-controls":`config-advanced-settings`,onClick:()=>f(e=>!e),className:`flex w-full items-center justify-between gap-3 px-3 py-3 text-left hover:bg-bg/30`,children:[(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`span`,{className:`block text-xs font-semibold text-ink`,children:r(`settings.advanced`)}),(0,X.jsx)(`span`,{className:`mt-0.5 block text-[10px] text-ink-faint`,children:r(`settings.advancedHint`)})]}),(0,X.jsx)(o,{icon:T,className:`text-xs text-ink-faint transition-transform ${d?`rotate-180`:``}`})]}),d&&(0,X.jsxs)(`div`,{id:`config-advanced-settings`,className:`space-y-4 border-t border-line/70 p-3`,children:[(0,X.jsxs)(`section`,{className:`rounded-lg border border-line bg-surface p-3`,children:[(0,X.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-wide text-ink-faint`,children:r(`settings.connection`)}),(0,X.jsxs)(`div`,{className:`mt-2 grid gap-2 text-[10px] sm:grid-cols-[100px_minmax(0,1fr)]`,children:[(0,X.jsx)(`span`,{className:`text-ink-faint`,children:r(`settings.webApi`)}),(0,X.jsx)(`code`,{className:`min-w-0 break-all text-ink-dim`,children:fe.webApi}),(0,X.jsx)(`span`,{className:`text-ink-faint`,children:r(`settings.eventStream`)}),(0,X.jsx)(`code`,{className:`min-w-0 break-all text-ink-dim`,children:fe.eventStream}),(0,X.jsx)(`span`,{className:`text-ink-faint`,children:r(`settings.taskDaemon`)}),(0,X.jsx)(`span`,{className:`text-ink-dim`,children:r(`settings.taskDaemonValue`)})]})]}),(0,X.jsxs)(`form`,{onSubmit:e=>void ue(e),className:`rounded-lg border border-blue/30 bg-blue/5 p-3`,children:[(0,X.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-wide text-blue`,children:r(`settings.overrideTitle`)}),(0,X.jsx)(`p`,{className:`mt-0.5 text-[10px] text-ink-faint`,children:r(`settings.overrideHint`)}),(0,X.jsxs)(`div`,{className:`mt-2 grid gap-2 sm:grid-cols-[minmax(0,1fr)_minmax(0,1fr)_auto]`,children:[(0,X.jsx)(`input`,{value:C,onChange:e=>w(e.target.value),placeholder:r(`settings.namePlaceholder`),className:`h-9 rounded border border-line bg-bg px-2 font-mono text-xs text-ink outline-none focus:border-blue`}),(0,X.jsx)(`input`,{value:E,onChange:e=>D(e.target.value),placeholder:r(`settings.valuePlaceholder`),className:`h-9 rounded border border-line bg-bg px-2 font-mono text-xs text-ink outline-none focus:border-blue`}),(0,X.jsx)(`button`,{disabled:ee||!C.trim()||!E.trim(),title:r(`settings.applyAdvanced`),"aria-label":r(`settings.applyAdvanced`),className:`flex h-9 w-9 items-center justify-center rounded border border-blue/35 bg-blue/8 text-xs font-medium text-blue hover:border-blue-deep hover:bg-blue-deep hover:text-white disabled:opacity-40`,children:ee?`…`:(0,X.jsx)(o,{icon:S})})]}),te?(0,X.jsx)(`div`,{className:`mt-2 text-xs text-ink-dim`,children:te}):null]}),a.roles.length>0&&(0,X.jsxs)(`section`,{children:[(0,X.jsx)(`div`,{className:`mb-2 text-[10px] font-semibold uppercase tracking-[0.14em] text-ink-faint`,children:r(`settings.rolesTitle`)}),(0,X.jsx)(`div`,{className:`grid gap-2 sm:grid-cols-2`,children:a.roles.map(e=>(0,X.jsxs)(`div`,{className:`rounded-lg border border-line bg-surface p-3`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,X.jsx)(`div`,{className:`text-xs font-semibold text-ink`,children:e.role===`curator`?r(`settings.role.curator`):Vi(e.role,r)}),(0,X.jsx)(`span`,{className:`text-[10px] text-ink-faint`,children:e.backend_label})]}),(0,X.jsx)(`div`,{className:`mt-2 truncate font-mono text-[11px] text-ink-dim`,title:e.model,children:e.model}),(0,X.jsxs)(`div`,{className:`mt-1 flex items-center gap-2 text-[10px] text-ink-faint`,children:[(0,X.jsx)(`span`,{className:`truncate`,children:Io(e.model_source,r)}),e.reasoning_effort&&(0,X.jsx)(`span`,{className:`ml-auto shrink-0`,style:{color:ft(e.reasoning_effort)},children:Ro(e.reasoning_effort,r)})]}),Fo[e.role]&&(0,X.jsx)(`p`,{className:`mt-2 text-[10px] leading-relaxed text-ink-faint`,children:r(Fo[e.role])})]},e.role))})]}),Object.keys(de).length>0&&(0,X.jsxs)(`section`,{children:[(0,X.jsx)(`div`,{className:`mb-2 text-[10px] font-semibold uppercase tracking-[0.14em] text-ink-faint`,children:r(`settings.rawConfig`)}),Object.entries(de).map(([e,t])=>(0,X.jsxs)(`div`,{className:`mt-3 first:mt-0`,children:[(0,X.jsx)(`div`,{className:`mb-1.5 text-[10px] font-semibold uppercase tracking-[0.14em] text-ink-faint`,children:r(Po[e])}),(0,X.jsx)(`div`,{className:`overflow-hidden rounded-lg border border-line`,children:t.map((e,t)=>{let n=No[e.name],i=Lo(e,r);return(0,X.jsxs)(`div`,{className:`grid gap-1 px-3 py-2.5 sm:grid-cols-[minmax(0,1fr)_auto] ${t?`border-t border-line/60`:``}`,children:[(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsx)(`div`,{className:`text-xs font-medium text-ink-dim`,children:r(n.label)}),(0,X.jsx)(`code`,{className:`mt-0.5 block break-all text-[9px] text-ink-faint`,children:e.name}),(0,X.jsx)(`div`,{className:`mt-1 text-[10px] leading-relaxed text-ink-faint`,children:r(n.doc)})]}),(0,X.jsxs)(`div`,{className:`text-left sm:text-right`,children:[(0,X.jsxs)(`div`,{className:`text-[11px] text-ink`,children:[i,i!==e.value&&(0,X.jsxs)(`code`,{className:`ml-1 text-[9px] text-ink-faint`,children:[`(`,e.value,`)`]})]}),(0,X.jsx)(`div`,{className:`mt-0.5 text-[9px] text-ink-faint`,children:Io(e.source,r)})]})]},e.name)})})]},e))]}),(0,X.jsxs)(`p`,{className:`text-[10px] text-ink-faint`,children:[r(`settings.footer`),` `,(0,X.jsx)(`code`,{children:`argus-skill --config-help`}),`.`]})]})]})]})]})]})}function Ho({sid:e,open:t,onClose:n}){let{t:r}=Z(),{data:i,isLoading:a,refetch:s}=Cr(e,t),[c,l]=(0,I.useState)(``),[u,d]=(0,I.useState)(!1),[f,p]=(0,I.useState)(``);(0,I.useEffect)(()=>{t&&i!=null&&l(i)},[i,t]);let h=async()=>{if(!u){d(!0),p(``);try{await U.setIdentity(e,c),await s(),p(r(`identity.saved`))}catch(e){p(e instanceof Error?e.message:String(e))}finally{d(!1)}}};return(0,X.jsxs)(go,{open:t,onClose:n,label:r(`identity.title`),width:`max-w-2xl`,children:[(0,X.jsx)(_o,{title:r(`identity.title`),sub:r(`identity.subtitle`)}),(0,X.jsxs)(`div`,{className:`max-h-[64vh] overflow-y-auto scroll-thin p-5`,children:[a&&(0,X.jsx)(`div`,{className:`flex justify-center py-8`,children:(0,X.jsx)(bi,{})}),a?null:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`textarea`,{value:c,onChange:e=>l(e.target.value),rows:12,className:`w-full resize-y rounded-lg border border-line bg-bg p-3 font-sans text-sm leading-relaxed text-ink outline-none focus:border-blue`,placeholder:r(`identity.placeholder`)}),(0,X.jsxs)(`div`,{className:`mt-3 flex items-center justify-between`,children:[(0,X.jsx)(`span`,{className:`text-xs text-ink-faint`,children:f}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>void h(),disabled:u||c===(i??``),title:r(`identity.save`),"aria-label":r(`identity.save`),className:`flex h-9 w-9 items-center justify-center rounded border border-blue/35 bg-blue/8 text-xs font-medium text-blue hover:border-blue-deep hover:bg-blue-deep hover:text-white disabled:opacity-40`,children:u?`…`:(0,X.jsx)(o,{icon:m})})]})]})]})]})}function Uo({sid:e,open:t,onClose:n}){let{t:r}=Z(),{data:i,isLoading:a}=wr(e,t),o=i??[];return(0,X.jsxs)(go,{open:t,onClose:n,label:r(`transcript.title`),width:`max-w-2xl`,children:[(0,X.jsx)(_o,{title:r(`transcript.title`),sub:r(`transcript.subtitle`)}),(0,X.jsxs)(`div`,{className:`max-h-[64vh] overflow-y-auto scroll-thin p-4`,children:[a&&(0,X.jsx)(`div`,{className:`flex justify-center py-8`,children:(0,X.jsx)(bi,{})}),!a&&o.length===0&&(0,X.jsx)(xi,{children:r(`transcript.empty`)}),o.map((e,t)=>{let n=e.role===`operator`;return(0,X.jsxs)(`div`,{className:`grid grid-cols-[72px_minmax(0,1fr)] border-b border-line/50 py-2.5 last:border-b-0`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`div`,{className:`font-mono text-[10px] font-semibold uppercase tracking-wide ${n?`text-ink-faint`:`text-blue-sky`}`,children:n?r(`transcript.operator`):`argus`}),(0,X.jsx)(`div`,{className:`mt-0.5 text-[9px] text-ink-faint`,children:li(e.ts)})]}),(0,X.jsx)(`div`,{className:`whitespace-pre-wrap text-sm leading-relaxed text-ink-dim`,children:e.text})]},t)})]})]})}function Wo({questions:e,backlog:t,onAnswer:n,onLocate:r}){let{t:i}=Z(),a=_t(e,t);if(!a.length)return null;let o=a[0];return(0,X.jsxs)(`div`,{className:`mb-2 flex min-h-11 items-center gap-3 rounded-md border border-gold/40 bg-gold/5 px-3 py-2`,children:[(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`div`,{className:`truncate text-xs font-medium text-gold`,children:o.title}),(0,X.jsx)(`div`,{className:`truncate text-xs text-ink-dim`,title:o.reason||o.question,children:o.reason||o.question})]}),a.length>1?(0,X.jsxs)(`span`,{className:`font-mono text-xs text-ink-faint`,children:[`+`,a.length-1]}):null,r?(0,X.jsx)(`button`,{onClick:r,className:`shrink-0 text-xs text-ink-dim hover:text-gold`,children:i(`pending.showOnMap`)}):null,(0,X.jsx)(`button`,{onClick:n,className:`shrink-0 text-xs font-medium text-gold hover:text-gold-soft`,children:i(`pending.reviewRespond`)})]})}function Go({reply:e,open:t,busy:n,onClose:r,onSubmit:i}){let{t:a}=Z(),o=(0,I.useMemo)(()=>e?.options[0]?.id??`custom`,[e]),[s,c]=(0,I.useState)(o),[l,u]=(0,I.useState)(``),[d,f]=(0,I.useState)(``);if((0,I.useEffect)(()=>{t&&(c(o),u(``),f(``))},[o,t,e?.id]),!e)return null;let p=e.options.length===0,m=e.options.find(e=>e.id===s),h=p?!!l.trim():!!(m&&(!m.requires_note||l.trim())),g=()=>{if(!n){if(!h){f(a(`decision.noteRequired`));return}f(``),i(p?`custom`:s,l.trim())}};return(0,X.jsxs)(go,{open:t,onClose:n?()=>void 0:r,label:a(`decision.operator`),width:`max-w-2xl`,children:[(0,X.jsx)(_o,{title:a(`decision.required`),sub:e.title}),(0,X.jsxs)(`div`,{className:`space-y-4 px-5 py-4`,children:[e.reason?(0,X.jsxs)(`section`,{className:`rounded-md border border-gold/30 bg-gold/5 p-3`,children:[(0,X.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-wider text-gold`,children:a(`decision.whyBlocked`)}),(0,X.jsx)(`p`,{className:`mt-1 whitespace-pre-wrap text-sm leading-relaxed text-ink`,children:e.reason})]}):null,e.evidence.length?(0,X.jsxs)(`section`,{children:[(0,X.jsx)(`div`,{className:`mb-2 text-[10px] font-semibold uppercase tracking-wider text-ink-faint`,children:a(`decision.evidence`)}),(0,X.jsx)(`div`,{className:`space-y-2`,children:e.evidence.map((e,t)=>(0,X.jsxs)(`div`,{className:`rounded border border-line/70 bg-bg/40 p-2.5`,children:[(0,X.jsx)(`div`,{className:`text-xs font-medium text-ink`,children:e.label}),e.summary?(0,X.jsx)(`div`,{className:`mt-1 text-xs text-ink-dim`,children:e.summary}):null,e.path?(0,X.jsx)(`div`,{className:`mt-1 break-all font-mono text-[10px] text-blue-sky`,children:e.path}):null]},`${e.path}:${t}`))})]}):null,(0,X.jsx)(`p`,{className:`whitespace-pre-wrap text-sm leading-relaxed text-ink`,children:e.question}),e.options.length?(0,X.jsx)(`div`,{className:`space-y-2`,children:e.options.map(e=>(0,X.jsxs)(`button`,{type:`button`,onClick:()=>{c(e.id),f(``)},disabled:n,className:`w-full rounded-md border p-3 text-left ${s===e.id?`border-blue bg-blue/5`:`border-line bg-bg/30`}`,children:[(0,X.jsx)(`div`,{className:`text-sm font-medium text-ink`,children:e.label}),(0,X.jsx)(`div`,{className:`mt-1 text-xs leading-relaxed text-ink-dim`,children:e.description})]},e.id))}):null,p||m?.requires_note||l?(0,X.jsx)(`textarea`,{"data-autofocus":!0,value:l,onChange:e=>{u(e.target.value),f(``)},onKeyDown:e=>{sa(e)||e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),g())},rows:3,disabled:n,placeholder:a(`decision.notePlaceholder`),className:`w-full resize-y rounded-lg border border-line bg-bg px-3 py-2 text-sm leading-relaxed text-ink outline-none focus:border-blue disabled:opacity-60`}):null,d?(0,X.jsx)(`p`,{role:`alert`,className:`text-xs text-err`,children:d}):null,(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,X.jsx)(`span`,{className:`text-xs text-ink-faint`,children:a(`decision.resumeHint`)}),(0,X.jsxs)(`div`,{className:`flex gap-2`,children:[(0,X.jsx)(`button`,{type:`button`,onClick:r,disabled:n,className:`rounded-md px-3 py-2 text-xs text-ink-dim hover:bg-bg disabled:opacity-50`,children:a(`decision.later`)}),(0,X.jsx)(`button`,{type:`button`,onClick:g,disabled:n,className:`rounded-md border border-blue/35 bg-blue/8 px-3 py-2 text-xs font-medium text-blue hover:border-blue-deep hover:bg-blue-deep hover:text-white disabled:opacity-50`,children:a(n?`decision.applying`:p||s===`custom`?`decision.sendAnswer`:s===`stop`?`decision.stopCampaign`:`decision.useOption`)})]})]})]})]})}function Ko({alert:e}){if(!e)return null;let t=e.tone===`block`,n=e.kind===`budget`;return(0,X.jsxs)(`div`,{className:`mx-3 mt-3 flex items-center gap-2.5 rounded-lg border px-3.5 py-2 text-[13px] ${t?`border-err/50 bg-err/10 text-err`:`border-warn/50 bg-warn/10 text-warn`}`,role:t?`alert`:`status`,children:[(0,X.jsx)(`span`,{className:`shrink-0 font-mono text-xs font-bold leading-none`,children:n?`$`:t?`!`:`i`}),(0,X.jsx)(`span`,{className:`shrink-0 text-[10px] font-semibold uppercase tracking-wide`,children:n?`budget alarm`:t?`action required`:`notice`}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,title:e.text,children:e.text})]})}function qo({html:e,title:t,className:n=``,sid:r,path:i}){return r&&i?(0,X.jsx)(Jo,{sid:r,path:i,html:e,title:t,className:n}):(0,X.jsx)(`iframe`,{title:t,srcDoc:e,sandbox:`allow-scripts`,referrerPolicy:`no-referrer`,className:`min-h-0 w-full flex-1 border-0 bg-white ${n}`})}function Jo({html:e,title:t,className:n,sid:r,path:i}){let{locale:a}=Z(),o=a===`zh-CN`,s=ce({queryKey:[`artifact-html`,r,i,e],queryFn:({signal:e})=>U.artifactPreview(r,i,e),enabled:!!(r&&i),staleTime:3e4,retry:1});return r&&i&&s.isPending?(0,X.jsx)(`div`,{className:`m-auto p-6 text-sm text-ink-dim`,role:`status`,children:o?`正在加载网页和配套资源…`:`Loading the website and its assets…`}):r&&i&&s.isError?(0,X.jsxs)(`div`,{className:`m-auto p-6 text-sm text-err`,role:`alert`,children:[o?`网页预览加载失败,请重试或下载文件。`:`Preview could not load. Retry or download the file.`,(0,X.jsx)(`button`,{type:`button`,className:`ml-3 underline`,onClick:()=>void s.refetch(),children:o?`重试`:`Retry`})]}):(0,X.jsxs)(`div`,{className:`flex min-h-0 w-full flex-1 flex-col ${n}`,children:[!!s.data?.warnings.length&&(0,X.jsx)(`p`,{className:`shrink-0 bg-warn/10 px-3 py-2 text-xs text-warn`,role:`status`,children:o?`部分配套资源无法加载,页面可能不完整。`:`Some linked assets are unavailable; the preview may be incomplete.`}),(0,X.jsx)(`iframe`,{title:t,srcDoc:s.data?.html??e,sandbox:`allow-scripts allow-downloads`,referrerPolicy:`no-referrer`,className:`min-h-0 w-full flex-1 border-0 bg-white`})]})}function Yo(e){let t=e.trim();if(!t)return``;try{return JSON.stringify(JSON.parse(t),null,2)}catch{try{return t.split(/\r?\n/).filter(Boolean).map(e=>JSON.parse(e)).map(e=>JSON.stringify(e,null,2)).join(` +`)}catch{return e}}}function Xo(e,t){let n=[],r=[],i=``,a=!1;for(let o=0;oe.some(e=>e.length>0))}function Zo({value:e}){return(0,X.jsx)(`pre`,{className:`min-h-0 flex-1 overflow-auto whitespace-pre-wrap break-words p-5 font-mono text-xs leading-6 text-ink-dim scroll-thin`,children:Yo(e)||`(empty data)`})}function Qo({value:e,delimiter:t}){let n=Xo(e,t).slice(0,200),r=n[0]??[];return(0,X.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto p-4 scroll-thin`,children:n.length?(0,X.jsxs)(`table`,{className:`w-full border-collapse text-left text-xs`,children:[(0,X.jsx)(`thead`,{children:(0,X.jsx)(`tr`,{children:r.slice(0,40).map((e,t)=>(0,X.jsx)(`th`,{className:`border border-line/60 bg-surface px-2 py-1.5 font-semibold text-ink`,children:e},t))})}),(0,X.jsx)(`tbody`,{children:n.slice(1).map((e,t)=>(0,X.jsx)(`tr`,{children:r.slice(0,40).map((t,n)=>(0,X.jsx)(`td`,{className:`border border-line/50 px-2 py-1.5 align-top text-ink-dim`,children:e[n]??``},n))},t))})]}):(0,X.jsx)(`div`,{className:`text-sm text-ink-faint`,children:`(empty table)`})})}var $o=`/assets/pdf.min-Bbvtrhlt.mjs`,es=`/assets/pdf.worker.min-CLrFZWeq.mjs`,ts=null,ns=0;function rs(){ts=null,ns+=1}function is(){if(ts)return ts;let e=new URL($o,import.meta.url),t=new URL(es,import.meta.url);ns&&(e.searchParams.set(`retry`,String(ns)),t.searchParams.set(`retry`,String(ns)));let n=oi(()=>import(e.href).then(e=>(e.GlobalWorkerOptions.workerSrc=t.href,e)),[]).catch(e=>{throw ts===n&&rs(),e});return ts=n,n}function as(e,t,n,r){let i=Math.max(1,n-32)/Math.max(1,e),a=Math.max(1,r-32)/Math.max(1,t);return Math.min(2.5,i,a)}function os({src:e,name:t,className:n=``,onPageOrientation:r,onRetry:i}){let{locale:a}=Z(),o=a===`zh-CN`,s=(0,I.useRef)(null),c=(0,I.useRef)(null),l=(0,I.useRef)(null),[u,d]=(0,I.useState)(null),[f,p]=(0,I.useState)(1),[m,h]=(0,I.useState)(1),[g,_]=(0,I.useState)({width:0,height:0}),[v,y]=(0,I.useState)(!0),[b,x]=(0,I.useState)(!1),[S,C]=(0,I.useState)(``),[w,T]=(0,I.useState)(0);(0,I.useEffect)(()=>{let e=c.current;if(!e)return;let t=()=>_({width:e.clientWidth,height:e.clientHeight});t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[]),(0,I.useEffect)(()=>{let t=!0,n=new AbortController,r=null;return d(null),p(1),h(1),l.current=null,c.current?.scrollTo(0,0),C(``),y(!0),Promise.all([fetch(e,{signal:n.signal}).then(e=>{if(!e.ok)throw Error(`PDF request failed (${e.status})`);return e.arrayBuffer()}),is()]).then(async([e,n])=>{if(!t)return;r=n.getDocument({data:new Uint8Array(e)});let i=await r.promise;t&&(d(i),y(!1))}).catch(e=>{t&&(y(!1),C(e instanceof Error?e.message:String(e)))}),()=>{t=!1,n.abort(),r?.destroy().catch(()=>{})}},[e,w]),(0,I.useEffect)(()=>{let e=s.current;if(!u||!e||g.width<=0||g.height<=0)return;let t=!1,n=null;return x(!0),C(``),u.getPage(f).then(e=>{if(t||!s.current)return;let i=e.getViewport({scale:1});r?.(i.width>i.height?`landscape`:`portrait`);let a=as(i.width,i.height,g.width,g.height),o=e.getViewport({scale:a*m}),u=document.createElement(`canvas`),d=u.getContext(`2d`,{alpha:!1});if(!d)throw Error(`Canvas rendering is unavailable`);let f=Math.min(window.devicePixelRatio||1,2);return u.width=Math.max(1,Math.floor(o.width*f)),u.height=Math.max(1,Math.floor(o.height*f)),n=e.render({canvas:u,canvasContext:d,viewport:o,transform:f===1?void 0:[f,0,0,f,0,0]}),n.promise.then(()=>{if(t||!s.current)return;let e=s.current,n=e.getContext(`2d`,{alpha:!1});if(!n)throw Error(`Canvas rendering is unavailable`);e.width=u.width,e.height=u.height,e.style.width=`${o.width}px`,e.style.height=`${o.height}px`,n.drawImage(u,0,0);let r=c.current,i=l.current;if(r&&i){let t=r.getBoundingClientRect(),n=e.getBoundingClientRect();r.scrollLeft+=n.left+i.x*n.width-t.left-r.clientWidth/2,r.scrollTop+=n.top+i.y*n.height-t.top-r.clientHeight/2,l.current=null}})}).then(()=>{t||x(!1)}).catch(e=>{t||e instanceof Error&&e.name===`RenderingCancelledException`||(x(!1),C(e instanceof Error?e.message:String(e)))}),()=>{t=!0,n?.cancel()}},[r,f,u,g.height,g.width,m]);let E=e=>{let t=c.current,n=s.current;if(t&&n&&n.clientWidth&&n.clientHeight){let e=t.getBoundingClientRect(),r=n.getBoundingClientRect();l.current={x:Math.max(0,Math.min(1,(e.left+t.clientWidth/2-r.left)/r.width)),y:Math.max(0,Math.min(1,(e.top+t.clientHeight/2-r.top)/r.height))}}h(t=>Math.max(.6,Math.min(2.2,Math.round((t+e)*100)/100)))},D=()=>{l.current=null,c.current?.scrollTo(0,0),h(1)},ee=u?.numPages??0;return(0,X.jsxs)(`div`,{className:`pdf-viewer flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden bg-bg ${n}`,"aria-busy":v||b,children:[(0,X.jsxs)(`div`,{className:`flex min-h-10 shrink-0 flex-wrap items-center gap-2 border-b border-line/70 bg-panel px-3 py-1.5 text-[11px] text-ink-dim`,children:[(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-ink`,title:t,children:t}),(0,X.jsxs)(`span`,{className:`shrink-0 font-mono tabular-nums`,children:[o?`第`:`Page`,` `,f,` / `,ee||`…`]}),(0,X.jsx)(`button`,{type:`button`,disabled:!u||f<=1,onClick:()=>{c.current?.scrollTo(0,0),l.current=null,p(e=>Math.max(1,e-1))},className:`rounded border border-line px-2 py-1 hover:border-blue/50 hover:text-ink disabled:opacity-35`,children:o?`上一页`:`Previous`}),(0,X.jsx)(`button`,{type:`button`,disabled:!u||f>=ee,onClick:()=>{c.current?.scrollTo(0,0),l.current=null,p(e=>Math.min(ee,e+1))},className:`rounded border border-line px-2 py-1 hover:border-blue/50 hover:text-ink disabled:opacity-35`,children:o?`下一页`:`Next`}),(0,X.jsx)(`button`,{type:`button`,"aria-label":o?`缩小`:`Zoom out`,disabled:!u||m<=.6,onClick:()=>E(-.15),className:`flex h-7 w-7 items-center justify-center rounded border border-line hover:border-blue/50 hover:text-ink`,children:`−`}),(0,X.jsxs)(`span`,{className:`w-10 text-center font-mono tabular-nums`,children:[Math.round(m*100),`%`]}),(0,X.jsx)(`button`,{type:`button`,"aria-label":o?`放大`:`Zoom in`,disabled:!u||m>=2.2,onClick:()=>E(.15),className:`flex h-7 w-7 items-center justify-center rounded border border-line hover:border-blue/50 hover:text-ink`,children:`+`}),(0,X.jsx)(`button`,{type:`button`,disabled:!u,onClick:D,className:`rounded border border-line px-2 py-1 hover:border-blue/50 hover:text-ink disabled:opacity-35`,children:o?`适合页面`:`Fit page`})]}),(0,X.jsxs)(`div`,{ref:c,className:`pdf-scroll-viewport relative min-h-0 min-w-0 flex-1 overflow-auto bg-surface/60 p-4 scroll-thin`,tabIndex:0,"aria-label":o?`PDF 页面滚动区域`:`PDF page scroll area`,children:[v?(0,X.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center`,children:(0,X.jsx)(bi,{})}):null,S?(0,X.jsxs)(`div`,{role:`alert`,className:`m-auto max-w-sm rounded border border-err/35 bg-err/5 p-4 text-center text-sm text-err`,children:[(0,X.jsx)(`p`,{children:o?`PDF 暂时无法预览`:`PDF preview is temporarily unavailable`}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>{rs(),i?i():T(e=>e+1)},className:`mt-3 rounded border border-line bg-panel px-3 py-1.5 text-ink hover:border-blue/50`,children:o?`重试预览`:`Retry preview`}),(0,X.jsxs)(`details`,{className:`mt-3 break-words text-xs text-ink-dim`,children:[(0,X.jsx)(`summary`,{children:o?`错误详情`:`Error details`}),S]})]}):null,S?null:(0,X.jsx)(`div`,{className:`pdf-page-stage flex min-h-full min-w-full w-max items-center justify-center`,children:(0,X.jsx)(`canvas`,{ref:s,role:`img`,"aria-label":`${t} · ${o?`第`:`page`} ${f}`,className:`block max-w-none shrink-0 bg-white shadow-xl`})})]})]})}function ss(e,t){return typeof e==`string`?e.trim().slice(0,t):``}function cs(e,t){return ss(e,t*2).replace(/!?(?:\[([^\]]+)\])\([^)]+\)/g,`$1`).replace(/[*_`#]/g,``).replace(/\s+/g,` `).trim().slice(0,t)}function ls(e){let t=ss(e.completionId,300);if(!t)return null;let n=ss(e.path,1e3);return{deliveryId:t,title:cs(e.title,240)||`已完成的任务`,summary:cs(e.summary,500),...n?{path:n}:{}}}function us(){return typeof window>`u`||window.parent===window?null:window.parent}function ds(e){if(!e||typeof e!=`object`||Array.isArray(e))return null;let t=e,n=ss(t.deliveryId,300);if(!n)return null;let r=ss(t.path,1e3);return{deliveryId:n,title:ss(t.title,240)||`Argus`,summary:ss(t.summary,1e3),...r?{path:r}:{}}}function fs(e){let t=ds(e),n=us();return!t||!n?Promise.resolve(!1):(n.postMessage({type:`argus:notify-completion`,payload:t},`*`),Promise.resolve(!0))}function ps(e){let t=us();t&&t.postMessage({type:`argus:large-preview`,payload:e},`*`)}function ms(e){let t=us();if(!t)return()=>void 0;let n=n=>{if(n.source!==t||n.data?.type!==`argus:open-delivery`)return;let r=ds(n.data.payload);r&&e(r)};return window.addEventListener(`message`,n),()=>window.removeEventListener(`message`,n)}function hs(e){let t=us();if(!t)return()=>void 0;let n=n=>{n.source===t&&n.data?.type===`argus:new-chat`&&e()};return window.addEventListener(`message`,n),()=>window.removeEventListener(`message`,n)}function gs(){if(typeof document>`u`)return()=>void 0;let e=us();if(!e)return()=>void 0;let t=t=>{if(t.defaultPrevented||t.button!==0&&t.button!==1)return;let n=t.target instanceof Element?t.target.closest(`a[href]`):null;if(!n)return;let r;try{r=new URL(n.href,window.location.href)}catch{return}r.origin===window.location.origin||![`http:`,`https:`].includes(r.protocol)||(t.preventDefault(),e.postMessage({type:`argus:open-external`,payload:r.toString()},`*`))},n=t=>{if(t.defaultPrevented||t.isComposing||t.altKey||t.shiftKey||!(t.ctrlKey||t.metaKey))return;let n=t.key===`,`?`argus:show-setup`:t.key.toLowerCase()===`n`?`argus:request-new-chat`:null;n&&(t.preventDefault(),e.postMessage({type:n},`*`))},r=()=>e.postMessage({type:`argus:cockpit-interaction`},`*`);return document.addEventListener(`click`,t,!0),document.addEventListener(`auxclick`,t,!0),window.addEventListener(`keydown`,n),document.addEventListener(`pointerdown`,r,{passive:!0}),()=>{document.removeEventListener(`click`,t,!0),document.removeEventListener(`auxclick`,t,!0),window.removeEventListener(`keydown`,n),document.removeEventListener(`pointerdown`,r)}}function _s(e){return e.kind===`markdown`||e.mime?.split(`;`,1)[0].trim().toLowerCase()===`text/markdown`||/\.(?:md|markdown)$/i.test(e.name||e.path||``)}function vs({sid:e,path:t,onClose:n,delivery:r,deliveries:i=[],onSelectDelivery:a,onSelectPath:o,reviewActivity:s}){let{t:c,locale:l}=Z(),u=l===`zh-CN`,d=r?Qr(r):[],f=Er(e,t),p=f.data,m=p?_s(p):!1,[h,g]=(0,I.useState)(null),[_,v]=(0,I.useState)(``),[y,b]=(0,I.useState)(0),[x,S]=(0,I.useState)(!1),[C,w]=(0,I.useState)(!1),[T,E]=(0,I.useState)(`portrait`),D=p?.kind===`pdf`||t?.toLowerCase().endsWith(`.pdf`)===!0,ee=!!(t&&/(?:^|[\\/])REVIEW\.md$/i.test(t));(0,I.useEffect)(()=>{if(!(!t||!D))return ps(!0),()=>ps(!1)},[t,D]),(0,I.useEffect)(()=>{if(E(`portrait`),g(null),v(``),!e||!t||!p||![`image`,`pdf`,`audio`,`video`].includes(p.kind))return;let n=!0,r=``,i=new AbortController;return U.artifactBlob(e,t,!1,i.signal).then(e=>{n&&(r=URL.createObjectURL(e),g(r))},e=>n&&v(e.message)),()=>{n=!1,i.abort(),r&&URL.revokeObjectURL(r)}},[e,t,p?.kind,y]);let O=async(n=!1)=>{if(!(!e||!t||!p)){S(!0),v(``);try{let r=n?await U.artifactBundle(e,t):await U.artifactBlob(e,t,!0),i=URL.createObjectURL(r),a=document.createElement(`a`);a.href=i,a.download=n?`${p.name.replace(/\.html?$/i,``)}-website.zip`:p.name,document.body.appendChild(a),a.click(),a.remove(),window.setTimeout(()=>URL.revokeObjectURL(i),0)}catch(e){v(e.message)}finally{S(!1)}}};return(0,X.jsxs)(go,{open:!!(t||r),onClose:n,label:r?u?`交付成果`:`Delivery`:c(`artifact.preview`),width:r?C?`max-w-none`:`max-w-6xl`:D?`max-w-none`:`max-w-5xl`,viewport:r?C:D,showClose:!1,style:r?{height:C?`100dvh`:`min(92dvh, 960px)`,display:`flex`,flexDirection:`column`,overflow:`hidden`}:D?{maxWidth:T===`portrait`?`min(96vw, 76dvh)`:`min(96vw, 145dvh)`}:void 0,children:[r&&!C&&(0,X.jsxs)(`header`,{className:`delivery-header`,children:[(0,X.jsxs)(`div`,{className:`delivery-heading`,children:[(0,X.jsx)(`span`,{className:`delivery-mark`,children:(0,X.jsx)(eo,{size:22})}),(0,X.jsxs)(`div`,{children:[(0,X.jsxs)(`p`,{children:[`DELIVERY · `,u?`交付成果`:`Your results`]}),(0,X.jsx)(`h2`,{children:u?`成果文件`:`Result files`})]}),(0,X.jsxs)(`button`,{type:`button`,onClick:n,className:`delivery-return`,"aria-label":u?`关闭交付弹窗`:`Close delivery`,children:[u?`返回地图`:`Back to map`,` ×`]})]}),i.length>1?(0,X.jsx)(`select`,{"aria-label":u?`选择交付任务`:`Choose delivery`,className:`delivery-task-select`,value:r.delivery_id,onChange:e=>{let t=i.find(t=>t.delivery_id===e.target.value);t&&a?.(t)},children:i.map(e=>(0,X.jsx)(`option`,{value:e.delivery_id,children:e.title},e.delivery_id))}):(0,X.jsx)(`p`,{className:`delivery-task-title`,title:r.title,children:r.title}),(0,X.jsxs)(`div`,{className:`delivery-facts`,children:[(0,X.jsxs)(`span`,{children:[(0,X.jsx)(Ua,{size:13}),[`done`,`passed`,`approved`,`accepted`].includes(r.review_status)?u?`任务已完成`:`Task completed`:u?`可查看`:`Available`]}),(0,X.jsxs)(`span`,{children:[d.length,` `,u?`个文件`:`files`]})]}),r.summary&&(0,X.jsxs)(`details`,{className:`delivery-summary`,children:[(0,X.jsx)(`summary`,{children:u?`查看成果说明`:`Result summary`}),(0,X.jsx)(`p`,{children:ei(r.summary)})]})]}),!C&&!!d.length&&(0,X.jsx)(`nav`,{className:`delivery-files`,"aria-label":u?`交付文件`:`Delivery files`,children:d.map(e=>(0,X.jsxs)(`button`,{type:`button`,"aria-pressed":t===e.path,onClick:()=>o?.(e.path),title:e.path,children:[(0,X.jsx)(`span`,{children:e.path.split(`/`).at(-1)}),r?.primary_target?.path===e.path&&(0,X.jsx)(`small`,{children:u?`主要成果`:`Main result`})]},e.path))}),(0,X.jsxs)(`div`,{className:`flex shrink-0 items-start gap-2 border-b border-line px-4 py-3 sm:px-5 ${t?``:`hidden`}`,children:[(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`h2`,{className:`truncate font-mono text-sm font-semibold text-ink`,title:p?.storage_path??p?.path??t??``,children:p?.name??t??c(`artifact.title`)}),(0,X.jsx)(`p`,{className:`mt-0.5 truncate text-[11px] text-ink-faint`,children:p?`${p.kind} · ${fi(p.size)} · ${p.mime}`:c(`artifact.approvedEvidence`)})]}),r&&(0,X.jsx)(`button`,{type:`button`,onClick:()=>w(e=>!e),"aria-label":C?u?`收起预览`:`Exit full screen`:u?`全屏预览`:`Full screen preview`,title:u?`切换全屏预览`:`Toggle full screen preview`,className:`shrink-0 rounded-md border border-line p-2 text-ink-dim`,children:C?(0,X.jsx)($a,{size:16}):(0,X.jsx)(Qa,{size:16})}),p?.kind===`html`&&(0,X.jsx)(`button`,{type:`button`,disabled:x,onClick:()=>void O(!0),className:`shrink-0 rounded-md border border-blue-deep/60 bg-blue-deep/10 px-3 py-2 text-xs text-blue-sky disabled:opacity-50`,children:u?`下载完整网页`:`Download website`}),(0,X.jsx)(`button`,{type:`button`,disabled:!p||x,onClick:()=>void O(),className:`rounded-md border border-blue-deep/60 bg-blue-deep/10 px-3 py-1.5 text-xs text-blue-sky transition-colors hover:bg-blue-deep/20 disabled:cursor-wait disabled:opacity-50`,children:c(x?`artifact.downloading`:`artifact.download`)}),(!r||C)&&(0,X.jsx)(`button`,{type:`button`,"aria-label":c(`artifact.close`),onClick:n,className:`rounded-md px-2 py-1 text-lg leading-none text-ink-faint hover:bg-surface hover:text-ink`,children:`×`})]}),(0,X.jsxs)(`div`,{className:r?`flex min-h-0 flex-1 flex-col overflow-auto bg-bg/40 p-2 sm:p-3`:D?`flex min-h-0 flex-1 flex-col overflow-hidden bg-bg/40`:`flex min-h-64 max-h-[72vh] flex-col overflow-x-hidden overflow-y-auto bg-bg/40 p-3 scroll-thin sm:p-4`,children:[!t&&r&&(0,X.jsx)(`p`,{className:`m-auto p-6 text-sm text-ink-dim`,children:ei(r.summary)}),f.isLoading?(0,X.jsx)(`div`,{className:`m-auto`,children:(0,X.jsx)(bi,{})}):null,f.isError?(0,X.jsxs)(`div`,{className:`m-auto text-sm text-err`,children:[c(`artifact.unavailable`),` · `,f.error.message]}):null,p?.why&&!D&&!r?(0,X.jsxs)(`div`,{className:`mb-3 rounded-md border border-line bg-surface px-3 py-2 text-xs text-ink-dim`,children:[(0,X.jsx)(`span`,{className:`mr-1 text-ink-faint`,children:`Reviewer:`}),p.why]}):null,p?.kind===`text`&&!m?(0,X.jsxs)(`pre`,{className:`min-h-52 overflow-x-hidden overflow-y-auto whitespace-pre-wrap break-words rounded-lg border border-line bg-bg p-4 font-mono text-xs leading-relaxed text-ink-dim scroll-thin`,children:[p.preview||c(`artifact.empty`),p.truncated?`\n\n… ${c(`artifact.truncated`)}`:``]}):null,p&&m?(0,X.jsxs)(`div`,{className:`min-h-52 overflow-auto rounded-lg border border-line bg-bg p-4 text-sm text-ink-dim scroll-thin`,children:[ee&&(0,X.jsxs)(`div`,{className:`mb-4 border-b border-line pb-3 text-xs leading-5 text-ink-faint`,role:`status`,children:[s===`revising`?u?`正在根据这份意见修改论文,修改后的版本尚待复审。`:`The paper is being revised against this opinion; the revised version awaits review.`:s===`reviewing`?u?`Reviewer 正在更新本轮审稿意见,内容会自动刷新。`:`The Reviewer is updating this round’s opinion. This file refreshes automatically.`:u?`这是最近保存的审稿意见,文件更新后会自动刷新。`:`This is the latest saved review. Changes to this file appear automatically.`,p.mtime!=null&&(0,X.jsxs)(`div`,{children:[u?`最近更新:`:`Last updated: `,new Date(p.mtime*1e3).toLocaleString(l)]})]}),(0,X.jsx)(ki,{artifacts:d.map(e=>({path:e.path})),onOpenArtifact:o,children:p.preview||c(`artifact.empty`)})]}):null,p?.kind===`json`?(0,X.jsx)(Zo,{value:p.preview||``}):null,p?.kind===`table`?(0,X.jsx)(Qo,{value:p.preview||``,delimiter:p.name.endsWith(`.tsv`)?` `:`,`}):null,p?.kind===`html`?(0,X.jsx)(`div`,{className:`flex flex-1 overflow-hidden rounded-lg border border-line ${r?`min-h-0`:`min-h-[60vh]`}`,children:(0,X.jsx)(qo,{sid:e,path:t,html:p.preview||``,title:`HTML preview: ${p.name}`})}):null,p?.kind===`image`&&h?(0,X.jsx)(`div`,{className:`flex min-h-64 flex-1 items-center justify-center rounded border border-line bg-bg/50`,children:(0,X.jsx)(`img`,{src:h,alt:p.why||p.name,className:`max-h-[62vh] max-w-full object-contain`})}):null,p?.kind===`pdf`&&h?(0,X.jsx)(os,{src:h,name:p.name,className:`min-h-0 overflow-hidden`,onPageOrientation:E,onRetry:()=>b(e=>e+1)}):null,p?.kind===`audio`&&h?(0,X.jsx)(`div`,{className:`m-auto w-full max-w-xl`,children:(0,X.jsx)(`audio`,{controls:!0,preload:`metadata`,src:h,className:`w-full`})}):null,p?.kind===`video`&&h?(0,X.jsx)(`div`,{className:`flex min-h-64 flex-1 items-center justify-center rounded border border-line bg-black`,children:(0,X.jsx)(`video`,{controls:!0,playsInline:!0,preload:`metadata`,src:h,className:`max-h-[62vh] max-w-full`})}):null,p&&[`image`,`pdf`,`audio`,`video`].includes(p.kind)&&!h&&!_?(0,X.jsx)(`div`,{className:`m-auto`,children:(0,X.jsx)(bi,{})}):null,p?.kind===`binary`?(0,X.jsxs)(`div`,{className:`m-auto max-w-md text-center`,children:[(0,X.jsx)(`div`,{className:`text-3xl text-ink-faint`,children:`◇`}),(0,X.jsx)(`p`,{className:`mt-2 text-sm text-ink-dim`,children:c(`artifact.noPreview`)}),(0,X.jsx)(`p`,{className:`mt-1 text-xs text-ink-faint`,children:c(`artifact.downloadHint`)})]}):null,_?(0,X.jsx)(`div`,{className:`mt-3 text-center text-xs text-err`,children:_}):null]})]})}var ys=`__argus_live_progress__`,bs=new Set([`framed`,`grounding`,`queued`,`running`,`in_progress`,`working`]),xs=new Set([`complete`,`completed`,`done`,`success`]);function Ss(e){return xs.has(String(e?.mission.status||``).toLowerCase())}function Cs(e){return(e??[]).filter(e=>e.source===`manager_live`)}function ws(e){return Cs(e).filter(e=>e.exists)[0]??null}function Ts(e){let t=e??[],n={markdown:0,pdf:1,html:2,text:3,table:4,json:5,image:6,video:7,audio:8,binary:9},r=t.filter(e=>e.exists&&e.source===`delivery`),i=t.filter(e=>e.exists&&e.source===`manager_live`),a=t.filter(e=>e.exists&&e.source!==`manager_live`&&e.source!==`delivery`);return a.length||r.length?[...r,...[...a].sort((e,t)=>(n[e.kind]??99)-(n[t.kind]??99)),...i]:i}function Es(e){return Ts(e).find(e=>e.exists)??null}function Ds(e){let t=Ts(e);return t.find(e=>e.source===`delivery`)??t.find(e=>e.source!==`manager_live`)??t[0]??null}function Os(e){let t=e.path.split(`/`);return t[t.length-1]||e.path}function ks(e,t){if(e){let n=String(e.mission.status||``).toLowerCase();if(bs.has(n))return ys;let r=e.delivery?.primary_target?.path;if(r)return r;if(Ss(e))return Ds(t)?.path??`__argus_live_progress__`;let i=ws(t);return i?i.path:ys}return Es(t)?.path??``}var As={manager:`Manager`,planner:`Planner`,engineer:`Engineer`,reviewer:`Reviewer`};function js(e){let t=String(e.agent_layer??e.actor??``);if(t===`main`)return`engineer`;if(t)return t;let n=String(e.type??``);return n.startsWith(`round.review`)||n.startsWith(`reviewer`)?`reviewer`:n.startsWith(`life.planner`)?`planner`:n.startsWith(`life.manager`)||n.startsWith(`manager`)?`manager`:n.startsWith(`engineer`)||n.startsWith(`round.`)?`engineer`:``}function Ms(e,t=[]){if(Ss(e))return null;let n=String(e?.active_role??``);if(!n)return null;let r=e?.roles.find(e=>e.role===n),i=``;for(let e=t.length-1;e>=0;--e){let r=t[e];if(js(r)!==n||String(r.kind??``)===`reasoning`)continue;let a=String(r.text??r.action_summary??``).trim();if(!(!a||a.startsWith(`{`))){i=a.split(` +`)[0].slice(0,240);break}}return{role:n,roleLabel:As[n]??n,label:r?.label||`Working`,detail:i}}function Ns(e){let t=e.dag.find(e=>[`running`,`in_progress`,`claimed`].includes(e.status)),n=e.dag.filter(e=>[`done`,`completed`].includes(e.status)).length,r=e.dag.length,i=`Awaiting Planner`;return e.mission.status===`idle`?i=`Ready for a new mission`:e.mission.status===`complete`&&(i=`Mission complete`),{title:Cn(t?.title||e.mission.title||i),dagProgress:r>0?`${n} / ${r} complete`:`Not planned`}}function Ps({view:e,liveStatus:t,artifacts:n=[],onOpenArtifact:r}){let{t:i}=Z(),a=Ns(e),o=[...n].filter(e=>e.exists&&e.source!==`manager_live`).sort((e,t)=>Number(t.mtime??0)-Number(e.mtime??0)).slice(0,4),s=e.timeline.slice(-6).reverse(),c=e.delivery,l=e=>e===`done`?`text-ok`:[`running`,`in_progress`,`claimed`].includes(e)?`text-blue-sky`:[`failed`,`blocked`,`rejected`].includes(e)?`text-err`:`text-ink-faint`;return(0,X.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-5 text-sm text-ink-dim scroll-thin`,children:[c?(0,X.jsxs)(`section`,{className:`mb-4 rounded-lg border border-ok/35 bg-ok/10 p-4`,children:[(0,X.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-[0.14em] text-ok`,children:c.kind===`submission_certified`?`交付已认证`:`已完成`}),(0,X.jsx)(`h3`,{className:`mt-2 text-base font-semibold leading-snug text-ink`,children:c.title}),c.summary?(0,X.jsx)(`p`,{className:`mt-2 text-xs leading-5 text-ink-dim`,children:c.summary}):null,c.primary_target?(0,X.jsxs)(`button`,{type:`button`,onClick:()=>r(c.primary_target.path),title:n.find(e=>e.path===c.primary_target.path)?.storage_path||c.primary_target.path,className:`mt-3 rounded border border-ok/40 bg-panel px-2.5 py-1.5 font-mono text-[10px] text-ok hover:border-ok`,children:[`打开成果 · `,c.primary_target.label||c.primary_target.path]}):null]}):null,(0,X.jsxs)(`section`,{className:`rounded-lg border border-blue-deep/30 bg-blue-deep/10 p-4`,children:[(0,X.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-[0.14em] text-blue-sky`,children:i(`research.currentWork`)}),(0,X.jsx)(`h3`,{className:`mt-2 text-base font-semibold leading-snug text-ink`,children:a.title}),t?.detail?(0,X.jsx)(`p`,{className:`mt-2 leading-6 text-ink-dim`,children:t.detail}):null,(0,X.jsxs)(`div`,{className:`mt-3 grid grid-cols-2 gap-3 text-xs`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`span`,{className:`text-ink-faint`,children:i(`mission.stage`)}),(0,X.jsx)(`div`,{className:`mt-1 font-medium capitalize text-blue-sky`,children:e.stage.label||e.stage.id||`—`})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`span`,{className:`text-ink-faint`,children:i(`mission.campaign`)}),(0,X.jsx)(`div`,{className:`mt-1 font-mono text-ink`,children:wn(e.mission.campaign_elapsed_seconds)})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`span`,{className:`text-ink-faint`,children:i(`mission.round`)}),(0,X.jsxs)(`div`,{className:`mt-1 font-mono text-ink`,children:[e.round.current||`—`,e.round.max?` / ${e.round.max}`:``]})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`span`,{className:`text-ink-faint`,children:i(`research.dagProgress`)}),(0,X.jsx)(`div`,{className:`mt-1 font-mono text-ink`,children:a.dagProgress})]})]})]}),(0,X.jsxs)(`section`,{className:`mt-5`,children:[(0,X.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-[0.14em] text-ink-faint`,children:i(`mission.researchDag`)}),(0,X.jsx)(`div`,{className:`mt-2 space-y-2`,children:e.dag.map(e=>(0,X.jsx)(`div`,{className:`rounded-md border border-line/60 bg-panel px-3 py-2.5`,children:(0,X.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,X.jsx)(`span`,{className:`mt-0.5 shrink-0 font-mono text-xs ${l(e.status)}`,children:e.status===`done`?`✓`:[`running`,`in_progress`,`claimed`].includes(e.status)?`●`:`○`}),(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`div`,{className:`text-xs font-medium leading-5 text-ink`,children:e.title}),(0,X.jsx)(`div`,{className:`mt-0.5 font-mono text-[10px] ${l(e.status)}`,children:e.status})]})]})},e.id))})]}),o.length?(0,X.jsxs)(`section`,{className:`mt-5`,children:[(0,X.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-[0.14em] text-ink-faint`,children:i(`research.verifiedOutputs`)}),(0,X.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:o.map(e=>(0,X.jsxs)(`button`,{type:`button`,onClick:()=>r(e.path),title:e.storage_path||e.path,className:`rounded border border-line/70 bg-panel px-2.5 py-1.5 font-mono text-[10px] text-blue-sky hover:border-blue/60`,children:[Os(e),` ↗`]},e.path))})]}):null,s.length?(0,X.jsxs)(`section`,{className:`mt-5`,children:[(0,X.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-[0.14em] text-ink-faint`,children:i(`research.recentMilestones`)}),(0,X.jsx)(`div`,{className:`mt-2 space-y-2 border-l border-line/70 pl-3`,children:s.map(e=>(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`div`,{className:`text-xs font-medium text-ink`,children:e.title}),e.detail?(0,X.jsx)(`div`,{className:`mt-0.5 line-clamp-2 text-xs leading-5 text-ink-faint`,children:e.detail}):null]},e.id))})]}):null]})}function Fs({sid:e,artifacts:t,error:n=!1,onExpand:r,onOpenFile:i,className:a=``,embedded:s=!1,onCollapse:c,missionView:l,activityEvents:u=[],requestedPath:d,requestedPathToken:f}){let{t:p,locale:m}=Z(),h=(0,I.useMemo)(()=>Ts(t),[t]),g=(0,I.useMemo)(()=>Es(t),[t]),_=Ss(l),v=(0,I.useMemo)(()=>{if(!_)return null;let e=l?.delivery?.primary_target?.path;return h.find(t=>t.path===e&&t.exists)??Ds(t)},[t,_,l?.delivery?.primary_target?.path,h]),[y,b]=(0,I.useState)(null);(0,I.useEffect)(()=>{b(_&&v?v.path:null)},[_,v?.path,l?.mission.id,e]),(0,I.useEffect)(()=>{if(!d)return;let e=h.find(e=>e.path===d&&e.exists);e&&b(e.path)},[h,d,f]);let S=e=>{b(e),e!==`__argus_live_progress__`&&i?.()},C=y??ks(l,t),w=C===ys,T=w?null:h.find(e=>e.path===C)??(_?v:g),E=Er(e,T?.exists?T.path:null,T?.mtime??null),D=E.data,ee=D?_s(D):!1,[O,te]=(0,I.useState)(null),[ne,k]=(0,I.useState)(``),[re,A]=(0,I.useState)(!1),[j,ie]=(0,I.useState)(``),ae=(0,I.useMemo)(()=>Ms(l,u),[u,l]);(0,I.useEffect)(()=>{if(te(null),k(``),!e||!T||!D||![`image`,`pdf`,`audio`,`video`].includes(D.kind))return;let t=!0,n=``,r=new AbortController;return U.artifactBlob(e,T.path,!1,r.signal).then(e=>{t&&(n=URL.createObjectURL(e),te(n))},e=>t&&k(e.message)),()=>{t=!1,r.abort(),n&&URL.revokeObjectURL(n)}},[e,T?.path,D?.kind,D?.mtime]);let M=l?.delivery??null,oe=M?.primary_target?.path??``,se=!!(_&&!w&&T&&(T.source===`delivery`||T.path===oe)),N=m===`zh-CN`?M?.kind===`submission_certified`?`交付已认证`:`已完成`:M?.kind===`submission_certified`?`Certified delivery`:`Delivered result`,ce=se?N:w?p(`research.liveProgress`):h[0]?.group_title||p(`research.artifact`),le=async()=>{if(!(!e||!T)){A(!0),ie(``);try{let t=await U.artifactBlob(e,T.path,!0),n=URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=T.name,document.body.appendChild(r),r.click(),r.remove(),window.setTimeout(()=>URL.revokeObjectURL(n),0)}catch(e){ie(e.message)}finally{A(!1)}}};return(0,X.jsxs)(`section`,{className:`glass-panel glass-panel--side flex min-h-0 flex-col overflow-hidden ${s?``:`rounded-lg border`} ${a}`,"aria-label":p(`research.canvas`),children:[(0,X.jsxs)(`header`,{className:`flex h-12 shrink-0 items-center gap-3 border-b border-line/50 bg-panel px-4`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 shrink-0 items-center gap-2`,children:[(0,X.jsx)(`span`,{className:`h-2 w-2 rounded-full ${se?`bg-ok`:`animate-pulse bg-blue`}`}),(0,X.jsx)(`h2`,{className:`max-w-24 truncate text-sm font-semibold text-ink sm:max-w-48`,children:ce})]}),l||h.length>0?(0,X.jsxs)(`label`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`span`,{className:`sr-only`,children:p(`research.previewArtifact`)}),(0,X.jsxs)(`select`,{value:w?ys:T?.path??``,onChange:e=>S(e.target.value),title:w?p(`research.liveProgress`):T?.storage_path||T?.path,className:`h-8 w-full min-w-0 max-w-64 truncate rounded-md border border-line/50 bg-bg px-2 font-mono text-xs text-ink-dim outline-none focus:border-blue/60`,children:[l?(0,X.jsx)(`option`,{value:ys,children:p(`research.liveProgress`)}):null,h.map(e=>(0,X.jsxs)(`option`,{value:e.path,disabled:!e.exists,title:e.storage_path||e.path,children:[e.source===`delivery`?`交付 · `:e.source===`manager_live`?`Checkpoint · `:``,Os(e),e.exists?``:` · pending`]},e.path))]})]}):(0,X.jsx)(`div`,{className:`flex-1`}),(0,X.jsx)(`div`,{className:`shrink-0`,children:T?(0,X.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,X.jsx)(`button`,{type:`button`,onClick:()=>void le(),disabled:re||!T.exists,title:p(`artifact.download`),"aria-label":p(`artifact.download`),className:`flex h-7 w-7 items-center justify-center rounded-md text-ink-faint hover:bg-surface hover:text-ink disabled:opacity-40`,children:(0,X.jsx)(`svg`,{viewBox:`0 0 16 16`,"aria-hidden":`true`,className:`h-4 w-4`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.25`,children:(0,X.jsx)(`path`,{d:`M8 2.25v7.5M5.25 7.5 8 10.25 10.75 7.5M3 13.25h10`})})}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>r(T.path),title:p(`research.openLarge`),"aria-label":p(`research.openLarge`),className:`flex h-7 w-7 items-center justify-center rounded-md text-ink-faint hover:bg-surface hover:text-ink`,children:(0,X.jsx)(`svg`,{viewBox:`0 0 16 16`,"aria-hidden":`true`,className:`h-4 w-4`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.25`,children:(0,X.jsx)(`path`,{d:`M6 3H3v3M10 3h3v3M6 13H3v-3M10 13h3v-3`})})})]}):null}),c?(0,X.jsx)(`button`,{type:`button`,onClick:c,"aria-label":p(`research.collapse`),title:p(`research.collapse`),className:`hidden h-8 w-8 shrink-0 items-center justify-center rounded-md border border-line/50 bg-bg/40 text-ink-faint hover:border-blue/50 hover:text-ink lg:flex`,children:(0,X.jsx)(o,{icon:x,className:`h-3.5 w-3.5`})}):null]}),ae?(0,X.jsxs)(`div`,{className:`shrink-0 border-b border-line/50 bg-blue-deep/10 px-4 py-3`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2 text-xs`,children:[(0,X.jsx)(`span`,{"data-role-dot":ae.role,className:`h-2 w-2 shrink-0 animate-pulse rounded-full motion-reduce:animate-none`,style:{background:W.role[ae.role]??W.inkFaint},"aria-hidden":`true`}),(0,X.jsx)(`span`,{className:`font-semibold text-ink`,children:ae.roleLabel}),(0,X.jsx)(`span`,{className:`text-blue-sky`,children:p(`mission.active`)}),(0,X.jsxs)(`span`,{className:`truncate text-ink-faint`,children:[`· `,ae.label]})]}),ae.detail?(0,X.jsx)(`p`,{className:`mt-1 line-clamp-2 text-xs leading-5 text-ink-dim`,children:ae.detail}):null]}):null,(0,X.jsxs)(`div`,{className:`relative flex min-h-0 flex-1 flex-col bg-bg`,children:[w&&l?(0,X.jsx)(Ps,{view:l,liveStatus:ae,artifacts:t,onOpenArtifact:S}):null,!w&&n?(0,X.jsx)(`div`,{className:`m-auto max-w-sm px-6 text-center text-sm text-warn`,children:p(`research.unavailable`)}):null,!w&&!n&&h.length===0?(0,X.jsxs)(`div`,{className:`m-auto max-w-sm px-8 text-center`,children:[(0,X.jsx)(`div`,{className:`text-3xl text-ink-faint`,children:`◇`}),(0,X.jsx)(`h3`,{className:`mt-3 text-xs text-ink-faint`,children:p(`research.noPreview`)})]}):null,!w&&!n&&h.length>0&&!T?(0,X.jsxs)(`div`,{className:`m-auto max-w-sm px-8 text-center`,children:[(0,X.jsx)(bi,{}),(0,X.jsx)(`p`,{className:`mt-3 text-xs text-ink-faint`,children:p(`research.waiting`)})]}):null,T&&!T.exists?(0,X.jsxs)(`div`,{className:`m-auto max-w-sm px-8 text-center`,children:[(0,X.jsx)(bi,{}),(0,X.jsx)(`p`,{className:`mt-3 text-xs text-ink-faint`,children:p(`research.updating`)})]}):null,T?.exists&&E.isLoading?(0,X.jsx)(`div`,{className:`m-auto`,children:(0,X.jsx)(bi,{})}):null,T?.exists&&E.isError?(0,X.jsxs)(`div`,{className:`m-auto px-6 text-center text-sm text-err`,children:[p(`artifact.unavailable`),` · `,E.error.message]}):null,D?.kind===`text`&&!ee?(0,X.jsxs)(`pre`,{className:`min-h-0 flex-1 overflow-x-hidden overflow-y-auto whitespace-pre-wrap break-words p-5 font-mono text-xs leading-6 text-ink-dim scroll-thin`,children:[D.preview||`(empty file)`,D.truncated?` + +… live preview truncated · expand to inspect the complete file`:``]}):null,D&&ee?(0,X.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto p-5 text-sm text-ink-dim scroll-thin`,children:(0,X.jsx)(ki,{artifacts:t,onOpenArtifact:S,children:D.preview||`(empty file)`})}):null,D?.kind===`json`?(0,X.jsx)(Zo,{value:D.preview||``}):null,D?.kind===`table`?(0,X.jsx)(Qo,{value:D.preview||``,delimiter:D.name.endsWith(`.tsv`)?` `:`,`}):null,D?.kind===`html`&&!D.truncated?(0,X.jsx)(qo,{sid:e,path:D.path,html:D.preview||``,title:`Live HTML preview: ${D.name}`}):null,D?.kind===`html`&&D.truncated?(0,X.jsx)(`div`,{className:`m-auto max-w-sm px-8 text-center text-sm text-warn`,children:p(`artifact.htmlTooLarge`)}):null,D?.kind===`image`&&O?(0,X.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center overflow-hidden p-4`,children:(0,X.jsx)(`img`,{src:O,alt:D.why||D.name,className:`max-h-full max-w-full object-contain`})}):null,D?.kind===`pdf`&&O?(0,X.jsx)(os,{src:O,name:D.name}):null,D?.kind===`audio`&&O?(0,X.jsx)(`div`,{className:`m-auto w-full max-w-xl px-6`,children:(0,X.jsx)(`audio`,{controls:!0,preload:`metadata`,src:O,className:`w-full`})}):null,D?.kind===`video`&&O?(0,X.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center overflow-hidden bg-black p-2`,children:(0,X.jsx)(`video`,{controls:!0,playsInline:!0,preload:`metadata`,src:O,className:`max-h-full max-w-full`})}):null,D?.kind===`binary`?(0,X.jsx)(`div`,{className:`m-auto max-w-sm px-8 text-center text-sm text-ink-dim`,children:p(`research.fileUnavailable`)}):null,D&&[`image`,`pdf`,`audio`,`video`].includes(D.kind)&&!O&&!ne?(0,X.jsx)(`div`,{className:`m-auto`,children:(0,X.jsx)(bi,{})}):null,ne?(0,X.jsx)(`div`,{className:`m-auto px-6 text-center text-sm text-err`,children:ne}):null]}),w?(0,X.jsxs)(`footer`,{className:`flex h-9 items-center gap-2 border-t border-line px-4 font-mono text-xs text-ink-faint`,children:[(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:p(`research.eventSourced`)}),(0,X.jsx)(`span`,{className:`shrink-0 text-ok`,children:se?N:p(`common.live`)})]}):D?(0,X.jsxs)(`footer`,{className:`flex h-9 items-center gap-2 border-t border-line px-4 font-mono text-xs text-ink-faint`,children:[(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,title:D.storage_path||D.path,children:D.storage_path||D.path}),j?(0,X.jsx)(`span`,{className:`ml-auto truncate text-err`,title:j,children:p(`research.downloadFailed`)}):null,(0,X.jsxs)(`span`,{className:`shrink-0`,children:[D.kind,` · `,fi(D.size)]}),(0,X.jsx)(`span`,{className:`shrink-0 text-ok`,children:se?N:p(`common.live`)})]}):null]})}function Is({notice:e,onClose:t}){if((0,I.useEffect)(()=>{if(!e)return;let n=window.setTimeout(t,e.tone===`error`?8e3:4e3);return()=>window.clearTimeout(n)},[e,t]),!e)return null;let n=e.tone===`error`?`border-err/60 bg-err/10 text-err`:e.tone===`success`?`border-ok/60 bg-ok/10 text-ok`:`border-blue-deep/60 bg-panel text-blue-sky`;return(0,X.jsxs)(`div`,{role:e.tone===`error`?`alert`:`status`,"aria-live":e.tone===`error`?`assertive`:`polite`,className:`fixed bottom-4 left-4 right-4 z-[70] flex items-start gap-2 rounded-md border px-3 py-2.5 shadow-glow sm:left-auto sm:max-w-md ${n}`,children:[(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`mt-px shrink-0`,children:e.tone===`error`?`!`:e.tone===`success`?`✓`:`i`}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 break-words text-xs leading-relaxed text-ink-dim`,children:e.message}),(0,X.jsx)(`button`,{type:`button`,"aria-label":`dismiss notification`,onClick:t,className:`shrink-0 rounded px-1 text-base leading-none opacity-70 hover:bg-white/5 hover:opacity-100`,children:`×`})]})}function Ls({open:e,busy:t,onClose:n,onCreate:r}){let{t:i}=Z(),[a,o]=(0,I.useState)(``),[s,c]=(0,I.useState)(``),[l,u]=(0,I.useState)(``),d=(0,I.useRef)(null);(0,I.useEffect)(()=>{e&&(o(``),c(``),u(``))},[e]);let f=()=>{t||n()},p=async e=>{e.preventDefault(),!t&&await r(a.trim(),s.trim(),l.trim())&&n()},m=e=>{sa(e)||e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),d.current?.requestSubmit())},h=!!s.trim();return(0,X.jsx)(go,{open:e,onClose:f,label:i(`new.createDaemon`),width:`max-w-xl`,showClose:!1,children:(0,X.jsxs)(`form`,{ref:d,onSubmit:e=>void p(e),children:[(0,X.jsxs)(`div`,{className:`flex items-start gap-3 border-b border-line px-5 py-4`,children:[(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`h2`,{className:`text-base font-semibold text-ink`,children:i(`landing.new`)}),(0,X.jsx)(`p`,{className:`mt-0.5 text-xs text-ink-faint`,children:i(`new.subtitle`)})]}),(0,X.jsx)(`button`,{type:`button`,"aria-label":i(`new.close`),onClick:f,disabled:t,className:`rounded px-2 py-1 text-lg leading-none text-ink-faint hover:bg-surface hover:text-ink disabled:opacity-40`,children:`×`})]}),(0,X.jsxs)(`div`,{className:`space-y-4 p-5`,children:[(0,X.jsxs)(`label`,{className:`block`,children:[(0,X.jsxs)(`span`,{className:`mb-1 block text-[10px] font-semibold uppercase tracking-wider text-ink-faint`,children:[i(`new.name`),` `,(0,X.jsx)(`span`,{className:`normal-case tracking-normal`,children:i(`new.optional`)})]}),(0,X.jsx)(`input`,{"data-autofocus":!0,value:a,onChange:e=>o(e.target.value),maxLength:80,disabled:t,placeholder:i(`new.namePlaceholder`),className:`h-10 w-full rounded border border-line bg-bg/50 px-3 text-sm text-ink outline-none placeholder:text-ink-faint focus:border-blue-deep disabled:opacity-50`})]}),(0,X.jsxs)(`label`,{className:`block`,children:[(0,X.jsxs)(`span`,{className:`mb-1 block text-[10px] font-semibold uppercase tracking-wider text-ink-faint`,children:[i(`new.workdir`),` `,(0,X.jsx)(`span`,{className:`normal-case tracking-normal`,children:i(`new.optional`)})]}),(0,X.jsx)(`input`,{value:l,onChange:e=>u(e.target.value),disabled:t,placeholder:i(`newDaemon.workdirPlaceholder`),className:`h-10 w-full rounded border border-line bg-bg/50 px-3 font-mono text-xs text-ink outline-none placeholder:text-ink-faint focus:border-blue-deep disabled:opacity-50`}),(0,X.jsx)(`span`,{className:`mt-1 block text-[10px] leading-relaxed text-ink-faint`,children:i(`new.workdirHint`)})]}),(0,X.jsxs)(`label`,{className:`block`,children:[(0,X.jsxs)(`span`,{className:`mb-1 block text-[10px] font-semibold uppercase tracking-wider text-ink-faint`,children:[i(`new.objective`),` `,(0,X.jsx)(`span`,{className:`normal-case tracking-normal`,children:i(`new.optional`)})]}),(0,X.jsx)(`textarea`,{value:s,onChange:e=>c(e.target.value),onKeyDown:m,maxLength:4e3,disabled:t,rows:4,placeholder:i(`new.objectivePlaceholder`),className:`w-full resize-y rounded border border-line bg-bg/50 px-3 py-2.5 text-sm leading-relaxed text-ink outline-none placeholder:text-ink-faint focus:border-blue-deep disabled:opacity-50`})]}),(0,X.jsxs)(`div`,{className:`rounded border p-3 ${h?`border-gold/40 bg-gold/5`:`border-line bg-bg/30`}`,children:[(0,X.jsx)(`div`,{className:`text-xs font-medium ${h?`text-gold`:`text-blue-sky`}`,children:i(h?`new.startsAfterCreate`:`new.idleUntilMessage`)}),(0,X.jsx)(`p`,{className:`mt-1 text-[11px] leading-relaxed text-ink-faint`,children:i(h?`new.startsHint`:`new.idleHint`)})]})]}),(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-t border-line px-5 py-3`,children:[(0,X.jsx)(`span`,{className:`text-[10px] text-ink-faint`,children:i(`new.shortcut`)}),(0,X.jsxs)(`div`,{className:`flex gap-2`,children:[(0,X.jsx)(`button`,{type:`button`,onClick:f,disabled:t,className:`rounded border border-line px-3 py-1.5 text-xs text-ink-dim hover:bg-surface disabled:opacity-40`,children:i(`common.cancel`)}),(0,X.jsx)(`button`,{type:`submit`,disabled:t,className:`rounded border border-blue/35 bg-blue/8 px-3 py-1.5 text-xs font-medium text-blue hover:border-blue-deep hover:bg-blue-deep hover:text-white disabled:cursor-wait disabled:opacity-50`,children:i(t?`new.creating`:h?`new.createAndStart`:`sidebar.create`)})]})]})]})})}function Rs({open:e,sid:t,name:n,alive:r,controlAvailable:i=!0,busy:a,onClose:o,onRename:s,onStart:c,onStop:l,onDelete:u}){let{t:d}=Z(),[f,p]=(0,I.useState)(n),[m,h]=(0,I.useState)(!1),[g,_]=(0,I.useState)(!1);(0,I.useEffect)(()=>{e&&(p(n),h(!1),_(!1))},[e,n,t]);let v=async e=>{e.preventDefault(),await s(f.trim())},y=r&&!g,b=async()=>{if(y){await l()&&_(!0);return}await c()&&_(!1)};return(0,X.jsxs)(go,{open:e,onClose:()=>!a&&o(),label:d(`manage.daemon`),width:`max-w-lg`,children:[(0,X.jsxs)(`div`,{className:`border-b border-line px-5 py-4`,children:[(0,X.jsx)(`h2`,{className:`text-base font-semibold text-ink`,children:d(`topbar.manageSession`)}),(0,X.jsx)(`p`,{className:`mt-0.5 font-mono text-[10px] text-ink-faint`,children:t})]}),(0,X.jsx)(`form`,{onSubmit:e=>void v(e),className:`border-b border-line p-5`,children:(0,X.jsxs)(`label`,{className:`block`,children:[(0,X.jsx)(`span`,{className:`mb-1 block text-[10px] font-semibold uppercase tracking-wider text-ink-faint`,children:d(`manage.displayName`)}),(0,X.jsxs)(`div`,{className:`flex gap-2`,children:[(0,X.jsx)(`input`,{value:f,onChange:e=>p(e.target.value),maxLength:80,disabled:a,className:`h-9 min-w-0 flex-1 rounded border border-line bg-bg/50 px-3 text-sm text-ink outline-none focus:border-blue-deep disabled:opacity-50`}),(0,X.jsx)(`button`,{type:`submit`,disabled:a||f.trim()===n,className:`rounded border border-line px-3 text-xs text-ink-dim hover:bg-surface disabled:opacity-40`,children:d(`common.save`)})]})]})}),(0,X.jsxs)(`div`,{className:`border-b border-line p-5`,children:[(0,X.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-wider text-ink-faint`,children:d(`manage.executor`)}),(0,X.jsxs)(`div`,{className:`mt-2 flex items-center justify-between rounded border border-line bg-bg/30 p-3`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`div`,{className:`text-sm text-ink`,children:d(y?i?`manage.running`:`manage.runningExternally`:`manage.paused`)}),(0,X.jsx)(`p`,{className:`mt-0.5 text-[11px] text-ink-faint`,children:d(y?i?`manage.stopNowHint`:`manage.externalHint`:`manage.resumeHint`)})]}),(0,X.jsx)(`button`,{type:`button`,disabled:a||!i,onClick:()=>void b(),className:`rounded border px-3 py-1.5 text-xs disabled:cursor-wait disabled:opacity-50 ${y?`border-warn/50 text-warn hover:bg-warn/10`:`border-blue-deep bg-blue-deep text-white hover:bg-blue-deep/80`}`,children:d(a?`manage.working`:i?y?`manage.stopNow`:`manage.resume`:`common.external`)})]})]}),(0,X.jsxs)(`div`,{className:`p-5`,children:[(0,X.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-wider text-err`,children:d(`manage.deleteSession`)}),(0,X.jsx)(`p`,{className:`mt-1 text-[11px] leading-relaxed text-ink-faint`,children:d(`manage.deleteHint`)}),m?(0,X.jsxs)(`div`,{className:`mt-3 flex items-center justify-between gap-3 rounded border border-err/40 bg-err/5 p-3`,children:[(0,X.jsx)(`span`,{className:`text-xs text-ink-dim`,children:d(`manage.confirmQuestion`)}),(0,X.jsxs)(`div`,{className:`flex gap-2`,children:[(0,X.jsx)(`button`,{type:`button`,onClick:()=>h(!1),className:`rounded px-2 py-1 text-xs text-ink-faint hover:bg-surface`,children:d(`common.cancel`)}),(0,X.jsx)(`button`,{type:`button`,disabled:a,onClick:()=>void u(),className:`rounded bg-err px-3 py-1 text-xs font-medium text-bg disabled:opacity-50`,children:d(`manage.confirmDelete`)})]})]}):(0,X.jsx)(`button`,{type:`button`,disabled:a||y,onClick:()=>h(!0),className:`mt-3 rounded border border-err/40 px-3 py-1.5 text-xs text-err hover:bg-err/10 disabled:cursor-not-allowed disabled:opacity-40`,children:d(`manage.delete`)})]})]})}var zs={科学环境已就绪:`Scientific environment ready`,"科学环境 · ⟦0⟧ 项待配置":`Scientific environment · ⟦0⟧ item(s) to configure`,科学环境:`Scientific environment`,检查环境:`Check environment`,"免费科学组件自动配置;SHELX 需要你在官网取得学术授权后输入下载凭据。":`Free scientific components are configured automatically; SHELX requires academic authorization from the official website before entering download credentials.`,修复依赖:`Repair dependencies`,"配置 SHELX":`Configure SHELX`,"SHELX 授权安装":`SHELX authorized installation`,学术授权:`Academic authorization`,前往官网申请:`Apply on official website`,"填写授权邮件中的 username 和 password,即可自动下载安装。凭据仅用于本次官方下载,不保存,也不发送给模型。":`Enter the username and password from the authorization email to download and install automatically. Credentials are used only for this official download, are not saved, and are not sent to the model.`,用户名:`Username`,"SHELX 用户名":`SHELX username`,密码:`Password`,"SHELX 密码":`SHELX password`,"查看许可 ↗":`View license ↗`,"下载并安装 SHELX":`Download and install SHELX`,取消:`Cancel`,科学软件健康检查:`Scientific software health check`,"点击“检查环境”可验证科学内核与外部程序。":`Click “Check environment” to verify the scientific kernel and external programs.`,可用:`Available`,待授权安装:`Authorization required`,待修复:`Needs repair`,查看检查详情:`View check details`,查看原因与安装方式:`View cause and installation method`,"官方安装说明 ↗":`Official installation instructions ↗`,使用已有安装:`Use existing installation`,"DIALS 环境目录":`DIALS environment directory`,"Systre JAR 路径(需要已有 Java)":`Systre JAR path (existing Java required)`,"⟦0⟧ 可执行文件路径":`⟦0⟧ executable path`,"填写运行 Argus 的电脑上的路径,验证成功后生效。":`Enter the path on the computer running Argus. It takes effect after successful verification.`,验证并使用:`Verify and use`,最近检查:`Last checked`,"· 检查不调用模型":`· Check does not call the model`,无法读取插件列表:`Unable to read plugin list`,插件操作未完成:`Plugin operation incomplete`,插件:`Plugins`,关闭插件列表:`Close plugin list`,"按需安装研究工具,沿用 Argus 的模型与执行后端。":`Install research tools as needed, using Argus's model and execution backend.`,"正在读取插件…":`Reading plugins…`,暂无可用插件:`No plugins available`,已启用:`Enabled`,已停用:`Disabled`,未安装:`Not installed`,"· 当前后端":`· Current backend`,安装:`Install`,打开工作台:`Open workbench`,启用:`Enable`,更新至:`Update to`,停用:`Disable`,卸载:`Uninstall`,"原生会话输入 ⟦0⟧ 可启用后台工具。卸载保留会话、研究数据和科学软件。":`Native session input ⟦0⟧ can enable background tools. Uninstalling preserves sessions, research data, and scientific software.`,"首次安装自动配置独立 Python、DIALS、Systre / Java 和 PLATON 学术免费组件。SHELX 稍后输入授权信息即可安装。":`First installation automatically configures standalone Python, DIALS, Systre / Java, and free academic PLATON components. SHELX can be installed later by entering authorization details.`,"暂不支持,敬请期待。当前插件支持 Codex、Copilot 和 Pi。":`Not supported yet. Stay tuned. Current plugins support Codex, Copilot, and Pi.`,"安装科学环境需要 Python 3.11–3.13。请安装 Python 后重试,或设置 ARGUS_PLUGIN_PYTHON。":`Installing the scientific environment requires Python 3.11–3.13. Install Python and try again, or set ARGUS_PLUGIN_PYTHON.`,准备安装:`Prepare installation`,获取并校验插件包:`Download and verify plugin package`,"安装独立运行环境(首次可能需要几分钟)":`Install standalone environment (may take several minutes the first time)`,"插件仍有任务运行,请等任务结束或先暂停,再进行此操作。":`This plugin still has running tasks. Wait for them to finish or pause them before continuing.`,"此插件版本尚未提供可校验的发行包。":`No verifiable release package is available for this plugin version.`,"插件包校验失败,未安装。":`Plugin package verification failed. Not installed.`,正在准备:`Preparing`,"当前系统或 Argus 插件接口版本暂不支持此插件。":`This plugin is not currently supported by the system or Argus plugin API version.`,"插件发行包尚未发布。":`The plugin release package has not been published.`,安装完成:`Installation complete`,环境检查完成:`Environment check complete`,"此插件已有安装或更新操作正在进行。":`An installation or update operation for this plugin is already in progress.`,插件尚未安装:`Plugin not installed`,"安装进程已中断;已有可用版本保持不变,可重试。":`Installation was interrupted. The existing available version is unchanged; you can retry.`,"安装未完成,已有版本保持不变":`Installation incomplete; existing version unchanged`,"此版本已安装,可启用插件。":`This version is installed. You can enable the plugin.`,请先安装插件:`Install the plugin first`,请先更新插件以使用环境管理功能:`Update the plugin first to use environment management`,"插件包超过允许大小。":`The plugin package exceeds the allowed size.`,科学计算内核:`Scientific computing kernel`,"cctbx · Gemmi · RDKit · 科学服务":`cctbx · Gemmi · RDKit · scientific services`,衍射帧处理与探测器格式支持:`Diffraction frame processing and detector format support`,周期网络与拓扑识别:`Periodic networks and topology identification`,"本地 checkCIF 结构校验 · 学术免费":`Local checkCIF structure validation · free for academic use`,"结构精修 · 需要学术授权":`Structure refinement · academic authorization required`,"结构求解 · 需要学术授权":`Structure solution · academic authorization required`,全部组件可用:`All components available`,部分组件需要配置或修复:`Some components require configuration or repair`,"PLATON 官网中间证书已更换,请更新插件安装器":`The PLATON official-site intermediate certificate has changed. Update the plugin installer.`,"PLATON Mac 发行包架构不符":`PLATON Mac release package architecture mismatch`,"请输入授权邮件中的用户名和密码。":`Enter the username and password from the authorization email.`,请选择有效的科学软件路径:`Select a valid scientific software path`,检查科学软件与运行环境:`Check scientific software and runtime environment`,"正在修复科学 Python 依赖":`Repairing scientific Python dependencies`,"(首次下载可能需要几分钟)":`(The initial download may take several minutes)`,"from cctbx.array_family import flex; import gemmi,rdkit; from argus_crystalpilot import worker; from argus_crystalpilot.resources import bundle_root; assert (bundle_root()/'ui/dist/index.html').is_file(); import crystalpilot; from pathlib import Path; assert (Path(crystalpilot.__file__).parent/'io/dxtbx_plugin/pyproject.toml').is_file(); assert flex.double([1,2]).size()==2; print('科学内核及工作台资源可用')":`from cctbx.array_family import flex; import gemmi,rdkit; from argus_crystalpilot import worker; from argus_crystalpilot.resources import bundle_root; assert (bundle_root()/'ui/dist/index.html').is_file(); import crystalpilot; from pathlib import Path; assert (Path(crystalpilot.__file__).parent/'io/dxtbx_plugin/pyproject.toml').is_file(); assert flex.double([1,2]).size()==2; print('Scientific kernel and workbench resources available')`,"; from importlib.metadata import entry_points; assert {'FormatCBFMiniRigaku:FormatCBF','FormatBrukerSfrmGeom:FormatBruker','FormatRODLegacy:FormatROD'} <= {e.name for e in entry_points(group='dxtbx.format')}; from dials.util.version import dials_version; assert flex.reflection_table() is not None; print(dials_version()+' · 探测器格式插件可用')":`; from importlib.metadata import entry_points; assert {'FormatCBFMiniRigaku:FormatCBF','FormatBrukerSfrmGeom:FormatBruker','FormatRODLegacy:FormatROD'} <= {e.name for e in entry_points(group='dxtbx.format')}; from dials.util.version import dials_version; assert flex.reflection_table() is not None; print(dials_version()+' · detector format plugins available')`,"Systre 19.6.0 · pcu 拓扑计算通过":`Systre 19.6.0 · pcu topology calculation passed`,"正在安装 Apple Rosetta 2 兼容组件":`Installing Apple Rosetta 2 compatibility components`,"从 SHELX 官方站点下载":`Downloading from the official SHELX site`,"SHELX 下载内容不是支持的可执行程序":`SHELX download is not a supported executable`,"已可用,保留当前安装":`Already available; keeping current installation`,正在安装:`Installing`,"尚未安装 DIALS":`DIALS is not installed`,"PLATON 编译需要 Apple 命令行工具;请运行 xcode-select --install,然后点击修复依赖。":`PLATON compilation requires Apple Command Line Tools; run xcode-select --install, then click Repair dependencies.`,"SHELX 官方 Mac 版需要 Rosetta 2,请先同意安装兼容组件。":`The official Mac version of SHELX requires Rosetta 2. Agree to install the compatibility components first.`,"暂未完成;可在健康检查中重试":`Not completed; retry from the health check`,"SHELX 下载或启动失败;请核对授权、网络及系统平台后重试。":`SHELX download or launch failed; check authorization, network, and system platform, then retry.`,"尚未安装 Systre":`Systre is not installed`,"尚未安装 Java":`Java is not installed`,"Systre 未能识别内置 pcu 网络":`Systre could not identify the built-in pcu network`,"尚未安装 PLATON":`PLATON is not installed`,"PLATON 安装配方已更新,点击修复依赖即可使用当前版本。":`The PLATON installation recipe has been updated. Click Repair dependencies to use the current version.`,"PLATON 未生成校验规则;请检查运行库":`PLATON did not generate verification rules; check the runtime`,"请输入 SHELX 授权信息以安装":`Enter SHELX authorization details to install`,"无法启动,请核对平台与运行库":`Unable to start; check the platform and runtime`,"衍射数据处理、结构求解、精修与三维晶体研究工作台":`Diffraction data processing, structure solution, refinement and a 3D crystallography workbench`},Bs=e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),Vs=/⟦\d+⟧/g,Hs=Object.entries(zs).filter(([e])=>e.includes(`⟦`)).sort((e,t)=>t[0].length-e[0].length).map(([e,t])=>({regex:RegExp(`^`+e.split(Vs).map(Bs).join(`([\\s\\S]*?)`)+`$`),slots:e.match(Vs)??[],target:t})),Us=new RegExp(Object.keys(zs).filter(e=>e.length>1&&!e.includes(`⟦`)).sort((e,t)=>t.length-e.length).map(Bs).join(`|`),`g`);function Ws(e,t){if(t===`zh-CN`||!/[\u3400-\u9fff]/.test(e))return e;if(zs[e.trim()])return e.replace(e.trim(),zs[e.trim()]);for(let t of Hs){let n=t.regex.exec(e.trim());if(n){let e=new Map(t.slots.map((e,t)=>[e,n[t+1]]));return t.target.replace(Vs,t=>e.get(t)??t)}}return e.replace(Us,e=>zs[e])}function Gs(){let{locale:e}=Z();return t=>typeof t==`string`?Ws(t,e):t}var Ks=Se(),qs=`inline-flex items-center justify-center gap-1.5 rounded-lg border border-line px-3 py-1.5 text-sm transition-colors hover:bg-bg disabled:cursor-not-allowed disabled:opacity-45`;function Js({health:e,setup:t,running:n,act:r,platform:i,machine:a}){let o=Gs(),[s,c]=(0,I.useState)(!1),[l,u]=(0,I.useState)(!1),[d,f]=(0,I.useState)(``),[p,m]=(0,I.useState)(``),[h,g]=(0,I.useState)(null),[_,v]=(0,I.useState)(``),[y,b]=(0,I.useState)(!1),x=t.license?.platform_consent,S=x?.platform===i&&x?.machines.includes(a||``),C=e?.components||[],w=C.filter(e=>e.status!==`ready`),T=w.some(e=>e.license_required),E=w.some(e=>e.automatic);async function D(e){e.preventDefault();let n=await r(t.license.action,{username:d,password:p,accept_platform_license:y});m(``),n&&(u(!1),f(``),c(!0))}return(0,X.jsxs)(`div`,{className:`mt-5 border-t border-line/60 pt-4`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,X.jsxs)(`button`,{type:`button`,"aria-expanded":s,onClick:()=>c(!s),className:`inline-flex items-center gap-2 text-sm text-ink-dim hover:text-ink`,children:[(0,X.jsx)(ro,{size:16,strokeWidth:1.5}),(0,X.jsx)(`span`,{children:o(e?.checked?e.ready?o(`科学环境已就绪`):o(`科学环境 · ${w.length} 项待配置`):o(`科学环境`))}),(0,X.jsx)(Ha,{size:13,className:`transition-transform duration-200 ${s?`rotate-180`:``}`})]}),(0,X.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 text-xs text-ink-faint hover:text-ink disabled:opacity-45`,disabled:n,onClick:()=>{c(!0),r(`health`)},children:[(0,X.jsx)(no,{size:12}),o(`检查环境`)]})]}),o((T||E||!e?.checked)&&(0,X.jsx)(`p`,{className:`mt-2 text-xs leading-relaxed text-ink-faint`,children:o(` 免费科学组件自动配置;SHELX 需要你在官网取得学术授权后输入下载凭据。 `)})),(0,X.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[o((E||!e?.checked)&&(0,X.jsxs)(`button`,{className:qs,disabled:n,onClick:()=>{c(!0),r(`repair`)},children:[(0,X.jsx)(qa,{size:14}),o(`修复依赖`)]})),o(t.license&&(0,X.jsxs)(`button`,{className:qs,disabled:n,onClick:()=>{u(!l),m(``),f(``)},children:[(0,X.jsx)(Xa,{size:14}),o(o(T?`配置 SHELX`:`SHELX 授权安装`))]}))]}),o(l&&t.license&&(0,X.jsxs)(`form`,{onSubmit:D,className:`mt-4 rounded-lg bg-bg/70 p-3`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-2 text-sm`,children:[(0,X.jsxs)(`span`,{className:`font-medium`,children:[o(t.license.name),o(` 学术授权`)]}),(0,X.jsxs)(`a`,{href:t.license.url,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-xs text-blue`,children:[o(`前往官网申请`),(0,X.jsx)(Ja,{size:11})]})]}),(0,X.jsx)(`p`,{className:`mb-3 mt-1.5 text-xs leading-relaxed text-ink-faint`,children:o(`填写授权邮件中的 username 和 password,即可自动下载安装。凭据仅用于本次官方下载,不保存,也不发送给模型。`)}),(0,X.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,X.jsxs)(`label`,{className:`text-xs text-ink-dim`,children:[o(`用户名`),(0,X.jsx)(`input`,{"aria-label":o(`SHELX 用户名`),value:d,onChange:e=>f(e.target.value),required:!0,maxLength:200,autoComplete:`off`,autoCapitalize:`none`,spellCheck:!1,className:`mt-1.5 w-full rounded-md border border-line bg-panel px-2.5 py-2 text-sm text-ink outline-none focus:border-blue/60`})]}),(0,X.jsxs)(`label`,{className:`text-xs text-ink-dim`,children:[o(`密码`),(0,X.jsx)(`input`,{"aria-label":o(`SHELX 密码`),type:`password`,value:p,onChange:e=>m(e.target.value),required:!0,maxLength:500,autoComplete:`new-password`,className:`mt-1.5 w-full rounded-md border border-line bg-panel px-2.5 py-2 text-sm text-ink outline-none focus:border-blue/60`})]})]}),o(S&&x&&(0,X.jsxs)(`label`,{className:`mt-3 flex items-start gap-2 text-xs leading-relaxed text-ink-faint`,children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:y,onChange:e=>b(e.target.checked),className:`mt-0.5`}),(0,X.jsxs)(`span`,{children:[o(x.text),` `,(0,X.jsx)(`a`,{href:x.url,target:`_blank`,rel:`noreferrer`,className:`text-blue`,children:o(`查看许可 ↗`)})]})]})),(0,X.jsxs)(`div`,{className:`mt-3 flex gap-2`,children:[(0,X.jsxs)(`button`,{type:`submit`,className:qs,disabled:n||!d.trim()||!p.trim(),children:[(0,X.jsx)(qa,{size:14}),o(`下载并安装 SHELX`)]}),(0,X.jsx)(`button`,{type:`button`,className:`px-2 text-xs text-ink-faint`,onClick:()=>{u(!1),f(``),m(``)},children:o(`取消`)})]})]})),s&&(0,X.jsxs)(`div`,{className:`mt-3`,"aria-label":o(`科学软件健康检查`),children:[o(!C.length&&(0,X.jsx)(`p`,{className:`py-2 text-xs text-ink-faint`,children:o(`点击“检查环境”可验证科学内核与外部程序。`)})),C.map(e=>(0,X.jsx)(`div`,{className:`border-b border-line/40 py-2.5 last:border-0`,children:(0,X.jsxs)(`div`,{className:`flex items-start gap-2.5`,children:[o(e.status===`ready`?(0,X.jsx)(Va,{size:15,strokeWidth:1.7,className:`mt-0.5 shrink-0 text-blue/75`}):(0,X.jsx)(Wa,{size:15,strokeWidth:1.5,className:`mt-0.5 shrink-0 text-ink-faint`})),(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-3 text-sm`,children:[(0,X.jsx)(`span`,{children:o(e.name)}),(0,X.jsx)(`span`,{className:`shrink-0 text-xs text-ink-faint`,children:o(e.status===`ready`?o(`可用`):e.license_required?o(`待授权安装`):o(`待修复`))})]}),(0,X.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-ink-faint`,children:o(e.description)}),(0,X.jsxs)(`details`,{className:`mt-1.5 text-xs text-ink-faint`,children:[(0,X.jsx)(`summary`,{className:`cursor-pointer hover:text-ink-dim`,children:o(e.status===`ready`?o(`查看检查详情`):o(`查看原因与安装方式`))}),(0,X.jsx)(`p`,{className:`mt-2 whitespace-pre-wrap break-words leading-relaxed`,children:o(e.detail)}),e.path&&(0,X.jsx)(`p`,{className:`mt-1 break-all leading-relaxed`,children:e.path}),(0,X.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-3`,children:[(0,X.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,className:`text-blue`,children:o(`官方安装说明 ↗`)}),o(e.id!==`python`&&t.actions.includes(`configure`)&&(0,X.jsx)(`button`,{type:`button`,disabled:n,onClick:()=>{g(e.id),v(``)},className:`text-blue`,children:o(`使用已有安装`)}))]})]})]})]})},e.id)),o(h&&(0,X.jsxs)(`form`,{onSubmit:async e=>{e.preventDefault(),await r(`configure`,{paths:{[h]:_}})&&(g(null),v(``))},className:`mt-3 rounded-lg bg-bg/70 p-3`,children:[(0,X.jsxs)(`label`,{className:`text-xs text-ink-dim`,children:[o(o(h===`dials`?`DIALS 环境目录`:h===`systre`?`Systre JAR 路径(需要已有 Java)`:`${h.toUpperCase()} 可执行文件路径`)),(0,X.jsx)(`input`,{required:!0,value:_,onChange:e=>v(e.target.value),className:`mt-2 w-full rounded-md border border-line bg-panel px-2 py-2 text-sm text-ink`})]}),(0,X.jsx)(`p`,{className:`mt-1.5 text-xs text-ink-faint`,children:o(`填写运行 Argus 的电脑上的路径,验证成功后生效。`)}),(0,X.jsxs)(`div`,{className:`mt-3 flex gap-3`,children:[(0,X.jsx)(`button`,{className:qs,disabled:n,children:o(`验证并使用`)}),(0,X.jsx)(`button`,{type:`button`,className:`text-xs text-ink-faint`,onClick:()=>g(null),children:o(`取消`)})]})]})),o(e?.checked&&(0,X.jsxs)(`p`,{className:`mt-2 text-[11px] text-ink-faint`,children:[o(`最近检查 `),o(new Date(e.checked*1e3).toLocaleString()),o(` · 检查不调用模型`)]}))]})]})}function Ys({compact:e=!1}){let t=Gs(),{locale:n}=Z(),[r,i]=(0,I.useState)(!1),[a,o]=(0,I.useState)([]),[s,c]=(0,I.useState)(``),[l,u]=(0,I.useState)(!1),[d,f]=(0,I.useState)(null),p=(0,I.useRef)(null);async function m(e){let n=await fetch(`/api/plugins`,{headers:Ke(),signal:e});if(!n.ok)throw Error(t(`无法读取插件列表`));o((await n.json()).plugins)}(0,I.useEffect)(()=>{if(!r)return;let e=new AbortController;p.current?.focus(),c(``),u(!0),m(e.signal).catch(t=>{e.signal.aborted||c(t.message)}).finally(()=>u(!1));let t=window.setInterval(()=>void m(e.signal).catch(()=>{}),1500),n=e=>{e.key===`Escape`&&i(!1)};return window.addEventListener(`keydown`,n),()=>{e.abort(),window.clearInterval(t),window.removeEventListener(`keydown`,n)}},[r]);async function h(e,n,r){f(e.id),c(``);try{let i=await fetch(`/api/plugins/${e.id}/${n===`launch`?`launch`:`manage/${n}`}`,{method:`POST`,headers:{...Ke(),"Content-Type":`application/json`},body:r?JSON.stringify(r):void 0}),a=await i.json();if(!i.ok)throw Error(a.detail||t(`插件操作未完成`));return n===`launch`?window.location.assign(a.url):await m(),!0}catch(e){return c(e instanceof Error?e.message:String(e)),!1}finally{f(null)}}return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`button`,{type:`button`,onClick:()=>i(!0),title:t(`插件`),"aria-label":t(`插件`),className:`mx-2 my-1 flex h-9 shrink-0 items-center rounded-md text-sm text-ink-dim transition-colors hover:bg-bg hover:text-ink ${e?`justify-center`:`gap-2 px-3`}`,children:[(0,X.jsx)(Ba,{size:17,strokeWidth:1.5}),t(!e&&(0,X.jsx)(`span`,{children:t(`插件`)}))]}),r&&(0,Ks.createPortal)((0,X.jsx)(`div`,{className:`fixed inset-0 z-[100] flex items-center justify-center bg-black/20 p-5 backdrop-blur-sm`,onClick:()=>i(!1),children:(0,X.jsxs)(`section`,{role:`dialog`,"aria-modal":`true`,"aria-labelledby":`plugin-title`,onClick:e=>e.stopPropagation(),className:`max-h-[85vh] w-full max-w-xl overflow-y-auto rounded-2xl border border-line bg-panel p-6 text-ink shadow-xl`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,X.jsx)(`h2`,{id:`plugin-title`,className:`text-lg font-semibold`,children:t(`插件`)}),(0,X.jsx)(`button`,{ref:p,type:`button`,"aria-label":t(`关闭插件列表`),className:`icon-control p-1.5`,onClick:()=>i(!1),children:(0,X.jsx)(oo,{size:18})})]}),(0,X.jsx)(`p`,{className:`mb-6 mt-2 text-sm text-ink-faint`,children:t(`按需安装研究工具,沿用 Argus 的模型与执行后端。`)}),t(s&&(0,X.jsx)(`p`,{role:`alert`,className:`mb-4 text-sm text-ink-dim`,children:t(s)})),t(l&&(0,X.jsx)(`p`,{className:`text-sm text-ink-faint`,children:t(`正在读取插件…`)})),t(!l&&!a.length&&(0,X.jsx)(`p`,{className:`text-sm text-ink-faint`,children:t(`暂无可用插件`)})),t(a.map(e=>{let r=e.operation?.status===`running`||d===e.id,i=r||!e.supported,a=`inline-flex items-center justify-center gap-1.5 rounded-lg border border-line px-3 py-1.5 text-sm transition-colors hover:bg-bg disabled:cursor-not-allowed disabled:opacity-45`;return(0,X.jsxs)(`article`,{className:`rounded-xl border border-line/70 p-4`,"data-testid":`plugin-${e.id}`,children:[(0,X.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,X.jsx)(Ka,{size:24,strokeWidth:1.25,className:`mt-0.5 shrink-0 text-blue`}),(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,X.jsx)(`h3`,{className:`font-medium`,children:t(e.name)}),(0,X.jsx)(`span`,{className:`text-xs text-ink-faint`,children:t(e.installed_version||e.version)})]}),(0,X.jsx)(`p`,{className:`mt-1 text-sm leading-relaxed text-ink-faint`,children:t(e.description)})]})]}),(0,X.jsxs)(`div`,{className:`mt-4 text-xs text-ink-faint`,children:[t(e.installed?e.enabled?t(`已启用`):t(`已停用`):t(`未安装`)),t(` · 当前后端 `),t(Array.from(new Set(Object.values(e.backends))).join(` / `))]}),t(!e.supported&&(0,X.jsx)(`p`,{className:`mt-3 text-sm text-ink-dim`,children:t(e.reason)})),t(e.operation?.status===`running`&&(0,X.jsxs)(`p`,{role:`status`,className:`mt-3 flex items-center gap-2 text-sm text-ink-dim`,children:[(0,X.jsx)(Za,{size:14,className:`animate-spin`}),t(e.operation.progress)]})),t(e.operation?.status===`failed`&&(0,X.jsx)(`p`,{role:`status`,className:`mt-3 break-words text-sm text-ink-dim`,children:t(e.operation.error)})),(0,X.jsxs)(`div`,{className:`mt-4 flex flex-wrap items-center gap-2`,children:[t(!e.installed&&(0,X.jsxs)(`button`,{className:a,disabled:i,onClick:()=>void h(e,`install`),children:[(0,X.jsx)(qa,{size:14}),t(`安装`)]})),t(e.installed&&e.enabled&&(0,X.jsxs)(`button`,{className:a,disabled:i,onClick:()=>void h(e,`launch`),children:[t(`打开工作台`),(0,X.jsx)(Ra,{size:14})]})),t(e.installed&&!e.enabled&&(0,X.jsx)(`button`,{className:a,disabled:i,onClick:()=>void h(e,`enable`),children:t(`启用`)})),t(e.update_available&&(0,X.jsxs)(`button`,{className:a,disabled:i,onClick:()=>void h(e,`update`),children:[(0,X.jsx)(no,{size:14}),t(`更新至 `),t(e.version)]})),t(e.installed&&e.enabled&&(0,X.jsx)(`button`,{className:a,disabled:r,onClick:()=>void h(e,`disable`),children:t(`停用`)})),t(e.installed&&(0,X.jsx)(`button`,{className:a,disabled:r,onClick:()=>void h(e,`uninstall`),children:t(`卸载`)}))]}),(0,X.jsx)(`p`,{className:`mt-4 text-xs leading-relaxed text-ink-faint`,children:t(e.installed?t(`原生会话输入 ${e.command||``} 可启用后台工具。卸载保留会话、研究数据和科学软件。`):t(`首次安装自动配置独立 Python、DIALS、Systre / Java 和 PLATON 学术免费组件。SHELX 稍后输入授权信息即可安装。`))}),t(e.rights_notice&&(0,X.jsx)(`p`,{className:`mt-3 text-[10px] leading-relaxed text-ink-faint`,"data-testid":`plugin-rights-notice`,children:t(n===`zh-CN`&&e.rights_notice_zh||e.rights_notice)})),t(e.installed&&e.setup&&(0,X.jsx)(Js,{health:e.health,setup:e.setup,running:r,platform:e.platform,machine:e.machine,act:(t,n)=>h(e,t,n)}))]},e.id)}))]})}),document.body)]})}function Xs(e){return e.replace(/[\\/]+$/,``).split(/[\\/]/).at(-1)||e}function Zs(e,t,n){if(e.length===0)return`local`;let r=n.trim(),i=r?e.filter(e=>e.launch_cwd?.trim()===r):[];return i.length===0||t&&!i.some(e=>e.id===t)?`all`:`local`}function Qs({projects:e,activeId:t,localCwd:n,onSelect:i,onPrefetch:a,onManage:s,onResume:l,resumingId:u,onOpenPanel:d,onNew:f,loading:p,creating:m=!1,error:h,onRetry:_,mobileOpen:v=!1,collapsed:y=!1,onToggleCollapse:S,themeMode:w,onCycleTheme:ee}){let{locale:O,setLocale:te,t:k}=Z(),[re,A]=(0,I.useState)(`local`),j=(0,I.useRef)(!1),[ie,ae]=(0,I.useState)(``),[M,oe]=(0,I.useState)(()=>new Set),se=y&&!v,N=n.trim(),ce=(0,I.useMemo)(()=>N?e.filter(e=>e.launch_cwd?.trim()===N):[],[N,e]);(0,I.useEffect)(()=>{j.current||p||e.length===0||(j.current=!0,A(Zs(e,t,N)))},[t,p,N,e]);let le=re===`local`?ce:e,ue=ie.trim()?Mn(le,ie):le,de=(0,I.useMemo)(()=>{if(re===`local`)return ue.length>0?[[N||`Local`,ue]]:[];let e=new Map;return ue.forEach(t=>{let n=t.launch_cwd?.trim()||k(`common.unassigned`),r=e.get(n)??[];r.push(t),e.set(n,r)}),[...e.entries()]},[N,re,ue]),fe=w===`light`?c:ne,P=w===`light`?`dark`:`light`,F=e=>M.has(e)&&!ie.trim();return(0,X.jsxs)(`aside`,{"data-state":se?`collapsed`:`expanded`,"data-resizable-panel":`left`,className:`glass-panel glass-panel--side fixed inset-y-0 left-0 z-50 flex h-full shrink-0 flex-col border-r transition-[width,transform,visibility] duration-panel ease-panel lg:visible lg:static lg:z-auto lg:translate-x-0 ${se?`w-14`:`w-64 lg:w-[var(--sidebar-width)]`} ${v?`visible translate-x-0`:`invisible -translate-x-full`}`,children:[(0,X.jsx)(`div`,{className:`chrome-seam-surface flex h-12 shrink-0 items-center border-b border-line/50 ${se?`justify-center`:`justify-between px-4`}`,children:se?(0,X.jsx)(Mi,{size:22,compact:!0}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Mi,{size:24}),(0,X.jsx)(`button`,{type:`button`,onClick:S,"aria-label":k(`sidebar.collapse`),title:`${k(`sidebar.collapse`)} · Ctrl/⌘ B`,className:`icon-control flex h-8 w-8 shrink-0 items-center justify-center`,children:(0,X.jsx)(o,{icon:E,className:`h-3.5 w-3.5`})})]})}),se?(0,X.jsx)(`div`,{className:`flex h-12 shrink-0 items-center justify-center`,children:(0,X.jsx)(`button`,{type:`button`,onClick:S,"aria-label":k(`sidebar.expand`),title:`${k(`sidebar.expand`)} · Ctrl/⌘ B`,className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-md border border-line/50 bg-bg/40 text-ink-faint hover:border-blue/50 hover:text-ink`,children:(0,X.jsx)(o,{icon:x,className:`h-3.5 w-3.5`})})}):null,(0,X.jsx)(Ys,{compact:se}),se?null:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`flex h-12 shrink-0 items-center gap-1 border-b border-line/50 px-3`,children:[[`local`,`all`].map(t=>(0,X.jsxs)(`button`,{type:`button`,onClick:()=>A(t),className:`h-8 rounded-md px-3 text-xs font-medium capitalize transition-colors ${re===t?`bg-bg text-ink`:`text-ink-faint hover:text-ink-dim`}`,children:[k(`common.${t}`),(0,X.jsx)(`span`,{className:`ml-1.5 font-mono text-ink-faint`,children:t===`local`?ce.length:e.length})]},t)),(0,X.jsx)(`button`,{type:`button`,onClick:f,disabled:m,"aria-label":k(`sidebar.create`),title:k(`sidebar.create`),className:`ml-auto flex h-8 w-8 items-center justify-center rounded-md text-lg text-blue hover:bg-bg disabled:opacity-40`,children:m?`…`:`+`})]}),(0,X.jsxs)(`div`,{className:`px-3 py-2`,children:[(0,X.jsx)(`label`,{className:`sr-only`,htmlFor:`daemon-search`,children:k(`sidebar.find`)}),(0,X.jsxs)(`div`,{className:`flex items-center rounded-md border border-line/60 bg-bg/60 px-2 focus-within:border-blue/60`,children:[(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`mr-1.5 text-xs text-ink-faint`,children:`/`}),(0,X.jsx)(`input`,{id:`daemon-search`,value:ie,onChange:e=>ae(e.target.value),placeholder:k(`sidebar.find`),className:`h-8 min-w-0 flex-1 bg-transparent text-xs text-ink outline-none placeholder:text-ink-faint`}),ie?(0,X.jsx)(`button`,{type:`button`,"aria-label":k(`sidebar.clearSearch`),onClick:()=>ae(``),className:`px-1 text-sm text-ink-faint hover:text-ink`,children:`×`}):null]})]}),(0,X.jsxs)(`div`,{className:`mobile-scroll-region min-h-0 flex-1 overflow-x-hidden overflow-y-auto px-3 pb-3 scroll-thin`,children:[p&&e.length===0?(0,X.jsx)(`div`,{className:`px-1 py-3 text-xs text-ink-faint`,children:k(`common.loading`)}):null,h?(0,X.jsx)(`button`,{type:`button`,onClick:_,className:`mb-2 w-full rounded-md bg-err/5 px-3 py-2 text-left text-xs text-err`,children:k(`sidebar.refreshFailed`)}):null,!p&&!h&&ue.length===0?(0,X.jsxs)(`div`,{className:`px-1 py-4 text-xs text-ink-faint`,children:[(0,X.jsx)(`div`,{children:ie.trim()?k(`sidebar.noMatches`,{query:ie.trim()}):k(`sidebar.noSessions`)}),ie.trim()?(0,X.jsx)(`button`,{type:`button`,onClick:()=>ae(``),className:`mt-2 text-xs text-ink-dim underline underline-offset-2 hover:text-ink`,children:k(`sidebar.clearSearch`)}):null]}):null,de.map(([e,n])=>(0,X.jsxs)(`section`,{className:`mb-4 last:mb-0`,children:[(0,X.jsxs)(`button`,{type:`button`,"aria-expanded":!F(e),title:e,onClick:()=>oe(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),className:`mb-1 flex h-7 w-full items-center gap-2 rounded-md px-1.5 text-left text-[11px] font-medium text-ink-faint hover:bg-bg/70 hover:text-ink-dim`,children:[(0,X.jsx)(o,{icon:T,className:`h-2.5 w-2.5 transition-transform ${F(e)?`-rotate-90`:``}`}),(0,X.jsx)(o,{icon:C,className:`h-3 w-3`}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:Xs(e)}),(0,X.jsx)(`span`,{className:`font-mono text-[10px]`,children:n.length})]}),F(e)?null:n.map(e=>{let n=e.id===t,c=En(e),d=c?(e.label||e.display_name||``).trim():e.objective.trim()||e.id||k(`sidebar.unnamedSession`),f=e.daemon_alive&&e.daemon_protocol_compatible===!1,p=f&&e.daemon_protocol_error===`daemon release is incompatible with WebAPI release`,m=f&&!p,h=!e.daemon_alive&&e.last_active>0&&!!e.workdir?.trim();return(0,X.jsxs)(`div`,{"data-active":n?`true`:`false`,onPointerEnter:()=>{n||a?.(e.id)},className:`session-card group relative mb-0.5 h-14 w-full rounded-md transition-colors duration-150 ease-panel ${n?`text-ink`:`text-ink-dim hover:text-ink`}`,children:[(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`absolute left-0 transition-colors ${n?`inset-y-1 w-px bg-blue`:`inset-y-2 w-px bg-transparent group-hover:bg-ink-faint/30`}`}),(0,X.jsxs)(`button`,{type:`button`,onClick:()=>i(e.id),onFocus:()=>{n||a?.(e.id)},"aria-current":n?`page`:void 0,title:`${d}${!c&&d!==e.id?` · ${e.id}`:``}${e.objective&&e.objective!==d?` — ${e.objective}`:``}`,className:`flex h-14 w-full min-w-0 flex-col justify-center px-2.5 text-left ${h?`pr-[4.75rem]`:`pr-10`}`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,X.jsx)(gi,{ok:e.daemon_alive&&!m,title:m?k(`sidebar.updateRequired`):e.daemon_alive?k(`sidebar.daemonAlive`):k(`sidebar.stopped`)}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm font-medium`,children:d})]}),(0,X.jsxs)(`div`,{className:`mt-1 flex min-w-0 items-center gap-1.5 pl-3.5 text-[11px] text-ink-faint`,children:[(0,X.jsx)(`span`,{className:`min-w-0 truncate ${m?`text-warn`:``}`,children:m?k(`sidebar.updateRequired`):e.daemon_alive?k(`sidebar.runningFor`,{uptime:ui(e.uptime_seconds)}):li(e.last_active)}),p&&(0,X.jsx)(`span`,{title:k(`sidebar.updateAvailableHint`),className:`shrink-0 rounded border border-line px-1 text-[10px] leading-4`,children:k(`sidebar.updateAvailable`)})]})]}),h&&l?(0,X.jsx)(`button`,{type:`button`,disabled:u!=null,onClick:t=>{t.stopPropagation(),l(e.id)},"aria-label":k(`sidebar.resume`),title:k(`sidebar.resumeHint`,{workdir:e.workdir??``}),className:`absolute right-9 top-3 flex h-8 w-8 items-center justify-center rounded-md text-blue opacity-100 hover:bg-blue/10 disabled:opacity-40 sm:opacity-0 sm:group-hover:opacity-100 sm:group-focus-within:opacity-100`,children:u===e.id?`…`:(0,X.jsx)(o,{icon:r,className:`h-3 w-3`})}):null,(0,X.jsx)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),s(e.id)},"aria-label":k(`sidebar.manage`,{name:d}),title:k(`sidebar.manageHint`),className:`absolute right-1 top-3 flex h-8 w-8 items-center justify-center rounded-md text-ink-faint opacity-100 transition-opacity hover:bg-panel-raised hover:text-ink sm:opacity-0 sm:group-hover:opacity-100 sm:group-focus-within:opacity-100`,children:(0,X.jsx)(o,{icon:D,className:`h-4 w-4`})})]},e.id)})]},e))]}),(0,X.jsxs)(`div`,{className:`flex min-h-14 items-center justify-between border-t border-line/50 px-4 py-2`,children:[(0,X.jsx)(`button`,{type:`button`,onClick:()=>d(`config`),className:`icon-control flex h-8 w-8 items-center justify-center`,"aria-label":k(`sidebar.openSettings`),title:k(`common.settings`),children:(0,X.jsx)(o,{icon:b,className:`h-3.5 w-3.5`})}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>te(O===`zh-CN`?`en`:`zh-CN`),title:k(`language.switchTo`,{language:k(O===`zh-CN`?`language.english`:`language.chinese`)}),"aria-label":k(`language.switchTo`,{language:k(O===`zh-CN`?`language.english`:`language.chinese`)}),className:`icon-control flex h-8 w-8 items-center justify-center`,children:(0,X.jsx)(o,{icon:g,className:`h-3.5 w-3.5`})}),(0,X.jsx)(`button`,{type:`button`,onClick:ee,title:k(`sidebar.theme`,{current:w,next:P}),"aria-label":k(`sidebar.theme`,{current:w,next:P}),className:`icon-control flex h-8 w-8 items-center justify-center`,children:(0,X.jsx)(o,{icon:fe,className:`h-3.5 w-3.5`})})]})]})]})}var $s={in_progress:`rgb(var(--blue))`,running:`rgb(var(--blue))`,pending:`rgb(var(--ink-faint))`,queued:`rgb(var(--ink-faint))`,done:`rgb(var(--blue))`,completed:`rgb(var(--blue))`,blocked:`rgb(var(--err))`,failed:`rgb(var(--err))`};function ec({items:e,onDispose:t,onStop:n,onInspect:r,busy:i,readOnly:a=!1}){let{t:o}=Z(),[s,c]=(0,I.useState)(!1),l=Vn(e,!1),u=Vn(e,!0),d=s?u:l;return(0,X.jsxs)(`section`,{className:`card flex flex-col ${d.length>0?`min-h-0 flex-1`:`shrink-0`}`,children:[(0,X.jsx)(yi,{title:o(`panel.backlog`),right:(0,X.jsx)(`button`,{className:`text-[10px] text-ink-faint transition-colors hover:text-ink`,onClick:()=>c(e=>!e),children:o(s?`backlog.active`:`backlog.history`,{count:s?l.length:u.length})})}),(0,X.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto scroll-thin`,children:[d.length===0&&(0,X.jsx)(xi,{children:o(s?`backlog.noHistory`:`backlog.empty`)}),d.map(e=>{let s=$s[e.status]??`rgb(var(--ink-faint))`,c=e.iterate;return(0,X.jsx)(`div`,{className:`group border-b border-line/60 px-3 py-2 last:border-0`,children:(0,X.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsx)(`button`,{type:`button`,onClick:()=>r?.(e.id),disabled:!r,className:`block max-w-full truncate text-left text-xs font-medium text-ink enabled:hover:text-blue-sky enabled:focus-visible:outline-none enabled:focus-visible:underline`,title:r?o(`backlog.viewDetails`):void 0,children:e.title||e.objective}),(0,X.jsxs)(`div`,{className:`mt-0.5 flex items-center gap-1.5`,children:[(0,X.jsx)(_i,{color:s,children:Bi(e.status,o)}),typeof e.priority==`number`&&(0,X.jsx)(`span`,{className:`text-[10px] text-ink-faint`,children:Hi(e.priority,o)}),c&&(0,X.jsxs)(`span`,{className:`text-[10px] text-blue-sky`,children:[`↻ `,o(`backlog.iterating`)]})]})]}),(0,X.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1 opacity-0 transition-opacity group-focus-within:opacity-100 group-hover:opacity-100`,children:[!a&&c&&(0,X.jsx)(vi,{variant:`ghost`,onClick:()=>n(e.id),disabled:i,title:o(`backlog.stopIterating`),children:o(`backlog.stop`)}),!a&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(vi,{variant:`ghost`,onClick:()=>t(e.id,`done`),disabled:i,title:o(`backlog.markDone`),children:`✓`}),(0,X.jsx)(vi,{variant:`ghost`,onClick:()=>t(e.id,`rm`),disabled:i,title:o(`backlog.remove`),children:`✕`})]})]})]})},e.id)})]})]})}var tc={win:`rgb(var(--blue))`,milestone:`rgb(var(--blue))`,insight:`rgb(var(--ink-dim))`,decision:`rgb(var(--ink-dim))`,failure:`rgb(var(--err))`,note:`rgb(var(--ink-faint))`};function nc({entries:e}){let{t}=Z(),n=[...e].reverse();return(0,X.jsxs)(`section`,{className:`card flex min-h-0 flex-1 flex-col`,children:[(0,X.jsx)(yi,{title:t(`panel.journal`),right:(0,X.jsx)(`span`,{className:`text-[10px] text-ink-faint`,children:e.length})}),(0,X.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto scroll-thin`,children:[e.length===0&&(0,X.jsx)(xi,{children:`no journal entries yet`}),n.map(e=>{let t=tc[e.kind]??`rgb(var(--ink-faint))`,n=String(e.extra?.pricing_status??``),r=e.extra&&Object.prototype.hasOwnProperty.call(e.extra,`cost_usd`)?e.extra.cost_usd:e.cost_usd,i=typeof r==`number`&&r>0?`${di(r)}${n===`partial`||n===`unpriced`?`+`:``}`:n===`partial`||n===`unpriced`?n:``;return(0,X.jsxs)(`div`,{className:`border-b border-line/60 px-3 py-2 last:border-0`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,X.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full`,style:{background:t}}),(0,X.jsx)(`span`,{className:`text-[10px] uppercase tracking-wide`,style:{color:t},children:e.kind}),(0,X.jsx)(`span`,{className:`ml-auto text-[10px] text-ink-faint`,children:li(e.ts)})]}),(0,X.jsx)(`div`,{className:`mt-1 text-xs font-medium text-ink`,children:e.title}),e.summary&&(0,X.jsx)(`div`,{className:`mt-0.5 text-[11px] leading-snug text-ink-dim`,children:e.summary}),(0,X.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-1`,children:[(e.tags??[]).slice(0,4).map(e=>(0,X.jsx)(`span`,{className:`rounded bg-line/60 px-1 text-[9px] text-ink-faint`,children:e},e)),i?(0,X.jsx)(`span`,{className:`ml-auto text-[10px] text-ink-faint`,children:i}):null]})]},e.id)})]})]})}var rc=[`manager`,`planner`,`engineer`,`reviewer`];function ic(e){return e==null?``:e<3?`now`:e<60?`${Math.floor(e)}s`:e<3600?`${Math.floor(e/60)}m`:`${Math.floor(e/3600)}h`}function ac({roles:e}){let{t}=Z(),n=new Map(e.map(e=>[e.role,e])),r=rc.map(e=>n.get(e)).filter(Boolean),i=e.filter(e=>!rc.includes(e.role)),a=[...r,...i];return(0,X.jsxs)(`section`,{className:`card`,children:[(0,X.jsx)(yi,{title:t(`panel.roles`)}),(0,X.jsx)(`div`,{children:a.map(e=>{let t=W.role[e.role]??W.info;return(0,X.jsxs)(`div`,{className:`grid grid-cols-[84px_minmax(0,1fr)_auto] items-center gap-2 border-b border-line/60 px-3 py-2 last:border-b-0`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,X.jsx)(`span`,{"data-role-dot":e.role,"aria-hidden":`true`,className:`inline-block h-1.5 w-1.5 shrink-0 rounded-full`,style:{background:t}}),(0,X.jsx)(`span`,{className:`text-[11px] font-medium capitalize`,style:{color:e.active?t:W.inkDim},children:e.role})]}),(0,X.jsx)(`div`,{className:`min-w-0 truncate font-mono text-[10px] text-ink-faint`,title:e.model,children:e.model||`—`}),(0,X.jsxs)(`div`,{className:`flex items-center gap-1 text-right`,children:[(0,X.jsx)(`span`,{className:`text-[10px]`,style:{color:e.active?W.ink:W.inkFaint},children:e.active?e.status||`active`:`idle`}),e.active&&ic(e.age_s)&&(0,X.jsxs)(`span`,{className:`text-[10px] tabular-nums text-ink-faint`,children:[`· `,ic(e.age_s)]}),e.effort&&(0,X.jsxs)(`span`,{className:`text-[10px]`,style:{color:ft(e.effort)},children:[`· `,e.effort]})]})]},e.role)})})]})}function oc({open:e,snap:t,journal:n,busy:r,onClose:i,onDispose:a,onStop:o,onInspect:s}){let{t:c}=Z();return(0,X.jsxs)(go,{open:e,onClose:i,label:`Project inspector`,width:`max-w-6xl`,children:[(0,X.jsx)(_o,{title:c(`panel.project`),sub:t.session.display_name||t.session.id}),(0,X.jsxs)(`div`,{className:`h-[68vh] min-h-0 space-y-3 overflow-y-auto bg-bg p-3 scroll-thin lg:grid lg:grid-cols-[minmax(0,1.4fr)_minmax(300px,0.8fr)] lg:gap-3 lg:space-y-0 lg:overflow-hidden`,children:[(0,X.jsx)(ec,{items:t.backlog,onDispose:a,onStop:o,onInspect:s,busy:r}),(0,X.jsxs)(`div`,{className:`flex min-h-0 flex-col gap-3`,children:[(0,X.jsx)(ac,{roles:t.roles}),(0,X.jsx)(nc,{entries:n})]})]})]})}var sc=e=>e?new Date(e*1e3).toLocaleString():`—`;function cc({label:e,value:t}){return(0,X.jsxs)(`div`,{className:`rounded-md border border-line/70 bg-bg/40 px-3 py-2`,children:[(0,X.jsx)(`div`,{className:`text-[9px] font-semibold uppercase tracking-wider text-ink-faint`,children:e}),(0,X.jsx)(`div`,{className:`mt-0.5 text-xs text-ink-dim`,children:t})]})}function lc({sid:e,itemId:t,onClose:n,onDone:r,onSkip:i,onStop:a,busy:o,readOnly:s=!1}){let{t:c}=Z(),l=Or(e,t),u=l.data,d=u?Bn(u):!1,f=Ui(u?.outcome,c);return(0,X.jsxs)(go,{open:!!t,onClose:n,label:c(`task.details`),width:`max-w-3xl`,showClose:!1,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-start gap-3 border-b border-line px-4 py-3 sm:flex-nowrap sm:px-5`,children:[(0,X.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(`h2`,{className:`truncate text-sm font-semibold text-ink`,children:u?.title||c(`task.details`)}),u?(0,X.jsx)(_i,{children:Bi(u.status,c)}):null]})}),!s&&u&&!d?(0,X.jsxs)(`div`,{className:`order-3 flex w-full shrink-0 items-center justify-end gap-1 sm:order-none sm:w-auto`,children:[u.iterate?(0,X.jsx)(vi,{onClick:()=>a(u.id),disabled:o,children:c(`task.stopLoop`)}):null,(0,X.jsx)(vi,{onClick:()=>r(u.id),disabled:o,children:c(`task.done`)}),(0,X.jsx)(vi,{variant:`danger`,onClick:()=>i(u.id),disabled:o,children:c(`task.skip`)})]}):null,(0,X.jsx)(`button`,{type:`button`,"aria-label":c(`task.close`),onClick:n,className:`order-2 rounded-md px-2 py-1 text-lg leading-none text-ink-faint hover:bg-surface hover:text-ink sm:order-none`,children:`×`})]}),(0,X.jsxs)(`div`,{className:`max-h-[70vh] overflow-y-auto p-4 scroll-thin sm:p-5`,children:[l.isLoading?(0,X.jsx)(`div`,{className:`flex justify-center py-12`,children:(0,X.jsx)(bi,{})}):null,l.isError?(0,X.jsx)(`div`,{className:`rounded-md border border-err/40 bg-err/5 p-3 text-xs text-err`,children:l.error.message}):null,u?(0,X.jsxs)(`div`,{className:`space-y-4`,children:[u.pending_question?(0,X.jsxs)(`div`,{className:`rounded-lg border border-warn/40 bg-warn/5 p-3`,children:[(0,X.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-wider text-warn`,children:c(`task.waitingOnYou`)}),(0,X.jsx)(`p`,{className:`mt-1 whitespace-pre-wrap text-sm leading-relaxed text-ink`,children:u.pending_question})]}):null,(0,X.jsxs)(`section`,{children:[(0,X.jsx)(`div`,{className:`mb-1 text-[10px] font-semibold uppercase tracking-wider text-ink-faint`,children:c(`task.objective`)}),(0,X.jsx)(`div`,{className:`whitespace-pre-wrap rounded-lg border border-line bg-bg/50 p-3 text-sm leading-relaxed text-ink-dim`,children:u.objective||u.original_objective||c(`task.noObjective`)})]}),(0,X.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 sm:grid-cols-4`,children:[(0,X.jsx)(cc,{label:c(`task.priority`),value:Hi(u.priority,c)}),(0,X.jsx)(cc,{label:c(`task.started`),value:sc(u.started_ts)}),(0,X.jsx)(cc,{label:c(`task.finished`),value:sc(u.finished_ts)})]}),f.length?(0,X.jsxs)(`section`,{children:[(0,X.jsx)(`div`,{className:`mb-1 text-[10px] font-semibold uppercase tracking-wider text-ink-faint`,children:c(`task.outcome`)}),(0,X.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:f.map(e=>(0,X.jsx)(_i,{children:e},e))})]}):null,u.iterate||u.iteration_cycles_done||u.iteration_cost_usd?(0,X.jsxs)(`section`,{children:[(0,X.jsx)(`div`,{className:`mb-1 text-[10px] font-semibold uppercase tracking-wider text-ink-faint`,children:c(`task.iteration`)}),(0,X.jsxs)(`div`,{className:`grid grid-cols-3 gap-2`,children:[(0,X.jsx)(cc,{label:c(`task.mode`),value:u.iterate?c(`task.autoIterate`):c(`task.singlePass`)}),(0,X.jsx)(cc,{label:c(`task.cycles`),value:`${u.iteration_cycles_done??0}/${u.iteration_max_cycles??`—`}`}),(0,X.jsx)(cc,{label:c(`task.cost`),value:`$${(u.iteration_cost_usd??0).toFixed(2)}`})]})]}):null,u.last_error?(0,X.jsxs)(`section`,{className:`rounded-lg border border-err/30 bg-err/5 p-3`,children:[(0,X.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-wider text-err`,children:c(`task.lastError`)}),(0,X.jsx)(`p`,{className:`mt-1 whitespace-pre-wrap font-mono text-xs leading-relaxed text-ink-dim`,children:u.last_error})]}):null,u.notes?(0,X.jsxs)(`section`,{children:[(0,X.jsx)(`div`,{className:`mb-1 text-[10px] font-semibold uppercase tracking-wider text-ink-faint`,children:c(`task.notes`)}),(0,X.jsx)(`p`,{className:`whitespace-pre-wrap text-xs leading-relaxed text-ink-dim`,children:u.notes})]}):null,u.tags?.length||u.deps?.length?(0,X.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[(u.tags??[]).map(e=>(0,X.jsxs)(_i,{children:[`#`,e]},`tag-${e}`)),u.deps?.length?(0,X.jsx)(_i,{children:c(`task.dependsOnCount`,{count:u.deps.length})}):null]}):null]}):null]})]})}function uc({onPointerDown:e,onReset:t,onNudge:n,value:r,min:i=240,max:a=600,label:o=`Resize panel`}){return(0,X.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":o,"aria-valuenow":r,"aria-valuemin":i,"aria-valuemax":a,tabIndex:0,onPointerDown:e,onDoubleClick:t,onKeyDown:e=>{e.key===`ArrowLeft`?(e.preventDefault(),n(-16)):e.key===`ArrowRight`?(e.preventDefault(),n(16)):e.key===`Home`&&(e.preventDefault(),t())},className:`group relative hidden w-2 shrink-0 cursor-col-resize items-center justify-center outline-none lg:flex`,children:(0,X.jsx)(`span`,{className:`h-full w-px bg-line/30 transition-colors duration-150 group-hover:bg-blue/70 group-focus:bg-blue/70`})})}var dc=[`manager`,`planner`,`engineer`,`reviewer`],Q=new Set([`grounding`,`task`,`decision`,`agent_message`,`assistant_message`,`command_execution`,`tool_use`,`handoff`,`review`,`verdict`,`completion`,`plan`,`file_change`,`result`]),fc=/^(using a tool|running project command|inspecting project state|working|reporting progress|暂无详细记录)$/i;function pc(e){let t=Et(e).replace(/^\s*(?:RESULT|SUMMARY)\s*=\s*/gim,``).trim();return fc.test(t)||t.startsWith(`{`)?``:t}function mc(e,t,n=``){if(n){if(/^(?:rg|grep|glob|search)$/.test(n))return t?`检索项目文件`:`Searching project files`;if(/^(?:view|read|read_file)$/.test(n))return t?`读取文件`:`Reading a file`;if(/apply_patch|edit|write/.test(n))return t?`编辑文件`:`Editing a file`;if(/bash|shell|exec|terminal/.test(n))return t?`运行终端命令`:`Running a command`;if(/playwright|browser/.test(n))return t?`检查浏览器交互`:`Checking browser interactions`}return({grounding:[`理解任务与检查项目`,`Understanding the task`],task:[`安排任务`,`Task assignment`],decision:[`确定执行方案`,`Execution decision`],plan:[`制定执行计划`,`Planning the work`],agent_message:[`更新执行进度`,`Progress update`],assistant_message:[`更新执行进度`,`Progress update`],command_execution:[`运行项目命令`,`Running a project command`],tool_use:[`使用工具`,`Using a tool`],file_change:[`更新项目文件`,`Updating project files`],handoff:[`提交结果与交接`,`Results and handoff`],review:[`复核实现与结果`,`Reviewing implementation and results`],verdict:[`给出审查结论`,`Review verdict`],completion:[`完成任务`,`Task completed`],result:[`产出结果`,`Result`]}[e]??[e,e])[+!t]}function hc(e,t,n){let r=new Map;for(let i of e?.role_work??[]){if(i.role!==t||!Q.has(i.kind))continue;let e=i.item_id||i.mission_id;n&&e!==n||r.set(i.id,{...i,detail:pc(i.detail)})}return[...r.values()].sort((e,t)=>t.ts-e.ts)}function gc(e,t,n){return[...e].reverse().find(e=>e.type===`engineer.progress`&&[`tool_use`,`command_execution`,`file_change`].includes(String(e.kind))&&String(e.agent_layer||e.actor||e.role)===t&&(!n||String(e.item_id||e.mission_id)===n))}function _c(e,t,n,r,i){return r||[`done`,`completed`,`failed`,`aborted`,`stopped`].includes(e?.mission.status??``)||i&&e?.mission.id!==i?!1:t.length?t.some(e=>e.role===n&&e.active):e?.active_role===n&&[`working`,`grounding`,`framed`,`running`].includes(e?.mission.status??``)}var vc={manager:[`统筹`,`Manager`],planner:[`规划`,`Planner`],engineer:[`执行`,`Engineer`],reviewer:[`审查`,`Reviewer`]};function yc({view:e,roles:t=[],events:n=[],taskId:r,paused:i=!1,selectedRole:a,onSelectRole:o,onClose:s,showTabs:c=!0}){let{locale:l}=Z(),u=l===`zh-CN`,[d,f]=(0,I.useState)(null),[p,m]=(0,I.useState)(Date.now),h=a||d||t.find(e=>e.active)?.role||e?.active_role||`manager`,g=_c(e,t,h,i,r),_=hc(e,h,r),v=_[0],y=_.find(e=>e.detail&&[`agent_message`,`assistant_message`,`decision`,`verdict`,`handoff`,`review`,`completion`].includes(e.kind)),b=gc(n,h,r),x=b&&Number(b.ts||0)>=(v?.ts??0),S=!x&&v&&[`agent_message`,`assistant_message`].includes(v.kind)&&v.detail?v.detail.split(/[。\n]/)[0].slice(0,70):mc(x?String(b.kind):v?.kind||`task`,u,x?String(b.tool_name||``):``),C=t.find(e=>e.role===h)?.model||e?.roles.find(e=>e.role===h)?.model,w=v?Math.max(0,Math.floor(p/1e3-v.ts)):0;(0,I.useEffect)(()=>{if(!g)return;let e=setInterval(()=>m(Date.now()),1e3);return()=>clearInterval(e)},[g]);let T=e=>vc[e]?.[+!u]||e;return(0,X.jsxs)(`section`,{className:`agent-activity`,"aria-label":u?`Agent 工作详情`:`Agent work details`,children:[(0,X.jsxs)(`header`,{className:`agent-activity-heading`,children:[(0,X.jsxs)(`span`,{children:[(0,X.jsx)(La,{size:15}),u?`Agent 动态`:`Agent activity`]}),s&&(0,X.jsx)(`button`,{type:`button`,onClick:s,"aria-label":u?`关闭 Agent 详情`:`Close Agent details`,children:(0,X.jsx)(oo,{size:17})})]}),c&&(0,X.jsx)(`div`,{className:`agent-activity-tabs`,role:`group`,"aria-label":u?`筛选 Agent`:`Filter agents`,children:dc.map(n=>(0,X.jsxs)(`button`,{type:`button`,"data-role":n,"aria-pressed":h===n,onClick:()=>{f(n),o?.(n)},children:[(0,X.jsx)(`i`,{"data-active":_c(e,t,n,i,r)}),T(n)]},n))}),(0,X.jsxs)(`div`,{className:`agent-current`,"data-active":g,children:[(0,X.jsxs)(`div`,{className:`agent-current-kicker`,children:[(0,X.jsx)(`span`,{children:g?T(h)+(u?` Agent 正在工作`:` is working`):i?u?`会话已暂停`:`Session paused`:u?`最近进度`:`Latest progress`}),g?(0,X.jsxs)(`span`,{className:`agent-live-indicator`,children:[(0,X.jsx)(`i`,{}),`LIVE`]}):(0,X.jsx)(to,{size:12})]}),(0,X.jsx)(`h3`,{children:v||x?S:u?`等待任务分配`:`Waiting for an assignment`}),y?.detail&&(0,X.jsx)(`div`,{className:`agent-current-summary`,children:(0,X.jsx)(ki,{children:y.detail})}),!y&&v?.detail&&(0,X.jsx)(`p`,{className:`agent-current-summary`,children:v.detail}),v&&(0,X.jsxs)(`div`,{className:`agent-current-meta`,children:[(0,X.jsx)(Ga,{size:12}),(0,X.jsx)(`span`,{children:u?`${w<60?w+` 秒`:Math.floor(w/60)+` 分钟`}前更新`:`Updated ${w<60?w+`s`:Math.floor(w/60)+`m`} ago`}),C&&(0,X.jsx)(`span`,{children:C})]})]}),(0,X.jsxs)(`div`,{className:`agent-records-heading`,children:[(0,X.jsx)(`span`,{children:u?`工作记录`:`Work log`}),(0,X.jsxs)(`span`,{children:[_.length,` `,u?`条`:`records`]})]}),(0,X.jsxs)(`div`,{className:`agent-records`,role:`log`,"aria-live":`off`,children:[_.slice(0,24).map((e,t)=>{let n=g&&t===0,r=[`done`,`completed`].includes(e.status),i=[`failed`,`error`,`rejected`].includes(e.status),a=r?Va:[`tool_use`,`command_execution`].includes(e.kind)?ao:Ya;return(0,X.jsxs)(`article`,{className:`agent-record`,"data-active":n,"data-failed":i,children:[(0,X.jsx)(`span`,{className:`agent-record-icon`,children:(0,X.jsx)(a,{size:13})}),(0,X.jsxs)(`div`,{children:[(0,X.jsxs)(`div`,{className:`agent-record-title`,children:[(0,X.jsx)(`strong`,{children:mc(e.kind,u)}),(0,X.jsx)(`time`,{children:new Date(e.ts*1e3).toLocaleTimeString(u?`zh-CN`:`en-US`,{hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hour12:!1})})]}),(0,X.jsxs)(`small`,{children:[n?u?`进行中`:`In progress`:i?u?`需要处理`:`Needs attention`:r?u?`已完成`:`Completed`:u?`已记录`:`Recorded`,e.round_index==null?``:u?` · 第 ${e.round_index} 轮`:` · Round ${e.round_index}`]}),e.detail&&(0,X.jsxs)(`details`,{open:t===0||e===y,children:[(0,X.jsxs)(`summary`,{children:[(0,X.jsx)(`span`,{children:u?`查看详情`:`Read details`}),(0,X.jsx)(Ha,{size:12})]}),(0,X.jsx)(`div`,{className:`agent-record-detail`,children:(0,X.jsx)(ki,{children:e.detail})})]})]})]},e.id)}),!_.length&&(0,X.jsx)(`p`,{className:`agent-records-empty`,children:u?`${T(h)}尚未留下这个任务的工作记录。`:`No work has been recorded for this task by ${T(h)}.`})]})]})}var bc=[`manager`,`planner`,`engineer`,`reviewer`],xc=[`active`,`running`,`in_progress`,`claimed`],Sc=[`complete`,`completed`,`done`,`success`,`incomplete`,`stalled`,`blocked`,`ended`],Cc=864e5,wc=300;function Tc(e,t){return bc.includes(e)?t(`role.${e}`):Vi(e,t)}function Ec(e){let t=e.type.toLowerCase().split(/[._-]/).at(-1);return[`failed`,`failure`,`error`].includes(t??``)||e.tone===`error`&&/\bfailed\b/i.test(e.title)}function Dc(e,t,n=new Date){let r=new Date(e*1e3),i=r.toLocaleTimeString(t,{hour:`2-digit`,minute:`2-digit`,hourCycle:`h23`}),a=Date.UTC(n.getFullYear(),n.getMonth(),n.getDate()),o=Date.UTC(r.getFullYear(),r.getMonth(),r.getDate());if(o===a)return i;let s=+(t===`zh-CN`);return o>=a-(n.getDay()-s+7)%7*Cc&&ot;(0,I.useEffect)(()=>{if(t!=null||a)return;let e=i.current;if(!e)return;let n=()=>c(e.scrollHeight>e.clientHeight);n();let r=new ResizeObserver(n);return r.observe(e),()=>r.disconnect()},[e,a,t]);let u=!a&&t!=null&&l?`${e.slice(0,t)}…`:e;return(0,X.jsxs)(`div`,{className:`mt-2`,children:[(0,X.jsx)(`p`,{ref:i,className:`${t==null&&!a?`line-clamp-3`:``} whitespace-pre-wrap break-words ${n}`,children:u}),l?(0,X.jsx)(`button`,{type:`button`,onClick:()=>o(e=>!e),"aria-expanded":a,className:`mt-1 text-[11px] text-blue-sky hover:text-ink`,children:r(a?`mission.showLess`:`mission.showMore`)}):null]})}function kc(e){let t=[...e.dag],n=[],r=new Set;for(;t.length;){let i=t.findIndex(t=>t.deps.every(t=>r.has(t)||!e.dag.some(e=>e.id===t))),[a]=t.splice(i>=0?i:0,1);n.push(a),r.add(a.id)}return n}function Ac(e,t=16){let n=kc(e);if(n.length<=t)return{nodes:n,hidden:[]};let r=new Set(n.slice(-t).map(e=>e.id)),i=n.find(e=>[`running`,`in_progress`,`claimed`].includes(e.status)),a=new Map(n.map(e=>[e.id,e])),o=i?[i]:[];for(;o.length;){let e=o.pop();r.has(e.id)||(r.add(e.id),e.deps.forEach(e=>{let t=a.get(e);t&&o.push(t)}))}return{nodes:n.filter(e=>r.has(e.id)),hidden:n.filter(e=>!r.has(e.id))}}function jc({view:e}){let{t}=Z(),n=e.achievement;return n?(0,X.jsxs)(`section`,{className:`border-b border-ok/35 bg-ok/5 px-5 py-4 animate-appear`,children:[(0,X.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-[0.16em] text-ok`,children:t(`mission.achievement`)}),(0,X.jsx)(`div`,{className:`mt-2 text-sm font-semibold text-ink`,children:n.title}),n.summary?(0,X.jsx)(`div`,{className:`mt-1 text-xs text-ink-dim`,children:n.summary}):null,(0,X.jsxs)(`div`,{className:`mt-2 text-xs`,children:[(0,X.jsxs)(`span`,{className:`text-ink-faint`,children:[t(`mission.elapsed`),` `]}),(0,X.jsx)(`span`,{className:`font-mono text-ink`,children:wn(n.elapsed_seconds??0)})]}),(0,X.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-x-5 gap-y-1 text-[11px] text-ink-dim`,children:[(0,X.jsx)(`span`,{children:t(`mission.rejectedAttempts`,{count:n.rejected_attempts??0})}),(0,X.jsx)(`span`,{children:t(`mission.skillsLearned`,{count:n.skills_learned??0})}),(0,X.jsx)(`span`,{children:t(`mission.artifacts`,{count:n.artifacts??0})})]})]}):null}function Mc({view:e,sid:t=``,snapshot:n,artifacts:r=[],onOpenArtifact:i,onOpenDelivery:a,gitDiff:o,onNotify:s}){let{locale:c,t:l}=Z(),u=new Map(e.roles.map(e=>[e.role,e])),d=e.dag.find(e=>[`running`,`in_progress`,`claimed`].includes(e.status)),f=Ac(e),p=f.nodes,m=Cn(e.mission.objective||e.mission.title||l(`mission.waiting`)),h=e.mission.final_output?.trim()||``,g=!!(h&&h!==e.mission.summary.trim()),[_,v]=(0,I.useState)(Math.max(0,e.timeline.length-1)),[y,b]=(0,I.useState)(e.active_role||`planner`),[x,S]=(0,I.useState)(d?.id||``),[C,w]=(0,I.useState)(!1),T=e.delivery,E=new Map(r.map(e=>[e.path,e])),D=e.learned_skills.filter(e=>e.status===`active`),ee=e.learned_wiki_pages.filter(e=>e.status!==`retired`),O=!!(e.storage.project_skill_dir||e.storage.global_skill_dir||e.storage.wiki_paths.length||e.storage.skill_history_compressed||e.storage.wiki_retired_compressed),te=!!(D.length||ee.length||O),ne=e.mission.status.toLowerCase(),k=[`working`,`grounding`,`framed`].includes(ne),re=[`degraded`,`red`,`critical`].includes(e.health?.toLowerCase()??``),A=[`failed`,`error`].includes(e.mission.status.toLowerCase()),j=e.dag.some(t=>t.status.toLowerCase()===`failed`&&(t.id===e.mission.id||!k&&!d)),ie=[`hold`,`paused`].includes(e.stage.id.toLowerCase()),ae=e.outcome.execution_status?.toLowerCase()===`failed`&&e.stage.id.toLowerCase()===`delivery`,M=re||ae||A||j||ie,oe=re?`mission.attentionHealth`:ae?`mission.deliveryFailed`:A?`mission.attentionFailed`:j?`mission.attentionStepFailed`:`mission.attentionPaused`,se=e.role_work.filter(e=>xc.includes(e.status.toLowerCase())).sort((e,t)=>t.ts-e.ts),N=se.find(t=>t.role===e.active_role)??se[0],ce=Sc.includes(ne),le=Ui(e.outcome,l)[0]??Bi(e.mission.status,l),ue=M?l(oe):ce?l(`mission.statusDone`,{outcome:le,elapsed:wn(e.mission.elapsed_seconds)}):k&&N?l(`mission.statusActive`,{role:Vi(e.active_role||N.role,l),work:N.title}):l(`mission.statusWaiting`),de=re||ae||A||j?`error`:ie?`waiting`:ce?`done`:k&&N?`active`:`waiting`;(0,I.useEffect)(()=>v(Math.max(0,e.timeline.length-1)),[e.timeline.length]),(0,I.useEffect)(()=>{d?.id&&S(d.id)},[d?.id]);let fe=async()=>{if(!C){w(!0);try{await U.setContinuous(t,!0,n?.continuous?.objective??``),s?.(`success`,l(`sidebar.resumeSuccess`))}catch(e){s?.(`error`,l(`sidebar.resumeFailed`,{error:mi(e)}))}finally{w(!1)}}},P=e.timeline.slice(0,_+1).slice(-12).reverse(),F=e.dag.find(e=>e.id===x);return(0,X.jsxs)(`section`,{className:`min-h-0 flex-1 overflow-x-hidden overflow-y-auto bg-panel scroll-thin`,"aria-label":l(`mission.control`),children:[(0,X.jsxs)(`header`,{className:`border-b border-line/60 px-5 py-5`,children:[(0,X.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-[0.16em] text-ink-faint`,children:l(`mobile.mission`)}),(0,X.jsx)(`div`,{role:`heading`,"aria-level":1,className:`mt-1 line-clamp-4 max-w-4xl text-lg font-semibold leading-snug text-ink`,title:m,children:(0,X.jsx)(ki,{artifacts:r,onOpenArtifact:i,children:m})}),m.length>600?(0,X.jsxs)(`details`,{className:`mt-2 text-xs text-ink-faint`,children:[(0,X.jsx)(`summary`,{className:`cursor-pointer hover:text-ink`,children:l(`mission.showObjective`)}),(0,X.jsx)(`div`,{className:`mt-2 text-ink-dim`,children:(0,X.jsx)(ki,{artifacts:r,onOpenArtifact:i,children:m})})]}):null,(0,X.jsxs)(`div`,{className:`mission-status-line`,"data-tone":de,role:M?`alert`:`status`,children:[(0,X.jsxs)(`div`,{className:`mission-status-line__signal`,children:[(0,X.jsx)(`span`,{className:`mission-status-line__marker`,"aria-hidden":`true`}),(0,X.jsx)(`span`,{children:ue})]}),e.frontier.change?(0,X.jsx)(`div`,{className:`mission-status-line__subtitle`,children:e.frontier.change}):null]}),e.mission.summary||g?(0,X.jsxs)(`div`,{className:`mt-3 rounded border border-ok/25 bg-ok/5 px-3 py-2`,children:[(0,X.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-[0.12em] text-ok`,children:l(`mission.summary`)}),(0,X.jsx)(`div`,{className:`mt-1 whitespace-pre-wrap text-xs leading-relaxed text-ink-dim`,children:(0,X.jsx)(ki,{artifacts:r,onOpenArtifact:i,children:e.mission.summary})}),g?(0,X.jsxs)(`details`,{className:`mt-2 border-t border-ok/20 pt-2 text-xs text-ink-dim`,children:[(0,X.jsx)(`summary`,{className:`cursor-pointer font-medium text-ok hover:text-ink`,children:l(`mission.showFullOutput`)}),(0,X.jsx)(`div`,{className:`mt-3 break-words text-sm leading-relaxed text-ink`,children:(0,X.jsx)(ki,{artifacts:r,onOpenArtifact:i,children:h})})]}):null]}):null,T?(0,X.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-3 rounded border border-ok/30 bg-ok/5 px-3 py-2`,children:[(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-[0.12em] text-ok`,children:l(T.kind===`submission_certified`?`mission.deliveryCertified`:`mission.taskCompleted`)}),(0,X.jsx)(`div`,{className:`mt-1 truncate text-xs text-ink-dim`,title:T.summary||T.title,children:T.summary||T.title})]}),a?(0,X.jsx)(`button`,{type:`button`,onClick:()=>a(T),title:T.primary_target?E.get(T.primary_target.path)?.storage_path||T.primary_target.path:T.title,className:`shrink-0 rounded border border-ok/40 px-2 py-1 font-mono text-[10px] text-ok hover:border-ok`,children:l(T.primary_target?`mission.openResult`:`mission.viewTask`)}):null]}):null]}),n?.continuous?.done_at&&(0,X.jsxs)(`div`,{className:`mb-3 flex items-center gap-3 rounded-lg border-l-2 border-blue bg-blue/5 px-3 py-2`,children:[(0,X.jsx)(`span`,{className:`text-base`,children:`↩`}),(0,X.jsxs)(`span`,{className:`min-w-0 flex-1 truncate text-sm text-ink-dim`,children:[l(`mission.continuousDone`),n.continuous.objective?` · ${n.continuous.objective}`:``]}),(0,X.jsx)(`button`,{type:`button`,disabled:C,onClick:()=>void fe(),className:`compact-control shrink-0 px-3`,children:C?`…`:l(`mission.resumeContinuous`)})]}),(0,X.jsx)(jc,{view:e}),(0,X.jsxs)(`section`,{className:`border-b border-line/60 px-5 py-4`,"aria-label":l(`mission.team`),children:[(0,X.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-[0.16em] text-ink-faint`,children:l(`mission.team`)}),(0,X.jsx)(`div`,{className:`mt-3 grid gap-2 sm:grid-cols-2 xl:grid-cols-4`,children:bc.map(e=>{let t=u.get(e),n=t?.status===`active`,r=t?.status===`rejected`||t?.status===`error`,i=W.role[e]??W.inkFaint;return(0,X.jsxs)(`button`,{type:`button`,onClick:()=>b(e),"aria-pressed":y===e,className:`min-w-0 rounded-r-md border-l-2 py-2 pl-3 text-left transition-colors hover:bg-bg/60 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue`,style:{borderColor:y===e||n||t?.status===`done`?i:`rgb(var(--line))`,backgroundColor:y===e?`color-mix(in srgb, ${i} 8%, transparent)`:void 0},children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(`span`,{"data-role-dot":e,"aria-hidden":`true`,className:`h-2 w-2 shrink-0 rounded-full ${n?`animate-pulse motion-reduce:animate-none`:``}`,style:{background:i}}),(0,X.jsx)(`span`,{className:`text-xs font-semibold`,style:{color:i},children:Vi(e,l)})]}),(0,X.jsx)(`div`,{className:`mt-1 truncate text-xs ${r?`text-err`:`text-ink-dim`}`,children:t?.label||l(`mission.waitingShort`)})]},e)})})]}),(0,X.jsxs)(`section`,{className:`border-b border-line/60 px-5 py-4`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,X.jsxs)(`div`,{className:`text-[10px] font-semibold uppercase tracking-[0.16em] text-ink-faint`,children:[l(`mission.roleWork`),` · `,(0,X.jsx)(`span`,{style:{color:W.role[y]??W.inkDim},children:Vi(y,l)})]}),F?(0,X.jsx)(`button`,{type:`button`,onClick:()=>S(``),className:`text-[10px] text-ink-faint hover:text-ink`,children:l(`mission.filteredBy`,{task:F.title||F.objective||l(`task.untitled`)})}):(0,X.jsx)(`span`,{className:`text-[10px] text-ink-faint`,children:l(`mission.allVisible`)})]}),(0,X.jsx)(`div`,{className:`mt-3`,children:(0,X.jsx)(yc,{view:e,roles:n?.roles,events:n?.recent_events,taskId:x||void 0,selectedRole:y,showTabs:!1,paused:n?!n.daemon.alive:!1})})]}),(0,X.jsxs)(`div`,{className:`grid min-h-[320px] border-b border-line/60 lg:grid-cols-[minmax(0,1.15fr)_minmax(260px,0.85fr)]`,children:[(0,X.jsxs)(`section`,{className:`min-w-0 border-b border-line/60 px-5 py-4 lg:border-b-0 lg:border-r`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,X.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-[0.16em] text-ink-faint`,children:l(`mission.researchDag`)}),d?(0,X.jsxs)(`span`,{className:`max-w-48 truncate text-[10px] text-blue-sky`,children:[l(`mission.active`),` · `,d.title]}):null]}),(0,X.jsxs)(`div`,{className:`mt-3 space-y-0`,children:[f.hidden.length?(0,X.jsx)(`div`,{className:`mb-3 rounded border border-line/60 bg-bg/50 px-3 py-2 text-[10px] text-ink-faint`,children:l(`mission.hiddenTasks`,{count:f.hidden.length,failed:f.hidden.filter(e=>[`failed`,`blocked`].includes(e.status)).length,skipped:f.hidden.filter(e=>e.status===`skipped`).length})}):null,p.length?p.map((e,t)=>{let n=e.id===d?.id,r=[`done`,`completed`].includes(e.status),i=[`failed`,`blocked`].includes(e.status);return(0,X.jsxs)(`button`,{type:`button`,onClick:()=>S(e.id),className:`relative flex w-full min-w-0 gap-3 pb-3 text-left last:pb-0 ${x===e.id?`bg-white/[0.03]`:``}`,children:[t(0,X.jsx)(`li`,{children:e},e))})]}):null]}):null]}),(0,X.jsxs)(`section`,{className:`min-w-0 px-5 py-4`,children:[(0,X.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-[0.16em] text-ink-faint`,children:l(`mission.capabilities`)}),D.length?(0,X.jsxs)(`div`,{className:`mt-3`,children:[(0,X.jsx)(`div`,{className:`text-[10px] uppercase tracking-[0.12em] text-ok`,children:l(`mission.capabilitiesUnlocked`)}),(0,X.jsx)(`div`,{className:`mt-2 space-y-2`,children:D.slice(-8).map(e=>(0,X.jsxs)(`details`,{className:`rounded border border-ok/35 bg-ok/5 px-2 py-1.5`,children:[(0,X.jsx)(`summary`,{className:`cursor-pointer text-[10px] text-ok`,children:String(e.name||l(`mission.learnedCapability`))}),e.mission_title?(0,X.jsx)(`div`,{className:`mt-2 text-[9px] text-ink-faint`,children:l(`mission.learnedDuring`,{mission:e.mission_title})}):null,e.content?(0,X.jsxs)(`pre`,{className:`mt-2 max-h-64 overflow-auto whitespace-pre-wrap border-t border-ok/20 pt-2 font-mono text-[10px] leading-5 text-ink-dim scroll-thin`,children:[e.content,e.content_truncated?`\n… ${l(`mission.contentTruncated`)}`:``]}):(0,X.jsx)(`div`,{className:`mt-2 text-[10px] text-ink-faint`,children:l(`mission.skillUnavailable`)})]},String(e.id)))})]}):null,ee.length?(0,X.jsxs)(`div`,{className:`mt-4 border-t border-line/50 pt-3`,children:[(0,X.jsx)(`div`,{className:`text-[10px] uppercase tracking-[0.12em] text-blue-sky`,children:l(`mission.knowledgeRetained`)}),(0,X.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:ee.slice(-6).map(e=>(0,X.jsx)(`span`,{className:`rounded border border-blue/35 bg-blue/5 px-2 py-1 text-[10px] text-blue-sky`,children:String(e.title||e.id)},String(e.id)))})]}):null,O?(0,X.jsxs)(`div`,{className:`mt-4 border-t border-line/50 pt-3`,children:[(0,X.jsx)(`div`,{className:`text-[10px] uppercase tracking-[0.12em] text-ink-faint`,children:l(`mission.selfEvolution`)}),(0,X.jsx)(`div`,{className:`mt-2 text-[10px] text-ink-dim`,children:l(`mission.knowledgeSaved`)})]}):null,te?null:(0,X.jsx)(`div`,{className:`py-10 text-center text-xs text-ink-faint`,children:l(`mission.noCapabilities`)})]})]}),(0,X.jsxs)(`section`,{className:`px-5 py-4`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,X.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-[0.16em] text-ink-faint`,children:l(`mission.replay`)}),e.timeline.length>1?(0,X.jsx)(`input`,{type:`range`,min:0,max:e.timeline.length-1,value:_,onChange:e=>v(Number(e.target.value)),"aria-label":l(`mission.replayTimeline`),className:`h-1 min-w-32 flex-1 accent-blue`}):null,P.length?(0,X.jsx)(`span`,{className:`text-[10px] text-ink-faint`,children:l(P.length===1?`mission.showingLatestEvent`:`mission.showingLastEvents`,{count:P.length})}):null]}),(0,X.jsxs)(`div`,{className:`mt-3 space-y-3`,children:[P.map(e=>{let t=new Date(e.ts*1e3),n=W.role[e.role]??W.inkFaint,r=Ec(e)?l(`mission.roleFailed`,{role:Tc(e.role,l)}):e.title;return(0,X.jsxs)(`article`,{className:`rounded border border-line/60 bg-bg/35 px-3 py-2.5 text-xs`,children:[(0,X.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`mt-1.5 h-2 w-2 shrink-0 rounded-full ${e.tone===`error`?`bg-err`:e.tone===`success`||e.tone===`metric`||e.tone===`skill`?`bg-ok`:`bg-blue`}`}),(0,X.jsx)(`span`,{className:`shrink-0 rounded-full border px-2 py-0.5 text-[10px] font-medium`,style:{borderColor:n,color:n},children:Tc(e.role,l)}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 break-words font-medium leading-5 text-ink`,children:r}),(0,X.jsx)(`time`,{dateTime:t.toISOString(),title:t.toLocaleString(c,{dateStyle:`medium`,timeStyle:`short`}),className:`shrink-0 font-mono text-[10px] text-ink-faint`,children:Dc(e.ts,c)})]}),e.detail?(0,X.jsx)(Oc,{detail:e.detail,previewLength:wc,textClassName:`leading-5 text-ink-dim`}):null]},e.id)}),e.timeline.length?null:(0,X.jsx)(`div`,{className:`py-10 text-center text-xs text-ink-faint`,children:l(`mission.waitingEvents`)})]}),e.artifacts.length?(0,X.jsx)(`div`,{className:`mt-5 flex flex-wrap gap-2 border-t border-line/50 pt-4`,children:e.artifacts.slice(-8).map(e=>{let t=String(e.path||``),n=E.get(t);return(0,X.jsx)(`button`,{type:`button`,disabled:!t||!i||n?.exists===!1,onClick:()=>t&&i?.(t),title:n?.storage_path||t,className:`rounded border border-line px-2 py-1 font-mono text-[10px] text-blue-sky hover:border-blue-sky/50 disabled:text-ink-faint`,children:String(e.title||l(`research.artifact`))},String(e.id||t))})}):null,o?.available&&(o.status||o.diff)?(0,X.jsxs)(`div`,{className:`mt-5 border-t border-line/50 pt-4 text-[10px] text-ink-faint`,children:[(0,X.jsx)(`span`,{className:`font-semibold uppercase tracking-[0.14em]`,children:l(`mission.projectFilesChanged`)}),(0,X.jsxs)(`span`,{children:[` · `,l(`mission.reviewInIde`)]})]}):null]})]})}var Nc={available:`bg-ok/10 text-ok`,absent:`bg-bg text-ink-faint`,inaccessible:`bg-warn/10 text-warn`,degraded:`bg-warn/10 text-warn`};function Pc({status:e,error:t}){let{t:n}=Z();return(0,X.jsxs)(`section`,{className:`rounded-lg border border-line bg-panel p-4 lg:col-span-2`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,X.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wide text-ink-dim`,children:n(`resource.title`)}),e?(0,X.jsx)(`span`,{className:`rounded px-2 py-1 text-[10px] font-semibold uppercase ${e.enforcement===`strict`?`bg-ok/10 text-ok`:`bg-warn/10 text-warn`}`,children:Gi(e.enforcement,n)}):null]}),t?(0,X.jsx)(`p`,{className:`mt-3 text-xs text-err`,children:t}):null,!e&&!t?(0,X.jsx)(`p`,{className:`mt-3 text-xs text-ink-faint`,children:n(`resource.loading`)}):null,e?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`mt-3 grid gap-2 sm:grid-cols-2`,children:e.accelerators.map(e=>(0,X.jsxs)(`div`,{className:`rounded border border-line bg-bg p-3`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,X.jsx)(`span`,{className:`text-xs font-semibold text-ink`,children:Wi(e.kind,n)}),(0,X.jsxs)(`span`,{className:`rounded px-2 py-0.5 text-[10px] font-medium ${Nc[e.status]}`,children:[Bi(e.status,n),` · `,n(`resource.devices`,{count:e.device_count})]})]}),e.detail?(0,X.jsx)(`p`,{className:`mt-2 text-xs text-ink-faint`,children:e.detail}):null]},e.kind))}),(0,X.jsxs)(`div`,{className:`mt-4 grid gap-4 md:grid-cols-2`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`h4`,{className:`text-[10px] font-semibold uppercase tracking-wide text-ink-faint`,children:n(`resource.inUse`,{count:e.holders.length})}),(0,X.jsx)(`div`,{className:`mt-2 space-y-2`,children:e.holders.length===0?(0,X.jsx)(`p`,{className:`text-xs text-ink-faint`,children:n(`resource.none`)}):e.holders.map((e,t)=>(0,X.jsxs)(`div`,{className:`rounded border border-line bg-bg p-3 text-xs`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,X.jsx)(`span`,{className:`font-medium text-ink`,children:n(`resource.devices`,{count:e.device_count})}),(0,X.jsx)(`span`,{className:`shrink-0 font-mono text-ink-faint`,children:n(`resource.timeLeft`,{ttl:Tn(e.ttl_seconds)})})]}),(0,X.jsx)(`p`,{className:`mt-1 text-ink-dim`,children:e.intent||n(`resource.noIntent`)}),e.yield_requests.map((e,t)=>(0,X.jsxs)(`div`,{className:`mt-2 border-l-2 border-warn/50 pl-2 text-ink-faint`,children:[(0,X.jsx)(`div`,{children:n(`resource.yieldRequest`,{reason:e.reason})}),e.response?(0,X.jsxs)(`div`,{children:[Ki(e.response.decision,n),` · `,e.response.reason]}):null]},t))]},`${e.project}:${e.task_id}:${t}`))})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`h4`,{className:`text-[10px] font-semibold uppercase tracking-wide text-ink-faint`,children:n(`resource.queue`,{count:e.queue.length})}),(0,X.jsx)(`div`,{className:`mt-2 space-y-2`,children:e.queue.length===0?(0,X.jsx)(`p`,{className:`text-xs text-ink-faint`,children:n(`resource.none`)}):e.queue.map(e=>(0,X.jsxs)(`div`,{className:`rounded border border-line bg-bg p-3 text-xs`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,X.jsx)(`span`,{className:`font-medium text-ink`,children:n(`resource.queuePosition`,{position:e.position})}),(0,X.jsx)(`span`,{className:`shrink-0 font-mono text-ink-faint`,children:n(`resource.timeLeft`,{ttl:Tn(e.ttl_seconds)})})]}),(0,X.jsx)(`p`,{className:`mt-1 text-ink-dim`,children:e.intent||n(`resource.noIntent`)})]},e.position))})]})]})]}):null]})}var Fc=e=>e instanceof Error?e.message:String(e||`Unknown error`);async function Ic(e){let t=await e,n=t&&typeof t==`object`?t:{},r=String(n.command_status??``);if(Number(n.rc??0)!==0||r===`failed`||r===`rejected`)throw Error(String(n.error||`daemon command ${r||`failed`}`));return t}function Lc({open:e,sid:t,snap:n,onClose:i,onChanged:s,onRestored:c}){let{t:l}=Z(),[p,m]=(0,I.useState)(`task`),[g,_]=(0,I.useState)(``),[v,x]=(0,I.useState)(n.session.workdir??n.session.cwd??``),[C,T]=(0,I.useState)(`ls`),[E,D]=(0,I.useState)(``),[ne,k]=(0,I.useState)(``),[re,A]=(0,I.useState)(null),[j,ie]=(0,I.useState)(null),[ae,M]=(0,I.useState)(null),[oe,se]=(0,I.useState)(``),[N,ce]=(0,I.useState)([]),[le,ue]=(0,I.useState)(0),[de,fe]=(0,I.useState)(``),[P,F]=(0,I.useState)(``),[pe,me]=(0,I.useState)(`work`);(0,I.useEffect)(()=>{e&&(x(n.session.workdir??n.session.cwd??``),Promise.all([U.metrics(),U.trash()]).then(([e,t])=>{A(e),ce(t.entries),ue(t.total)},e=>D(Fc(e))))},[e,n.session.cwd,n.session.workdir]),(0,I.useEffect)(()=>{if(!e)return;let t=!1,n=async()=>{try{let e=await U.sourceUpdateStatus();t||ie(e)}catch(e){t||D(Fc(e))}};U.sourceUpdateStatus().then(async e=>{if(!t&&(ie(e),!e.running)){let e=await U.checkSourceUpdate();t||ie(e)}}).catch(e=>{t||D(Fc(e))});let r=window.setInterval(()=>void n(),1500);return()=>{t=!0,window.clearInterval(r)}},[e]),(0,I.useEffect)(()=>{!e||pe!==`system`||(M(null),se(``),U.resources().then(M,e=>se(Fc(e))))},[e,pe]);let he=async(e,t,n)=>{if(!P){F(e),D(``);try{let e=await t();n!==null&&D(n||JSON.stringify(e,null,2)),s()}catch(e){D(Fc(e))}finally{F(``)}}},ge=async()=>{let e=g.trim();if(e){if(p===`plan`){await he(`quick`,async()=>{let n=await U.previewPlan(t,e);return D([...n.steps.map((e,t)=>`${t+1}. ${e.title}${e.detail?` — ${e.detail}`:``}`),...n.notes.map(e=>`Note: ${e}`),...n.error?[`Error: ${n.error}`]:[]].join(` +`)),n},null);return}await he(`quick`,p===`task`?()=>U.addTask(t,e):p===`nudge`?()=>U.nudge(t,e):()=>U.note(t,e),`${p} submitted.`),_(``)}},_e=async e=>{await he(`restore:${e.trash_id}`,async()=>{let t=await U.restoreTrash(e.trash_id);return ce(t=>t.filter(t=>t.trash_id!==e.trash_id)),ue(e=>Math.max(0,e-1)),await c(t.sid),t},`Restored ${e.label}.`)},ve=n.daemon.alive&&n.daemon.protocol_compatible===!1,ye=n.daemon.alive&&n.daemon.control_available===!1,be=n.daemon_admission?.running_daemons??[],xe=p===`task`?h:p===`nudge`?te:p===`note`?d:y,Se=l(`operations.action.${p}`),Ce=async()=>{await he(`trash-search`,async()=>{let e=await U.trash(de);return ce(e.entries),ue(e.total),e},null)};return(0,X.jsxs)(go,{open:e,onClose:()=>!P&&i(),label:l(`operations.title`),width:`max-w-5xl`,children:[(0,X.jsx)(_o,{title:l(`operations.title`),sub:n.session.display_name||t}),(0,X.jsx)(`div`,{className:`flex gap-1 overflow-x-auto border-b border-line bg-panel px-4 py-2 scroll-thin`,children:[[`work`,l(`operations.work`),h],[`runtime`,l(`operations.runtime`),b],[`system`,l(`operations.system`),u],[`recovery`,l(`operations.recovery`),a]].map(([e,t,n])=>(0,X.jsxs)(`button`,{type:`button`,onClick:()=>{me(e),D(``)},"aria-current":pe===e?`page`:void 0,className:`flex h-8 shrink-0 items-center justify-center gap-2 rounded-md px-3 text-xs font-medium ${pe===e?`bg-blue/10 text-blue`:`text-ink-faint hover:bg-bg hover:text-ink`}`,children:[(0,X.jsx)(o,{icon:n}),(0,X.jsx)(`span`,{children:t})]},e))}),(0,X.jsxs)(`div`,{className:`grid max-h-[76vh] gap-3 overflow-y-auto bg-bg p-3 scroll-thin lg:grid-cols-2`,children:[pe===`work`?(0,X.jsxs)(`section`,{className:`rounded-lg border border-line bg-panel p-4 lg:col-span-2`,children:[(0,X.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wide text-ink-dim`,children:l(`operations.workInput`)}),(0,X.jsx)(`p`,{className:`mt-1 text-xs text-ink-faint`,children:l(`operations.workHint`)}),(0,X.jsx)(`div`,{className:`mt-3 grid grid-cols-2 gap-1 sm:grid-cols-4`,children:[[`task`,h],[`nudge`,te],[`note`,d],[`plan`,y]].map(([e,t])=>(0,X.jsxs)(`button`,{type:`button`,onClick:()=>m(e),"aria-pressed":p===e,className:`flex h-9 items-center justify-center gap-2 rounded px-2 text-xs font-medium ${p===e?`bg-blue/10 text-blue`:`bg-bg text-ink-dim hover:text-ink`}`,children:[(0,X.jsx)(o,{icon:t}),(0,X.jsx)(`span`,{children:l(`operations.action.${e}`)})]},e))}),(0,X.jsx)(`textarea`,{value:g,onChange:e=>_(e.target.value),rows:5,placeholder:p===`plan`?l(`operations.planPlaceholder`):l(`operations.actionPlaceholder`,{action:p}),className:`mt-3 w-full resize-y rounded border border-line bg-bg p-3 text-sm text-ink outline-none focus:border-blue`}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>void ge(),disabled:!!P||!g.trim(),className:`mt-2 flex h-9 items-center justify-center gap-2 rounded border border-blue/35 bg-blue/8 px-3 text-xs font-medium text-blue hover:border-blue-deep hover:bg-blue-deep hover:text-white disabled:opacity-40`,children:P===`quick`?`…`:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(o,{icon:xe}),(0,X.jsx)(`span`,{children:p===`plan`?l(`operations.previewPlan`):l(`operations.submitAction`,{action:Se})})]})})]}):null,pe===`runtime`?(0,X.jsxs)(`section`,{className:`rounded-lg border border-line bg-panel p-4 lg:col-span-2`,children:[(0,X.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wide text-ink-dim`,children:l(`operations.runtime`)}),(0,X.jsx)(`p`,{className:`mt-1 text-xs text-ink-faint`,children:l(`operations.runtimeHint`)}),(0,X.jsx)(`label`,{className:`mt-3 block text-[10px] uppercase tracking-wide text-ink-faint`,children:l(`operations.workdir`)}),(0,X.jsxs)(`div`,{className:`mt-1 flex gap-2`,children:[(0,X.jsx)(`input`,{value:v,onChange:e=>x(e.target.value),className:`h-9 min-w-0 flex-1 rounded border border-line bg-bg px-2 font-mono text-xs text-ink outline-none focus:border-blue`}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>void he(`cwd`,()=>U.setWorkdir(t,v),l(`operations.workdirUpdated`)),disabled:!!P||!v.trim(),title:l(`operations.applyWorkdir`),"aria-label":l(`operations.applyWorkdir`),className:`flex h-9 w-9 items-center justify-center rounded border border-blue/50 text-xs text-blue disabled:opacity-40`,children:(0,X.jsx)(o,{icon:S})})]}),(0,X.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-2`,children:[(0,X.jsx)(`button`,{type:`button`,onClick:()=>void he(`reset`,()=>U.resetManager(t),`Manager context reset.`),disabled:!!P,title:l(`operations.resetManager`),"aria-label":l(`operations.resetManager`),className:`flex h-9 w-9 items-center justify-center rounded border border-line text-xs text-ink-dim disabled:opacity-40`,children:(0,X.jsx)(o,{icon:O})}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>void he(`upgrade`,()=>Ic(U.upgradeDaemon(t,n.daemon_commands?.revision)),`Current-release daemon started after safely draining active work.`),disabled:!!P||ye,title:ye?`Externally supervised daemon cannot be restarted from this Web host`:ve?`Upgrade incompatible daemon`:`Restart on current release`,"aria-label":ye?`Externally supervised daemon`:ve?`Upgrade incompatible daemon`:`Restart on current release`,className:`flex h-9 w-9 items-center justify-center rounded border text-xs disabled:opacity-40 ${ve?`border-err/60 bg-err/10 text-err`:`border-line text-ink-dim`}`,children:(0,X.jsx)(o,{icon:w})})]}),(0,X.jsxs)(`div`,{className:`mt-4 rounded-lg border border-line bg-bg p-3`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-start gap-3`,children:[(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(`span`,{className:`text-xs font-semibold text-ink`,children:l(`operations.sourceUpdate`)}),(0,X.jsx)(`span`,{className:`rounded px-1.5 py-0.5 text-[10px] font-semibold ${j?.state===`failed`?`bg-err/10 text-err`:j?.update_available?`bg-warn/10 text-warn`:j?.update_available===!1?`bg-ok/10 text-ok`:`bg-line text-ink-dim`}`,children:j?.running?l(`operations.updateRunning`):j?.update_available?l(`operations.updateAvailable`):j?.update_available===!1?l(`operations.updateCurrent`):l(`operations.updateChecking`)})]}),(0,X.jsx)(`p`,{className:`mt-1 text-xs text-ink-faint`,children:j?.error||j?.message||l(`operations.updateChecking`)}),(0,X.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-x-4 gap-y-1 font-mono text-[10px] text-ink-dim`,children:[(0,X.jsxs)(`span`,{children:[l(`operations.currentRevision`),`: `,j?.current_revision?.slice(0,12)||`—`]}),(0,X.jsxs)(`span`,{children:[l(`operations.latestRevision`),`: `,j?.upstream_revision?.slice(0,12)||`—`]}),j?.phase&&j.phase!==`complete`&&j.phase!==`idle`?(0,X.jsxs)(`span`,{children:[l(`operations.updatePhase`),`: `,j.phase]}):null]}),j?.running?(0,X.jsx)(`div`,{className:`mt-2 h-1 overflow-hidden rounded bg-line`,children:(0,X.jsx)(`div`,{className:`h-full w-1/2 animate-pulse rounded bg-blue`})}):null]}),(0,X.jsxs)(`button`,{type:`button`,onClick:()=>void he(`source-update`,async()=>{let e=await U.applySourceUpdate();return ie(e),e},null),disabled:!!P||!!j?.running||j?.can_update===!1,title:j?.can_update===!1?j.error||l(`operations.updateUnavailable`):l(`operations.pullLatest`),"aria-label":l(`operations.pullLatest`),className:`flex h-9 items-center gap-2 rounded border border-blue/50 px-3 text-xs font-medium text-blue disabled:opacity-40`,children:[(0,X.jsx)(o,{icon:f}),(0,X.jsx)(`span`,{children:j?.running?l(`operations.updateRunning`):l(`operations.pullLatest`)})]})]}),j?.restart_required?(0,X.jsx)(`p`,{className:`mt-2 text-xs text-warn`,children:l(`operations.updateRestart`)}):null]}),n.daemon.protocol_error?(0,X.jsx)(`p`,{className:`mt-2 text-xs text-err`,children:n.daemon.protocol_error}):null,be.length?(0,X.jsxs)(`div`,{className:`mt-4`,children:[(0,X.jsx)(`div`,{className:`text-[10px] uppercase tracking-wide text-ink-faint`,children:l(`operations.replaceSlot`)}),(0,X.jsx)(`div`,{className:`mt-2 space-y-1`,children:be.map(e=>(0,X.jsxs)(`button`,{type:`button`,disabled:!!P,onClick:()=>void he(`replace:${e.id}`,()=>Ic(U.replaceDaemon(t,e.id,!!n.continuous?.enabled,n.daemon_commands?.revision)),`Parked ${e.label||e.id} and started this session.`),title:`Replace ${e.label||e.id}`,"aria-label":`Replace ${e.label||e.id}`,className:`flex w-full items-center justify-between rounded border border-line bg-bg px-2 py-1.5 text-left text-xs text-ink-dim disabled:opacity-40`,children:[(0,X.jsx)(`span`,{className:`truncate`,children:e.label||e.id}),(0,X.jsx)(o,{icon:w,className:`ml-2 text-warn`})]},e.id))})]}):null]}):null,pe===`system`?(0,X.jsxs)(`section`,{className:`rounded-lg border border-line bg-panel p-4`,children:[(0,X.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wide text-ink-dim`,children:l(`operations.skills`)}),(0,X.jsxs)(`div`,{className:`mt-3 flex gap-2`,children:[(0,X.jsx)(`input`,{value:C,onChange:e=>T(e.target.value),className:`h-9 min-w-0 flex-1 rounded border border-line bg-bg px-2 font-mono text-xs text-ink outline-none focus:border-blue`,placeholder:`ls, stats, show NAME…`}),(0,X.jsx)(`button`,{type:`button`,disabled:!!P,onClick:()=>void he(`skills`,async()=>{let e=await U.skills(t,C);return k(e),e},null),title:l(`operations.runSkill`),"aria-label":l(`operations.runSkill`),className:`flex h-9 w-9 items-center justify-center rounded border border-blue/50 text-xs text-blue disabled:opacity-40`,children:(0,X.jsx)(o,{icon:r})})]}),ne?(0,X.jsx)(`pre`,{className:`mt-3 max-h-48 overflow-auto whitespace-pre-wrap rounded bg-bg p-3 font-mono text-xs text-ink-dim scroll-thin`,children:ne}):null]}):null,pe===`system`?(0,X.jsxs)(`section`,{className:`rounded-lg border border-line bg-panel p-4`,children:[(0,X.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wide text-ink-dim`,children:l(`operations.metrics`)}),(0,X.jsxs)(`div`,{className:`mt-3 flex items-center gap-3`,children:[(0,X.jsx)(`span`,{className:`rounded px-2 py-1 text-xs font-semibold ${re?.slo?.status===`healthy`?`bg-ok/10 text-ok`:`bg-warn/10 text-warn`}`,children:re?.slo?.status??`loading`}),(0,X.jsxs)(`span`,{className:`text-xs text-ink-faint`,children:[`event validation failures: `,re?.event_validation_failures??`—`]})]}),re?(0,X.jsx)(`pre`,{className:`mt-3 max-h-48 overflow-auto whitespace-pre-wrap rounded bg-bg p-3 font-mono text-[10px] text-ink-dim scroll-thin`,children:JSON.stringify({web:re.web,provider:re.provider,cost_control:re.cost_control},null,2)}):null]}):null,pe===`system`?(0,X.jsx)(Pc,{status:ae,error:oe}):null,pe===`recovery`?(0,X.jsxs)(`section`,{className:`rounded-lg border border-line bg-panel p-4 lg:col-span-2`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsxs)(`h3`,{className:`mr-auto text-xs font-semibold uppercase tracking-wide text-ink-dim`,children:[l(`operations.trash`),` · `,le]}),(0,X.jsx)(`input`,{value:de,onChange:e=>fe(e.target.value),onKeyDown:e=>{!sa(e)&&e.key===`Enter`&&Ce()},placeholder:l(`operations.searchTrash`),className:`h-8 min-w-52 rounded border border-line bg-bg px-2 text-xs text-ink outline-none focus:border-blue`}),(0,X.jsx)(`button`,{type:`button`,disabled:!!P,onClick:()=>void Ce(),title:l(`operations.searchTrash`),"aria-label":l(`operations.searchTrash`),className:`flex h-8 w-8 items-center justify-center rounded border border-blue/50 text-xs text-blue disabled:opacity-40`,children:(0,X.jsx)(o,{icon:ee})})]}),N.length?(0,X.jsx)(`div`,{className:`mt-3 grid gap-2 sm:grid-cols-2`,children:N.map(e=>(0,X.jsxs)(`div`,{className:`flex items-center gap-3 rounded border border-line bg-bg p-2`,children:[(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`div`,{className:`truncate text-xs text-ink`,children:e.label}),(0,X.jsx)(`div`,{className:`truncate font-mono text-[10px] text-ink-faint`,children:e.trash_path})]}),(0,X.jsx)(`button`,{type:`button`,disabled:!!P,onClick:()=>void _e(e),title:`Restore ${e.label}`,"aria-label":`Restore ${e.label}`,className:`flex h-8 w-8 items-center justify-center rounded border border-blue/50 text-xs text-blue disabled:opacity-40`,children:(0,X.jsx)(o,{icon:a})})]},e.trash_id))}):(0,X.jsx)(`p`,{className:`mt-3 text-xs text-ink-faint`,children:l(`operations.trashEmpty`)}),le>N.length?(0,X.jsxs)(`p`,{className:`mt-2 text-[10px] text-ink-faint`,children:[`Showing the newest `,N.length,` matches. Narrow the search to find older sessions.`]}):null]}):null,E?(0,X.jsx)(`pre`,{className:`rounded-lg border border-line bg-panel p-3 font-mono text-xs whitespace-pre-wrap text-ink-dim lg:col-span-2`,children:E}):null]})]})}var Rc=[`handshake.service`,`handshake.project`,`handshake.ready`];function zc(){let{t:e}=Z(),t=(0,I.useRef)(null);return ci(t,(e,t)=>{if(t){e.set(`[data-handshake-line], [data-handshake-node]`,{opacity:1,scale:1,clearProps:`transform`});return}e.to(`[data-handshake-mark]`,{scale:1.055,duration:.75,ease:`sine.inOut`,repeat:-1,yoyo:!0,transformOrigin:`50% 50%`}),e.timeline({repeat:-1,repeatDelay:.25}).fromTo(`[data-handshake-line]`,{scaleX:0,opacity:.25,transformOrigin:`0% 50%`},{scaleX:1,opacity:.8,duration:.9,ease:`power2.inOut`}).fromTo(`[data-handshake-node]`,{autoAlpha:.25,scale:.72},{autoAlpha:1,scale:1,duration:.28,stagger:.16,ease:`back.out(1.8)`},.12).to(`[data-handshake-node]`,{autoAlpha:.35,duration:.3,stagger:.08},`+=0.35`)}),(0,X.jsxs)(`div`,{ref:t,role:`status`,"aria-label":e(`handshake.connecting`),className:`w-full max-w-xl px-6 text-center`,children:[(0,X.jsx)(`div`,{"data-handshake-mark":!0,className:`handshake-mark glass-card mx-auto flex h-16 w-16 items-center justify-center rounded-3xl text-blue shadow-glow sm:h-20 sm:w-20`,children:(0,X.jsx)(Ai,{size:48,className:`text-ink`})}),(0,X.jsxs)(`div`,{className:`relative mx-auto mt-8 h-10 max-w-sm sm:max-w-md`,children:[(0,X.jsx)(`div`,{className:`absolute left-[10%] right-[10%] top-3 h-px bg-line/80`}),(0,X.jsx)(`div`,{"data-handshake-line":!0,className:`handshake-line absolute left-[10%] right-[10%] top-3 h-px`}),(0,X.jsx)(`div`,{className:`relative flex justify-between`,children:Rc.map(t=>(0,X.jsxs)(`div`,{className:`flex w-20 flex-col items-center gap-2.5`,children:[(0,X.jsx)(`span`,{"data-handshake-node":!0,className:`handshake-node h-6 w-6 rounded-full border ring-4 ring-bg`,children:(0,X.jsx)(`span`,{className:`m-auto mt-[7px] block h-2 w-2 rounded-full bg-blue`})}),(0,X.jsx)(`span`,{className:`text-xs font-medium text-ink-faint`,children:e(t)})]},t))})]}),(0,X.jsx)(`p`,{className:`mt-9 text-base font-medium text-ink-dim`,children:e(`handshake.title`)}),(0,X.jsx)(`p`,{className:`mt-1.5 text-sm text-ink-faint`,children:e(`handshake.detail`)})]})}function Bc({loading:e,hasProjects:t,error:n,onRetry:r,onNew:i,onChoose:a,canCreate:o}){let{t:s}=Z();return(0,X.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-4 text-center`,children:[e?(0,X.jsx)(zc,{}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Mi,{size:32,tag:ca}),(0,X.jsx)(`p`,{className:`max-w-md text-sm leading-relaxed ${n?`text-err`:`text-ink-faint`}`,children:n||s(t?`landing.selectOrCreate`:`landing.noSessions`)})]}),!e&&(0,X.jsxs)(`div`,{className:`flex flex-wrap justify-center gap-2`,children:[n?(0,X.jsx)(vi,{onClick:r,variant:`danger`,children:s(`common.retry`)}):null,t?(0,X.jsx)(vi,{onClick:a,children:s(`landing.select`)}):o?(0,X.jsx)(vi,{onClick:i,variant:`primary`,children:s(`landing.new`)}):null]})]})}function $({active:e,onSelect:t,onOpenSessions:n,sidebarOpen:r=!1}){let{t:a}=Z(),s=[{id:`mission`,label:a(`mobile.mission`),icon:y},{id:`activity`,label:a(`mobile.activity`),icon:l},{id:`workbench`,label:a(`mobile.workbench`),icon:p},{id:`map`,label:a(`mobile.map`),icon:y},{id:`preview`,label:a(`mobile.preview`),icon:i}];return(0,X.jsxs)(`nav`,{"aria-label":a(`mobile.views`),className:`mobile-tabbar glass-panel glass-panel--raised fixed inset-x-0 bottom-0 z-40 items-stretch border-t border-line/60 lg:hidden ${r?`hidden`:`flex`}`,children:[n?(0,X.jsxs)(`button`,{type:`button`,onClick:n,"aria-label":a(`topbar.openSessions`),className:`flex min-h-[3.25rem] flex-1 flex-col items-center justify-center gap-0.5 text-ink-faint active:bg-panel-raised`,children:[(0,X.jsx)(o,{icon:_,className:`h-4 w-4`}),(0,X.jsx)(`span`,{className:`text-[10px] leading-none`,children:a(`mobile.sessions`)})]}):null,s.map(n=>{let r=n.id===e;return(0,X.jsxs)(`button`,{type:`button`,onClick:()=>t(n.id),"aria-current":r?`page`:void 0,className:`flex min-h-[3.25rem] flex-1 flex-col items-center justify-center gap-0.5 active:bg-panel-raised ${r?`text-blue`:`text-ink-faint`}`,children:[(0,X.jsx)(o,{icon:n.icon,className:`h-4 w-4`}),(0,X.jsx)(`span`,{className:`text-[10px] leading-none`,children:n.label})]},n.id)})]})}function Vc(){(0,I.useEffect)(()=>{let e=window.visualViewport,t=document.documentElement;if(!e)return;let n=null,r=()=>{n!=null&&window.cancelAnimationFrame(n),n=window.requestAnimationFrame(()=>{let n=window.innerHeight-e.height-e.offsetTop,r=n>24?Math.round(n):0;t.style.setProperty(`--keyboard-inset`,`${r}px`)})};return r(),e.addEventListener(`resize`,r),e.addEventListener(`scroll`,r),()=>{n!=null&&window.cancelAnimationFrame(n),e.removeEventListener(`resize`,r),e.removeEventListener(`scroll`,r),t.style.removeProperty(`--keyboard-inset`)}},[])}async function Hc(e,t){let n=Ht(e.trim());if(!n)return{kind:`not-command`};if(!n.cmd){let e=Ut(n.name);return{kind:`error`,message:e?`Unknown command ${n.name}. Did you mean ${e}?`:`Unknown command ${n.name}. Use /help for the full list.`}}if(n.cmd.id===`ask`||n.cmd.id===`crystalpilot`)return{kind:`not-command`};if(Ft(n.cmd)&&!n.rest)return{kind:`error`,message:`Usage: ${n.cmd.name}${n.cmd.arg?` ${n.cmd.arg}`:``}`};try{await t[n.cmd.id](n.rest)}catch(e){return{kind:`error`,message:e instanceof Error?e.message:String(e??`Command failed`)}}return{kind:`handled`}}function Uc({activeSid:e,activityEventsRef:t,notify:n,onClearEvents:r,onDispose:i,onOpenConfig:a,onOpenDoctor:o,onOpenHelp:s,onOpenIdentity:c,onOpenInspector:l,onOpenNewDaemon:u,onOpenOperations:d,onOpenSidebar:f,onReconnectEvents:p,onRenameProject:m,onRewriteDraft:h,onSelectProject:g,onSetArtifactPath:_,onSetEventFilter:v,onSetEventQuery:y,onSetTaskItemId:b,onSetWorkspaceView:x,onShowArtifacts:S,onStopIteration:C,onStopWaiting:w,refetchSnapshot:T}){return{status:async()=>l(),roles:async()=>d(),journal:async()=>l(),backlog:async()=>x(`mission`),item:async e=>{e&&b(e)},artifacts:async()=>S(),artifact:async e=>{e&&_(e)},events:async e=>{x(`activity`);let{filter:t,query:n}=Vt(e);v(t),y(n)},find:async e=>{x(`activity`),v(`all`),y(e)},run:async()=>x(`activity`),clear:async()=>{x(`activity`),v(`all`),y(``),r(t.current.length)},cancel:async()=>w(),task:async t=>{e&&(await U.addTask(e,t),T(),n(`success`,`Task queued.`))},rewrite:async e=>{let t=e.trim();if(!t){n(`info`,`Type your prompt in the composer and press Rewrite, or use /rewrite .`);return}h(t)},plan:async t=>{if(!e)return;let r=await U.previewPlan(e,t);r.error?n(`error`,r.error):n(`info`,r.steps.map(e=>e.title).join(` +`)||`Plan preview ready.`)},nudge:async t=>{e&&(await U.nudge(e,t),n(`success`,`Guidance injected.`))},abort:async t=>{e&&(await U.abortMission(e,t||`operator abort`),n(`info`,`Abort requested.`))},note:async t=>{e&&(await U.note(e,t),n(`success`,`Note appended to timeline.`))},done:async e=>{e&&i(e,`done`)},skip:async e=>{e&&i(e,`rm`)},stop:async e=>{e&&C(e)},new:async()=>u(),daemons:async()=>f(),resume:async e=>{e&&e!==`list`?g(e):f()},attach:async e=>{e&&g(e)},rename:async t=>{!e||!t||await m(t)},doctor:async()=>o(),backend:async t=>{if(!e||!t){a();return}await U.setConfig(e,`runner_backend`,t),n(`success`,`Backend set to ${t}.`)},config:async t=>{if(!e||!t){a();return}let r=t.indexOf(`=`);r>0?(await U.setConfig(e,t.slice(0,r).trim(),t.slice(r+1).trim()),n(`success`,`Config updated.`)):a()},identity:async()=>c(),reset:async()=>{e&&(await U.resetManager(e),n(`success`,`Manager context reset.`))},skills:async t=>{e&&n(`info`,(await U.skills(e,t||`ls`)).slice(0,400))},reconnect:async()=>p(),help:async()=>s(),quit:async()=>n(`info`,`Background work continues; close this browser tab when ready.`)}}function Wc(e){return e.kind===`error`?(typeof e.reply==`string`?e.reply.trim():``)||`Manager could not handle this message.`:null}function Gc(e,t){e.kind===`task`&&t.dispatchTask(e);let n=Wc(e);n&&t.notifyError(n),t.refetchTranscript()}var Kc={skipFirst:0,reconnectKey:0};function qc(e,t){return t.kind===`clear`?{...e,skipFirst:Math.max(0,t.offset)}:t.kind===`reconnect`?{skipFirst:0,reconnectKey:e.reconnectKey+1}:{...e,skipFirst:0}}var Jc=`local_request_id`;function Yc(e,t,n,r=Date.now()){return{type:`ui.operator`,agent_layer:`operator`,text:n,ts:r/1e3,event_id:`local-${e}-${t}-operator`,message_id:`local-${t}-operator`,[Jc]:t}}function Xc(e,t,n,r,i,a=Date.now(),o=`auto`){let s=r.trim();if(!s)return e;let c=e.findIndex(e=>e.type===`ui.argus`&&Number(e[Jc])===n),l=i.endsWith(`-argus`)?`${i.slice(0,-6)}-operator`:``,u=l?e.map(e=>e.type===`ui.operator`&&Number(e[Jc])===n?{...e,message_id:l}:e):e,d=u.find(e=>e.type===`ui.operator`&&Number(e[Jc])===n),f=d?Math.max(0,a-Number(d.ts??a/1e3)*1e3):0;if(c<0)return[...u,{type:`ui.argus`,agent_layer:`manager`,text:s,ts:a/1e3,event_id:`local-${t}-${n}-argus`,message_id:i||`local-${n}-argus`,fragment_mode:o,response_latency_ms:f,[Jc]:n}];let p=u[c],m=[...u];return m[c]={...p,text:kt(String(p.text??``),s,o),message_id:i||p.message_id,fragment_mode:o},m}function Zc(e,t,n){let r=new Map;e.forEach(e=>{let t=String(e.type??``);if(t!==`ui.operator`&&t!==`ui.argus`)return;let n=`${t}\u0000${String(e.text??``)}`;r.set(n,(r.get(n)??0)+1)});let i=t.map(e=>({type:e.role===`operator`?`ui.operator`:`ui.argus`,agent_layer:e.role===`operator`?`operator`:`manager`,text:e.text,ts:e.ts,message_id:e.message_id||`transcript-${e.ts}-${e.role}`,...e.mission_result===!0?{mission_result:!0}:{},...typeof e.item_id==`string`?{item_id:e.item_id}:{},...typeof e.success==`boolean`?{success:e.success}:{},...typeof e.summary==`string`?{summary:e.summary}:{},...typeof e.delivery_id==`string`?{delivery_id:e.delivery_id}:{},...e.delivery&&typeof e.delivery==`object`?{delivery:e.delivery}:{}})),a=Array(i.length).fill(!0);for(let e=i.length-1;e>=0;--e){let t=i[e],n=`${String(t.type)}\u0000${String(t.text??``)}`,o=r.get(n)??0;o>0&&(a[e]=!1,r.set(n,o-1))}let o=[...i.filter((e,t)=>a[t]),...e],s=Array(o.length).fill(!0),c=new Set,l=n.map(e=>{let t=String(e.message_id??``),n=t?o.findIndex((e,n)=>!c.has(n)&&String(e.message_id??``)===t):-1,r=Number(e.ts??0);if(n<0&&(n=o.findIndex((t,n)=>{if(c.has(n)||t.type!==e.type||t.text!==e.text)return!1;let i=Number(t.ts??0);return Math.abs(i-r)<=5})),n>=0){c.add(n),s[n]=!1;let t=o[n];return{...e,...t.mission_result===!0?{mission_result:!0}:{},...typeof t.item_id==`string`?{item_id:t.item_id}:{},...typeof t.success==`boolean`?{success:t.success}:{},...typeof t.summary==`string`?{summary:t.summary}:{},...typeof t.delivery_id==`string`?{delivery_id:t.delivery_id}:{},...t.delivery&&typeof t.delivery==`object`?{delivery:t.delivery}:{}}}return e});return[...o.filter((e,t)=>s[t]),...l].sort((e,t)=>Number(e.ts??0)-Number(t.ts??0))}function Qc(e,t){if(!t.length)return e;let n=new Map(t.map(e=>[e.id,e]));return e.map(e=>{let t=n.get(e.id);return t?{...e,spend_usd:t.spend_usd,known_cost_usd:t.known_cost_usd,spend_status:t.spend_status,usage_calls:t.usage_calls,premium_requests:t.premium_requests,cost_updated_at:t.updated_at}:e})}async function $c(e,t,n,r=``){let i=await e.createDaemon(``,t,r),a=n.trim();return{created:i,startCampaign:a?()=>e.setContinuous(i.sid,!0,a):null}}var el=e=>e instanceof Error?e.message:String(e||`Unknown error`);function tl({localCwd:e,notify:t,onFocusComposer:n,queryClient:r,refetchProjects:i,selectProject:a}){let[o,s]=(0,I.useState)(!1),c=(0,I.useRef)(!1);return{createDaemon:async(o,l,u)=>{if(c.current)return!1;c.current=!0,s(!0);try{let{created:s,startCampaign:c}=await $c(U,o,l,u),d=String(s.workdir||u||``);return r.setQueryData([`projects`],t=>({local_cwd:t?.local_cwd??e,projects:[{id:s.sid,label:o||s.sid,display_name:o,objective:``,launch_cwd:d,workdir:d,last_active:Date.now()/1e3,daemon_alive:!1,daemon_pid:null,uptime_seconds:null},...(t?.projects??[]).filter(e=>e.id!==s.sid)]})),a(s.sid),i(),window.setTimeout(n,0),t(c?`info`:`success`,c?`Session created and selected. Campaign is starting in the background.`:`Session created and selected.`),c&&c().then(()=>{r.invalidateQueries({queryKey:[`snapshot`,s.sid]}),i(),t(`success`,`Campaign started.`)}).catch(e=>{t(`error`,`Session was created, but the campaign could not start: ${el(e)}`)}),!0}catch(e){return t(`error`,`Could not create session: ${el(e)}`),!1}finally{c.current=!1,s(!1)}},creatingDaemon:o}}var nl=e=>e instanceof Error?e.message:String(e||`Unknown error`);function rl({actions:e,manageActions:t,manageTargetSid:n,setManageTargetSid:r,activeSid:i,clearProjectSelection:a,continuous:o,notify:s,refetchProjects:c,selectProject:l,setDaemonManageOpen:u}){let d=e.startDaemon.isPending||e.stopDaemon.isPending||e.forceStopDaemon.isPending||t.startDaemon.isPending||t.forceStopDaemon.isPending||t.updateProject.isPending||t.deleteProject.isPending,f=(0,I.useCallback)(e=>({onSuccess:()=>s(`success`,e),onError:e=>s(`error`,nl(e))}),[s]),p=(0,I.useCallback)(()=>e.startDaemon.mutate(void 0,f(`Daemon start requested.`)),[f,e.startDaemon]),m=(0,I.useCallback)(()=>e.forceStopDaemon.mutate(void 0,f(`Stop requested; the verified daemon process is being interrupted.`)),[f,e.forceStopDaemon]),h=(0,I.useCallback)(async()=>{try{return await t.startDaemon.mutateAsync(),s(`success`,`Daemon resumed.`),!0}catch(e){return s(`error`,nl(e)),!1}},[t.startDaemon,s]),g=(0,I.useCallback)(async()=>{try{return await t.forceStopDaemon.mutateAsync(),await c(),s(`success`,`Daemon stopped. This session can now be deleted.`),!0}catch(e){return s(`error`,nl(e)),!1}},[t.forceStopDaemon,s,c]),_=(0,I.useCallback)(async e=>{if(!n)return!1;try{return await t.updateProject.mutateAsync({sid:n,name:e}),s(`success`,`Session name updated.`),!0}catch(e){return s(`error`,nl(e)),!1}},[t.updateProject,n,s]),v=(0,I.useCallback)(async()=>{if(!n)return!1;try{let e=n,o=await t.deleteProject.mutateAsync();u(!1),r(null);let d=await c();if(e===i){a(`replace`);let e=Dn(d.data?.projects??[])[0];e&&l(e.id,`replace`)}return s(`success`,o.workdir_preserved?`Session moved to recoverable trash. Files remain in ${o.workdir}.`:`Session moved to recoverable trash.`),!0}catch(e){return s(`error`,nl(e)),!1}},[i,a,t.deleteProject,n,s,c,l,u,r]),y=(0,I.useCallback)(e=>{r(e),u(!0)},[u,r]);return{daemonBusy:d,manageDeleteProject:v,manageStopDaemon:g,manageRenameProject:_,manageStartDaemon:h,requestDispose:(0,I.useCallback)((t,n)=>e.disposeBacklog.mutate({id:t,op:n},{onSuccess:()=>s(`success`,n===`done`?`Work marked done.`:`Work removed.`),onError:e=>s(`error`,nl(e))}),[e.disposeBacklog,s]),requestManageSession:y,requestStartDaemon:p,requestStopDaemon:m,requestStopIteration:(0,I.useCallback)(t=>e.stopBacklog.mutate(t,{onSuccess:()=>s(`success`,`Iteration stopped.`),onError:e=>s(`error`,nl(e))}),[e.stopBacklog,s]),toggleContinuous:(0,I.useCallback)(()=>{if(!o)return;let t=!o.enabled;e.setContinuous.mutate({enabled:t,objective:o.objective},f(t?`Continuous campaign enabled.`:`Continuous campaign stopped.`))},[f,e.setContinuous,o])}}function il({focusComposer:e,openHelp:t,toggleKiosk:n,togglePalette:r,toggleReasoning:i,toggleSidebarCollapse:a}){(0,I.useEffect)(()=>{let o=o=>{let s=o.target,c=s?.tagName===`INPUT`||s?.tagName===`TEXTAREA`,l=o.metaKey||o.ctrlKey;l&&o.key.toLowerCase()===`k`?(o.preventDefault(),r()):l&&o.key.toLowerCase()===`t`?(o.preventDefault(),i()):l&&o.key===`.`?(o.preventDefault(),n()):l&&o.key.toLowerCase()===`b`?(o.preventDefault(),a()):l&&o.key.toLowerCase()===`j`?(o.preventDefault(),e()):!c&&o.key===`?`?(o.preventDefault(),t()):!c&&o.key===`/`&&(o.preventDefault(),e())};return window.addEventListener(`keydown`,o),()=>window.removeEventListener(`keydown`,o)},[e,t,n,r,i,a])}var al=e=>e instanceof Error?e.message:String(e||`Unknown error`),ol=`argus.decision.prompted.v1`,sl=()=>{try{return window.sessionStorage.getItem(ol)??``}catch{return``}},cl=e=>{try{window.sessionStorage.setItem(ol,e)}catch{}};function ll({activeSid:e,autoOpen:t=!0,backlog:n,notify:r,pendingQuestions:i,refetchSnapshot:a}){let[o,s]=(0,I.useState)(!1),[c,l]=(0,I.useState)(!1),u=(0,I.useRef)(``),d=(0,I.useMemo)(()=>{let e=(n??[]).map(e=>({...e,operator_decision:e.operator_decision}));return _t(i??[],e)[0]??null},[n,i]);return(0,I.useEffect)(()=>{if(!d||!e){s(!1);return}if(!t)return;let n=`${e}:${d.id}`;u.current!==n&&sl()!==n&&(u.current=n,cl(n),s(!0))},[e,t,d]),{answerPendingReply:async(t,n)=>{if(!(!e||!d||c)){l(!0);try{let i=d.legacy?await U.answerPending(e,d.item_id,n):await U.resolveDecision(e,d.id,t,n);if(i.resolved===!1){r(`info`,String(i.reply||`Manager needs a more specific answer.`));return}s(!1),await a(),i.daemon&&Number(i.daemon.rc??0)!==0?r(`error`,`Answer queued, but the daemon did not start: ${i.daemon.error||`operator action required`}`):r(`success`,String(i.reply||`Manager delivered your answer to the team.`))}catch(e){await a(),r(`error`,`Could not send answer: ${al(e)}`)}finally{l(!1)}}},pendingReply:d,pendingReplyBusy:c,pendingReplyOpen:o,setPendingReplyOpen:s}}var ul=`argus.browser.project.v1`;function dl(){try{return window.sessionStorage.getItem(ul)}catch{return null}}function fl(e){try{e?window.sessionStorage.setItem(ul,e):window.sessionStorage.removeItem(ul)}catch{}}function pl(e,t){let n=new URL(window.location.href);e?n.searchParams.set(`project`,e):n.searchParams.delete(`project`);let r=t===`push`?`pushState`:`replaceState`;window.history[r](window.history.state,``,n.toString())}function ml({cancelActiveMessage:e,notify:t,projects:n,projectsError:r,projectsReady:i,queryClient:a,setArtifactPath:o,setSidebarOpen:s,setTaskItemId:c}){let l=new URLSearchParams(window.location.search),[u,d]=(0,I.useState)(l.get(`project`)||dl()),f=(0,I.useRef)(u),p=(0,I.useRef)(!1);f.current=u;let m=(0,I.useCallback)(t=>{t!==f.current&&(e(),o(null),c(null)),f.current=t,d(t),fl(t)},[e,o,c]),h=(0,I.useCallback)((e,t=`push`)=>{let n=new URLSearchParams(window.location.search).get(`project`);m(e),n!==e&&pl(e,t)},[m]),g=(0,I.useCallback)((e=`replace`)=>{let t=new URLSearchParams(window.location.search).get(`project`);m(null),t!=null&&pl(null,e)},[m]),_=(0,I.useCallback)(e=>{a.prefetchQuery({queryKey:[`snapshot`,e],queryFn:({signal:t})=>U.prefetchSnapshot(e,t),staleTime:3e3})},[a]);return(0,I.useEffect)(()=>{if(!i)return;let e=p.current,r=An(n,f.current,e);if(!e&&(p.current=!0,r.id===f.current?fl(r.id):m(r.id),new URLSearchParams(window.location.search).get(`project`)!==r.id&&pl(r.id,`replace`),r.recovered)){let e=n.find(e=>e.id===r.id);t(`info`,e?`Project “${r.requested}” was not found. Switched to ${e.label||e.id}.`:`Project “${r.requested}” was not found. Create a daemon to continue.`)}},[m,t,n,i]),(0,I.useEffect)(()=>{let e=()=>{let e=new URLSearchParams(window.location.search).get(`project`);if(s(!1),!e){m(null);return}if(!i){m(e);return}let r=kn(n,e);if(m(r.id),r.recovered){pl(r.id,`replace`);let e=n.find(e=>e.id===r.id);t(`info`,e?`Project “${r.requested}” was not found. Switched to ${e.label||e.id}.`:`Project “${r.requested}” was not found. Create a daemon to continue.`)}};return window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)},[m,t,n,i,s]),{activateProject:m,activeSid:i?u&&n.some(e=>e.id===u)?u:null:r?u:null,clearProjectSelection:g,prefetchProject:_,selectProject:h,sid:u,sidRef:f}}function hl(e){try{return globalThis.localStorage?.getItem(e)??null}catch{return null}}function gl(e,t){try{return globalThis.localStorage?.setItem(e,t),!!globalThis.localStorage}catch{return!1}}function _l(e,t,n){let r=n?t+8:56,i=Math.max(320,e-r-360-8);return Math.max(320,Math.min(840,i,Math.round(e*.45)))}var vl=`argus.themeStyle`;function yl(){return`standard`}function bl(){gl(vl,`standard`)}function xl(e,t){let n=hl(e);return n==null?t:n===`true`}function Sl(e){document.documentElement.dataset.theme=e,window.parent!==window&&window.parent.postMessage({type:`argus:theme-changed`,payload:e},`*`)}function Cl(){let e=new URLSearchParams(window.location.search),[t,n]=(0,I.useState)(e.get(`kiosk`)===`1`),[r,i]=(0,I.useState)(()=>xl(`argus.reasoning.visible.v1`,!1)),[a,o]=(0,I.useState)(()=>{let t=e.get(`view`);if(t===`mission`||t===`activity`||t===`workbench`||t===`map`)return t;let n=hl(`argus.workspace.view`);return n===`mission`||n===`activity`||n===`workbench`||n===`map`?n:`map`}),[s,c]=(0,I.useState)(`activity`),[l,u]=(0,I.useState)(()=>xl(`argus.preview.expanded.v5`,!0)),[d,f]=(0,I.useState)(()=>{let e=Number(hl(`argus.sidebar.width.v2`)||256);return Number.isFinite(e)?Math.max(220,Math.min(400,e)):256}),[p,m]=(0,I.useState)(()=>{let e=Number(hl(`argus.preview.width.v2`)||440);return Number.isFinite(e)?Math.max(320,Math.min(840,e)):440}),[h,g]=(0,I.useState)(!1),[_,v]=(0,I.useState)(()=>xl(`argus.sidebar.expanded.v4`,!0)),[y,b]=(0,I.useState)(()=>{let t=e.get(`desktopTheme`);if(t===`light`||t===`dark`)return t;let n=hl(`argus.theme`);return n===`light`||n===`dark`?n:null}),x=yl(),[S,C]=(0,I.useState)(()=>window.matchMedia(`(prefers-color-scheme: dark)`).matches),w=y??(S?`dark`:`light`),T=(0,I.useRef)(w),E=(0,I.useRef)(null),D=(0,I.useRef)(null);(0,I.useEffect)(()=>{gl(`argus.sidebar.expanded.v4`,String(_)),gl(`argus.preview.expanded.v5`,String(l)),gl(`argus.sidebar.width.v2`,String(d)),gl(`argus.preview.width.v2`,String(p))},[_,d,l,p]),(0,I.useEffect)(()=>{gl(`argus.workspace.view`,a)},[a]),(0,I.useEffect)(()=>{gl(`argus.reasoning.visible.v1`,String(r))},[r]),(0,I.useEffect)(()=>{let e=window.matchMedia(`(prefers-color-scheme: dark)`),t=()=>C(e.matches);return t(),e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]),(0,I.useEffect)(()=>{T.current=w,Sl(w)},[w]),(0,I.useEffect)(()=>{document.documentElement.dataset.themeStyle=x,bl()},[x]),(0,I.useEffect)(()=>{window.parent!==window&&window.parent.postMessage({type:`argus:theme-preference`,payload:y||`system`},`*`)},[y]);let ee=(0,I.useCallback)(()=>{let e=T.current===`light`?`dark`:`light`;T.current=e,Sl(e),gl(`argus.theme`,e);let t=new URL(window.location.href);t.searchParams.has(`desktopTheme`)&&(t.searchParams.set(`desktopTheme`,e),window.history.replaceState(window.history.state,``,t.toString())),(0,I.startTransition)(()=>b(e))},[]),O=(0,I.useCallback)(()=>{u(!0),c(`preview`);let e=E.current?.clientWidth??window.innerWidth;if(e>=1024){let t=_l(e,d,_);m(e=>Math.max(e,t))}},[_,d]),te=(0,I.useCallback)((e,t)=>{let n=E.current;if(!n)return;t.preventDefault();let r=n.getBoundingClientRect(),i=e===`left`?d:p;n.dataset.resizing=e,document.body.style.cursor=`col-resize`,document.body.style.userSelect=`none`;let a=t=>{if(e===`left`){let e=l?p+8:56,n=Math.max(220,Math.min(400,r.width-e-360-8));i=Math.max(220,Math.min(n,t.clientX-r.left))}else{let e=_?d+8:56,n=Math.max(320,Math.min(840,r.width-e-360-8));i=Math.max(320,Math.min(n,r.right-t.clientX))}D.current??=window.requestAnimationFrame(()=>{n.style.setProperty(e===`left`?`--sidebar-width`:`--preview-width`,`${i}px`),D.current=null})},o=()=>{D.current!=null&&window.cancelAnimationFrame(D.current),D.current=null,n.style.setProperty(e===`left`?`--sidebar-width`:`--preview-width`,`${i}px`),e===`left`?f(i):m(i),delete n.dataset.resizing,document.body.style.cursor=``,document.body.style.userSelect=``,window.removeEventListener(`pointermove`,a),window.removeEventListener(`pointerup`,o),window.removeEventListener(`pointercancel`,o)};window.addEventListener(`pointermove`,a),window.addEventListener(`pointerup`,o,{once:!0}),window.addEventListener(`pointercancel`,o,{once:!0})},[_,d,l,p]);return(0,I.useEffect)(()=>{let e=()=>{if(window.innerWidth<1024||!E.current)return;let e=E.current.clientWidth,t=_?d:56,n=l?p:56,r=(_?8:0)+(l?8:0),i=Math.max(540,e-360-r);if(t+n<=i)return;let a=l?Math.max(320,Math.min(p,i-t)):n,o=_?Math.max(220,Math.min(d,i-a)):t;o+a>i&&l&&(a=Math.max(320,i-o)),_&&f(o),l&&m(a)};return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[_,d,l,p]),{cycleTheme:ee,kiosk:t,leftPanelOpen:_,leftWidth:d,mobileView:s,openPreview:O,resizeSidebar:te,rightPanelOpen:l,rightWidth:p,setKiosk:n,setLeftPanelOpen:v,setLeftWidth:f,setMobileView:c,setRightPanelOpen:u,setRightWidth:m,setShowReasoning:i,setSidebarOpen:g,setWorkspaceView:o,shellRef:E,showReasoning:r,sidebarOpen:h,themeMode:w,themeStyle:x,workspaceView:a}}function wl(e){let t=e.trim();if(!t||/\s/.test(t))return``;if(!t.includes(`?`)&&!t.includes(`://`))return t;try{return new URL(t,window.location.href).searchParams.get(`token`)?.trim()??``}catch{return``}}function Tl({error:e,onRetry:t}){let{t:n}=Z(),r=L(e),i=e instanceof Ze,[a,o]=(0,I.useState)(!1),[s,c]=(0,I.useState)(``),[l,u]=(0,I.useState)(``);return!r&&!i?null:(0,X.jsxs)(`div`,{role:`alert`,className:`fixed left-1/2 top-3 z-[100] flex w-[min(92vw,42rem)] -translate-x-1/2 flex-wrap items-start gap-3 rounded-xl border border-err/50 bg-panel/95 px-4 py-3 text-left text-sm text-ink shadow-xl backdrop-blur`,children:[(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`mt-0.5 font-mono font-bold text-err`,children:`!`}),(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`strong`,{className:`block text-err`,children:n(r?`connection.pairingTitle`:`connection.unreachableTitle`)}),(0,X.jsx)(`span`,{className:`mt-0.5 block text-xs leading-relaxed text-ink-dim`,children:n(r?`connection.pairingDetail`:`connection.unreachableDetail`)})]}),r&&!a?(0,X.jsx)(`button`,{type:`button`,onClick:()=>o(!0),className:`shrink-0 rounded-md border border-blue/45 bg-blue/10 px-2.5 py-1 text-xs font-medium text-blue hover:bg-blue/15`,children:n(`connection.pairAgain`)}):r?null:(0,X.jsx)(`button`,{type:`button`,onClick:t,className:`shrink-0 rounded-md border border-err/40 px-2.5 py-1 text-xs text-err hover:bg-err/10`,children:n(`common.retry`)}),r&&a?(0,X.jsxs)(`form`,{onSubmit:e=>{e.preventDefault();let t=wl(s);if(!t){u(n(`connection.pairingInvalid`));return}let r=new URL(window.location.href);r.searchParams.set(`token`,t),window.location.replace(r.toString())},className:`flex w-full basis-full flex-wrap gap-2 pl-7`,children:[(0,X.jsx)(`label`,{className:`sr-only`,htmlFor:`pairing-link`,children:n(`connection.pairingInput`)}),(0,X.jsx)(`input`,{id:`pairing-link`,"data-autofocus":!0,type:`password`,autoComplete:`off`,value:s,onChange:e=>{c(e.target.value),u(``)},placeholder:n(`connection.pairingPlaceholder`),className:`h-9 min-w-0 flex-1 rounded-md border border-line bg-bg px-3 text-xs text-ink outline-none focus:border-blue`}),(0,X.jsx)(`button`,{type:`submit`,className:`h-9 rounded-md border border-blue/35 bg-blue/8 px-3 text-xs font-medium text-blue hover:border-blue-deep hover:bg-blue-deep hover:text-white`,children:n(`connection.connect`)}),l?(0,X.jsx)(`span`,{role:`alert`,className:`w-full text-xs text-err`,children:l}):null]}):null]})}function El(e){try{let t=JSON.parse(hl(e)||`[]`);return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}catch{return[]}}function Dl(e,t,n,r=!0){let i=(0,I.useRef)(),[a,o]=(0,I.useState)(null),s=(0,I.useCallback)(t=>{if(!e)return;let n=`argus.delivery.seen.v1:${e}`;gl(n,JSON.stringify([...new Set([...El(n),t])].slice(-80)))},[e]),c=(0,I.useCallback)((t,n)=>{if(!e)return;s(t.delivery_id);let r=Qr(t),i=r.find(e=>e.path===n)?.path||r[0]?.path||null;o({sid:e,receipt:t,path:i})},[e,s]);return(0,I.useEffect)(()=>{if(!e||!t)return;let a=n?.delivery_id;if(i.current?.sid!==e){i.current={sid:e,ids:new Set(a?[a]:[])},o(null);return}!a||i.current.ids.has(a)||!r||(i.current.ids.add(a),n&&Qr(n).length&&!El(`argus.delivery.seen.v1:${e}`).includes(a)&&c(n))},[e,t,n,c,r]),{selection:a?.sid===e?a:null,open:c,close:(0,I.useCallback)(()=>o(null),[]),selectPath:(0,I.useCallback)(e=>o(t=>t&&{...t,path:e}),[])}}var Ol=0,kl=(0,I.lazy)(async()=>({default:(await oi(()=>import(`./ResearchWorkbenchPanel-DZNe62z_.js`),__vite__mapDeps([2,1,3,4,5,6]))).ResearchWorkbenchPanel})),Al=(0,I.lazy)(async()=>({default:(await oi(()=>import(`./MapPanel-DOAsDr5E.js`),__vite__mapDeps([7,1,3,4,8,9,5,10]))).MapPanel}));function jl(e,t){let[n,r]=(0,I.useState)(e),i=(0,I.useRef)(e),a=(0,I.useRef)(null),o=(0,I.useRef)(0);return i.current=e,(0,I.useEffect)(()=>{if(e===n)return;let s=o.current+t-Date.now();if(s<=0){o.current=Date.now(),r(e);return}a.current||=setTimeout(()=>{a.current=null,o.current=Date.now(),r(i.current)},s)},[e,n,t]),(0,I.useEffect)(()=>()=>{a.current&&clearTimeout(a.current)},[]),n}function Ml(){let{locale:e,t}=Z(),n=oe(),r=_r(),i=vr(),a=(0,I.useMemo)(()=>Dn(Qc(r.data?.projects??[],i.data?.projects??[])),[i.data?.projects,r.data?.projects]),s=r.data?.local_cwd??``,c=[r.error,i.error].find(e=>Qe(e)),[l,u]=(0,I.useState)(`none`),{cycleTheme:d,kiosk:f,leftPanelOpen:p,leftWidth:m,mobileView:h,openPreview:g,resizeSidebar:_,rightPanelOpen:v,rightWidth:y,setKiosk:b,setLeftPanelOpen:x,setLeftWidth:S,setMobileView:C,setRightPanelOpen:w,setRightWidth:T,setShowReasoning:D,setSidebarOpen:ee,setWorkspaceView:O,shellRef:te,showReasoning:ne,sidebarOpen:k,themeMode:re,workspaceView:A}=Cl(),[j,ie]=(0,I.useState)(()=>A===`mission`?`mission`:`activity`),[ae,M]=(0,I.useState)(A===`workbench`);(0,I.useEffect)(()=>{if(A===`workbench`){M(!0);return}A!==`map`&&ie(A)},[A]),Vc();let[se,N]=(0,I.useState)(0),[ce,le]=(0,I.useState)(``),[ue,de]=(0,I.useState)([]),fe=(0,I.useRef)(ce);fe.current=ce;let[P,F]=(0,I.useState)(!1),[pe,me]=(0,I.useState)(0),[he,ge]=(0,I.useState)(Rr),[_e,ve]=(0,I.useState)(!1),[ye,be]=(0,I.useState)([]),[xe,Se]=(0,I.useState)([]),[Ce,we]=(0,I.useState)(null),[Te,Ee]=(0,I.useState)({path:``,token:0}),[De,Oe]=(0,I.useState)(null),[ke,Ae]=(0,I.useState)(!1),[je,Me]=(0,I.useState)(!1),[Ne,Pe]=(0,I.useState)(null),[Fe,Ie]=(0,I.useState)(null),Le=(0,I.useRef)(!1),Re=(0,I.useRef)(null),ze=(0,I.useRef)(0),Be=(0,I.useRef)(),Ve=(0,I.useRef)({sid:``,completionId:``,view:null,artifacts:[]}),He=(0,I.useRef)(null),[Ue,We]=(0,I.useState)(null),[Ge,Ke]=(0,I.useReducer)(qc,Kc),[qe,Je]=(0,I.useState)(`all`),[Ye,Xe]=(0,I.useState)(``),Ze=(0,I.useCallback)(()=>We(null),[]);(0,I.useEffect)(()=>{try{localStorage.setItem(Lr,he)}catch{}},[he]);let L=(0,I.useCallback)((e,t)=>{We({id:++Ol,tone:e,message:t})},[]),$e=(0,I.useCallback)(()=>{let e=!!Re.current;return ze.current+=1,Re.current?.controller.abort(),Re.current=null,ve(!1),Se([]),e},[]),et=(0,I.useCallback)(()=>{$e()&&L(`info`,`Stopped waiting for this reply. Server-side work may still finish in the project timeline.`)},[$e,L]),{activeSid:R,clearProjectSelection:z,prefetchProject:tt,selectProject:nt,sidRef:rt}=ml({cancelActiveMessage:$e,notify:L,projects:a,projectsError:r.isError,projectsReady:r.isSuccess,queryClient:n,setArtifactPath:we,setSidebarOpen:ee,setTaskItemId:Oe});(0,I.useEffect)(()=>()=>{ze.current+=1,Re.current?.controller.abort(),Re.current=null},[]),(0,I.useEffect)(()=>gs(),[]);let it=(0,I.useCallback)(e=>{let t=(e||``).trim(),n=rt.current;!t||!n||P||(F(!0),U.rewritePrompt(n,t).then(e=>{if(F(!1),e.error||!e.rewritten.trim()){L(`error`,`Rewrite failed: ${e.error||`empty rewrite`} — your prompt is unchanged`);return}le(e.rewritten),N(e=>e+1);let t=e.questions.length?` Manager asks: ${e.questions.join(` · `)}`:``;L(`success`,`Prompt rewritten — review it, then send.${t}`)},e=>{F(!1),L(`error`,`Rewrite failed: ${mi(e)} — your prompt is unchanged`)}))},[L,P,rt]),{createDaemon:B,creatingDaemon:at}=tl({localCwd:s,notify:L,onFocusComposer:()=>N(e=>e+1),queryClient:n,refetchProjects:r.refetch,selectProject:nt});(0,I.useEffect)(()=>hs(()=>Ae(!0)),[]);let ot=yr(R),st=yr(Ne),V=ot.data,H=V?.session.id===R?R:null,ct=V?.continuous,lt=Tr(H,!0),ut=Dr(H,j===`mission`),{events:dt,connected:W}=Ir(H,Ge.reconnectKey),ft=(0,I.useMemo)(()=>Nr(dt),[dt]),pt=(0,I.useMemo)(()=>Fr(dt),[dt]);(0,I.useEffect)(()=>{if(!H||!ft)return;let e=window.setTimeout(()=>{n.invalidateQueries({queryKey:[`artifacts`,H],exact:!0})},180);return()=>window.clearTimeout(e)},[ft,H,n]),(0,I.useEffect)(()=>{if(!H||!pt)return;let e=window.setTimeout(()=>{n.invalidateQueries({queryKey:[`snapshot`,H],exact:!0})},80);return()=>window.clearTimeout(e)},[H,n,pt]);let mt=(0,I.useMemo)(()=>Rn(dt),[dt]),ht=wr(H,j===`activity`,120),gt=br(R,20,l===`inspector`),{answerPendingReply:_t,pendingReply:G,pendingReplyBusy:vt,pendingReplyOpen:yt,setPendingReplyOpen:bt}=ll({activeSid:R,autoOpen:A!==`map`,backlog:V?.backlog,notify:L,pendingQuestions:V?.pending_questions,refetchSnapshot:ot.refetch}),xt=(0,I.useMemo)(()=>Zc(dt,ht.data??[],ye),[dt,ye,ht.data]),St=jl(dt,250),Ct=jl(xt,250),wt=(0,I.useMemo)(()=>V?xn(V,xt,lt.data??[]):null,[xt,lt.data,V]),Tt=V?.daemon.alive&&wt?.routing.vertical===`research`?wt.active_role.startsWith(`reviewer`)?`reviewing`:wt.active_role.startsWith(`engineer`)?`revising`:void 0:void 0,Et=ti((0,I.useMemo)(()=>ra(xt),[xt]),wt?.delivery??null,xt),Dt=V?.backlog.some(e=>[`pending`,`running`,`in_progress`,`claimed`].includes(e.status))??!1,Ot=Ss(wt)&&!Dt&&!V?.continuous?.enabled,kt=H&&Ot&&wt?.mission.id?`completion:${H}:${wt.mission.id}`:``;He.current=Et,Ve.current={sid:H||``,completionId:kt,view:wt,artifacts:lt.data??[]};let At=(0,I.useCallback)(()=>{g()},[g]),jt=(0,I.useCallback)((e,t=!0)=>{let n=e.trim();if(!n){t&&O(`mission`);return}if(A===`map`){we(n);return}w(!0),C(`preview`),Ee(e=>({path:n,token:e.token+1}))},[C,w,O,A]),Mt=Dl(H,!!V&&!ht.isPending,Et,!Ce&&!ni(V?.backlog??[],Et?.item_id)),Pt=Mt.open,Ft=(0,I.useMemo)(()=>{let e=new Map;for(let t of xt){let n=t.delivery;n?.delivery_id&&Array.isArray(n.targets)&&e.set(n.delivery_id,n)}for(let t of[wt?.delivery,Et])t&&e.set(t.delivery_id,t);return[...e.values()].filter(e=>Qr(e).length).sort((e,t)=>t.delivered_at-e.delivered_at)},[xt,wt?.delivery,Et]);(0,I.useEffect)(()=>{H&&Et?.delivery_id&&n.invalidateQueries({queryKey:[`artifacts`,H],exact:!0})},[H,Et?.delivery_id,n]),(0,I.useEffect)(()=>{if(!H)return;let e=Be.current;if(!e||e.sid!==H){Be.current={sid:H,id:kt||null};return}if(!kt){Be.current={sid:H,id:null};return}if(e.id===kt)return;let n=window.setTimeout(()=>{let e=Ve.current;if(e.sid!==H||e.completionId!==kt||!e.view)return;let n=e.view.delivery,r=Ds(e.artifacts),i=ls({completionId:kt,title:n?.title||e.view.mission.title||t(`mission.taskCompleted`),summary:n?.summary||e.view.mission.summary,path:n?.primary_target?.path||r?.path});i&&fs(i),Be.current={sid:H,id:kt}},500);return()=>window.clearTimeout(n)},[kt,H,t]),(0,I.useEffect)(()=>ms(e=>{let t=He.current;t&&t.delivery_id===e.deliveryId?Pt(t):e.path?jt(e.path):(C(`activity`),O(`mission`))}),[jt,Pt,C,O]);let K=(0,I.useRef)(xt);K.current=xt,(0,I.useEffect)(()=>{Je(`all`),Xe(``),be([]),Ke({kind:`reset`})},[H]);let It=kr(R,V?.daemon_commands?.revision),Lt=kr(Ne,st.data?.daemon_commands?.revision),Rt=(0,I.useCallback)(async e=>{Ie(e);try{await U.startDaemon(e),await r.refetch(),L(`success`,t(`sidebar.resumeSuccess`))}catch(e){L(`error`,t(`sidebar.resumeFailed`,{error:mi(e)}))}finally{Ie(null)}},[L,r,t]),{daemonBusy:zt,manageDeleteProject:Bt,manageStopDaemon:Vt,manageRenameProject:Ht,manageStartDaemon:Ut,requestDispose:Wt,requestManageSession:Gt,requestStartDaemon:Kt,requestStopDaemon:qt,requestStopIteration:Jt,toggleContinuous:Yt}=rl({actions:It,manageActions:Lt,manageTargetSid:Ne,setManageTargetSid:Pe,activeSid:R,clearProjectSelection:z,continuous:ct,notify:L,refetchProjects:r.refetch,selectProject:nt,setDaemonManageOpen:Me}),Xt=(0,I.useCallback)(async e=>{if(!R)return;let t=await It.updateProject.mutateAsync({sid:R,name:e});L(`success`,`Renamed to "${t.name}".`)},[It.updateProject,R,L]),Zt=(0,I.useMemo)(()=>Uc({activeSid:R,activityEventsRef:K,notify:L,onClearEvents:e=>Ke({kind:`clear`,offset:e}),onDispose:Wt,onOpenConfig:()=>u(`config`),onOpenDoctor:()=>u(`doctor`),onOpenHelp:()=>u(`help`),onOpenIdentity:()=>u(`identity`),onOpenInspector:()=>u(`inspector`),onOpenNewDaemon:()=>Ae(!0),onOpenOperations:()=>u(`operations`),onOpenSidebar:()=>ee(!0),onReconnectEvents:()=>Ke({kind:`reconnect`}),onRenameProject:Xt,onRewriteDraft:it,onSelectProject:nt,onSetArtifactPath:we,onSetEventFilter:Je,onSetEventQuery:Xe,onSetTaskItemId:Oe,onSetWorkspaceView:O,onShowArtifacts:At,onStopIteration:Jt,onStopWaiting:et,refetchSnapshot:ot.refetch}),[R,L,At,Xt,Wt,Jt,nt,ot.refetch,et,O]);il({focusComposer:()=>N(e=>e+1),openHelp:()=>u(`help`),toggleKiosk:()=>b(e=>!e),togglePalette:()=>u(e=>e===`palette`?`none`:`palette`),toggleReasoning:()=>D(e=>!e),toggleSidebarCollapse:()=>x(e=>!e)});let Qt=async(e,n=[],r)=>{let i=R;if(!i||Le.current||Re.current)return!1;Le.current=!0;let a,o;try{if(!n.length){let t=await Hc(e,Zt);if(t.kind===`handled`)return r?.({type:`settled`,outcome:`message`}),!0;if(t.kind===`error`)return L(`error`,t.message),!1}a=++ze.current,o=new AbortController,Re.current={id:a,sid:i,controller:o}}finally{Le.current=!1}let s=()=>{let e=Re.current;return!!(e&&e.id===a&&e.sid===i&&rt.current===i&&!o.signal.aborted)},c=()=>{Re.current?.id===a&&(Re.current=null,ve(!1),Se([]))};ve(!0),Se([]);let l=[];if(n.length)try{let e=await U.uploadAttachments(i,n,o.signal);if(!s())return!1;l=e.attachments.map(e=>({attachment_id:e.attachment_id}))}catch(e){return s()&&(L(`error`,t(`chat.attachmentUploadFailed`,{error:mi(e)})),c()),!1}be(t=>[...t,Yc(i,a,e)]);let u=(e,t=``,n=`auto`)=>{!s()||typeof e!=`string`||!e.trim()||be(r=>Xc(r,i,a,e,t,Date.now(),n))},d=e=>{if(!s())return;let t=e.item;typeof t?.id==`string`&&r?.({type:`task`,taskId:t.id});let n=e.daemon&&typeof e.daemon==`object`?e.daemon:null,i=typeof e.reply==`string`?e.reply:null;n?.admission_required?L(`error`,i||`Task queued, but all daemon slots are busy: ${String(n.error||`operator action required`)}`):n&&Number(n.rc??0)!==0?L(`error`,i||`Task queued, but executor did not start: ${String(n.error||`unknown error`)}`):i&&!r&&L(`success`,i),ot.refetch?.()},f=e=>{s()&&Gc(e,{dispatchTask:d,notifyError:e=>L(`error`,e),refetchTranscript:()=>{ht.refetch()}})};return(async()=>{let t=!1,n=null,a=[];try{try{await U.messageStream(i,e,{onPhase:(e,t,n)=>{!s()||n.heartbeat||(a=Kn(a,{label:e,role:t,kind:n.kind,detail:n.detail,heartbeat:n.heartbeat,quietS:n.quietS}),Se(a))},onDelta:(e,n,r)=>{s()&&(t=!0,a=qn(a),Se(a),u(e,n,r===`append`||r===`snapshot`?r:`auto`))},onDone:e=>{if(!s())return;u(e.reply,``,`snapshot`),f(e);let t=e.item;(e.kind!==`task`||typeof t?.id!=`string`)&&r?.({type:`settled`,outcome:e.kind===`error`?`error`:`message`})},onError:e=>{s()&&(n=e)}},{signal:o.signal,attachments:l,routeOverride:he})}catch(e){s()&&(n=e)}if(!s())return;n&&(L(`error`,hi(n,t)),r?.({type:`settled`,outcome:`error`}))}finally{o.signal.aborted&&r?.({type:`settled`,outcome:`cancelled`}),c()}})(),!0},$t=(0,I.useRef)(Qt);$t.current=Qt;let en=async(e,t=[])=>{let n=fe.current,r=rt.current,i=await Qt(e,t);return i&&rt.current===r&&(le(e=>e===n?``:e),de(e=>e.filter(e=>!t.includes(e)))),i},tn=(0,I.useMemo)(()=>{let n=vo(Nt,e=>{$t.current(e)},e=>{le(e),N(e=>e+1)},e),r=[...f?[]:[{id:`new`,label:t(`palette.newDaemon`),hint:`+`,group:t(`palette.view`),run:()=>Ae(!0)}],{id:`transcript`,label:t(`palette.openTranscript`),hint:`/transcript`,group:t(`palette.view`),run:()=>u(`transcript`)},{id:`inspector`,label:t(`palette.openProject`),hint:t(`palette.projectHint`),group:t(`palette.view`),run:()=>u(`inspector`)},{id:`operations`,label:t(`palette.openOperations`),hint:t(`palette.operationsHint`),group:t(`palette.view`),run:()=>u(`operations`)},{id:`help`,label:t(`help.title`),hint:`?`,group:t(`palette.view`),run:()=>u(`help`)},{id:`reasoning`,label:t(ne?`palette.hideReasoning`:`palette.showReasoning`),hint:`⌘T`,group:t(`palette.view`),run:()=>D(e=>!e)},{id:`kiosk`,label:t(f?`palette.exitKiosk`:`palette.enterKiosk`),hint:`⌘.`,group:t(`palette.view`),run:()=>b(e=>!e)}],i=f?[]:[{id:`message`,label:t(`palette.messageArgus`),hint:`/`,group:t(`palette.action`),run:()=>N(e=>e+1)},..._e?[{id:`cancel-message`,label:t(`palette.stopWaiting`),hint:`Esc`,group:t(`palette.action`),run:et}]:[],...ct?[{id:`continuous`,label:ct.enabled?t(`palette.stopContinuous`):t(`palette.startContinuous`),group:t(`palette.action`),run:Yt}]:[],...V?.daemon.control_available===!1?[]:[V?.daemon.alive?{id:`stop`,label:t(`palette.stopDaemon`),group:t(`palette.action`),run:qt}:{id:`start`,label:t(`palette.startDaemon`),group:t(`palette.action`),run:Kt}]],o=a.map(e=>({id:`p-${e.id}`,label:e.label||e.id,hint:e.daemon_alive?`● ${t(`common.live`)}`:`○`,keywords:`${e.id} ${e.display_name??``} ${e.objective} ${e.daemon_alive?`live running`:`stopped idle`}`,group:t(`palette.project`),run:()=>nt(e.id)}));return[...r,...i,...n,...o]},[a,V?.daemon.alive,f,ne,ct?.enabled,_e,et,e,t]);return(0,X.jsxs)(`div`,{ref:te,style:{"--sidebar-width":`${m}px`,"--preview-width":`${y}px`},className:`workbench-shell ambient-canvas flex w-screen max-w-full overflow-hidden text-ink`,children:[(0,X.jsx)(Tl,{error:c,onRetry:()=>{r.refetch(),i.refetch()}}),Mt.selection&&(0,X.jsx)(vs,{sid:Mt.selection.sid,path:Mt.selection.path,delivery:Mt.selection.receipt,deliveries:Ft,reviewActivity:Mt.selection.sid===H?Tt:void 0,onSelectDelivery:Pt,onSelectPath:Mt.selectPath,onClose:Mt.close},`${Mt.selection.sid}:${Mt.selection.receipt.delivery_id}`),!f&&k?(0,X.jsx)(`button`,{type:`button`,"aria-label":t(`common.closeSessions`),onClick:()=>ee(!1),className:`fixed inset-0 z-30 bg-black/40 lg:hidden`}):null,f?null:(0,X.jsx)(Qs,{projects:a,activeId:R,localCwd:s,onSelect:e=>{nt(e),ee(!1)},onPrefetch:tt,onManage:Gt,onResume:e=>void Rt(e),resumingId:Fe,onOpenPanel:e=>u(e),onNew:()=>Ae(!0),loading:r.isLoading,creating:at,error:r.isError?mi(r.error):void 0,onRetry:()=>void r.refetch(),mobileOpen:k,collapsed:!p,onToggleCollapse:()=>x(e=>!e),themeMode:re,onCycleTheme:d}),!f&&p?(0,X.jsx)(uc,{label:t(`common.resizeSessions`),value:m,min:220,max:400,onPointerDown:e=>_(`left`,e),onReset:()=>S(256),onNudge:e=>S(t=>Math.max(220,Math.min(400,t+e)))}):null,(0,X.jsx)(`main`,{className:`flex min-w-0 flex-1 overflow-x-hidden`,children:V?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`section`,{className:`${h===`activity`?`flex`:`hidden`} glass-panel glass-panel--main h-full min-w-0 flex-1 flex-col lg:flex`,children:[A!==`map`&&(0,X.jsx)(Zr,{snap:V,streamOk:W,onStart:Kt,onStop:qt,onManage:()=>R&&Gt(R),busy:zt,snapshotStale:ot.isError,readOnly:f,missionView:wt}),(0,X.jsxs)(`div`,{className:`hidden h-10 shrink-0 items-center gap-1 border-b border-line/60 px-3 lg:flex`,children:[(0,X.jsxs)(`div`,{className:`workspace-tabs`,"data-active":A,children:[(0,X.jsx)(`span`,{className:`workspace-tab-indicator`,"aria-hidden":`true`}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>O(`mission`),className:`workspace-tab`,"data-selected":A===`mission`,children:t(`mobile.mission`)}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>O(`activity`),className:`workspace-tab`,"data-selected":A===`activity`,children:t(`mobile.activity`)}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>O(`workbench`),className:`workspace-tab`,"data-selected":A===`workbench`,children:t(`mobile.workbench`)}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>O(`map`),className:`workspace-tab`,"data-selected":A===`map`,children:t(`mobile.map`)})]}),A===`mission`?(0,X.jsx)(`span`,{className:`ml-auto hidden max-w-72 truncate text-[10px] text-ink-faint sm:block`,children:wt?.active_role?t(`mission.roleActive`,{role:wt.active_role}):t(`mission.overview`)}):(0,X.jsx)(`span`,{className:`ml-auto`}),!f&&A!==`map`?(0,X.jsx)(`button`,{type:`button`,onClick:()=>u(`operations`),className:`rounded border border-line/60 px-2 py-1 text-[10px] text-ink-faint hover:border-blue/50 hover:text-blue`,children:t(`mission.operations`)}):null]}),A===`map`&&(0,X.jsx)(I.Suspense,{fallback:(0,X.jsx)(`div`,{className:`m-auto text-sm text-ink-faint`,children:t(`common.loading`)}),children:(0,X.jsx)(Al,{snapshot:V,events:St,managerSteps:xe,draft:ce,onDraftChange:le,onSend:Qt,pending:_e,onCancel:et,focusSignal:se,readOnly:f,onOpenSettings:()=>u(`config`),routeOverride:he,onRouteOverrideChange:ge,conversationEvents:Ct,connected:W,artifacts:lt.data??[],deliveryCount:Ft.length,onOpenDelivery:()=>{let e=$r(Ft,wt?.routing.vertical||``);e&&Pt(e.receipt,e.path)},onOpenReceipt:Pt,onOpenArtifact:we,onAnswer:()=>bt(!0)},V.session.id)}),(0,X.jsxs)(`div`,{className:`${A===`workbench`||A===`map`?`hidden`:`flex`} min-h-0 flex-1 flex-col`,children:[(0,X.jsx)(Ko,{alert:mt}),j===`mission`&&wt?(0,X.jsx)(Mc,{view:wt,sid:V.session.id,snapshot:V,gitDiff:ut.data,artifacts:lt.data,onOpenArtifact:jt,onOpenDelivery:Pt,onNotify:L}):(0,X.jsx)(oa,{events:xt,connected:W,showReasoning:ne,onToggleReasoning:()=>D(e=>!e),embedded:!0,filter:qe,query:Ye,skipFirst:Ge.skipFirst,artifacts:lt.data,onOpenArtifact:jt,onOpenDelivery:Pt}),f?null:(0,X.jsx)(`div`,{className:`composer-dock shrink-0 px-4 pt-3`,children:(0,X.jsxs)(`div`,{className:`mx-auto w-full max-w-full lg:max-w-[61.8vw]`,children:[(0,X.jsx)(Wo,{questions:V.pending_questions??[],backlog:V.backlog,onAnswer:()=>bt(!0)}),(0,X.jsx)(ho,{value:ce,attachments:ue,onAttachmentsChange:de,onChange:le,onSend:en,onCancel:et,disabled:!R,pending:_e,focusSignal:se,embedded:!0,steps:xe,onRewrite:it,rewriting:P,slashSelection:pe,onSlashSelectionChange:me,routeOverride:he,onRouteOverrideChange:ge},R||`no-session`)]})})]}),ae&&R?(0,X.jsx)(`div`,{className:`${A===`workbench`?`flex`:`hidden`} min-h-0 flex-1`,children:(0,X.jsx)(I.Suspense,{fallback:(0,X.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center text-xs text-ink-faint`,children:t(`common.loading`)}),children:(0,X.jsx)(kl,{sid:R,active:A===`workbench`})})}):null]}),v&&A!==`map`?(0,X.jsx)(uc,{label:t(`common.resizePreview`),value:y,min:320,max:840,onPointerDown:e=>_(`right`,e),onReset:()=>T(440),onNudge:e=>T(t=>Math.max(320,Math.min(840,t-e)))}):null,(A!==`map`||h===`preview`)&&(0,X.jsxs)(`aside`,{"data-resizable-panel":`right`,className:`${h===`preview`?`flex`:`hidden`} relative min-w-0 flex-1 flex-col overflow-hidden border-l border-line/60 bg-panel transition-[width] duration-[250ms] ease-panel lg:flex lg:flex-none ${v?`lg:w-[var(--preview-width)]`:`lg:w-14`}`,children:[(0,X.jsx)(`div`,{className:`lg:hidden`,children:(0,X.jsx)(Zr,{snap:V,streamOk:W,onStart:Kt,onStop:qt,onManage:()=>R&&Gt(R),busy:zt,snapshotStale:ot.isError,readOnly:f,missionView:wt})}),(0,X.jsx)(Fs,{sid:H,artifacts:lt.data,error:lt.isError,onExpand:we,onOpenFile:At,className:`min-h-0 flex-1 mobile-scroll-region ${v?`lg:flex`:`lg:hidden`}`,embedded:!0,onCollapse:()=>w(!1),missionView:wt,activityEvents:xt,requestedPath:Te.path,requestedPathToken:Te.token}),v?null:(0,X.jsx)(`div`,{className:`hidden h-12 items-center justify-center border-b border-line/50 text-ink-faint lg:flex`,children:(0,X.jsx)(`button`,{type:`button`,onClick:At,"aria-label":t(`common.expandPreview`),title:t(`common.expandPreview`),className:`flex h-8 w-8 items-center justify-center rounded-md border border-line/50 bg-bg/40 hover:border-blue/50 hover:text-ink`,children:(0,X.jsx)(o,{icon:E,className:`h-3.5 w-3.5`})})})]})]}):(0,X.jsx)(Bc,{loading:r.isLoading||!!(R&&ot.isLoading),hasProjects:a.length>0,error:r.isError&&a.length===0?mi(r.error):ot.isError&&!V?mi(ot.error):void 0,onRetry:()=>{r.refetch(),R&&ot.refetch()},onNew:()=>Ae(!0),onChoose:()=>ee(!0),canCreate:!f})}),(0,X.jsx)(bo,{open:l===`palette`,onClose:()=>u(`none`),items:tn}),(0,X.jsx)(So,{open:l===`help`,onClose:()=>u(`none`)}),R&&(0,X.jsx)(Bo,{sid:R,open:l===`doctor`,onClose:()=>u(`none`)}),R&&(0,X.jsx)(Vo,{sid:R,open:l===`config`,onClose:()=>u(`none`)}),R&&(0,X.jsx)(Ho,{sid:R,open:l===`identity`,onClose:()=>u(`none`)}),R&&(0,X.jsx)(Uo,{sid:R,open:l===`transcript`,onClose:()=>u(`none`)}),R&&V?(0,X.jsx)(oc,{open:l===`inspector`,snap:V,journal:gt.data??[],busy:It.disposeBacklog.isPending||It.stopBacklog.isPending,onClose:()=>u(`none`),onDispose:Wt,onStop:Jt,onInspect:Oe}):null,R&&V?(0,X.jsx)(Lc,{open:l===`operations`,sid:R,snap:V,onClose:()=>u(`none`),onChanged:()=>{ot.refetch(),r.refetch()},onRestored:async e=>{await r.refetch(),nt(e)}}):null,(0,X.jsx)(vs,{sid:R,path:Ce,reviewActivity:R===H?Tt:void 0,onClose:()=>we(null)}),(0,X.jsx)(lc,{sid:R,itemId:De,onClose:()=>Oe(null),onDone:e=>Wt(e,`done`),onSkip:e=>Wt(e,`rm`),onStop:Jt,busy:It.disposeBacklog.isPending||It.stopBacklog.isPending,readOnly:f}),(0,X.jsx)(Ls,{open:ke,busy:at,onClose:()=>Ae(!1),onCreate:B}),(0,X.jsx)(Go,{reply:G,open:yt,busy:vt,onClose:()=>bt(!1),onSubmit:_t}),Ne?(0,X.jsx)(Rs,{open:je,sid:Ne,name:st.data?.session.display_name||a.find(e=>e.id===Ne)?.display_name||a.find(e=>e.id===Ne)?.label||``,alive:st.data?.daemon.alive??!!a.find(e=>e.id===Ne)?.daemon_alive,controlAvailable:st.data?.daemon.control_available!==!1,busy:zt,onClose:()=>{Me(!1),Pe(null)},onRename:Ht,onStart:Ut,onStop:Vt,onDelete:Bt}):null,(0,X.jsx)(Is,{notice:Ue,onClose:Ze}),V&&!f?(0,X.jsx)($,{active:h===`preview`?`preview`:A,sidebarOpen:k,onSelect:e=>{if(e===`preview`){C(`preview`);return}C(`activity`),O(e)},onOpenSessions:()=>ee(!0)}):null]})}function Nl({onDone:e}){let{t}=Z(),n=(0,I.useRef)(!1),r=(0,I.useCallback)(()=>{n.current||(n.current=!0,e())},[e]);return(0,I.useEffect)(()=>{let e=window.setTimeout(r,970),t=()=>r();return window.addEventListener(`keydown`,t,{once:!0}),()=>{window.clearTimeout(e),window.removeEventListener(`keydown`,t)}},[r]),(0,X.jsx)(`div`,{role:`status`,"aria-label":t(`splash.starting`),onClick:r,onAnimationEnd:e=>{e.currentTarget===e.target&&r()},className:`argus-web-splash`,children:(0,X.jsx)(`div`,{className:`argus-web-splash-logo`,"aria-hidden":`true`,children:(0,X.jsx)(Ai,{size:168})})})}var Pl=class extends I.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}render(){if(!this.state.failed)return this.props.children;let e=this.props.locale===`zh-CN`;return(0,X.jsx)(`main`,{className:`flex min-h-dvh items-center justify-center bg-bg p-8 text-ink`,role:`alert`,children:(0,X.jsxs)(`section`,{className:`max-w-lg rounded-xl border border-line bg-panel p-8 shadow-lg`,children:[(0,X.jsx)(`p`,{className:`mb-3 text-xs font-semibold uppercase tracking-widest text-blue`,children:`Argus`}),(0,X.jsx)(`h1`,{className:`text-lg font-semibold`,children:e?`工作台暂时无法显示`:`The workspace could not be displayed`}),(0,X.jsx)(`p`,{className:`mt-3 text-sm leading-relaxed text-ink-dim`,children:e?`页面资源未能正确加载。后端任务不会因此被停止;你仍可使用桌面菜单查看日志或设置。重新加载会丢弃页面中尚未发送的输入。`:`A page resource failed to load. Backend work has not been stopped. Desktop menus remain available for logs and settings. Reloading discards unsent input on this page.`}),(0,X.jsxs)(`div`,{className:`mt-6 flex flex-wrap gap-3`,children:[(0,X.jsx)(`button`,{type:`button`,className:`rounded-md bg-blue px-4 py-2 text-sm text-white`,onClick:()=>window.location.reload(),children:e?`重新加载工作台`:`Reload workspace`}),(0,X.jsx)(`button`,{type:`button`,className:`rounded-md border border-line px-4 py-2 text-sm`,onClick:()=>{let e=new URL(window.location.href);e.searchParams.set(`view`,`activity`),window.location.assign(e.toString())},children:e?`返回对话页面`:`Return to conversation`})]})]})})}};function Fl(e,t,n){let r=!1;e.addEventListener(`vite:preloadError`,e=>{let i=e.payload,a=i instanceof Error?i.message:String(i??``);if(!/\/(?:pdf[.-]|pdfjs)[^/\s]*\.(?:m?js)(?:[?#\s]|$)/i.test(a)&&/failed to fetch dynamically imported module|importing a module script failed|loading chunk .+ failed/i.test(a)){if(r){e.preventDefault();return}try{let e=n.storage(),t=`argus.stale-chunk-reloaded`;if(e.getItem(t)===n.releaseId)return;e.setItem(t,n.releaseId)}catch{return}e.preventDefault(),r=!0,t()}})}Fl(window,()=>window.location.reload(),{releaseId:Ne,storage:()=>window.sessionStorage}),We();var Il=window.parent!==window;document.documentElement.dataset.argusEmbedded=String(Il);var Ll=new De({defaultOptions:{queries:{staleTime:3e3,retry:pr,refetchOnWindowFocus:!1}}});function Rl(){let{locale:e}=Z(),[t,n]=(0,I.useState)(!Il);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Pl,{locale:e,children:(0,X.jsx)(Ml,{})}),t?(0,X.jsx)(Nl,{onDone:()=>n(!1)}):null]})}Oe.createRoot(document.getElementById(`root`)).render((0,X.jsx)(I.StrictMode,{children:(0,X.jsx)(de,{client:Ll,children:(0,X.jsx)(Jr,{children:(0,X.jsx)(Rl,{})})})}));export{ba as A,U as B,Ua as C,La as D,za as E,Ai as F,Se as G,qe as H,ki as I,fi as L,Aa as M,sa as N,Ia as O,oa as P,ei as R,Wa as S,Va as T,H as U,Ke as V,et as W,eo as _,Wo as a,Ya as b,co as c,uo as d,oo as f,to as g,no as h,os as i,Da as j,ja as k,lo as l,ro as m,gl as n,go as o,io as p,yc as r,so as s,hl as t,fo as u,Qa as v,Ha as w,Ga as x,Za as y,Z as z}; \ No newline at end of file diff --git a/frontend/web/dist/assets/play-DT9RZkLC.js b/frontend/web/dist/assets/play-DT9RZkLC.js new file mode 100644 index 000000000..cfc324a91 --- /dev/null +++ b/frontend/web/dist/assets/play-DT9RZkLC.js @@ -0,0 +1 @@ +import{O as e}from"./index-BmfdUynJ.js";var t=e(`ChevronRight`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]),n=e(`GitBranch`,[[`line`,{x1:`6`,x2:`6`,y1:`3`,y2:`15`,key:`17qcm7`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}],[`circle`,{cx:`6`,cy:`18`,r:`3`,key:`fqmcym`}],[`path`,{d:`M18 9a9 9 0 0 1-9 9`,key:`n2h4wq`}]]),r=e(`Play`,[[`polygon`,{points:`6 3 20 12 6 21 6 3`,key:`1oa8hb`}]]);export{n,t as r,r as t}; \ No newline at end of file diff --git a/frontend/web/dist/index.html b/frontend/web/dist/index.html index 80da623d4..a75f65dc6 100644 --- a/frontend/web/dist/index.html +++ b/frontend/web/dist/index.html @@ -38,7 +38,7 @@ document.documentElement.dataset.themeStyle = style; })(); - +