From c1608574b5275ae4627a9e81ffd4487a1c5a8b65 Mon Sep 17 00:00:00 2001 From: stormstarlight <182098146+stormstarlight@users.noreply.github.com> Date: Fri, 11 Sep 2026 05:00:24 +0800 Subject: [PATCH] fix(plugins): preserve task host context and prepare Windows PLATON --- .gitignore | 2 + .../adapters/agent_cli_backend/_exec.py | 4 +- argus_skill/agent_cli/_prompt_delivery.py | 6 + argus_skill/core/platon_windows.py | 162 +++++++++++++++ argus_skill/core/plugin_manager.py | 172 +++++++++++++++- argus_skill/core/plugin_runtime.py | 6 + argus_skill/core/workbench_plugins.py | 7 +- argus_skill/daemon/_life_worker_admission.py | 19 +- argus_skill/daemon/_life_worker_boot.py | 5 + .../life/supervisor/_mission_execution.py | 36 +++- argus_skill/life/supervisor/backlog_guard.py | 13 +- argus_skill/release.py | 1 + argus_skill/release_manifest.json | 4 +- argus_skill/skills/vertical_select.py | 10 + argus_skill/trial/client.py | 9 +- argus_skill/webapi/routes/plugins.py | 9 +- desktop-tauri/argus_backend.spec | 8 +- desktop-tauri/scripts/build-backend.ps1 | 2 + desktop-tauri/scripts/build-native-tools.ps1 | 19 ++ desktop-tauri/scripts/platon-headless.rs | 52 +++++ desktop-tauri/src-tauri/src/backend.rs | 3 +- docs/windows-plugin-runtime.md | 33 +++ frontend/core/src/release.generated.ts | 4 +- frontend/tui/bundle/argus.mjs | 2 +- frontend/web/dist/assets/MapPanel-BiKfxq2V.js | 12 ++ frontend/web/dist/assets/MapPanel-H668aPZO.js | 12 ++ .../assets/ResearchWorkbenchPanel-BwZKryEc.js | 10 + .../assets/ResearchWorkbenchPanel-CKBt1t39.js | 10 + frontend/web/dist/assets/index-BsnK0I0S.js | 32 +++ frontend/web/dist/assets/index-bNAmS4fY.js | 32 +++ frontend/web/dist/assets/play-Cv7356zo.js | 1 + frontend/web/dist/assets/play-DxkqG8w4.js | 1 + frontend/web/dist/index.html | 2 +- .../web/src/components/PluginEnvironment.tsx | 18 +- frontend/web/src/lib/pluginEnglish.json | 10 + .../web/src/test/pluginEnvironment.test.tsx | 40 ++++ tests/core/test_platon_windows.py | 133 ++++++++++++ tests/core/test_plugin_manager.py | 39 ++++ tests/core/test_plugin_process_roots.py | 189 ++++++++++++++++++ tests/core/test_plugin_state_io.py | 52 +++++ 40 files changed, 1142 insertions(+), 39 deletions(-) create mode 100644 argus_skill/core/platon_windows.py create mode 100644 desktop-tauri/scripts/build-native-tools.ps1 create mode 100644 desktop-tauri/scripts/platon-headless.rs create mode 100644 docs/windows-plugin-runtime.md create mode 100644 frontend/web/dist/assets/MapPanel-BiKfxq2V.js create mode 100644 frontend/web/dist/assets/MapPanel-H668aPZO.js create mode 100644 frontend/web/dist/assets/ResearchWorkbenchPanel-BwZKryEc.js create mode 100644 frontend/web/dist/assets/ResearchWorkbenchPanel-CKBt1t39.js create mode 100644 frontend/web/dist/assets/index-BsnK0I0S.js create mode 100644 frontend/web/dist/assets/index-bNAmS4fY.js create mode 100644 frontend/web/dist/assets/play-Cv7356zo.js create mode 100644 frontend/web/dist/assets/play-DxkqG8w4.js create mode 100644 frontend/web/src/test/pluginEnvironment.test.tsx create mode 100644 tests/core/test_platon_windows.py create mode 100644 tests/core/test_plugin_process_roots.py create mode 100644 tests/core/test_plugin_state_io.py diff --git a/.gitignore b/.gitignore index 3ee41a1a3..ae54e06d6 100644 --- a/.gitignore +++ b/.gitignore @@ -131,6 +131,8 @@ docs/Argus_BP* # proprietary binary/npm release staging /dist-binary/ /.pyinstaller/ +# Reproducibly built first-party Windows adapters; source lives in desktop scripts. +/argus_skill/_native/*.exe # Optional plugin release assets are published separately. /dist-plugins/ diff --git a/argus_skill/adapters/agent_cli_backend/_exec.py b/argus_skill/adapters/agent_cli_backend/_exec.py index 1e4263f28..6fa0fb366 100644 --- a/argus_skill/adapters/agent_cli_backend/_exec.py +++ b/argus_skill/adapters/agent_cli_backend/_exec.py @@ -49,8 +49,10 @@ def execute( # 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 + usage_context = getattr(backend, "_usage_context_snapshot", None) + project_root = usage_context()[0] if callable(usage_context) else None prompt, options = prepare_plugin_run(prompt, options, - backend=backend._runner.backend, run_label=run_label) + backend=backend._runner.backend, run_label=run_label, project_root=project_root) backend._plugin_execution_options = options try: return _execute_prepared(backend, prompt=prompt, options=options, run_label=run_label, resume_thread_id=resume_thread_id) diff --git a/argus_skill/agent_cli/_prompt_delivery.py b/argus_skill/agent_cli/_prompt_delivery.py index 79f5d7cf9..ba79b0799 100644 --- a/argus_skill/agent_cli/_prompt_delivery.py +++ b/argus_skill/agent_cli/_prompt_delivery.py @@ -347,6 +347,12 @@ def _child_env( env["GH_CONFIG_DIR"] = str( Path(tempfile.gettempdir()) / "argus-no-gh-auth" ) + if self.backend == BACKEND_COPILOT and env is not None and options.isolate_workdir: + # Isolation intentionally strips ambient credentials. Reapply only + # the selected hosted provider afterwards, never other account keys. + from ..trial.client import apply_trial_provider + + apply_trial_provider(env) 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 diff --git a/argus_skill/core/platon_windows.py b/argus_skill/core/platon_windows.py new file mode 100644 index 000000000..0a37bba13 --- /dev/null +++ b/argus_skill/core/platon_windows.py @@ -0,0 +1,162 @@ +"""User-local official PLATON Windows runtime, without running an installer. + +The proprietary plugin remains untouched. Its supported ``configure`` action +selects this verified external installation. Binaries are downloaded from their +publishers on the user's machine, never redistributed inside Argus releases. +""" +from __future__ import annotations + +import hashlib +import os +import shutil +import struct +import tempfile +import uuid +import zipfile +from pathlib import Path, PurePosixPath + +from .plugin_runtime import clean_env, download, run + +OFFICIAL_PAGE = "https://www.chem.gla.ac.uk/~louis/software/platon/" +PLATON_URL = OFFICIAL_PAGE + "platon.zip" +PLATON_SHA256 = "a8c845891dc1dca1cb98d691917355c1bdb1c380e947a91893966d163900063b" +TASKBAR_URL = OFFICIAL_PAGE + "pwt_setup.zip" +TASKBAR_SHA256 = "b60fa412f7b2e95287826c364a9aa7fff5cd962bc11fae42d91cc4e70cfab276" +DLL_SHA256 = "a5d3aec4cb1897543ad142634c0a4fd6285b5dd52d7c701249a0e8582a4b9de0" +EXTRACTOR_URL = "https://constexpr.org/innoextract/files/innoextract-1.9/innoextract-1.9-windows.zip" +# Publisher distribution independently checked against Scoop's SHA-512. +EXTRACTOR_SHA256 = "6989342c9b026a00a72a38f23b62a8e6a22cc5de69805cf47d68ac2fec993065" +LICENSE_NOTICE = ( + "PLATON 官方允许注明来源的学术、科学及非商业用途;商业用途需自行取得许可。" + "本操作只从官方网站下载到插件私有目录,不安装系统运行库、不修改系统 PATH。" +) + + +def _member(archive: Path, basename: str, *, limit: int = 20 * 1024**2) -> bytes: + """Read one regular file, never extract arbitrary ZIP paths or links.""" + with zipfile.ZipFile(archive) as package: + matches = [] + for entry in package.infolist(): + path = PurePosixPath(entry.filename.replace("\\", "/")) + if path.name.casefold() != basename.casefold(): + continue + if (path.is_absolute() or ".." in path.parts or ":" in entry.filename + or entry.is_dir() or (entry.external_attr >> 16) & 0o170000 == 0o120000 + or entry.file_size > limit): + raise ValueError("官方软件压缩包包含不安全或过大的文件,未安装。") + matches.append(entry) + if len(matches) != 1: + raise ValueError(f"官方软件包必须包含唯一的 {basename},未安装。") + return package.read(matches[0]) + + +def _machine(data: bytes) -> int: + if len(data) < 64 or data[:2] != b"MZ": + raise ValueError("Windows 科学软件不是有效的 PE 文件。") + offset = struct.unpack_from(" len(data) or data[offset:offset + 4] != b"PE\0\0": + raise ValueError("Windows 科学软件 PE 头损坏。") + return struct.unpack_from(" None: + with path.open("xb") as output: + output.write(data) + + +def launcher_path() -> Path: + return Path(__file__).resolve().parents[1] / "_native" / "platon-headless.exe" + + +def probe(executable: Path, *, on_start=None) -> None: + """Generate check.def in an empty temporary directory, never research data.""" + with tempfile.TemporaryDirectory(prefix="argus-platon-check-") as directory: + run([executable, "-z2"], cwd=directory, env=clean_env(), timeout=45, on_start=on_start) + if not (Path(directory) / "check.def").is_file(): + raise RuntimeError("PLATON 未能生成校验规则,已有安装保持不变。") + + +def prepare(resources_root: Path, *, accept_license: bool = False, progress=print, on_start=None) -> Path: + if accept_license is not True: + raise ValueError("请先确认 PLATON 使用许可。" + LICENSE_NOTICE) + if os.name != "nt": + raise ValueError("此官方运行环境准备操作仅适用于 Windows。") + root = Path(resources_root).resolve() + launcher = launcher_path() + if not launcher.is_file(): + raise ValueError("缺少 Windows PLATON 适配器,请使用完整 Windows 预览包或先构建桌面原生工具。") + launcher_data = launcher.read_bytes() + if _machine(launcher_data) != 0x8664: + raise ValueError("Windows PLATON 适配器架构不符。") + launcher_hash = hashlib.sha256(launcher_data).hexdigest() + cache = root / "cache" + cache.mkdir(parents=True, exist_ok=True) + progress("正在校验 PLATON 官方程序与 Windows 配套运行环境…") + program_archive = download(PLATON_URL, cache / "platon-win-64", checksum=PLATON_SHA256) + program = _member(program_archive, "platon.exe") + if _machine(program) != 0x14C: + raise ValueError("PLATON 官方程序架构已变化,需要更新兼容配方。") + program_hash = hashlib.sha256(program).hexdigest() + from .plugin_manager import read_json, write_json + + marker = root / "host-platon-runtime.json" + try: + current = Path(read_json(marker)["path"]).resolve() + if ((root / "software") in current.parents and not current.is_symlink() + and hashlib.sha256(current.read_bytes()).hexdigest() == launcher_hash + and hashlib.sha256((current.parent / "platon.exe").read_bytes()).hexdigest() == program_hash + and hashlib.sha256((current.parent / "salflibc.dll").read_bytes()).hexdigest() == DLL_SHA256): + probe(current, on_start=on_start) + progress("PLATON 官方运行环境已可用,保留当前安装。") + return current + except (OSError, ValueError, KeyError, RuntimeError): + pass + + taskbar = download(TASKBAR_URL, cache / "platon-taskbar-2026.1.zip", checksum=TASKBAR_SHA256) + extractor_archive = download(EXTRACTOR_URL, cache / "innoextract-1.9-windows.zip", checksum=EXTRACTOR_SHA256) + with tempfile.TemporaryDirectory(prefix="platon-prepare-", dir=root) as temporary: + work = Path(temporary) + extractor = work / "innoextract.exe" + setup = work / "setup.exe" + _write_new(extractor, _member(extractor_archive, "innoextract.exe")) + _write_new(setup, _member(taskbar, "setup.exe")) + progress("正在提取官方 Salford 运行库(不执行系统安装程序)…") + extracted = work / "extracted" + # setup.exe is input DATA to the pinned extractor, never a command. + # Inno 5 installers use platform-specific internal path spellings; + # extract this checksum-pinned archive into our disposable directory, + # then deploy only the independently pinned DLL below. + run([extractor, "--extract", "--output-dir", extracted, setup], + timeout=90, on_start=on_start) + libraries = list(extracted.rglob("salflibc.dll")) + if len(libraries) != 1 or libraries[0].is_symlink(): + raise ValueError("官方配套安装包未提供唯一的 Salford 运行库。") + library = libraries[0].read_bytes() + if hashlib.sha256(library).hexdigest() != DLL_SHA256 or _machine(library) != 0x14C: + raise ValueError("Salford 运行库校验或架构不符,未部署。") + candidate = root / "software" / ("platon-windows-" + uuid.uuid4().hex[:12]) + candidate.mkdir(parents=True) + executable = candidate / "platon-headless.exe" + try: + _write_new(executable, launcher_data) + _write_new(candidate / "platon.exe", program) + _write_new(candidate / "salflibc.dll", library) + _write_new(candidate / "SOURCE-AND-LICENSE.txt", ( + LICENSE_NOTICE + "\n" + OFFICIAL_PAGE + "\n" + "PLATON executable: " + PLATON_SHA256 + "\n" + "Official Windows Taskbar archive: " + TASKBAR_SHA256 + "\n" + "No proprietary plugin source or wheel has been modified.\n" + ).encode("utf-8")) + progress("正在实际运行 PLATON,验证 Windows 运行库和校验规则…") + probe(executable, on_start=on_start) + except BaseException: + # Only our unpublished, newly-created candidate. Existing software + # and the plugin's active registry are never deleted or replaced. + shutil.rmtree(candidate, ignore_errors=True) + raise + write_json(marker, {"path": str(executable), "program_sha256": program_hash, + "runtime_sha256": DLL_SHA256, "launcher_sha256": launcher_hash, + "source": OFFICIAL_PAGE, + "license_accepted": True}) + progress("PLATON 官方 Windows 运行环境验证通过。") + return executable diff --git a/argus_skill/core/plugin_manager.py b/argus_skill/core/plugin_manager.py index 3a1e7c891..169a28262 100644 --- a/argus_skill/core/plugin_manager.py +++ b/argus_skill/core/plugin_manager.py @@ -33,12 +33,53 @@ _loaded: dict[tuple[str, str, str], object] = {} _jobs: dict[tuple[str, str], threading.Thread] = {} _lock = threading.RLock() +_state_io_lock = threading.RLock() class PluginError(ValueError): pass +class PluginUnavailableError(PluginError): + """An explicitly selected plugin cannot execute; never reroute its work.""" + + +def require_plugin(plugin_id, root=None): + try: + plugin = load_plugin(plugin_id, root) + except Exception as exc: + raise PluginUnavailableError( + f"插件 {plugin_id} 加载失败,任务未执行;请检查插件安装和宿主目录。" + ) from exc + if plugin is None: + raise PluginUnavailableError( + f"插件 {plugin_id} 未安装、未启用或无法从宿主目录加载,任务未执行。" + "请在插件中心检查;不会切换为 research 执行。" + ) + return plugin + + +def session_plugin_name(life_dir): + """Resolve a reserved session namespace, never classify an objective.""" + sid = Path(life_dir).name + return next((name for name in catalog() if sid.startswith("s-" + name + "-")), None) + + +def require_session_plugin(life_dir, *, vertical=None, working_dir=None, check_binding=False): + name = session_plugin_name(life_dir) + if name is None: + return None # Native sessions may add tools without changing vertical. + plugin = require_plugin(name) + if vertical is not None and vertical != name: + raise PluginUnavailableError( + f"插件 {name} 工作台记录曾路由到其他流程,已阻止继续执行。" + "原记录保持不变,请新建会话验收;不会自动改写旧任务。" + ) + if check_binding and not plugin.owns_workdir(working_dir): + raise PluginUnavailableError(f"插件 {name} 的任务目录绑定缺失,任务未执行;请新建工作台会话。") + return plugin + + def host_root(root=None): return Path(root or os.environ.get("ARGUS_WORKBENCH_HOST_ROOT") or global_root()).resolve() @@ -47,18 +88,64 @@ def install_root(root=None): return host_root(root) / "extensions" +def _read_state_bytes(path): + if os.name != "nt": + return Path(path).read_bytes() + # Python's ordinary Windows open does not share DELETE access. The plugin + # center polls while the installer atomically replaces this same file; + # readers must permit replacement and finish reading their old snapshot. + import ctypes + import msvcrt + from ctypes import wintypes + + kernel = ctypes.WinDLL("kernel32", use_last_error=True) + kernel.CreateFileW.argtypes = [wintypes.LPCWSTR, wintypes.DWORD, wintypes.DWORD, + ctypes.c_void_p, wintypes.DWORD, wintypes.DWORD, wintypes.HANDLE] + kernel.CreateFileW.restype = wintypes.HANDLE + kernel.CloseHandle.argtypes = [wintypes.HANDLE] + handle = kernel.CreateFileW(str(path), 0x80000000, 0x7, None, 3, 0x80, None) + if handle == ctypes.c_void_p(-1).value: + raise ctypes.WinError(ctypes.get_last_error()) + try: + descriptor = msvcrt.open_osfhandle(handle, os.O_RDONLY | os.O_BINARY) + except BaseException: + kernel.CloseHandle(handle) + raise + with os.fdopen(descriptor, "rb") as stream: + return stream.read() + + 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")) + with _state_io_lock: + try: + return json.loads(_read_state_bytes(path)) + except FileNotFoundError: + return {} if default is None else default 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) + with _state_io_lock: + path.parent.mkdir(parents=True, exist_ok=True) + temp = path.with_name(path.name + "." + uuid.uuid4().hex + ".tmp") + try: + with temp.open("x", encoding="utf-8") as output: + json.dump(value, output, ensure_ascii=False, indent=2) + output.write("\n") + output.flush() + os.fsync(output.fileno()) + for attempt in range(20): + try: + os.replace(temp, path) + break + except PermissionError: + if os.name != "nt" or attempt == 19: + raise + # Bounded retry for antivirus/external readers, not a + # permission bypass. Persistent denial remains an error. + time.sleep(0.05) + finally: + temp.unlink(missing_ok=True) def catalog(): @@ -217,6 +304,24 @@ def plugin_rows(root=None): ) write_json(install_root(root) / name / "operation.json", operation) c = compatibility(spec) + setup = dict(spec.get("setup") or {}) + health = read_json(install_root(root) / name / "resources" / "health.json") + if name == "crystalpilot" and os.name == "nt": + from .platon_windows import LICENSE_NOTICE, OFFICIAL_PAGE + + setup["windows_runtime"] = { + "action": "platon_runtime", "name": "PLATON", + "url": OFFICIAL_PAGE, "notice": LICENSE_NOTICE, + } + for component in health.get("components", []): + if component.get("id") == "platon" and any( + code in str(component.get("detail", "")) + for code in ("3221225781", "0xC0000135") + ): + component["detail"] = ( + "PLATON 缺少 Windows Salford 运行库(0xC0000135)。" + "请使用“准备 PLATON 官方环境”,不必重复下载当前程序包。" + ) rows.append( { **{ @@ -236,7 +341,8 @@ def plugin_rows(root=None): ) ), "operation": operation, - "health": read_json(install_root(root) / name / "resources" / "health.json"), + "setup": setup, + "health": health, "available": c["supported"] and bool(state.get("enabled")), "url": f"/plugins/{name}/", } @@ -253,7 +359,9 @@ def _job_alive(root, name, operation): thread = _jobs.get((str(root), name)) if operation.get("pid") == os.getpid(): - return bool(thread and thread.is_alive()) + # A polling request can arrive between publishing the operation and + # Thread.start(); that is not an interrupted installer. + return bool(thread and (thread.is_alive() or thread.ident is None)) return process_identity_is_running(operation.get("pid", 0), operation.get("identity")) @@ -524,7 +632,32 @@ def _setup_job(name, spec, root, action, payload): if plugin: _busy(name, root) plugin.shutdown_workers() - _run_setup(name, spec, root, row["python"], action, payload) + if action == "platon_runtime": + from .platon_windows import prepare + from .process_identity import capture_process_identity + + def progress(message): + write_json(install_root(root) / name / "progress.json", { + "progress": message, "updated": time.time(), + }) + + def started(pid): + current = read_json(path) + current.update(installer_pid=pid, installer_identity=capture_process_identity(pid)) + write_json(path, current) + + executable = prepare( + install_root(root) / name / "resources", + accept_license=payload.get("accept_software_license") is True, + progress=progress, on_start=started, + ) + # Use the published plugin's supported external-install contract; + # never patch its dependencies module or forge a wheel version. + _run_setup(name, spec, root, row["python"], "configure", { + "paths": {"platon": str(executable)}, + }) + else: + _run_setup(name, spec, root, row["python"], action, payload) operation.update(status="completed", progress="环境检查完成", completed=time.time()) except Exception as exc: error = str(exc) @@ -553,7 +686,14 @@ def _start_job(root, name, action, target, args): "identity": capture_process_identity(os.getpid()), }, ) - job.start() + try: + job.start() + except RuntimeError as exc: + _jobs.pop((str(root), name), None) + write_json(install_root(root) / name / "operation.json", { + "status": "failed", "action": action, "error": "无法启动安装线程,请稍后重试。", + }) + raise PluginError("无法启动安装线程,请稍后重试。") from exc return {"status": "running"} @@ -584,6 +724,16 @@ def mutate(name, action, root=None, *, payload=None): ).get("sha256"): raise PluginError("此版本已安装,可启用插件。") return _start_job(root, name, action, _install, (name, spec, root, action)) + if action == "platon_runtime": + if name != "crystalpilot" or os.name != "nt": + raise PluginError("此官方运行环境准备操作仅适用于 Windows CrystalPilot。") + if not row.get("release"): + raise PluginError("请先安装插件") + if (payload or {}).get("accept_software_license") is not True: + raise PluginError("请先确认 PLATON 使用许可;商业用途需自行取得授权。") + installed_spec = read_json(_package_path(row, root) / "plugin.json") + return _start_job(root, name, action, _setup_job, + (name, installed_spec, root, action, dict(payload or {}))) if action in spec.get("setup", {}).get("actions", []): if not row.get("release"): raise PluginError("请先安装插件") diff --git a/argus_skill/core/plugin_runtime.py b/argus_skill/core/plugin_runtime.py index c30a9f0a9..0b5b4a6fc 100644 --- a/argus_skill/core/plugin_runtime.py +++ b/argus_skill/core/plugin_runtime.py @@ -105,6 +105,12 @@ def clean_env(): "LANG", "LC_ALL", "SYSTEMDRIVE", + # platform.machine() on Windows reads these non-sensitive OS values. + # Dropping them makes the installer incorrectly detect "windows/". + "PROCESSOR_ARCHITECTURE", + "PROCESSOR_ARCHITEW6432", + "NUMBER_OF_PROCESSORS", + "OS", "HTTP_PROXY", "HTTPS_PROXY", "NO_PROXY", diff --git a/argus_skill/core/workbench_plugins.py b/argus_skill/core/workbench_plugins.py index 582ee9d18..14af82b66 100644 --- a/argus_skill/core/workbench_plugins.py +++ b/argus_skill/core/workbench_plugins.py @@ -28,9 +28,14 @@ def native_plugin_command(text, *, sid, life_dir, global_root): return None -def prepare_plugin_run(prompt, options, *, backend, run_label): +def prepare_plugin_run(prompt, options, *, backend, run_label, project_root=None): import portalocker + if project_root is not None: + manager.require_session_plugin( + project_root, working_dir=getattr(options, "working_dir", None), + check_binding=options is not None and not options.disable_tools, + ) for name, plugin in installed_workbenches().items(): if options is None or not plugin.owns_workdir(options.working_dir): continue diff --git a/argus_skill/daemon/_life_worker_admission.py b/argus_skill/daemon/_life_worker_admission.py index af33a88e4..bf70ce213 100644 --- a/argus_skill/daemon/_life_worker_admission.py +++ b/argus_skill/daemon/_life_worker_admission.py @@ -418,16 +418,31 @@ def spawn_detached_daemon_clean( A short-lived exec helper starts from a clean interpreter and performs the existing admission-checked double-fork there. """ - if getattr(sys, "frozen", False): - return spawn_detached_daemon(config, quiet=quiet) + # Upstream 4b9bd93f: the frozen backend supports -m too. Keep the + # independent helper and its diagnostics on every packaged execution path. config.last_spawn_error = "" preflight_rc, preflight_error = _clean_spawn_preflight(config) + if not preflight_error: + from ..core.plugin_manager import PluginUnavailableError, require_session_plugin + from ..skills.vertical_select import resolve_vertical_if_decided + + try: + vertical = resolve_vertical_if_decided(config.life_dir) + require_session_plugin(config.life_dir, vertical=vertical, + working_dir=config.project_workdir, check_binding=True) + except PluginUnavailableError as exc: + preflight_rc, preflight_error = 2, str(exc) if preflight_error: detail = _record_spawn_error(config, preflight_error) if not quiet: sys.stderr.write(f"argus-skill: {detail}.\n") return preflight_rc env = os.environ.copy() + from ..core.plugin_manager import host_root + + # Pin the installation root while still in the submitting host. The + # daemon's global_root is a task namespace and may change ARGUS_SKILL_HOME. + env["ARGUS_WORKBENCH_HOST_ROOT"] = str(host_root()) env["ARGUS_BINARY_MODE"] = "cli" env["PYTHONUTF8"] = "1" env["PYTHONIOENCODING"] = "utf-8" diff --git a/argus_skill/daemon/_life_worker_boot.py b/argus_skill/daemon/_life_worker_boot.py index 4fceda7cf..f3de0036f 100644 --- a/argus_skill/daemon/_life_worker_boot.py +++ b/argus_skill/daemon/_life_worker_boot.py @@ -113,6 +113,11 @@ def _rf_bootstrap_environment(self) -> None: # Argus was launched through a Windows console script without activating # its virtual environment first. configure_framework_python_env(prepend_python_path=True) + from ..core.plugin_manager import host_root + + # Direct CLI daemons retain their launching host too. Never replace a + # root explicitly propagated by the desktop/clean-spawn helper. + os.environ.setdefault("ARGUS_WORKBENCH_HOST_ROOT", str(host_root())) if self.config.global_root is not None: os.environ["ARGUS_SKILL_HOME"] = str(self.config.global_root.resolve()) diff --git a/argus_skill/life/supervisor/_mission_execution.py b/argus_skill/life/supervisor/_mission_execution.py index 015930d3a..d26cb6ed9 100644 --- a/argus_skill/life/supervisor/_mission_execution.py +++ b/argus_skill/life/supervisor/_mission_execution.py @@ -80,13 +80,35 @@ def _run_one(self, item: BacklogItem) -> dict[str, Any]: if getattr(self, "manager", None) is not None else None ) - item = ensure_manager_decision( - self.memory, - item, - getattr(self, "chat_state", None), - manager=manager, - vertical_root=vertical_root, - ) + from ...core.plugin_manager import PluginUnavailableError + + try: + item = ensure_manager_decision( + self.memory, + item, + getattr(self, "chat_state", None), + manager=manager, + vertical_root=vertical_root, + ) + except PluginUnavailableError as exc: + # No mission was started. Seal this attempt visibly so the plugin + # monitor can leave "thinking" without paying for a fallback run. + reason = str(exc) + # "blocked" is an outcome, not a valid backlog status (unknown + # statuses normalize to pending and would immediately retry). + self.memory.backlog.update(item.id, status="failed", last_error=reason) + self._emit({ + "type": "life.mission.completed", "item_id": item.id, + "title": item.title, "success": False, "status": "failed", + "outcome_class": "blocked", "stop_kind": "permanent_error", + "stop_reason": reason, "failure_reason": reason, "summary": reason, + "resumable": False, "recoverable": False, + }) + return { + "status": "failed", "item_id": item.id, "success": False, + "outcome_class": "blocked", "stop_kind": "permanent_error", + "stop_reason": reason, + } prelude = self._build_mission_prelude(item) state = self._prepare_mission_context( diff --git a/argus_skill/life/supervisor/backlog_guard.py b/argus_skill/life/supervisor/backlog_guard.py index 2a9a6ef0e..d296cafd6 100644 --- a/argus_skill/life/supervisor/backlog_guard.py +++ b/argus_skill/life/supervisor/backlog_guard.py @@ -127,6 +127,12 @@ def ensure_manager_decision( returned unchanged: a blind run is better than a stalled queue, and the diagnostic surface already reports the item as undecided. """ + from ...core import plugin_manager + + state_root = Path(getattr(memory, "root", ".")).expanduser() + decision = getattr(item, DECISION_KEY, None) + selected = decision.get("vertical", "") if isinstance(decision, dict) and decision.get("routed") else None + plugin_manager.require_session_plugin(state_root, vertical=selected) if not needs_manager_decision(item): decision = getattr(item, DECISION_KEY, None) vertical = ( @@ -189,7 +195,11 @@ def ensure_manager_decision( evidence = decision_evidence(getattr(prepared, "decision", None)) or { "routed": True } - except Exception: # noqa: BLE001 + except Exception as exc: # noqa: BLE001 + if plugin_manager.session_plugin_name(state_root): + raise plugin_manager.PluginUnavailableError( + "插件工作台任务路由失败,任务未执行;请检查连接后新建会话。" + ) from exc log.exception( "backlog guard: could not route item %s through the Manager; running " "it as written", @@ -197,6 +207,7 @@ def ensure_manager_decision( ) return item + plugin_manager.require_session_plugin(state_root, vertical=evidence.get("vertical", "")) updates: dict[str, Any] = {DECISION_KEY: evidence} if execution_task and execution_task.strip() != objective: updates["objective"] = execution_task diff --git a/argus_skill/release.py b/argus_skill/release.py index 0985dac24..78662dc66 100644 --- a/argus_skill/release.py +++ b/argus_skill/release.py @@ -90,6 +90,7 @@ def _source_files(root: Path) -> Iterable[Path]: "desktop-tauri/scripts/*.mjs", "desktop-tauri/scripts/*.ps1", "desktop-tauri/scripts/*.py", + "desktop-tauri/scripts/*.rs", "desktop-tauri/package.json", "desktop-tauri/package-lock.json", "desktop-tauri/tsconfig.json", diff --git a/argus_skill/release_manifest.json b/argus_skill/release_manifest.json index 04dbdd356..a01259135 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+dd2c099dcbff094c", + "release_id": "0.1.3+86e9c05ef8cb1e6b", "schema_version": 1, - "source_digest": "dd2c099dcbff094c07fdb60baec88bfdd9955fa9f820990759d6c06ae236d53d" + "source_digest": "86e9c05ef8cb1e6b45cf40af74113baa7241f4116e518fef6e01eb69cfc66503" } diff --git a/argus_skill/skills/vertical_select.py b/argus_skill/skills/vertical_select.py index 3e23072f5..2bea7847b 100644 --- a/argus_skill/skills/vertical_select.py +++ b/argus_skill/skills/vertical_select.py @@ -206,6 +206,16 @@ def _known_vertical(value: object, project_root: object = None) -> str | None: if not isinstance(value, str): return None cleaned = _strip_needed(value) + if cleaned in VERTICALS: + return cleaned + from ..core import plugin_manager + + if cleaned in plugin_manager.catalog(): + # Catalog names belong to an explicit plugin, not a missing learned + # domain. Loss of its registration must never turn a crystal task into + # ordinary research (or silently skip its tools/accounting hooks). + plugin_manager.require_plugin(cleaned) + return cleaned if cleaned in available_verticals(): return cleaned if project_root is not None and cleaned: diff --git a/argus_skill/trial/client.py b/argus_skill/trial/client.py index feefbf472..269f7a759 100644 --- a/argus_skill/trial/client.py +++ b/argus_skill/trial/client.py @@ -21,10 +21,15 @@ TRIAL_ENV = "ARGUS_SKILL_COPILOT_TRIAL" -def profile_path() -> Path: +def trial_home() -> Path: + """Account configuration belongs to the host, not a plugin task namespace.""" from ..core.paths import global_root - return global_root() / "copilot-trial.json" + return Path(os.environ.get("ARGUS_WORKBENCH_HOST_ROOT") or global_root()).resolve() + + +def profile_path() -> Path: + return trial_home() / "copilot-trial.json" def trial_enabled(env: dict[str, str] | None = None) -> bool: diff --git a/argus_skill/webapi/routes/plugins.py b/argus_skill/webapi/routes/plugins.py index 9abcfc8a7..55bb1fb11 100644 --- a/argus_skill/webapi/routes/plugins.py +++ b/argus_skill/webapi/routes/plugins.py @@ -57,12 +57,11 @@ def manage( 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"}: + if set(payload) - {"username", "password", "paths", "accept_platform_license", "accept_software_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") + for consent in ("accept_platform_license", "accept_software_license"): + if consent in payload and type(payload[consent]) is not bool: + raise ValueError("Invalid software consent") if any( not isinstance(payload.get(key, ""), str) or len(payload.get(key, "")) > 500 for key in ("username", "password") diff --git a/desktop-tauri/argus_backend.spec b/desktop-tauri/argus_backend.spec index 61b1a469a..6e8a4e0d1 100644 --- a/desktop-tauri/argus_backend.spec +++ b/desktop-tauri/argus_backend.spec @@ -3,6 +3,7 @@ """PyInstaller specification for the Tauri desktop's frozen backend.""" from pathlib import Path +import sys from PyInstaller.utils.hooks import collect_data_files, collect_submodules @@ -28,6 +29,11 @@ datas = [(source, target) for source, target in collect_data_files("argus_skill" # 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") +if sys.platform == "win32": + platon_runner = ROOT / "argus_skill" / "_native" / "platon-headless.exe" + if not platon_runner.is_file(): + raise RuntimeError("Build the first-party Windows adapter with scripts/build-native-tools.ps1 first") + datas.append((str(platon_runner), "argus_skill/_native")) web_dist = ROOT / "frontend" / "web" / "dist" if web_dist.is_dir(): datas.append((str(web_dist), "argus_skill/_frontend/web/dist")) @@ -87,7 +93,7 @@ domain_overlay_modules = collect_provider_modules( ) hiddenimports = ( - ["tzdata", "argus_skill.trial.desktop", "certifi"] + ["tzdata"] + collect_submodules("uvicorn") + collect_submodules("fastapi") + collect_submodules("websockets") diff --git a/desktop-tauri/scripts/build-backend.ps1 b/desktop-tauri/scripts/build-backend.ps1 index 401c81d99..5f63893af 100644 --- a/desktop-tauri/scripts/build-backend.ps1 +++ b/desktop-tauri/scripts/build-backend.ps1 @@ -60,6 +60,8 @@ if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } +& (Join-Path $PSScriptRoot "build-native-tools.ps1") + Push-Location $repo try { & $backendPython -m PyInstaller ` diff --git a/desktop-tauri/scripts/build-native-tools.ps1 b/desktop-tauri/scripts/build-native-tools.ps1 new file mode 100644 index 000000000..0511985b7 --- /dev/null +++ b/desktop-tauri/scripts/build-native-tools.ps1 @@ -0,0 +1,19 @@ +[CmdletBinding()] +param() +$ErrorActionPreference = "Stop" +$desktop = Split-Path -Parent $PSScriptRoot +$repo = Split-Path -Parent $desktop +$source = Join-Path $PSScriptRoot "platon-headless.rs" +$output = Join-Path $repo "argus_skill\_native" +$tests = Join-Path $desktop "build\native-tests" +New-Item -ItemType Directory -Path $output, $tests -Force | Out-Null +$compiler = (Get-Command rustc -ErrorAction Stop).Source +$flags = @("--edition=2021", "--target", "x86_64-pc-windows-msvc", "-C", "target-feature=+crt-static", "-C", "link-arg=/Brepro") +$testBinary = Join-Path $tests "platon-headless-tests-$PID.exe" +& $compiler @flags --test $source -o $testBinary +if ($LASTEXITCODE -ne 0) { throw "PLATON adapter tests could not compile. Use a verified MSVC environment." } +& $testBinary +if ($LASTEXITCODE -ne 0) { throw "PLATON adapter argument tests failed." } +& $compiler @flags -O -C panic=abort $source -o (Join-Path $output "platon-headless.exe") +if ($LASTEXITCODE -ne 0) { throw "PLATON adapter build failed." } +Write-Host "native Windows adapter ready: $output\platon-headless.exe" diff --git a/desktop-tauri/scripts/platon-headless.rs b/desktop-tauri/scripts/platon-headless.rs new file mode 100644 index 000000000..f03394088 --- /dev/null +++ b/desktop-tauri/scripts/platon-headless.rs @@ -0,0 +1,52 @@ +//! First-party command adapter for the unmodified official Windows PLATON. +//! The publisher's PWT taskbar passes +00 to close the completion dialog. +//! Preserve native argument boundaries and the child's actual exit status. +use std::{env, ffi::OsString, path::PathBuf, process::{Command, ExitCode}}; +#[cfg(windows)] +use std::os::windows::process::CommandExt; + +fn arguments(input: impl Iterator) -> Vec { + input.chain(std::iter::once(OsString::from("+00"))).collect() +} + +fn run() -> std::io::Result { + let executable = env::current_exe()?; + let program: PathBuf = executable.parent().ok_or_else(|| + std::io::Error::other("Cannot locate the PLATON installation"))?.join("platon.exe"); + if !program.is_file() || program == executable { + return Err(std::io::Error::new(std::io::ErrorKind::NotFound, + "The official platon.exe must remain beside platon-headless.exe")); + } + let mut command = Command::new(program); + command.args(arguments(env::args_os().skip(1))); + #[cfg(windows)] + command.creation_flags(0x08000000); // CREATE_NO_WINDOW; never a shell. + Ok(command.status()?.code().unwrap_or(1)) +} + +fn main() -> ExitCode { + match run() { + Ok(code) => std::process::exit(code), + Err(error) => { + eprintln!("PLATON launch failed: {error}"); + ExitCode::FAILURE + } + } +} + +#[cfg(test)] +mod tests { + use super::*; + #[test] + fn preserves_spaces_unicode_and_shell_metacharacters_as_one_argument() { + let input = vec![OsString::from("-u"), OsString::from("D:/晶体数据/a & b.cif")]; + let output = arguments(input.clone().into_iter()); + assert_eq!(&output[..2], &input); + assert_eq!(output[2], "+00"); + } + #[test] + fn closes_the_official_completion_dialog_without_changing_probe_options() { + assert_eq!(arguments([OsString::from("-z2")].into_iter()), + vec![OsString::from("-z2"), OsString::from("+00")]); + } +} diff --git a/desktop-tauri/src-tauri/src/backend.rs b/desktop-tauri/src-tauri/src/backend.rs index fe1e4eb1a..3d8870f29 100644 --- a/desktop-tauri/src-tauri/src/backend.rs +++ b/desktop-tauri/src-tauri/src/backend.rs @@ -967,7 +967,8 @@ impl BackendSupervisor { .env("ARGUS_SKILL_PYTHON", &shell_command) .env("ARGUS_SKILL_WEB_TOKEN", &settings.token) .env("ARGUS_DESKTOP_LAUNCH_NONCE", &launch_nonce) - .env("ARGUS_SKILL_HOME", argus_home) + .env("ARGUS_SKILL_HOME", &argus_home) + .env("ARGUS_WORKBENCH_HOST_ROOT", &argus_home) .env( "PYTHONUTF8", env::var("PYTHONUTF8").unwrap_or_else(|_| "1".to_owned()), diff --git a/docs/windows-plugin-runtime.md b/docs/windows-plugin-runtime.md new file mode 100644 index 000000000..9e4d662f9 --- /dev/null +++ b/docs/windows-plugin-runtime.md @@ -0,0 +1,33 @@ +# Optional plugin task roots and Windows PLATON + +This change builds on draft PR #119's optional plugin API. It does not modify or repackage the separately licensed CrystalPilot wheel. + +## Separate installation identity from task state + +`ARGUS_WORKBENCH_HOST_ROOT` identifies the trusted host installation/registry. `ARGUS_SKILL_HOME` may identify a plugin workbench's independent task namespace. Desktop launch and clean daemon spawning pin the former before task bootstrap changes the latter; CLI descendants inherit it. Hosted trial profile lookup also remains under the host account root rather than copying credentials into a workbench. + +Catalog plugin names and reserved `s--...` session namespaces are explicit identities, not keyword classifiers. An unavailable plugin or missing workdir binding must reject execution. A workbench record already routed to a different vertical is retained and rejected, not silently rewritten or resumed as research. Native conversations may still add optional tools while keeping their original vertical. + +A refused mission emits a failed completion event with a blocked outcome so the workbench can leave its pending state. The backlog uses its existing `failed` status; an unknown `blocked` status would normalize to pending and cause repeated execution attempts. + +## Official PLATON Windows environment + +The plugin center offers **Prepare official PLATON runtime** on Windows. The operator must confirm compliance with the publisher's terms: acknowledged academic, scientific and non-commercial use, or separately authorized commercial use. No scientific software or license credential is bundled in this PR. + +The host downloads checksum-pinned publisher artifacts: + +- PLATON executable: +- Official Windows Taskbar/runtime: +- innoextract: , Zlib license. + +`setup.exe` is only archive input to the verified extractor. The host deploys the unmodified official `platon.exe` and `salflibc.dll` into a plugin-private directory; it does not run a system installer, change the registry/global PATH, or download individual DLLs from mirrors. Runtime bytes and PE architecture are verified before activation. An existing installation is retained on failure. + +The publisher's taskbar uses the `+00` switch to close PLATON's completion dialog. Without it, `-z2` can successfully generate `check.def` but leave the Windows process alive, causing unattended scientific probes to time out. The small first-party `platon-headless.exe` adapter forwards native argument boundaries, adds that switch, and returns the actual exit status. It never uses a shell or kills a process to declare success. + +The verified result is selected through the published plugin's existing `configure` action. SHELXT/SHELXL still require the user's own authorization. Runtime preparation or a minimal read-only tool test is not proof of a complete crystal solve/refinement. + +## Building and testing + +Windows desktop builds run `desktop-tauri/scripts/build-native-tools.ps1` before freezing the backend. Use a verified MSVC developer environment. The script compiles/tests `platon-headless.rs` with a static CRT and reproducible-link flag; the generated EXE is ignored by Git and explicitly included in the Windows PyInstaller payload. Source-only Windows users must build this adapter before using the host's preparation action, or configure another already-working installation. + +Regressions cover product-generated child environments, frozen/source launch behavior, plugin refusal and completion events, old misrouted sessions, missing bindings, account-root lookup, typed/explicit license consent, archive safety, real probe completion, and preservation of existing installations. Windows state readers also permit atomic replacement while polled, with bounded writer retries and correct installer-thread liveness. diff --git a/frontend/core/src/release.generated.ts b/frontend/core/src/release.generated.ts index ffc6edf0f..fa02fb075 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+dd2c099dcbff094c"; -export const RELEASE_SOURCE_DIGEST = "dd2c099dcbff094c07fdb60baec88bfdd9955fa9f820990759d6c06ae236d53d"; +export const RELEASE_ID = "0.1.3+86e9c05ef8cb1e6b"; +export const RELEASE_SOURCE_DIGEST = "86e9c05ef8cb1e6b45cf40af74113baa7241f4116e518fef6e01eb69cfc66503"; diff --git a/frontend/tui/bundle/argus.mjs b/frontend/tui/bundle/argus.mjs index 11a43a845..68fbc4524 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-BiKfxq2V.js b/frontend/web/dist/assets/MapPanel-BiKfxq2V.js new file mode 100644 index 000000000..a13f5187e --- /dev/null +++ b/frontend/web/dist/assets/MapPanel-BiKfxq2V.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-Cv7356zo.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-BsnK0I0S.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/MapPanel-H668aPZO.js b/frontend/web/dist/assets/MapPanel-H668aPZO.js new file mode 100644 index 000000000..fc64ba85a --- /dev/null +++ b/frontend/web/dist/assets/MapPanel-H668aPZO.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-DxkqG8w4.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-bNAmS4fY.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-BwZKryEc.js b/frontend/web/dist/assets/ResearchWorkbenchPanel-BwZKryEc.js new file mode 100644 index 000000000..3cdff94ee --- /dev/null +++ b/frontend/web/dist/assets/ResearchWorkbenchPanel-BwZKryEc.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-DxkqG8w4.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-bNAmS4fY.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-CKBt1t39.js b/frontend/web/dist/assets/ResearchWorkbenchPanel-CKBt1t39.js new file mode 100644 index 000000000..c54e95e05 --- /dev/null +++ b/frontend/web/dist/assets/ResearchWorkbenchPanel-CKBt1t39.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-Cv7356zo.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-BsnK0I0S.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-BsnK0I0S.js b/frontend/web/dist/assets/index-BsnK0I0S.js new file mode 100644 index 000000000..82490452e --- /dev/null +++ b/frontend/web/dist/assets/index-BsnK0I0S.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-CKBt1t39.js","assets/icons-2gFhc0pq.js","assets/query-CGMsBv4s.js","assets/play-Cv7356zo.js","assets/ResearchWorkbenchPanel-BXRghxPt.css","assets/MapPanel-BiKfxq2V.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`,"准备 PLATON 官方环境":`Prepare official PLATON runtime`,"下载、验证并配置":`Download, verify and configure`,"我确认用途符合 PLATON 官方许可;如用于商业用途,已另行取得授权。":`I confirm that my use complies with the official PLATON license; for commercial use, I have obtained separate authorization.`,"PLATON 官方允许注明来源的学术、科学及非商业用途;商业用途需自行取得许可。本操作只从官方网站下载到插件私有目录,不安装系统运行库、不修改系统 PATH。":`The publisher permits acknowledged academic, scientific and non-commercial use of PLATON; commercial use requires a separate license. This downloads from official sites into the plugin's private directory, without installing system runtimes or changing the system PATH.`,"PLATON 缺少 Windows Salford 运行库(0xC0000135)。请使用“准备 PLATON 官方环境”,不必重复下载当前程序包。":`PLATON is missing the Windows Salford runtime (0xC0000135). Use Prepare official PLATON runtime instead of downloading the same program package again.`,"正在校验 PLATON 官方程序与 Windows 配套运行环境…":`Verifying the official PLATON program and Windows runtime…`,"正在提取官方 Salford 运行库(不执行系统安装程序)…":`Extracting the official Salford runtime without executing the system installer…`,"正在实际运行 PLATON,验证 Windows 运行库和校验规则…":`Running PLATON to verify the Windows runtime and validation rules…`,"PLATON 官方 Windows 运行环境验证通过。":`The official PLATON Windows runtime passed verification.`,"PLATON 官方运行环境已可用,保留当前安装。":`The official PLATON runtime is already available; keeping the existing installation.`,"配置 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,S]=(0,I.useState)(!1),[C,w]=(0,I.useState)(!1),T=t.windows_runtime,E=t.license?.platform_consent,D=E?.platform===i&&E?.machines.includes(a||``),ee=e?.components||[],O=ee.filter(e=>e.status!==`ready`),te=O.some(e=>e.license_required),ne=O.some(e=>e.automatic);async function k(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(`科学环境 · ${O.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((te||ne||!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((ne||!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(te?`配置 SHELX`:`SHELX 授权安装`))]}))]}),T&&(0,X.jsxs)(`div`,{className:`mt-3`,children:[(0,X.jsxs)(`button`,{type:`button`,className:qs,disabled:n,onClick:()=>{w(!C),S(!1)},children:[(0,X.jsx)(qa,{size:14}),o(`准备 PLATON 官方环境`)]}),C&&(0,X.jsxs)(`form`,{className:`mt-3 rounded-lg bg-bg/70 p-3`,onSubmit:async e=>{e.preventDefault(),x&&await r(T.action,{accept_software_license:!0})&&(w(!1),S(!1),c(!0))},children:[(0,X.jsxs)(`p`,{className:`text-xs leading-relaxed text-ink-dim`,children:[o(T.notice),` `,(0,X.jsx)(`a`,{href:T.url,target:`_blank`,rel:`noreferrer`,className:`text-blue`,children:o(`官方安装说明 ↗`)})]}),(0,X.jsxs)(`label`,{className:`mt-3 flex items-start gap-2 text-xs leading-relaxed text-ink-dim`,children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:x,onChange:e=>S(e.target.checked),className:`mt-0.5`}),o(`我确认用途符合 PLATON 官方许可;如用于商业用途,已另行取得授权。`)]}),(0,X.jsxs)(`div`,{className:`mt-3 flex gap-3`,children:[(0,X.jsx)(`button`,{type:`submit`,className:qs,disabled:n||!x,children:o(`下载、验证并配置`)}),(0,X.jsx)(`button`,{type:`button`,className:`text-xs text-ink-faint`,onClick:()=>{w(!1),S(!1)},children:o(`取消`)})]})]})]}),o(l&&t.license&&(0,X.jsxs)(`form`,{onSubmit:k,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(D&&E&&(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(E.text),` `,(0,X.jsx)(`a`,{href:E.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(!ee.length&&(0,X.jsx)(`p`,{className:`py-2 text-xs text-ink-faint`,children:o(`点击“检查环境”可验证科学内核与外部程序。`)})),ee.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-CKBt1t39.js`),__vite__mapDeps([2,1,3,4,5,6]))).ResearchWorkbenchPanel})),Al=(0,I.lazy)(async()=>({default:(await oi(()=>import(`./MapPanel-BiKfxq2V.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/index-bNAmS4fY.js b/frontend/web/dist/assets/index-bNAmS4fY.js new file mode 100644 index 000000000..1d3609024 --- /dev/null +++ b/frontend/web/dist/assets/index-bNAmS4fY.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-BwZKryEc.js","assets/icons-2gFhc0pq.js","assets/query-CGMsBv4s.js","assets/play-DxkqG8w4.js","assets/ResearchWorkbenchPanel-BXRghxPt.css","assets/MapPanel-H668aPZO.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`,"准备 PLATON 官方环境":`Prepare official PLATON runtime`,"下载、验证并配置":`Download, verify and configure`,"我确认用途符合 PLATON 官方许可;如用于商业用途,已另行取得授权。":`I confirm that my use complies with the official PLATON license; for commercial use, I have obtained separate authorization.`,"PLATON 官方允许注明来源的学术、科学及非商业用途;商业用途需自行取得许可。本操作只从官方网站下载到插件私有目录,不安装系统运行库、不修改系统 PATH。":`The publisher permits acknowledged academic, scientific and non-commercial use of PLATON; commercial use requires a separate license. This downloads from official sites into the plugin's private directory, without installing system runtimes or changing the system PATH.`,"PLATON 缺少 Windows Salford 运行库(0xC0000135)。请使用“准备 PLATON 官方环境”,不必重复下载当前程序包。":`PLATON is missing the Windows Salford runtime (0xC0000135). Use Prepare official PLATON runtime instead of downloading the same program package again.`,"正在校验 PLATON 官方程序与 Windows 配套运行环境…":`Verifying the official PLATON program and Windows runtime…`,"正在提取官方 Salford 运行库(不执行系统安装程序)…":`Extracting the official Salford runtime without executing the system installer…`,"正在实际运行 PLATON,验证 Windows 运行库和校验规则…":`Running PLATON to verify the Windows runtime and validation rules…`,"PLATON 官方 Windows 运行环境验证通过。":`The official PLATON Windows runtime passed verification.`,"PLATON 官方运行环境已可用,保留当前安装。":`The official PLATON runtime is already available; keeping the existing installation.`,"配置 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,S]=(0,I.useState)(!1),[C,w]=(0,I.useState)(!1),T=t.windows_runtime,E=t.license?.platform_consent,D=E?.platform===i&&E?.machines.includes(a||``),ee=e?.components||[],O=ee.filter(e=>e.status!==`ready`),te=O.some(e=>e.license_required),ne=O.some(e=>e.automatic);async function k(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(`科学环境 · ${O.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((te||ne||!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((ne||!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(te?`配置 SHELX`:`SHELX 授权安装`))]}))]}),T&&(0,X.jsxs)(`div`,{className:`mt-3`,children:[(0,X.jsxs)(`button`,{type:`button`,className:qs,disabled:n,onClick:()=>{w(!C),S(!1)},children:[(0,X.jsx)(qa,{size:14}),o(`准备 PLATON 官方环境`)]}),C&&(0,X.jsxs)(`form`,{className:`mt-3 rounded-lg bg-bg/70 p-3`,onSubmit:async e=>{e.preventDefault(),x&&await r(T.action,{accept_software_license:!0})&&(w(!1),S(!1),c(!0))},children:[(0,X.jsxs)(`p`,{className:`text-xs leading-relaxed text-ink-dim`,children:[o(T.notice),` `,(0,X.jsx)(`a`,{href:T.url,target:`_blank`,rel:`noreferrer`,className:`text-blue`,children:o(`官方安装说明 ↗`)})]}),(0,X.jsxs)(`label`,{className:`mt-3 flex items-start gap-2 text-xs leading-relaxed text-ink-dim`,children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:x,onChange:e=>S(e.target.checked),className:`mt-0.5`}),o(`我确认用途符合 PLATON 官方许可;如用于商业用途,已另行取得授权。`)]}),(0,X.jsxs)(`div`,{className:`mt-3 flex gap-3`,children:[(0,X.jsx)(`button`,{type:`submit`,className:qs,disabled:n||!x,children:o(`下载、验证并配置`)}),(0,X.jsx)(`button`,{type:`button`,className:`text-xs text-ink-faint`,onClick:()=>{w(!1),S(!1)},children:o(`取消`)})]})]})]}),o(l&&t.license&&(0,X.jsxs)(`form`,{onSubmit:k,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(D&&E&&(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(E.text),` `,(0,X.jsx)(`a`,{href:E.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(!ee.length&&(0,X.jsx)(`p`,{className:`py-2 text-xs text-ink-faint`,children:o(`点击“检查环境”可验证科学内核与外部程序。`)})),ee.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-BwZKryEc.js`),__vite__mapDeps([2,1,3,4,5,6]))).ResearchWorkbenchPanel})),Al=(0,I.lazy)(async()=>({default:(await oi(()=>import(`./MapPanel-H668aPZO.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-Cv7356zo.js b/frontend/web/dist/assets/play-Cv7356zo.js new file mode 100644 index 000000000..48b208a80 --- /dev/null +++ b/frontend/web/dist/assets/play-Cv7356zo.js @@ -0,0 +1 @@ +import{O as e}from"./index-BsnK0I0S.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/assets/play-DxkqG8w4.js b/frontend/web/dist/assets/play-DxkqG8w4.js new file mode 100644 index 000000000..669a60967 --- /dev/null +++ b/frontend/web/dist/assets/play-DxkqG8w4.js @@ -0,0 +1 @@ +import{O as e}from"./index-bNAmS4fY.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 a75f65dc6..5724e3a8c 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/components/PluginEnvironment.tsx b/frontend/web/src/components/PluginEnvironment.tsx index 8ed5df7bb..8d685e90c 100644 --- a/frontend/web/src/components/PluginEnvironment.tsx +++ b/frontend/web/src/components/PluginEnvironment.tsx @@ -6,7 +6,7 @@ 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 } } }; +export type PluginSetup = { actions: string[]; windows_runtime?: { action: string; name: string; url: string; notice: 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 }: { @@ -22,6 +22,9 @@ export function PluginEnvironment({ health, setup, running, act, platform, machi const [manual, setManual] = useState(null); const [path, setPath] = useState(''); const [acceptPlatform, setAcceptPlatform] = useState(false); + const [runtimeConsent, setRuntimeConsent] = useState(false); + const [showRuntime, setShowRuntime] = useState(false); + const runtime = setup.windows_runtime; const terms = setup.license?.platform_consent; const platformConsent = terms?.platform === platform && terms?.machines.includes(machine || ''); const components = health?.components || []; @@ -51,6 +54,19 @@ export function PluginEnvironment({ health, setup, running, act, platform, machi {tr((needRepair || !health?.checked) && )} {tr(setup.license && )} + {runtime &&
+ + {showRuntime &&
{ + e.preventDefault(); + if (runtimeConsent && await act(runtime.action, { accept_software_license: true })) { + setShowRuntime(false); setRuntimeConsent(false); setExpanded(true); + } + }}> +

{tr(runtime.notice)} {tr("官方安装说明 ↗")}

+ +
+
} +
} {tr(credentials && setup.license &&
{tr(setup.license.name)}{tr(" 学术授权")} {tr("前往官网申请")}
diff --git a/frontend/web/src/lib/pluginEnglish.json b/frontend/web/src/lib/pluginEnglish.json index c8a305c0b..ee0db5455 100644 --- a/frontend/web/src/lib/pluginEnglish.json +++ b/frontend/web/src/lib/pluginEnglish.json @@ -5,6 +5,16 @@ "检查环境": "Check environment", "免费科学组件自动配置;SHELX 需要你在官网取得学术授权后输入下载凭据。": "Free scientific components are configured automatically; SHELX requires academic authorization from the official website before entering download credentials.", "修复依赖": "Repair dependencies", + "准备 PLATON 官方环境": "Prepare official PLATON runtime", + "下载、验证并配置": "Download, verify and configure", + "我确认用途符合 PLATON 官方许可;如用于商业用途,已另行取得授权。": "I confirm that my use complies with the official PLATON license; for commercial use, I have obtained separate authorization.", + "PLATON 官方允许注明来源的学术、科学及非商业用途;商业用途需自行取得许可。本操作只从官方网站下载到插件私有目录,不安装系统运行库、不修改系统 PATH。": "The publisher permits acknowledged academic, scientific and non-commercial use of PLATON; commercial use requires a separate license. This downloads from official sites into the plugin's private directory, without installing system runtimes or changing the system PATH.", + "PLATON 缺少 Windows Salford 运行库(0xC0000135)。请使用“准备 PLATON 官方环境”,不必重复下载当前程序包。": "PLATON is missing the Windows Salford runtime (0xC0000135). Use Prepare official PLATON runtime instead of downloading the same program package again.", + "正在校验 PLATON 官方程序与 Windows 配套运行环境…": "Verifying the official PLATON program and Windows runtime…", + "正在提取官方 Salford 运行库(不执行系统安装程序)…": "Extracting the official Salford runtime without executing the system installer…", + "正在实际运行 PLATON,验证 Windows 运行库和校验规则…": "Running PLATON to verify the Windows runtime and validation rules…", + "PLATON 官方 Windows 运行环境验证通过。": "The official PLATON Windows runtime passed verification.", + "PLATON 官方运行环境已可用,保留当前安装。": "The official PLATON runtime is already available; keeping the existing installation.", "配置 SHELX": "Configure SHELX", "SHELX 授权安装": "SHELX authorized installation", "学术授权": "Academic authorization", diff --git a/frontend/web/src/test/pluginEnvironment.test.tsx b/frontend/web/src/test/pluginEnvironment.test.tsx new file mode 100644 index 000000000..661675523 --- /dev/null +++ b/frontend/web/src/test/pluginEnvironment.test.tsx @@ -0,0 +1,40 @@ +import { createElement, type ReactNode } from 'react'; +import { act, create } from 'react-test-renderer'; +import { describe, expect, it, vi } from 'vitest'; +import { PluginEnvironment, type PluginSetup } from '../components/PluginEnvironment'; + +vi.mock('../lib/pluginText', () => ({ usePluginText: () => (value: ReactNode) => value })); + +const setup: PluginSetup = { + actions: ['health', 'repair', 'configure'], + windows_runtime: { + action: 'platon_runtime', name: 'PLATON', url: 'https://example.invalid/official', + notice: 'Official license terms; private directory only.', + }, +}; + +describe('official PLATON environment consent', () => { + it('does not submit before explicit consent and clears the form after submission', async () => { + const submit = vi.fn(async () => true); + let renderer!: ReturnType; + act(() => { renderer = create(createElement(PluginEnvironment, { setup, running: false, act: submit, platform: 'windows' })); }); + const button = (label: string) => renderer.root.findAllByType('button').find(node => node.children.includes(label))!; + act(() => button('准备 PLATON 官方环境').props.onClick()); + expect(button('下载、验证并配置').props.disabled).toBe(true); + await act(async () => { await renderer.root.findByType('form').props.onSubmit({ preventDefault() {} }); }); + expect(submit).not.toHaveBeenCalled(); + act(() => renderer.root.findByType('input').props.onChange({ target: { checked: true } })); + expect(button('下载、验证并配置').props.disabled).toBe(false); + await act(async () => { await renderer.root.findByType('form').props.onSubmit({ preventDefault() {} }); }); + expect(submit).toHaveBeenCalledExactlyOnceWith('platon_runtime', { accept_software_license: true }); + expect(renderer.root.findAllByType('form')).toHaveLength(0); + act(() => renderer.unmount()); + }); + + it('does not offer the host adapter when the server does not advertise it', () => { + let renderer!: ReturnType; + act(() => { renderer = create(createElement(PluginEnvironment, { setup: { actions: [] }, running: false, act: vi.fn() })); }); + expect(renderer.root.findAllByType('button').some(node => node.children.includes('准备 PLATON 官方环境'))).toBe(false); + act(() => renderer.unmount()); + }); +}); diff --git a/tests/core/test_platon_windows.py b/tests/core/test_platon_windows.py new file mode 100644 index 000000000..b421a4285 --- /dev/null +++ b/tests/core/test_platon_windows.py @@ -0,0 +1,133 @@ +"""Official Windows runtime preparation without installer or model execution.""" +from __future__ import annotations + +import hashlib +import json +import struct +import sys +import zipfile +from pathlib import Path + +import pytest + +from argus_skill.core import platon_windows as platon + + +def pe(machine=0x14C): + data = bytearray(72) + data[:2] = b"MZ" + struct.pack_into("