From f8baf5325358863c67e96dc0d27ec6485960171e Mon Sep 17 00:00:00 2001 From: Jason Robert Date: Thu, 21 May 2026 15:02:34 -0400 Subject: [PATCH 1/3] feat(engine): add type: wait step for in-process pauses (#218) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A new step type that pauses workflow execution for a parsed duration via asyncio.sleep. Cross-platform, no shell dependency. Composes with routing loop-backs for polling, rate-limit cooldowns, and demos. YAML: agents: - name: cooldown type: wait duration: 60s # int/float seconds, "Ns/Nm/Nh/Nms", or Jinja2 reason: "Cooling down" # optional, shown in dashboard routes: - to: next_step Behavior: - Duration accepts plain numbers, suffixed strings (ms/s/m/h), and Jinja2 templates. Workflow.input.* is available without an explicit input: declaration (wait joins script/workflow in _LOCAL_RENDER_AGENT_TYPES). - Schema enforces 0 < duration <= 24h and rejects boolean durations pre-coercion via a mode="before" field validator (Pydantic v2 would otherwise accept True as int 1). - Sleep races against the engine's interrupt_event so Esc/Ctrl+G cancels in-flight waits immediately. The event is NOT cleared by the executor — the engine's between-step _check_interrupt consumes it so the user still gets the normal interrupt menu. - Workflow-level limits.timeout_seconds cancels long waits via LimitEnforcer.wait_for_with_timeout (same wrapping used by scripts). - Wait counts toward limits.max_iterations (step counter) but is not subject to max_agent_iterations (per-LLM-agent tool counter — N/A). - Public output contract is strictly {"waited_seconds": float} per the issue spec. Extra metadata (requested_seconds, reason, interrupted) lives in event payloads only. Events: - The existing generic agent_started fires before type dispatch with agent_type: "wait", so dashboards keyed on agent lifecycle pick it up. Type-specific wait_started / wait_completed / wait_failed carry the additional fields (mirrors the script convention). - Resume replay extends _synth_agent_or_script with a wait branch so checkpointed wait steps round-trip cleanly. Validation: - Rejects wait inside parallel groups and as for_each inline agents (consistent with script). - Forbids 22 incompatible fields on wait (prompt, model, command, args, env, working_dir, tools, options, workflow, retry, dialog, reasoning, timeout, timeout_seconds, max_session_seconds, max_agent_iterations, max_depth, input_mapping, system_prompt, provider, output). - Forbids duration/reason on all non-wait types. Dashboard: - New 'wait' NodeType with WaitNode (Clock icon) and WaitDetail component. Graph layout maps wait -> waitNode. Workflow store carries duration_seconds, waited_seconds, requested_seconds, reason, and interrupted on NodeData. Activity log renders "Waiting Xs — reason" and "Wait completed (Xs) — interrupted". Documentation: - New examples/wait-step.yaml demonstrates a polling pattern with templated poll interval and route loop-back. Tests: - tests/test_engine/test_duration.py: pure parser (26 cases). - tests/test_config/test_wait_schema.py: schema validation (41 cases: valid forms, required duration, bool rejection, bounds, forbidden fields, parallel/for_each rejection, wait-only fields on other types). - tests/test_executor/test_wait.py: sleep accuracy, interrupt cancellation (verifies event stays set for engine consumption), templated durations, runtime validation (11 cases). - tests/test_engine/test_wait_workflow.py: end-to-end (6 cases) — linear wait, strict output contract, workflow timeout cancellation, event emission shape, templated duration from workflow input, interrupt-event cancels in-flight sleep. Closes #218 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- examples/wait-step.yaml | 104 ++++++ src/conductor/cli/run.py | 13 + src/conductor/config/schema.py | 129 ++++++- src/conductor/config/validator.py | 20 +- src/conductor/duration.py | 83 +++++ src/conductor/engine/context.py | 2 +- src/conductor/engine/workflow.py | 153 ++++++++ src/conductor/executor/__init__.py | 3 + src/conductor/executor/wait.py | 190 ++++++++++ .../src/components/detail/DetailPanel.tsx | 3 + .../src/components/detail/WaitDetail.tsx | 46 +++ .../src/components/graph/WaitNode.tsx | 150 ++++++++ .../src/components/graph/WorkflowGraph.tsx | 2 + .../src/components/graph/graph-layout.ts | 1 + .../web/frontend/src/lib/constants.ts | 2 +- .../web/frontend/src/stores/workflow-store.ts | 98 +++++ .../web/frontend/src/types/events.ts | 32 ++ .../web/frontend/tsconfig.tsbuildinfo | 2 +- src/conductor/web/server.py | 22 +- .../web/static/assets/index-CYmT69M5.js | 351 ++++++++++++++++++ .../web/static/assets/index-vaqTcrlj.js | 351 ------------------ src/conductor/web/static/index.html | 2 +- tests/test_config/test_wait_schema.py | 256 +++++++++++++ tests/test_engine/test_duration.py | 120 ++++++ tests/test_engine/test_wait_workflow.py | 249 +++++++++++++ tests/test_executor/test_wait.py | 131 +++++++ 26 files changed, 2154 insertions(+), 361 deletions(-) create mode 100644 examples/wait-step.yaml create mode 100644 src/conductor/duration.py create mode 100644 src/conductor/executor/wait.py create mode 100644 src/conductor/web/frontend/src/components/detail/WaitDetail.tsx create mode 100644 src/conductor/web/frontend/src/components/graph/WaitNode.tsx create mode 100644 src/conductor/web/static/assets/index-CYmT69M5.js delete mode 100644 src/conductor/web/static/assets/index-vaqTcrlj.js create mode 100644 tests/test_config/test_wait_schema.py create mode 100644 tests/test_engine/test_duration.py create mode 100644 tests/test_engine/test_wait_workflow.py create mode 100644 tests/test_executor/test_wait.py diff --git a/examples/wait-step.yaml b/examples/wait-step.yaml new file mode 100644 index 00000000..5814c7b7 --- /dev/null +++ b/examples/wait-step.yaml @@ -0,0 +1,104 @@ +# Wait Step Example +# +# This example demonstrates the `type: wait` step. A wait step pauses +# workflow execution for a parsed duration (seconds, "Ns/Nm/Nh/Nms", +# or a Jinja2 template that evaluates to one of those). The pause is +# pure in-process asyncio.sleep — no shell `sleep` command, so it works +# cross-platform. +# +# This workflow demonstrates a common pattern: polling an external +# system until it returns a "ready" status, with a cool-down between +# attempts. The wait step's duration is templated from a workflow +# input so the caller controls the poll cadence. +# +# Usage: +# conductor run examples/wait-step.yaml \ +# --input poll_interval_seconds=2 --input max_attempts=3 + +workflow: + name: wait-step-demo + description: Polling pattern with a wait step and a routing loop-back + version: "1.0.0" + entry_point: check_status + + runtime: + provider: copilot + + input: + poll_interval_seconds: + type: number + default: 5 + description: Seconds to wait between polling attempts. + max_attempts: + type: number + default: 3 + description: Maximum number of polling attempts before giving up. + + limits: + # Wait steps count toward max_iterations (each pause is one step), + # so allow enough headroom for max_attempts polls + waits + summary. + max_iterations: 20 + timeout_seconds: 600 + +agents: + # A trivial script that simulates polling an external system. In a + # real workflow this would hit an HTTP endpoint, query a job queue, + # check a CDN, etc. Here we just bump a counter and report "ready" + # on the third attempt. + - name: check_status + type: script + description: Poll the (simulated) external system for readiness. + command: python3 + args: + - "-c" + - | + import json, os, pathlib + # Use a small counter file in /tmp so reruns are independent. + p = pathlib.Path(os.environ.get("STATUS_FILE", "/tmp/wait-step-demo.count")) + count = int(p.read_text()) if p.exists() else 0 + count += 1 + p.write_text(str(count)) + ready = count >= int(os.environ.get("READY_AFTER", "3")) + print(json.dumps({ + "status": "ready" if ready else "pending", + "attempt": count, + })) + env: + STATUS_FILE: /tmp/wait-step-demo.count + READY_AFTER: "{{ workflow.input.max_attempts }}" + routes: + - to: summarize + when: "status == 'ready'" + - to: cool_down + + # Wait for the configured poll interval, then loop back to check_status. + # The duration template uses workflow.input.* directly — wait steps + # render locally (no LLM), so workflow.input is available without an + # explicit `input:` declaration. + - name: cool_down + type: wait + duration: "{{ workflow.input.poll_interval_seconds }}s" + reason: "Cooling down between polling attempts" + routes: + - to: check_status + + # Summarize the polling result. An ordinary agent reading the most + # recent check_status output and reporting back to the caller. + - name: summarize + description: Summarize the polling result. + model: claude-haiku-4.5 + input: + - "check_status.output" + prompt: | + The poll loop reported readiness on attempt {{ check_status.output.attempt }}. + Write a single short sentence summarizing the result. + output: + summary: + type: string + description: One-sentence summary of the polling result. + routes: + - to: $end + +output: + result: "{{ summarize.output.summary }}" + attempts: "{{ check_status.output.attempt }}" diff --git a/src/conductor/cli/run.py b/src/conductor/cli/run.py index e626d090..dd960411 100644 --- a/src/conductor/cli/run.py +++ b/src/conductor/cli/run.py @@ -775,6 +775,19 @@ def on_event(self, event: WorkflowEvent) -> None: d.get("elapsed", 0.0), ) + elif t == "wait_completed": + interrupted = d.get("interrupted", False) + waited = d.get("waited_seconds", d.get("elapsed", 0.0)) + suffix = " (interrupted)" if interrupted else "" + verbose_log(f" Wait done: {d.get('agent_name', '?')} after {waited:.2f}s{suffix}") + + elif t == "wait_failed": + verbose_log( + f" Wait failed: {d.get('agent_name', '?')} — " + f"{d.get('error_type', 'Error')}: {d.get('message', 'unknown')}", + style="red", + ) + def display_usage_summary(usage_data: dict[str, Any], console: Console | None = None) -> None: """Display final usage summary with token counts and costs. diff --git a/src/conductor/config/schema.py b/src/conductor/config/schema.py index 43e9d650..8a048dc0 100644 --- a/src/conductor/config/schema.py +++ b/src/conductor/config/schema.py @@ -10,8 +10,13 @@ from pydantic import BaseModel, ConfigDict, Field, field_validator, model_validator +from conductor.duration import parse_duration from conductor.providers.reasoning import ReasoningEffort +# Maximum allowed wait-step duration (24 hours). Anything longer almost +# certainly wants ``limits.timeout_seconds`` reconsidered first. +MAX_WAIT_DURATION_SECONDS = 24 * 60 * 60 + class InputDef(BaseModel): """Definition for a workflow input parameter.""" @@ -458,7 +463,7 @@ class AgentDef(BaseModel): description: str | None = None """Human-readable description of agent's purpose.""" - type: Literal["agent", "human_gate", "script", "workflow"] | None = None + type: Literal["agent", "human_gate", "script", "workflow", "wait"] | None = None """Agent type. Defaults to 'agent' if not specified.""" provider: Literal["copilot", "claude"] | None = None @@ -526,6 +531,23 @@ class AgentDef(BaseModel): timeout: int | None = None """Per-script timeout in seconds.""" + duration: str | int | float | None = None + """Duration to pause for ``type='wait'`` steps. + + Accepts: + - Plain ``int`` or ``float`` — interpreted as seconds. + - String with a unit suffix: ``ms``, ``s``, ``m``, ``h`` + (e.g. ``"500ms"``, ``"60s"``, ``"2.5m"``, ``"1h"``). + - A Jinja2 template that renders to one of the above + (e.g. ``"{{ workflow.input.poll_interval_seconds }}s"``). + + The resolved duration must be greater than 0 and no more than 24h. + Templated durations defer literal validation to runtime. + """ + + reason: str | None = None + """Optional human-readable reason shown in the dashboard for ``type='wait'`` steps.""" + workflow: str | None = None """Path to sub-workflow YAML file (required for type='workflow'). @@ -679,6 +701,20 @@ def validate_timeout(cls, v: int | None) -> int | None: raise ValueError("timeout must be a positive integer") return v + @field_validator("duration", mode="before") + @classmethod + def reject_bool_duration(cls, v: Any) -> Any: + """Reject boolean values for ``duration`` before Pydantic coerces them to int. + + Pydantic v2 coerces ``True``/``False`` to ``1``/``0`` when the union + accepts ``int``. Catch it pre-coercion so a YAML ``duration: true`` is + rejected with a clear message instead of silently becoming a 1-second + wait. + """ + if isinstance(v, bool): + raise ValueError(f"duration must be a number or duration string, not boolean: {v!r}") + return v + @model_validator(mode="after") def validate_agent_type(self) -> AgentDef: """Ensure agent has required fields for its type.""" @@ -758,6 +794,54 @@ def validate_agent_type(self) -> AgentDef: raise ValueError("workflow agents cannot have 'dialog'") if self.timeout_seconds is not None: raise ValueError("workflow agents cannot have 'timeout_seconds'") + elif self.type == "wait": + if self.duration is None: + raise ValueError("wait agents require 'duration'") + if self.prompt: + raise ValueError("wait agents cannot have 'prompt'") + if self.provider: + raise ValueError("wait agents cannot have 'provider'") + if self.model: + raise ValueError("wait agents cannot have 'model'") + if self.tools is not None: + raise ValueError("wait agents cannot have 'tools'") + if self.system_prompt: + raise ValueError("wait agents cannot have 'system_prompt'") + if self.options: + raise ValueError("wait agents cannot have 'options'") + if self.command: + raise ValueError("wait agents cannot have 'command'") + if self.args: + raise ValueError("wait agents cannot have 'args'") + if self.env: + raise ValueError("wait agents cannot have 'env'") + if self.working_dir: + raise ValueError("wait agents cannot have 'working_dir'") + if self.timeout is not None: + raise ValueError("wait agents cannot have 'timeout'") + if self.workflow: + raise ValueError("wait agents cannot have 'workflow'") + if self.input_mapping is not None: + raise ValueError("wait agents cannot have 'input_mapping'") + if self.max_depth is not None: + raise ValueError("wait agents cannot have 'max_depth'") + if self.max_session_seconds: + raise ValueError("wait agents cannot have 'max_session_seconds'") + if self.max_agent_iterations is not None: + raise ValueError("wait agents cannot have 'max_agent_iterations'") + if self.retry is not None: + raise ValueError("wait agents cannot have 'retry'") + if self.dialog is not None: + raise ValueError("wait agents cannot have 'dialog'") + if self.reasoning is not None: + raise ValueError("wait agents cannot have 'reasoning'") + if self.timeout_seconds is not None: + raise ValueError("wait agents cannot have 'timeout_seconds'") + if self.output is not None: + raise ValueError( + "wait agents cannot have 'output' (output is fixed: {'waited_seconds': float})" + ) + self._validate_wait_duration() else: # Regular agent or human_gate — input_mapping is not valid if self.input_mapping is not None: @@ -772,8 +856,51 @@ def validate_agent_type(self) -> AgentDef: ) if self.type == "workflow" and self.reasoning is not None: raise ValueError("workflow agents cannot have 'reasoning'") + + # Wait-only fields are forbidden on every other type. + if self.type != "wait": + if self.duration is not None: + raise ValueError( + f"'{self.type or 'agent'}' agents cannot have 'duration' " + "(only wait agents support duration)" + ) + if self.reason is not None: + raise ValueError( + f"'{self.type or 'agent'}' agents cannot have 'reason' " + "(only wait agents support reason)" + ) return self + def _validate_wait_duration(self) -> None: + """Validate ``duration`` for a ``wait`` agent. + + Booleans are rejected outright. Templated durations (containing + ``{{``) defer all literal validation to runtime; for everything + else we parse the value and enforce ``0 < d <= 24h``. + """ + value = self.duration + if isinstance(value, bool): + raise ValueError( + f"wait duration must be a number or duration string, not boolean: {value!r}" + ) + + if isinstance(value, str) and "{{" in value: + return + + try: + seconds = parse_duration(value) # type: ignore[arg-type] + except ValueError as exc: + raise ValueError(f"wait duration is invalid: {exc}") from exc + + if seconds <= 0: + raise ValueError(f"wait duration must be > 0 seconds (got {seconds!r})") + if seconds > MAX_WAIT_DURATION_SECONDS: + raise ValueError( + f"wait duration {seconds!r}s exceeds the 24h cap " + f"({MAX_WAIT_DURATION_SECONDS}s); reconsider using " + "'limits.timeout_seconds' instead" + ) + class MCPServerDef(BaseModel): """Definition for an MCP server.""" diff --git a/src/conductor/config/validator.py b/src/conductor/config/validator.py index 1b1f7531..4c32dcf2 100644 --- a/src/conductor/config/validator.py +++ b/src/conductor/config/validator.py @@ -171,8 +171,8 @@ def validate_workflow_config( errors.extend(input_errors) warnings.extend(input_warnings) - # Validate tool references (skip for script-type agents, they don't use tools) - if agent.tools is not None and agent.tools and agent.type != "script": + # Validate tool references (skip for script/wait-type agents, they don't use tools) + if agent.tools is not None and agent.tools and agent.type not in ("script", "wait"): tool_errors = _validate_tool_references(agent.name, agent.tools, set(config.tools)) errors.extend(tool_errors) @@ -204,13 +204,18 @@ def validate_workflow_config( parallel_errors = _validate_parallel_groups(config) errors.extend(parallel_errors) - # Validate for_each groups: reject script steps as inline agents + # Validate for_each groups: reject script and wait steps as inline agents for for_each_group in config.for_each: if for_each_group.agent.type == "script": errors.append( f"For-each group '{for_each_group.name}' uses a script step as its " "inline agent. Script steps cannot be used in for_each groups." ) + if for_each_group.agent.type == "wait": + errors.append( + f"For-each group '{for_each_group.name}' uses a wait step as its " + "inline agent. Wait steps cannot be used in for_each groups." + ) # Validate sub-workflow references (local paths and registry refs). # Skipped when workflow_path is not provided — relative paths cannot be @@ -493,6 +498,13 @@ def _validate_parallel_groups(config: WorkflowConfig) -> list[str]: "Script steps cannot be used in parallel groups." ) + # Validate no wait steps in parallel groups + if agent.type == "wait": + errors.append( + f"Agent '{agent_name}' in parallel group '{pg.name}' is a wait step. " + "Wait steps cannot be used in parallel groups." + ) + # Validate no workflow steps in parallel groups if agent.type == "workflow": errors.append( @@ -1357,7 +1369,7 @@ def _validate_template_references( ) elif ( is_explicit - and agent.type not in ("script", "workflow", "human_gate") + and agent.type not in ("script", "workflow", "human_gate", "wait") and input_name not in declared_workflow_inputs ): warnings.append( diff --git a/src/conductor/duration.py b/src/conductor/duration.py new file mode 100644 index 00000000..1f70d377 --- /dev/null +++ b/src/conductor/duration.py @@ -0,0 +1,83 @@ +"""Duration parsing for Conductor workflow steps. + +This module provides ``parse_duration`` for converting user-supplied +duration values (plain numbers or suffixed strings like ``"5m"``, +``"500ms"``, ``"1h"``) into a float seconds value. Used by the +``wait`` step type and shared as a primitive for other duration-aware +features. + +The parser raises :class:`ValueError` on invalid input so it nests +cleanly inside Pydantic ``ValidationError`` when called from schema +validators. Bounds checks (e.g., > 0, 24h cap) are intentionally left +to callers so the same parser can be reused for different policies. +""" + +from __future__ import annotations + +import re + +_DURATION_PATTERN = re.compile(r"^\s*(?P\d+(?:\.\d+)?)\s*(?Pms|s|m|h)?\s*$") + +_UNIT_TO_SECONDS: dict[str, float] = { + "ms": 1e-3, + "s": 1.0, + "m": 60.0, + "h": 3600.0, +} + + +def parse_duration(value: str | int | float) -> float: + """Parse a duration value into seconds. + + Accepts: + * Plain ``int`` or ``float`` — interpreted as seconds. + * Strings matching ```` where unit is one of + ``ms``, ``s``, ``m``, ``h``. Whitespace around the value and + between number/unit is tolerated. Omitting the unit defaults + to seconds. + + Examples:: + + parse_duration(60) # 60.0 + parse_duration(1.5) # 1.5 + parse_duration("60") # 60.0 + parse_duration("60s") # 60.0 + parse_duration("5m") # 300.0 + parse_duration("1h") # 3600.0 + parse_duration("500ms") # 0.5 + parse_duration("2.5m") # 150.0 + + Args: + value: The duration to parse. + + Returns: + Duration in seconds as a ``float``. + + Raises: + ValueError: If ``value`` is not a recognized duration. The + message is suitable for surfacing directly to a user in a + Pydantic ``ValidationError``. + """ + # Reject bool explicitly — Pydantic v2 / Python treat ``True`` as ``int(1)`` + # in many contexts, but accepting it here is almost certainly a mistake. + if isinstance(value, bool): + raise ValueError(f"duration must be a number or duration string, not boolean: {value!r}") + + if isinstance(value, (int, float)): + return float(value) + + if not isinstance(value, str): + raise ValueError( + f"duration must be a number or string like '60s'/'5m'/'1h', got {type(value).__name__}" + ) + + match = _DURATION_PATTERN.match(value) + if match is None: + raise ValueError( + f"duration {value!r} is not a valid duration; expected a number " + "or a value like '60s', '5m', '1h', '500ms'" + ) + + number = float(match.group("value")) + unit = match.group("unit") or "s" + return number * _UNIT_TO_SECONDS[unit] diff --git a/src/conductor/engine/context.py b/src/conductor/engine/context.py index 4b975473..1365ff78 100644 --- a/src/conductor/engine/context.py +++ b/src/conductor/engine/context.py @@ -22,7 +22,7 @@ # once at startup and present for the lifetime of the run. Per-step agent # outputs remain explicitly declared in ``input:`` for traceability, even for # local renders. -_LOCAL_RENDER_AGENT_TYPES = frozenset({"script", "workflow"}) +_LOCAL_RENDER_AGENT_TYPES = frozenset({"script", "workflow", "wait"}) def estimate_tokens(text: str) -> int: diff --git a/src/conductor/engine/workflow.py b/src/conductor/engine/workflow.py index eccc7404..c9c833ae 100644 --- a/src/conductor/engine/workflow.py +++ b/src/conductor/engine/workflow.py @@ -18,6 +18,7 @@ from pathlib import Path from typing import TYPE_CHECKING, Any +from conductor.duration import parse_duration from conductor.engine.checkpoint import CheckpointManager from conductor.engine.context import WorkflowContext from conductor.engine.limits import LimitEnforcer @@ -41,6 +42,7 @@ from conductor.executor.output import validate_output from conductor.executor.script import ScriptExecutor, ScriptOutput from conductor.executor.template import TemplateRenderer +from conductor.executor.wait import WaitExecutor, WaitOutput from conductor.gates.human import ( GateResult, HumanGateHandler, @@ -360,6 +362,7 @@ def __init__( self.gate_handler = HumanGateHandler(skip_gates=skip_gates) self.max_iterations_handler = MaxIterationsHandler(skip_gates=skip_gates) self.script_executor = ScriptExecutor() + self.wait_executor = WaitExecutor() self.usage_tracker = UsageTracker( pricing_overrides=self._build_pricing_overrides(), ) @@ -742,6 +745,32 @@ async def _execute_script(self, agent: AgentDef, context: dict[str, Any]) -> Scr operation_name=f"script '{agent.name}'", ) + async def _execute_wait(self, agent: AgentDef, context: dict[str, Any]) -> WaitOutput: + """Execute a wait step with workflow-level timeout enforcement. + + The wait races ``asyncio.sleep`` against the engine's + ``interrupt_event`` so Esc / Ctrl+G cancels an in-flight wait + immediately. The outer ``wait_for_with_timeout`` ensures the + workflow-level ``limits.timeout_seconds`` still fires if it + would expire before the wait completes. + + Args: + agent: Wait agent definition. + context: Workflow context for template rendering. + + Returns: + :class:`WaitOutput` with elapsed seconds and interrupt flag. + + Raises: + ValidationError: If the rendered duration is invalid. + ConductorTimeoutError: If the workflow timeout fires while + the wait is in progress. + """ + return await self.limits.wait_for_with_timeout( + self.wait_executor.execute(agent, context, interrupt_event=self._interrupt_event), + operation_name=f"wait '{agent.name}'", + ) + def _validate_script_output_schema( self, agent: AgentDef, @@ -2388,6 +2417,130 @@ async def _execute_loop(self, current_agent_name: str) -> dict[str, Any]: ) continue + # Handle wait steps + if agent.type == "wait": + agent_context = self.context.build_for_agent( + agent.name, + agent.input, + mode=self.config.workflow.context.mode, + agent_type=agent.type, + ) + _wait_start = _time.time() + + wait_execution_count = ( + self.limits.get_agent_execution_count(agent.name) + 1 + ) + + # Resolve the duration up-front so the + # ``wait_started`` event includes the parsed + # value (the dashboard renders a sleeping + # pill keyed off this). Templated durations + # that can't be rendered will raise inside + # ``_execute_wait`` below; emit ``None`` here + # so the event still fires for debuggability. + try: + rendered_duration = self.renderer.render( + str(agent.duration), agent_context + ) + preview_duration_seconds: float | None = parse_duration( + rendered_duration + ) + except (ValueError, Exception): # noqa: BLE001 — defensive + preview_duration_seconds = None + preview_reason: str | None = None + if agent.reason is not None: + try: + preview_reason = self.renderer.render( + agent.reason, agent_context + ) + except Exception: # noqa: BLE001 — defensive + preview_reason = agent.reason + + self._emit( + "wait_started", + { + "agent_name": agent.name, + "iteration": wait_execution_count, + "duration_seconds": preview_duration_seconds, + "reason": preview_reason, + }, + ) + + try: + wait_output = await self._execute_wait(agent, agent_context) + except Exception as exc: + _wait_elapsed = _time.time() - _wait_start + self._emit( + "wait_failed", + { + "agent_name": agent.name, + "elapsed": _wait_elapsed, + "error_type": type(exc).__name__, + "message": str(exc), + }, + ) + raise + _wait_elapsed = _time.time() - _wait_start + + # Public output contract (per issue #218): + # only ``waited_seconds`` is exposed in the + # workflow context. Extra metadata lives in + # the event payload below for the dashboard. + output_content: dict[str, Any] = { + "waited_seconds": wait_output.waited_seconds, + } + + self._emit( + "wait_completed", + { + "agent_name": agent.name, + "elapsed": _wait_elapsed, + "waited_seconds": wait_output.waited_seconds, + "requested_seconds": wait_output.requested_seconds, + "reason": wait_output.reason, + "interrupted": wait_output.interrupted, + }, + ) + + self.context.store(agent.name, output_content) + self.limits.record_execution(agent.name) + self.limits.check_timeout() + + route_result = self._evaluate_routes(agent, output_content) + + self._emit( + "route_taken", + { + "from_agent": agent.name, + "to_agent": route_result.target, + }, + ) + + if route_result.target == "$end": + result = self._build_final_output(route_result.output_transform) + self._emit( + "workflow_completed", + { + "elapsed": _time.time() - _workflow_start, + "output": result, + }, + ) + self._execute_hook("on_complete", result=result) + return result + + current_agent_name = route_result.target + + # Check for interrupt after wait step. If the + # sleep was cut short by ``interrupt_event``, + # the flag is still set here and triggers the + # normal interrupt menu / web-mode handling. + interrupt_result = await self._check_interrupt(current_agent_name) + if interrupt_result is not None: + current_agent_name = await self._handle_interrupt_result( + interrupt_result, current_agent_name + ) + continue + # Handle sub-workflow steps if agent.type == "workflow": agent_context = self.context.build_for_agent( diff --git a/src/conductor/executor/__init__.py b/src/conductor/executor/__init__.py index e33cd38a..03c30204 100644 --- a/src/conductor/executor/__init__.py +++ b/src/conductor/executor/__init__.py @@ -8,12 +8,15 @@ from conductor.executor.output import parse_json_output, validate_output from conductor.executor.script import ScriptExecutor, ScriptOutput from conductor.executor.template import TemplateRenderer +from conductor.executor.wait import WaitExecutor, WaitOutput __all__ = [ "AgentExecutor", "ScriptExecutor", "ScriptOutput", "TemplateRenderer", + "WaitExecutor", + "WaitOutput", "parse_json_output", "resolve_agent_tools", "validate_output", diff --git a/src/conductor/executor/wait.py b/src/conductor/executor/wait.py new file mode 100644 index 00000000..ed12fabb --- /dev/null +++ b/src/conductor/executor/wait.py @@ -0,0 +1,190 @@ +"""Wait step execution for Conductor workflow steps. + +This module provides the :class:`WaitExecutor` for ``type: wait`` agent +definitions. A wait step pauses workflow execution for a parsed duration +via :func:`asyncio.sleep`. The sleep races against an optional +``interrupt_event`` so Esc / Ctrl+G cancels an in-flight wait +immediately; workflow-level timeout enforcement is layered on top by +the engine via :meth:`LimitEnforcer.wait_for_with_timeout`. +""" + +from __future__ import annotations + +import asyncio +import contextlib +import time +from dataclasses import dataclass +from typing import TYPE_CHECKING, Any + +from conductor.config.schema import MAX_WAIT_DURATION_SECONDS +from conductor.duration import parse_duration +from conductor.exceptions import ValidationError +from conductor.executor.template import TemplateRenderer + + +def _verbose_log(message: str, style: str = "dim") -> None: + """Log a verbose message via the CLI run module. + + Uses a deferred import to avoid a circular import between + executor.wait and cli.run (cli.run imports WorkflowEngine which + imports executor modules). + """ + from conductor.cli.run import verbose_log + + verbose_log(message, style) + + +if TYPE_CHECKING: + from conductor.config.schema import AgentDef + + +@dataclass +class WaitOutput: + """Result of a wait step execution. + + Attributes: + waited_seconds: Wall-clock seconds actually slept. May be less + than ``requested_seconds`` if an interrupt cut the sleep short. + requested_seconds: Parsed duration value from the agent config. + reason: The rendered ``reason`` field, or ``None`` if not set. + interrupted: ``True`` if an interrupt signal cancelled the sleep + before ``requested_seconds`` elapsed. + """ + + waited_seconds: float + requested_seconds: float + reason: str | None + interrupted: bool + + +class WaitExecutor: + """Executes wait steps via :func:`asyncio.sleep`. + + Renders the agent's ``duration`` (and optional ``reason``) Jinja2 + templates, parses the duration string, then sleeps. If an + ``interrupt_event`` is provided, the sleep is raced against it so + the engine's Esc/Ctrl+G handler can cancel an in-flight wait + without waiting for the full duration. + + Example:: + + executor = WaitExecutor() + output = await executor.execute(agent, context, interrupt_event=ev) + print(output.waited_seconds, output.interrupted) + """ + + def __init__(self) -> None: + """Initialize the WaitExecutor with a template renderer.""" + self.renderer = TemplateRenderer() + + async def execute( + self, + agent: AgentDef, + context: dict[str, Any], + interrupt_event: asyncio.Event | None = None, + ) -> WaitOutput: + """Execute a wait step. + + Renders ``agent.duration`` and ``agent.reason`` with Jinja2, + parses the duration, then sleeps. Honors ``interrupt_event`` + for early cancellation. Does NOT clear ``interrupt_event`` — + the engine's between-step interrupt check consumes it after + the wait returns so the user gets the normal interrupt menu. + + Args: + agent: Agent definition with ``type='wait'``. + context: Workflow context for template rendering. + interrupt_event: Optional event signaling user interrupt. + + Returns: + :class:`WaitOutput` with elapsed time and interrupt flag. + + Raises: + ValidationError: If the rendered duration cannot be parsed + or falls outside ``(0, 24h]``. + """ + if agent.duration is None: + # Defensive: the schema validator forbids this, but keep a + # clear error in case of bypass. + raise ValidationError( + f"Wait '{agent.name}': duration is required", + ) + + # Render duration through Jinja2 (templated durations are common + # for poll-interval patterns). Coerce to str so int/float values + # render predictably. + rendered_duration = self.renderer.render(str(agent.duration), context) + rendered_reason: str | None = None + if agent.reason is not None: + rendered_reason = self.renderer.render(agent.reason, context) + + try: + seconds = parse_duration(rendered_duration) + except ValueError as exc: + raise ValidationError( + f"Wait '{agent.name}': {exc}", + suggestion=( + "Provide a number of seconds or a duration string " + "like '60s', '5m', '1h', '500ms'." + ), + ) from exc + + if seconds <= 0: + raise ValidationError( + f"Wait '{agent.name}': duration must be > 0 seconds (got {seconds!r})", + ) + if seconds > MAX_WAIT_DURATION_SECONDS: + raise ValidationError( + f"Wait '{agent.name}': duration {seconds!r}s exceeds the " + f"24h cap ({MAX_WAIT_DURATION_SECONDS}s)", + suggestion="Reconsider using 'limits.timeout_seconds' instead.", + ) + + _verbose_log(f" Wait: {seconds}s" + (f" — {rendered_reason}" if rendered_reason else "")) + + start = time.monotonic() + interrupted = await self._sleep_with_interrupt(seconds, interrupt_event) + elapsed = time.monotonic() - start + + return WaitOutput( + waited_seconds=elapsed, + requested_seconds=seconds, + reason=rendered_reason, + interrupted=interrupted, + ) + + @staticmethod + async def _sleep_with_interrupt(seconds: float, interrupt_event: asyncio.Event | None) -> bool: + """Sleep for ``seconds``, returning early on interrupt. + + Returns: + ``True`` if the sleep was cancelled by ``interrupt_event``, + ``False`` if the full duration elapsed. + """ + if interrupt_event is None: + await asyncio.sleep(seconds) + return False + + sleep_task = asyncio.create_task(asyncio.sleep(seconds)) + interrupt_task = asyncio.create_task(interrupt_event.wait()) + try: + done, pending = await asyncio.wait( + {sleep_task, interrupt_task}, + return_when=asyncio.FIRST_COMPLETED, + ) + for t in pending: + t.cancel() + with contextlib.suppress(asyncio.CancelledError): + await t + except BaseException: + # Cancellation from outside (e.g., workflow timeout) — clean + # up both tasks and re-raise so wait_for / outer cancellation + # handlers see the original exception. + for t in (sleep_task, interrupt_task): + if not t.done(): + t.cancel() + with contextlib.suppress(asyncio.CancelledError, Exception): + await t + raise + + return interrupt_task in done diff --git a/src/conductor/web/frontend/src/components/detail/DetailPanel.tsx b/src/conductor/web/frontend/src/components/detail/DetailPanel.tsx index f35c2f71..6516706d 100644 --- a/src/conductor/web/frontend/src/components/detail/DetailPanel.tsx +++ b/src/conductor/web/frontend/src/components/detail/DetailPanel.tsx @@ -8,6 +8,7 @@ import { GateDetail } from './GateDetail'; import { GroupDetail } from './GroupDetail'; import { DialogEngagementPrompt } from './DialogEngagementPrompt'; import { SubworkflowDetail } from './SubworkflowDetail'; +import { WaitDetail } from './WaitDetail'; import { cn } from '@/lib/utils'; export function DetailPanel() { @@ -47,6 +48,8 @@ export function DetailPanel() { switch (node.type) { case 'script': return ScriptDetail; + case 'wait': + return WaitDetail; case 'human_gate': return GateDetail; case 'parallel_group': diff --git a/src/conductor/web/frontend/src/components/detail/WaitDetail.tsx b/src/conductor/web/frontend/src/components/detail/WaitDetail.tsx new file mode 100644 index 00000000..d1ca5d51 --- /dev/null +++ b/src/conductor/web/frontend/src/components/detail/WaitDetail.tsx @@ -0,0 +1,46 @@ +import { MetadataGrid } from './MetadataGrid'; +import type { NodeData } from '@/stores/workflow-store'; +import { NODE_STATUS_HEX } from '@/lib/constants'; +import { formatElapsed } from '@/lib/utils'; +import type { NodeStatus } from '@/lib/constants'; + +interface WaitDetailProps { + node: NodeData; +} + +export function WaitDetail({ node }: WaitDetailProps) { + const status = node.status as NodeStatus; + const statusColor = NODE_STATUS_HEX[status] || NODE_STATUS_HEX.pending; + + const items: Array<{ label: string; value: string | number | null | undefined }> = []; + const requested = node.requested_seconds ?? node.duration_seconds; + if (requested != null) items.push({ label: 'Requested', value: formatElapsed(requested) }); + if (node.waited_seconds != null) { + items.push({ label: 'Waited', value: formatElapsed(node.waited_seconds) }); + } else if (node.elapsed != null) { + items.push({ label: 'Elapsed', value: formatElapsed(node.elapsed) }); + } + if (node.interrupted) items.push({ label: 'Interrupted', value: 'yes' }); + if (node.reason) items.push({ label: 'Reason', value: node.reason }); + if (node.error_type) items.push({ label: 'Error', value: node.error_type }); + if (node.error_message) items.push({ label: 'Message', value: node.error_message }); + + return ( +
+
+ + {status} + + Wait +
+ + +
+ ); +} diff --git a/src/conductor/web/frontend/src/components/graph/WaitNode.tsx b/src/conductor/web/frontend/src/components/graph/WaitNode.tsx new file mode 100644 index 00000000..4c25e24c --- /dev/null +++ b/src/conductor/web/frontend/src/components/graph/WaitNode.tsx @@ -0,0 +1,150 @@ +import { memo, useEffect, useRef, useState } from 'react'; +import { Handle, Position, type NodeProps } from '@xyflow/react'; +import { Clock } from 'lucide-react'; +import { cn, formatElapsed } from '@/lib/utils'; +import { NODE_STATUS_HEX } from '@/lib/constants'; +import { useWorkflowStore } from '@/stores/workflow-store'; +import { useViewedNodes } from '@/hooks/use-viewed-context'; +import { NodeTooltip } from './NodeTooltip'; +import type { GraphNodeData } from './graph-layout'; +import type { NodeStatus } from '@/lib/constants'; + +export const WaitNode = memo(function WaitNode({ data, id, selected }: NodeProps) { + const nodeData = data as unknown as GraphNodeData; + const viewedNodes = useViewedNodes(); + const storeStatus = viewedNodes[id]?.status; + const status = (storeStatus || nodeData.status || 'pending') as NodeStatus; + const borderColor = NODE_STATUS_HEX[status] || NODE_STATUS_HEX.pending; + + const nd = viewedNodes[id]; + const duration = nd?.duration_seconds ?? nd?.requested_seconds; + const waited = nd?.waited_seconds; + const elapsed = nd?.elapsed; + const interrupted = nd?.interrupted; + const errorType = nd?.error_type; + const errorMessage = nd?.error_message; + + const liveElapsed = useLiveElapsed(id, status); + const transitionClass = useStatusTransition(status); + + const statsLine = (() => { + if (status === 'failed' && errorMessage) { + const msg = errorMessage.length > 40 ? errorMessage.slice(0, 37) + '...' : errorMessage; + return { text: msg, className: 'text-red-400' }; + } + if (status === 'running') { + const target = typeof duration === 'number' ? ` / ${formatElapsed(duration)}` : ''; + return { text: `${liveElapsed}${target}`, className: 'text-[var(--text-muted)]' }; + } + if (status === 'completed') { + const parts: string[] = []; + if (waited != null) parts.push(formatElapsed(waited)); + else if (elapsed != null) parts.push(formatElapsed(elapsed)); + if (interrupted) parts.push('interrupted'); + return { text: parts.join(' · ') || null, className: 'text-[var(--text-muted)]' }; + } + if (status === 'pending' && typeof duration === 'number') { + return { text: formatElapsed(duration), className: 'text-[var(--text-muted)]' }; + } + return { text: null, className: '' }; + })(); + + return ( + <> + + +
+
+ +
+
+ {nodeData.label} + {statsLine.text && ( + + {statsLine.text} + + )} +
+
+
+ + + ); +}); + +function useLiveElapsed(id: string, status: NodeStatus): string { + const startedAt = useViewedNodes()[id]?.startedAt; + const replayMode = useWorkflowStore((s) => s.replayMode); + const lastEventTime = useWorkflowStore((s) => s.lastEventTime); + const [display, setDisplay] = useState('0.0s'); + const rafRef = useRef | null>(null); + + useEffect(() => { + if (status === 'running') { + if (replayMode) { + if (rafRef.current) clearInterval(rafRef.current); + const origin = startedAt ?? (lastEventTime ?? 0); + const now = lastEventTime ?? origin; + setDisplay(formatElapsed(now - origin)); + return; + } + const origin = startedAt != null ? startedAt * 1000 : Date.now(); + const tick = () => { + const sec = (Date.now() - origin) / 1000; + setDisplay(formatElapsed(sec)); + }; + tick(); + rafRef.current = setInterval(tick, 1000); + return () => { + if (rafRef.current) clearInterval(rafRef.current); + }; + } else { + if (rafRef.current) clearInterval(rafRef.current); + } + }, [status, startedAt, replayMode, lastEventTime]); + + return display; +} + +function useStatusTransition(status: NodeStatus): string { + const prevStatusRef = useRef(status); + const [transitionClass, setTransitionClass] = useState(''); + + useEffect(() => { + const prev = prevStatusRef.current; + prevStatusRef.current = status; + if (prev === status) return; + + if (status === 'running') { + setTransitionClass('node-activate'); + } else if (prev === 'running' && (status === 'completed' || status === 'failed')) { + setTransitionClass(status === 'completed' ? 'node-complete' : 'node-fail'); + } + + const timer = setTimeout(() => setTransitionClass(''), 400); + return () => clearTimeout(timer); + }, [status]); + + return transitionClass; +} diff --git a/src/conductor/web/frontend/src/components/graph/WorkflowGraph.tsx b/src/conductor/web/frontend/src/components/graph/WorkflowGraph.tsx index 97a7073a..1560afba 100644 --- a/src/conductor/web/frontend/src/components/graph/WorkflowGraph.tsx +++ b/src/conductor/web/frontend/src/components/graph/WorkflowGraph.tsx @@ -24,6 +24,7 @@ import { ScriptNode } from './ScriptNode'; import { GateNode } from './GateNode'; import { GroupNode } from './GroupNode'; import { WorkflowNode } from './WorkflowNode'; +import { WaitNode } from './WaitNode'; import { EndNode } from './EndNode'; import { StartNode } from './StartNode'; import { IngressNode } from './IngressNode'; @@ -40,6 +41,7 @@ const nodeTypes: NodeTypes = { gateNode: GateNode, groupNode: GroupNode, workflowNode: WorkflowNode, + waitNode: WaitNode, endNode: EndNode, startNode: StartNode, ingressNode: IngressNode, diff --git a/src/conductor/web/frontend/src/components/graph/graph-layout.ts b/src/conductor/web/frontend/src/components/graph/graph-layout.ts index 3e3a7d52..a5e45167 100644 --- a/src/conductor/web/frontend/src/components/graph/graph-layout.ts +++ b/src/conductor/web/frontend/src/components/graph/graph-layout.ts @@ -119,6 +119,7 @@ export function buildGraphElements( if (nodeType === 'script') flowNodeType = 'scriptNode'; else if (nodeType === 'human_gate') flowNodeType = 'gateNode'; else if (nodeType === 'workflow') flowNodeType = 'workflowNode'; + else if (nodeType === 'wait') flowNodeType = 'waitNode'; flowNodes.push({ id: a.name, diff --git a/src/conductor/web/frontend/src/lib/constants.ts b/src/conductor/web/frontend/src/lib/constants.ts index 0fd1db5d..c4a1faa1 100644 --- a/src/conductor/web/frontend/src/lib/constants.ts +++ b/src/conductor/web/frontend/src/lib/constants.ts @@ -1,5 +1,5 @@ export type NodeStatus = 'pending' | 'running' | 'completed' | 'failed' | 'paused' | 'idle' | 'waiting'; -export type NodeType = 'agent' | 'script' | 'human_gate' | 'parallel_group' | 'for_each_group' | 'workflow' | 'start' | 'end' | 'ingress' | 'egress'; +export type NodeType = 'agent' | 'script' | 'human_gate' | 'parallel_group' | 'for_each_group' | 'workflow' | 'wait' | 'start' | 'end' | 'ingress' | 'egress'; export const NODE_STATUS_HEX: Record = { pending: '#6b7280', diff --git a/src/conductor/web/frontend/src/stores/workflow-store.ts b/src/conductor/web/frontend/src/stores/workflow-store.ts index 4d1ad4b5..33b0ce73 100644 --- a/src/conductor/web/frontend/src/stores/workflow-store.ts +++ b/src/conductor/web/frontend/src/stores/workflow-store.ts @@ -14,6 +14,9 @@ import type { AgentMessageData, ScriptCompletedData, ScriptFailedData, + WaitStartedData, + WaitCompletedData, + WaitFailedData, GatePresentedData, GateResolvedData, GateOptionDetail, @@ -105,6 +108,12 @@ export interface NodeData { stdout?: string; stderr?: string; exit_code?: number; + // Wait-specific + duration_seconds?: number | null; + waited_seconds?: number; + requested_seconds?: number; + reason?: string | null; + interrupted?: boolean; // Gate-specific options?: string[]; option_details?: GateOptionDetail[]; @@ -1216,6 +1225,43 @@ const eventHandlers: Record { + const data = _data as unknown as WaitStartedData; + const t = activeTarget(state, _data); + const nd = ensureNode(t.nodes, data.agent_name); + nd.status = 'running'; + nd.startedAt = timestamp ?? Date.now() / 1000; + nd.duration_seconds = data.duration_seconds ?? null; + nd.reason = data.reason ?? null; + nd.iteration = data.iteration; + replaceNode(t.nodes, data.agent_name); + }, + + wait_completed: (state, _data) => { + const data = _data as unknown as WaitCompletedData; + const t = activeTarget(state, _data); + const nd = ensureNode(t.nodes, data.agent_name); + nd.status = 'completed'; + t.incrCompleted(); + nd.elapsed = data.elapsed; + nd.waited_seconds = data.waited_seconds; + nd.requested_seconds = data.requested_seconds; + nd.reason = data.reason ?? null; + nd.interrupted = data.interrupted; + replaceNode(t.nodes, data.agent_name); + }, + + wait_failed: (state, _data) => { + const data = _data as unknown as WaitFailedData; + const t = activeTarget(state, _data); + const nd = ensureNode(t.nodes, data.agent_name); + nd.status = 'failed'; + nd.elapsed = data.elapsed; + nd.error_type = data.error_type; + nd.error_message = data.message; + replaceNode(t.nodes, data.agent_name); + }, + gate_presented: (state, _data) => { const data = _data as unknown as GatePresentedData; const t = activeTarget(state, _data); @@ -1777,6 +1823,32 @@ function buildLogEntry(event: WorkflowEvent): LogEntry | null { case 'script_failed': return { timestamp: ts, level: 'error', source: String(d.agent_name), message: `Script failed: ${d.message || d.error_type || 'unknown error'}` }; + case 'wait_started': { + const dur = d.duration_seconds as number | null | undefined; + const reason = d.reason as string | null | undefined; + const durStr = typeof dur === 'number' ? formatSec(dur) : '?'; + return { + timestamp: ts, + level: 'info', + source: String(d.agent_name), + message: `Waiting ${durStr}${reason ? ` — ${reason}` : ''}`, + }; + } + + case 'wait_completed': { + const waited = d.waited_seconds as number | undefined; + const interrupted = d.interrupted as boolean | undefined; + return { + timestamp: ts, + level: 'success', + source: String(d.agent_name), + message: `Wait completed${waited != null ? ` (${formatSec(waited)})` : ''}${interrupted ? ' — interrupted' : ''}`, + }; + } + + case 'wait_failed': + return { timestamp: ts, level: 'error', source: String(d.agent_name), message: `Wait failed: ${d.message || d.error_type || 'unknown error'}` }; + case 'gate_presented': return { timestamp: ts, level: 'warning', source: String(d.agent_name), message: 'Waiting for human input…' }; @@ -1928,6 +2000,32 @@ function buildActivityLogEntry(event: WorkflowEvent): ActivityLogEntry | null { case 'script_failed': return { timestamp: ts, source: String(d.agent_name), type: 'turn', message: `Script failed: ${d.message || d.error_type || 'unknown'}` }; + case 'wait_started': { + const dur = d.duration_seconds as number | null | undefined; + const reason = d.reason as string | null | undefined; + const durStr = typeof dur === 'number' ? formatSec(dur) : '?'; + return { + timestamp: ts, + source: String(d.agent_name), + type: 'turn', + message: `Waiting ${durStr}${reason ? ` — ${reason}` : ''}`, + }; + } + + case 'wait_completed': { + const waited = d.waited_seconds as number | undefined; + const interrupted = d.interrupted as boolean | undefined; + return { + timestamp: ts, + source: String(d.agent_name), + type: 'tool-complete', + message: `Wait completed${waited != null ? ` (${formatSec(waited)})` : ''}${interrupted ? ' — interrupted' : ''}`, + }; + } + + case 'wait_failed': + return { timestamp: ts, source: String(d.agent_name), type: 'turn', message: `Wait failed: ${d.message || d.error_type || 'unknown'}` }; + default: return null; } diff --git a/src/conductor/web/frontend/src/types/events.ts b/src/conductor/web/frontend/src/types/events.ts index 16968cfc..64b1cba7 100644 --- a/src/conductor/web/frontend/src/types/events.ts +++ b/src/conductor/web/frontend/src/types/events.ts @@ -20,6 +20,9 @@ export type EventType = | 'script_started' | 'script_completed' | 'script_failed' + | 'wait_started' + | 'wait_completed' + | 'wait_failed' | 'gate_presented' | 'gate_resolved' | 'route_taken' @@ -157,6 +160,35 @@ export interface ScriptFailedData { message?: string; } +// --- Wait lifecycle --- + +export interface WaitStartedData { + agent_name: string; + iteration?: number; + /** Parsed duration in seconds (null if the template could not be pre-rendered). */ + duration_seconds?: number | null; + reason?: string | null; +} + +export interface WaitCompletedData { + agent_name: string; + elapsed?: number; + /** Actual wall-clock seconds slept. */ + waited_seconds: number; + /** Parsed requested duration. */ + requested_seconds: number; + reason?: string | null; + /** True if an interrupt cut the wait short. */ + interrupted?: boolean; +} + +export interface WaitFailedData { + agent_name: string; + elapsed?: number; + error_type?: string; + message?: string; +} + // --- Gate events --- export interface GateOptionDetail { diff --git a/src/conductor/web/frontend/tsconfig.tsbuildinfo b/src/conductor/web/frontend/tsconfig.tsbuildinfo index 853a8fa3..2a312a42 100644 --- a/src/conductor/web/frontend/tsconfig.tsbuildinfo +++ b/src/conductor/web/frontend/tsconfig.tsbuildinfo @@ -1 +1 @@ -{"root":["./src/app.tsx","./src/main.tsx","./src/components/detail/activitystream.tsx","./src/components/detail/agentdetail.tsx","./src/components/detail/detailpanel.tsx","./src/components/detail/dialogdetail.tsx","./src/components/detail/dialogengagementprompt.tsx","./src/components/detail/dialogoverlay.tsx","./src/components/detail/fileviewer.tsx","./src/components/detail/gatedetail.tsx","./src/components/detail/groupdetail.tsx","./src/components/detail/metadatagrid.tsx","./src/components/detail/outputviewer.tsx","./src/components/detail/scriptdetail.tsx","./src/components/detail/subworkflowdetail.tsx","./src/components/dialogs/iterationlimitmodal.tsx","./src/components/graph/agentnode.tsx","./src/components/graph/animatededge.tsx","./src/components/graph/egressnode.tsx","./src/components/graph/endnode.tsx","./src/components/graph/gatenode.tsx","./src/components/graph/groupnode.tsx","./src/components/graph/ingressnode.tsx","./src/components/graph/nodetooltip.tsx","./src/components/graph/scriptnode.tsx","./src/components/graph/startnode.tsx","./src/components/graph/workflowgraph.tsx","./src/components/graph/workflownode.tsx","./src/components/graph/graph-layout.ts","./src/components/layout/breadcrumbbar.tsx","./src/components/layout/errorbanner.tsx","./src/components/layout/header.tsx","./src/components/layout/outputpane.tsx","./src/components/layout/replaybar.tsx","./src/components/layout/resizablelayout.tsx","./src/components/layout/statusbar.tsx","./src/components/layout/yamlviewer.tsx","./src/hooks/use-deep-link.ts","./src/hooks/use-elapsed-timer.ts","./src/hooks/use-replay.ts","./src/hooks/use-viewed-context.ts","./src/hooks/use-websocket.ts","./src/lib/constants.ts","./src/lib/utils.ts","./src/stores/workflow-store.ts","./src/types/events.ts"],"version":"5.9.3"} \ No newline at end of file +{"root":["./src/app.tsx","./src/main.tsx","./src/components/detail/activitystream.tsx","./src/components/detail/agentdetail.tsx","./src/components/detail/detailpanel.tsx","./src/components/detail/dialogdetail.tsx","./src/components/detail/dialogengagementprompt.tsx","./src/components/detail/dialogoverlay.tsx","./src/components/detail/fileviewer.tsx","./src/components/detail/gatedetail.tsx","./src/components/detail/groupdetail.tsx","./src/components/detail/metadatagrid.tsx","./src/components/detail/outputviewer.tsx","./src/components/detail/scriptdetail.tsx","./src/components/detail/subworkflowdetail.tsx","./src/components/detail/waitdetail.tsx","./src/components/dialogs/iterationlimitmodal.tsx","./src/components/graph/agentnode.tsx","./src/components/graph/animatededge.tsx","./src/components/graph/egressnode.tsx","./src/components/graph/endnode.tsx","./src/components/graph/gatenode.tsx","./src/components/graph/groupnode.tsx","./src/components/graph/ingressnode.tsx","./src/components/graph/nodetooltip.tsx","./src/components/graph/scriptnode.tsx","./src/components/graph/startnode.tsx","./src/components/graph/waitnode.tsx","./src/components/graph/workflowgraph.tsx","./src/components/graph/workflownode.tsx","./src/components/graph/graph-layout.ts","./src/components/layout/breadcrumbbar.tsx","./src/components/layout/errorbanner.tsx","./src/components/layout/header.tsx","./src/components/layout/outputpane.tsx","./src/components/layout/replaybar.tsx","./src/components/layout/resizablelayout.tsx","./src/components/layout/statusbar.tsx","./src/components/layout/yamlviewer.tsx","./src/hooks/use-deep-link.ts","./src/hooks/use-elapsed-timer.ts","./src/hooks/use-replay.ts","./src/hooks/use-viewed-context.ts","./src/hooks/use-websocket.ts","./src/lib/constants.ts","./src/lib/utils.ts","./src/stores/workflow-store.ts","./src/types/events.ts"],"version":"5.9.3"} \ No newline at end of file diff --git a/src/conductor/web/server.py b/src/conductor/web/server.py index cecacc36..26ae9fee 100644 --- a/src/conductor/web/server.py +++ b/src/conductor/web/server.py @@ -639,7 +639,7 @@ def _synth_for_each(name: str, output: Any) -> tuple[str, dict[str, Any], str, d def _synth_agent_or_script( name: str, agent_def: Any, output: Any ) -> tuple[str, dict[str, Any], str, dict[str, Any]]: - """Build synthetic (started, completed) event payloads for an agent/script.""" + """Build synthetic (started, completed) event payloads for an agent/script/wait.""" agent_type = getattr(agent_def, "type", None) or "agent" output_dict = output if isinstance(output, dict) else {} @@ -659,6 +659,26 @@ def _synth_agent_or_script( } return "script_started", started_data, "script_completed", completed_data + if agent_type == "wait": + waited = output_dict.get("waited_seconds", 0.0) + started_data = { + "agent_name": name, + "iteration": 1, + "duration_seconds": waited, + "reason": getattr(agent_def, "reason", None), + "synthetic": True, + } + completed_data = { + "agent_name": name, + "elapsed": waited, + "waited_seconds": waited, + "requested_seconds": waited, + "reason": getattr(agent_def, "reason", None), + "interrupted": False, + "synthetic": True, + } + return "wait_started", started_data, "wait_completed", completed_data + started_data = { "agent_name": name, "iteration": 1, diff --git a/src/conductor/web/static/assets/index-CYmT69M5.js b/src/conductor/web/static/assets/index-CYmT69M5.js new file mode 100644 index 00000000..238faae9 --- /dev/null +++ b/src/conductor/web/static/assets/index-CYmT69M5.js @@ -0,0 +1,351 @@ +var FE=Object.defineProperty;var YE=(e,t,r)=>t in e?FE(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var jt=(e,t,r)=>YE(e,typeof t!="symbol"?t+"":t,r);function XE(e,t){for(var r=0;rl[a]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))l(a);new MutationObserver(a=>{for(const o of a)if(o.type==="childList")for(const s of o.addedNodes)s.tagName==="LINK"&&s.rel==="modulepreload"&&l(s)}).observe(document,{childList:!0,subtree:!0});function r(a){const o={};return a.integrity&&(o.integrity=a.integrity),a.referrerPolicy&&(o.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?o.credentials="include":a.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function l(a){if(a.ep)return;a.ep=!0;const o=r(a);fetch(a.href,o)}})();function Zo(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var oh={exports:{}},go={};/** + * @license React + * react-jsx-runtime.production.js + * + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var Py;function QE(){if(Py)return go;Py=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function r(l,a,o){var s=null;if(o!==void 0&&(s=""+o),a.key!==void 0&&(s=""+a.key),"key"in a){o={};for(var c in a)c!=="key"&&(o[c]=a[c])}else o=a;return a=o.ref,{$$typeof:e,type:l,key:s,ref:a!==void 0?a:null,props:o}}return go.Fragment=t,go.jsx=r,go.jsxs=r,go}var Gy;function ZE(){return Gy||(Gy=1,oh.exports=QE()),oh.exports}var y=ZE(),sh={exports:{}},Te={};/** + * @license React + * react.production.js + * + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var Fy;function KE(){if(Fy)return Te;Fy=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),r=Symbol.for("react.fragment"),l=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),o=Symbol.for("react.consumer"),s=Symbol.for("react.context"),c=Symbol.for("react.forward_ref"),h=Symbol.for("react.suspense"),d=Symbol.for("react.memo"),m=Symbol.for("react.lazy"),p=Symbol.for("react.activity"),x=Symbol.iterator;function b(q){return q===null||typeof q!="object"?null:(q=x&&q[x]||q["@@iterator"],typeof q=="function"?q:null)}var w={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},E=Object.assign,S={};function _(q,Y,C){this.props=q,this.context=Y,this.refs=S,this.updater=C||w}_.prototype.isReactComponent={},_.prototype.setState=function(q,Y){if(typeof q!="object"&&typeof q!="function"&&q!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,q,Y,"setState")},_.prototype.forceUpdate=function(q){this.updater.enqueueForceUpdate(this,q,"forceUpdate")};function N(){}N.prototype=_.prototype;function k(q,Y,C){this.props=q,this.context=Y,this.refs=S,this.updater=C||w}var T=k.prototype=new N;T.constructor=k,E(T,_.prototype),T.isPureReactComponent=!0;var M=Array.isArray;function A(){}var L={H:null,A:null,T:null,S:null},R=Object.prototype.hasOwnProperty;function V(q,Y,C){var P=C.ref;return{$$typeof:e,type:q,key:Y,ref:P!==void 0?P:null,props:C}}function H(q,Y){return V(q.type,Y,q.props)}function B(q){return typeof q=="object"&&q!==null&&q.$$typeof===e}function $(q){var Y={"=":"=0",":":"=2"};return"$"+q.replace(/[=:]/g,function(C){return Y[C]})}var ee=/\/+/g;function I(q,Y){return typeof q=="object"&&q!==null&&q.key!=null?$(""+q.key):Y.toString(36)}function F(q){switch(q.status){case"fulfilled":return q.value;case"rejected":throw q.reason;default:switch(typeof q.status=="string"?q.then(A,A):(q.status="pending",q.then(function(Y){q.status==="pending"&&(q.status="fulfilled",q.value=Y)},function(Y){q.status==="pending"&&(q.status="rejected",q.reason=Y)})),q.status){case"fulfilled":return q.value;case"rejected":throw q.reason}}throw q}function z(q,Y,C,P,X){var J=typeof q;(J==="undefined"||J==="boolean")&&(q=null);var ne=!1;if(q===null)ne=!0;else switch(J){case"bigint":case"string":case"number":ne=!0;break;case"object":switch(q.$$typeof){case e:case t:ne=!0;break;case m:return ne=q._init,z(ne(q._payload),Y,C,P,X)}}if(ne)return X=X(q),ne=P===""?"."+I(q,0):P,M(X)?(C="",ne!=null&&(C=ne.replace(ee,"$&/")+"/"),z(X,Y,C,"",function(xe){return xe})):X!=null&&(B(X)&&(X=H(X,C+(X.key==null||q&&q.key===X.key?"":(""+X.key).replace(ee,"$&/")+"/")+ne)),Y.push(X)),1;ne=0;var re=P===""?".":P+":";if(M(q))for(var se=0;se>>1,D=z[K];if(0>>1;Ka(C,Q))Pa(X,C)?(z[K]=X,z[P]=Q,K=P):(z[K]=C,z[Y]=Q,K=Y);else if(Pa(X,Q))z[K]=X,z[P]=Q,K=P;else break e}}return G}function a(z,G){var Q=z.sortIndex-G.sortIndex;return Q!==0?Q:z.id-G.id}if(e.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var o=performance;e.unstable_now=function(){return o.now()}}else{var s=Date,c=s.now();e.unstable_now=function(){return s.now()-c}}var h=[],d=[],m=1,p=null,x=3,b=!1,w=!1,E=!1,S=!1,_=typeof setTimeout=="function"?setTimeout:null,N=typeof clearTimeout=="function"?clearTimeout:null,k=typeof setImmediate<"u"?setImmediate:null;function T(z){for(var G=r(d);G!==null;){if(G.callback===null)l(d);else if(G.startTime<=z)l(d),G.sortIndex=G.expirationTime,t(h,G);else break;G=r(d)}}function M(z){if(E=!1,T(z),!w)if(r(h)!==null)w=!0,A||(A=!0,$());else{var G=r(d);G!==null&&F(M,G.startTime-z)}}var A=!1,L=-1,R=5,V=-1;function H(){return S?!0:!(e.unstable_now()-Vz&&H());){var K=p.callback;if(typeof K=="function"){p.callback=null,x=p.priorityLevel;var D=K(p.expirationTime<=z);if(z=e.unstable_now(),typeof D=="function"){p.callback=D,T(z),G=!0;break t}p===r(h)&&l(h),T(z)}else l(h);p=r(h)}if(p!==null)G=!0;else{var q=r(d);q!==null&&F(M,q.startTime-z),G=!1}}break e}finally{p=null,x=Q,b=!1}G=void 0}}finally{G?$():A=!1}}}var $;if(typeof k=="function")$=function(){k(B)};else if(typeof MessageChannel<"u"){var ee=new MessageChannel,I=ee.port2;ee.port1.onmessage=B,$=function(){I.postMessage(null)}}else $=function(){_(B,0)};function F(z,G){L=_(function(){z(e.unstable_now())},G)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(z){z.callback=null},e.unstable_forceFrameRate=function(z){0>z||125K?(z.sortIndex=Q,t(d,z),r(h)===null&&z===r(d)&&(E?(N(L),L=-1):E=!0,F(M,Q-K))):(z.sortIndex=D,t(h,z),w||b||(w=!0,A||(A=!0,$()))),z},e.unstable_shouldYield=H,e.unstable_wrapCallback=function(z){var G=x;return function(){var Q=x;x=G;try{return z.apply(this,arguments)}finally{x=Q}}}})(fh)),fh}var Qy;function eN(){return Qy||(Qy=1,ch.exports=WE()),ch.exports}var dh={exports:{}},Yt={};/** + * @license React + * react-dom.production.js + * + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var Zy;function tN(){if(Zy)return Yt;Zy=1;var e=Ko();function t(h){var d="https://react.dev/errors/"+h;if(1"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),dh.exports=tN(),dh.exports}/** + * @license React + * react-dom-client.production.js + * + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var Jy;function nN(){if(Jy)return xo;Jy=1;var e=eN(),t=Ko(),r=pw();function l(n){var i="https://react.dev/errors/"+n;if(1D||(n.current=K[D],K[D]=null,D--)}function C(n,i){D++,K[D]=n.current,n.current=i}var P=q(null),X=q(null),J=q(null),ne=q(null);function re(n,i){switch(C(J,i),C(X,n),C(P,null),i.nodeType){case 9:case 11:n=(n=i.documentElement)&&(n=n.namespaceURI)?hy(n):0;break;default:if(n=i.tagName,i=i.namespaceURI)i=hy(i),n=py(i,n);else switch(n){case"svg":n=1;break;case"math":n=2;break;default:n=0}}Y(P),C(P,n)}function se(){Y(P),Y(X),Y(J)}function xe(n){n.memoizedState!==null&&C(ne,n);var i=P.current,u=py(i,n.type);i!==u&&(C(X,n),C(P,u))}function be(n){X.current===n&&(Y(P),Y(X)),ne.current===n&&(Y(ne),fo._currentValue=Q)}var ye,pe;function Se(n){if(ye===void 0)try{throw Error()}catch(u){var i=u.stack.trim().match(/\n( *(at )?)/);ye=i&&i[1]||"",pe=-1)":-1g||Z[f]!==le[g]){var fe=` +`+Z[f].replace(" at new "," at ");return n.displayName&&fe.includes("")&&(fe=fe.replace("",n.displayName)),fe}while(1<=f&&0<=g);break}}}finally{De=!1,Error.prepareStackTrace=u}return(u=n?n.displayName||n.name:"")?Se(u):""}function ct(n,i){switch(n.tag){case 26:case 27:case 5:return Se(n.type);case 16:return Se("Lazy");case 13:return n.child!==i&&i!==null?Se("Suspense Fallback"):Se("Suspense");case 19:return Se("SuspenseList");case 0:case 15:return je(n.type,!1);case 11:return je(n.type.render,!1);case 1:return je(n.type,!0);case 31:return Se("Activity");default:return""}}function nt(n){try{var i="",u=null;do i+=ct(n,u),u=n,n=n.return;while(n);return i}catch(f){return` +Error generating stack: `+f.message+` +`+f.stack}}var Dt=Object.prototype.hasOwnProperty,Pt=e.unstable_scheduleCallback,Bt=e.unstable_cancelCallback,kn=e.unstable_shouldYield,Rn=e.unstable_requestPaint,Rt=e.unstable_now,Br=e.unstable_getCurrentPriorityLevel,ce=e.unstable_ImmediatePriority,ge=e.unstable_UserBlockingPriority,Ne=e.unstable_NormalPriority,Be=e.unstable_LowPriority,Xe=e.unstable_IdlePriority,Zt=e.log,On=e.unstable_setDisableYieldValue,It=null,bt=null;function Gt(n){if(typeof Zt=="function"&&On(n),bt&&typeof bt.setStrictMode=="function")try{bt.setStrictMode(It,n)}catch{}}var We=Math.clz32?Math.clz32:Xc,Qn=Math.log,fn=Math.LN2;function Xc(n){return n>>>=0,n===0?32:31-(Qn(n)/fn|0)|0}var fl=256,dl=262144,hl=4194304;function sr(n){var i=n&42;if(i!==0)return i;switch(n&-n){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return n&261888;case 262144:case 524288:case 1048576:case 2097152:return n&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return n&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return n}}function pl(n,i,u){var f=n.pendingLanes;if(f===0)return 0;var g=0,v=n.suspendedLanes,j=n.pingedLanes;n=n.warmLanes;var O=f&134217727;return O!==0?(f=O&~v,f!==0?g=sr(f):(j&=O,j!==0?g=sr(j):u||(u=O&~n,u!==0&&(g=sr(u))))):(O=f&~v,O!==0?g=sr(O):j!==0?g=sr(j):u||(u=f&~n,u!==0&&(g=sr(u)))),g===0?0:i!==0&&i!==g&&(i&v)===0&&(v=g&-g,u=i&-i,v>=u||v===32&&(u&4194048)!==0)?i:g}function Si(n,i){return(n.pendingLanes&~(n.suspendedLanes&~n.pingedLanes)&i)===0}function Qc(n,i){switch(n){case 1:case 2:case 4:case 8:case 64:return i+250;case 16:case 32: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 i+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function cs(){var n=hl;return hl<<=1,(hl&62914560)===0&&(hl=4194304),n}function _a(n){for(var i=[],u=0;31>u;u++)i.push(n);return i}function ki(n,i){n.pendingLanes|=i,i!==268435456&&(n.suspendedLanes=0,n.pingedLanes=0,n.warmLanes=0)}function Zc(n,i,u,f,g,v){var j=n.pendingLanes;n.pendingLanes=u,n.suspendedLanes=0,n.pingedLanes=0,n.warmLanes=0,n.expiredLanes&=u,n.entangledLanes&=u,n.errorRecoveryDisabledLanes&=u,n.shellSuspendCounter=0;var O=n.entanglements,Z=n.expirationTimes,le=n.hiddenUpdates;for(u=j&~u;0"u")return null;try{return n.activeElement||n.body}catch{return n.body}}var tf=/[\n"\\]/g;function en(n){return n.replace(tf,function(i){return"\\"+i.charCodeAt(0).toString(16)+" "})}function Ci(n,i,u,f,g,v,j,O){n.name="",j!=null&&typeof j!="function"&&typeof j!="symbol"&&typeof j!="boolean"?n.type=j:n.removeAttribute("type"),i!=null?j==="number"?(i===0&&n.value===""||n.value!=i)&&(n.value=""+Wt(i)):n.value!==""+Wt(i)&&(n.value=""+Wt(i)):j!=="submit"&&j!=="reset"||n.removeAttribute("value"),i!=null?Ca(n,j,Wt(i)):u!=null?Ca(n,j,Wt(u)):f!=null&&n.removeAttribute("value"),g==null&&v!=null&&(n.defaultChecked=!!v),g!=null&&(n.checked=g&&typeof g!="function"&&typeof g!="symbol"),O!=null&&typeof O!="function"&&typeof O!="symbol"&&typeof O!="boolean"?n.name=""+Wt(O):n.removeAttribute("name")}function Ss(n,i,u,f,g,v,j,O){if(v!=null&&typeof v!="function"&&typeof v!="symbol"&&typeof v!="boolean"&&(n.type=v),i!=null||u!=null){if(!(v!=="submit"&&v!=="reset"||i!=null)){Pr(n);return}u=u!=null?""+Wt(u):"",i=i!=null?""+Wt(i):u,O||i===n.value||(n.value=i),n.defaultValue=i}f=f??g,f=typeof f!="function"&&typeof f!="symbol"&&!!f,n.checked=O?n.checked:!!f,n.defaultChecked=!!f,j!=null&&typeof j!="function"&&typeof j!="symbol"&&typeof j!="boolean"&&(n.name=j),Pr(n)}function Ca(n,i,u){i==="number"&&Ni(n.ownerDocument)===n||n.defaultValue===""+u||(n.defaultValue=""+u)}function fr(n,i,u,f){if(n=n.options,i){i={};for(var g=0;g"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),of=!1;if(hr)try{var Ta={};Object.defineProperty(Ta,"passive",{get:function(){of=!0}}),window.addEventListener("test",Ta,Ta),window.removeEventListener("test",Ta,Ta)}catch{of=!1}var Gr=null,sf=null,Es=null;function pg(){if(Es)return Es;var n,i=sf,u=i.length,f,g="value"in Gr?Gr.value:Gr.textContent,v=g.length;for(n=0;n=Ma),bg=" ",wg=!1;function _g(n,i){switch(n){case"keyup":return p2.indexOf(i.keyCode)!==-1;case"keydown":return i.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Sg(n){return n=n.detail,typeof n=="object"&&"data"in n?n.data:null}var wl=!1;function g2(n,i){switch(n){case"compositionend":return Sg(i);case"keypress":return i.which!==32?null:(wg=!0,bg);case"textInput":return n=i.data,n===bg&&wg?null:n;default:return null}}function x2(n,i){if(wl)return n==="compositionend"||!hf&&_g(n,i)?(n=pg(),Es=sf=Gr=null,wl=!1,n):null;switch(n){case"paste":return null;case"keypress":if(!(i.ctrlKey||i.altKey||i.metaKey)||i.ctrlKey&&i.altKey){if(i.char&&1=i)return{node:u,offset:i-n};n=f}e:{for(;u;){if(u.nextSibling){u=u.nextSibling;break e}u=u.parentNode}u=void 0}u=zg(u)}}function Dg(n,i){return n&&i?n===i?!0:n&&n.nodeType===3?!1:i&&i.nodeType===3?Dg(n,i.parentNode):"contains"in n?n.contains(i):n.compareDocumentPosition?!!(n.compareDocumentPosition(i)&16):!1:!1}function Rg(n){n=n!=null&&n.ownerDocument!=null&&n.ownerDocument.defaultView!=null?n.ownerDocument.defaultView:window;for(var i=Ni(n.document);i instanceof n.HTMLIFrameElement;){try{var u=typeof i.contentWindow.location.href=="string"}catch{u=!1}if(u)n=i.contentWindow;else break;i=Ni(n.document)}return i}function gf(n){var i=n&&n.nodeName&&n.nodeName.toLowerCase();return i&&(i==="input"&&(n.type==="text"||n.type==="search"||n.type==="tel"||n.type==="url"||n.type==="password")||i==="textarea"||n.contentEditable==="true")}var E2=hr&&"documentMode"in document&&11>=document.documentMode,_l=null,xf=null,La=null,yf=!1;function Og(n,i,u){var f=u.window===u?u.document:u.nodeType===9?u:u.ownerDocument;yf||_l==null||_l!==Ni(f)||(f=_l,"selectionStart"in f&&gf(f)?f={start:f.selectionStart,end:f.selectionEnd}:(f=(f.ownerDocument&&f.ownerDocument.defaultView||window).getSelection(),f={anchorNode:f.anchorNode,anchorOffset:f.anchorOffset,focusNode:f.focusNode,focusOffset:f.focusOffset}),La&&Oa(La,f)||(La=f,f=yu(xf,"onSelect"),0>=j,g-=j,Kn=1<<32-We(i)+g|u<Re?(Ge=_e,_e=null):Ge=_e.sibling;var Ke=ae(te,_e,ie[Re],de);if(Ke===null){_e===null&&(_e=Ge);break}n&&_e&&Ke.alternate===null&&i(te,_e),W=v(Ke,W,Re),Ze===null?ke=Ke:Ze.sibling=Ke,Ze=Ke,_e=Ge}if(Re===ie.length)return u(te,_e),Fe&&mr(te,Re),ke;if(_e===null){for(;ReRe?(Ge=_e,_e=null):Ge=_e.sibling;var hi=ae(te,_e,Ke.value,de);if(hi===null){_e===null&&(_e=Ge);break}n&&_e&&hi.alternate===null&&i(te,_e),W=v(hi,W,Re),Ze===null?ke=hi:Ze.sibling=hi,Ze=hi,_e=Ge}if(Ke.done)return u(te,_e),Fe&&mr(te,Re),ke;if(_e===null){for(;!Ke.done;Re++,Ke=ie.next())Ke=he(te,Ke.value,de),Ke!==null&&(W=v(Ke,W,Re),Ze===null?ke=Ke:Ze.sibling=Ke,Ze=Ke);return Fe&&mr(te,Re),ke}for(_e=f(_e);!Ke.done;Re++,Ke=ie.next())Ke=oe(_e,te,Re,Ke.value,de),Ke!==null&&(n&&Ke.alternate!==null&&_e.delete(Ke.key===null?Re:Ke.key),W=v(Ke,W,Re),Ze===null?ke=Ke:Ze.sibling=Ke,Ze=Ke);return n&&_e.forEach(function(GE){return i(te,GE)}),Fe&&mr(te,Re),ke}function lt(te,W,ie,de){if(typeof ie=="object"&&ie!==null&&ie.type===E&&ie.key===null&&(ie=ie.props.children),typeof ie=="object"&&ie!==null){switch(ie.$$typeof){case b:e:{for(var ke=ie.key;W!==null;){if(W.key===ke){if(ke=ie.type,ke===E){if(W.tag===7){u(te,W.sibling),de=g(W,ie.props.children),de.return=te,te=de;break e}}else if(W.elementType===ke||typeof ke=="object"&&ke!==null&&ke.$$typeof===R&&Hi(ke)===W.type){u(te,W.sibling),de=g(W,ie.props),$a(de,ie),de.return=te,te=de;break e}u(te,W);break}else i(te,W);W=W.sibling}ie.type===E?(de=Mi(ie.props.children,te.mode,de,ie.key),de.return=te,te=de):(de=Os(ie.type,ie.key,ie.props,null,te.mode,de),$a(de,ie),de.return=te,te=de)}return j(te);case w:e:{for(ke=ie.key;W!==null;){if(W.key===ke)if(W.tag===4&&W.stateNode.containerInfo===ie.containerInfo&&W.stateNode.implementation===ie.implementation){u(te,W.sibling),de=g(W,ie.children||[]),de.return=te,te=de;break e}else{u(te,W);break}else i(te,W);W=W.sibling}de=Ef(ie,te.mode,de),de.return=te,te=de}return j(te);case R:return ie=Hi(ie),lt(te,W,ie,de)}if(F(ie))return we(te,W,ie,de);if($(ie)){if(ke=$(ie),typeof ke!="function")throw Error(l(150));return ie=ke.call(ie),Ce(te,W,ie,de)}if(typeof ie.then=="function")return lt(te,W,$s(ie),de);if(ie.$$typeof===k)return lt(te,W,Bs(te,ie),de);Vs(te,ie)}return typeof ie=="string"&&ie!==""||typeof ie=="number"||typeof ie=="bigint"?(ie=""+ie,W!==null&&W.tag===6?(u(te,W.sibling),de=g(W,ie),de.return=te,te=de):(u(te,W),de=kf(ie,te.mode,de),de.return=te,te=de),j(te)):u(te,W)}return function(te,W,ie,de){try{Ua=0;var ke=lt(te,W,ie,de);return Dl=null,ke}catch(_e){if(_e===Ml||_e===qs)throw _e;var Ze=hn(29,_e,null,te.mode);return Ze.lanes=de,Ze.return=te,Ze}finally{}}}var Ii=ix(!0),lx=ix(!1),Zr=!1;function Hf(n){n.updateQueue={baseState:n.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Bf(n,i){n=n.updateQueue,i.updateQueue===n&&(i.updateQueue={baseState:n.baseState,firstBaseUpdate:n.firstBaseUpdate,lastBaseUpdate:n.lastBaseUpdate,shared:n.shared,callbacks:null})}function Kr(n){return{lane:n,tag:0,payload:null,callback:null,next:null}}function Jr(n,i,u){var f=n.updateQueue;if(f===null)return null;if(f=f.shared,(Je&2)!==0){var g=f.pending;return g===null?i.next=i:(i.next=g.next,g.next=i),f.pending=i,i=Rs(n),$g(n,null,u),i}return Ds(n,f,i,u),Rs(n)}function Va(n,i,u){if(i=i.updateQueue,i!==null&&(i=i.shared,(u&4194048)!==0)){var f=i.lanes;f&=n.pendingLanes,u|=f,i.lanes=u,ds(n,u)}}function If(n,i){var u=n.updateQueue,f=n.alternate;if(f!==null&&(f=f.updateQueue,u===f)){var g=null,v=null;if(u=u.firstBaseUpdate,u!==null){do{var j={lane:u.lane,tag:u.tag,payload:u.payload,callback:null,next:null};v===null?g=v=j:v=v.next=j,u=u.next}while(u!==null);v===null?g=v=i:v=v.next=i}else g=v=i;u={baseState:f.baseState,firstBaseUpdate:g,lastBaseUpdate:v,shared:f.shared,callbacks:f.callbacks},n.updateQueue=u;return}n=u.lastBaseUpdate,n===null?u.firstBaseUpdate=i:n.next=i,u.lastBaseUpdate=i}var qf=!1;function Pa(){if(qf){var n=zl;if(n!==null)throw n}}function Ga(n,i,u,f){qf=!1;var g=n.updateQueue;Zr=!1;var v=g.firstBaseUpdate,j=g.lastBaseUpdate,O=g.shared.pending;if(O!==null){g.shared.pending=null;var Z=O,le=Z.next;Z.next=null,j===null?v=le:j.next=le,j=Z;var fe=n.alternate;fe!==null&&(fe=fe.updateQueue,O=fe.lastBaseUpdate,O!==j&&(O===null?fe.firstBaseUpdate=le:O.next=le,fe.lastBaseUpdate=Z))}if(v!==null){var he=g.baseState;j=0,fe=le=Z=null,O=v;do{var ae=O.lane&-536870913,oe=ae!==O.lane;if(oe?(Pe&ae)===ae:(f&ae)===ae){ae!==0&&ae===Al&&(qf=!0),fe!==null&&(fe=fe.next={lane:0,tag:O.tag,payload:O.payload,callback:null,next:null});e:{var we=n,Ce=O;ae=i;var lt=u;switch(Ce.tag){case 1:if(we=Ce.payload,typeof we=="function"){he=we.call(lt,he,ae);break e}he=we;break e;case 3:we.flags=we.flags&-65537|128;case 0:if(we=Ce.payload,ae=typeof we=="function"?we.call(lt,he,ae):we,ae==null)break e;he=p({},he,ae);break e;case 2:Zr=!0}}ae=O.callback,ae!==null&&(n.flags|=64,oe&&(n.flags|=8192),oe=g.callbacks,oe===null?g.callbacks=[ae]:oe.push(ae))}else oe={lane:ae,tag:O.tag,payload:O.payload,callback:O.callback,next:null},fe===null?(le=fe=oe,Z=he):fe=fe.next=oe,j|=ae;if(O=O.next,O===null){if(O=g.shared.pending,O===null)break;oe=O,O=oe.next,oe.next=null,g.lastBaseUpdate=oe,g.shared.pending=null}}while(!0);fe===null&&(Z=he),g.baseState=Z,g.firstBaseUpdate=le,g.lastBaseUpdate=fe,v===null&&(g.shared.lanes=0),ri|=j,n.lanes=j,n.memoizedState=he}}function ax(n,i){if(typeof n!="function")throw Error(l(191,n));n.call(i)}function ox(n,i){var u=n.callbacks;if(u!==null)for(n.callbacks=null,n=0;nv?v:8;var j=z.T,O={};z.T=O,ld(n,!1,i,u);try{var Z=g(),le=z.S;if(le!==null&&le(O,Z),Z!==null&&typeof Z=="object"&&typeof Z.then=="function"){var fe=R2(Z,f);Xa(n,i,fe,yn(n))}else Xa(n,i,f,yn(n))}catch(he){Xa(n,i,{then:function(){},status:"rejected",reason:he},yn())}finally{G.p=v,j!==null&&O.types!==null&&(j.types=O.types),z.T=j}}function q2(){}function rd(n,i,u,f){if(n.tag!==5)throw Error(l(476));var g=Ix(n).queue;Bx(n,g,i,Q,u===null?q2:function(){return qx(n),u(f)})}function Ix(n){var i=n.memoizedState;if(i!==null)return i;i={memoizedState:Q,baseState:Q,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:vr,lastRenderedState:Q},next:null};var u={};return i.next={memoizedState:u,baseState:u,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:vr,lastRenderedState:u},next:null},n.memoizedState=i,n=n.alternate,n!==null&&(n.memoizedState=i),i}function qx(n){var i=Ix(n);i.next===null&&(i=n.alternate.memoizedState),Xa(n,i.next.queue,{},yn())}function id(){return Ut(fo)}function Ux(){return _t().memoizedState}function $x(){return _t().memoizedState}function U2(n){for(var i=n.return;i!==null;){switch(i.tag){case 24:case 3:var u=yn();n=Kr(u);var f=Jr(i,n,u);f!==null&&(on(f,i,u),Va(f,i,u)),i={cache:Df()},n.payload=i;return}i=i.return}}function $2(n,i,u){var f=yn();u={lane:f,revertLane:0,gesture:null,action:u,hasEagerState:!1,eagerState:null,next:null},Ws(n)?Px(i,u):(u=_f(n,i,u,f),u!==null&&(on(u,n,f),Gx(u,i,f)))}function Vx(n,i,u){var f=yn();Xa(n,i,u,f)}function Xa(n,i,u,f){var g={lane:f,revertLane:0,gesture:null,action:u,hasEagerState:!1,eagerState:null,next:null};if(Ws(n))Px(i,g);else{var v=n.alternate;if(n.lanes===0&&(v===null||v.lanes===0)&&(v=i.lastRenderedReducer,v!==null))try{var j=i.lastRenderedState,O=v(j,u);if(g.hasEagerState=!0,g.eagerState=O,dn(O,j))return Ds(n,i,g,0),at===null&&Ms(),!1}catch{}finally{}if(u=_f(n,i,g,f),u!==null)return on(u,n,f),Gx(u,i,f),!0}return!1}function ld(n,i,u,f){if(f={lane:2,revertLane:Hd(),gesture:null,action:f,hasEagerState:!1,eagerState:null,next:null},Ws(n)){if(i)throw Error(l(479))}else i=_f(n,u,f,2),i!==null&&on(i,n,2)}function Ws(n){var i=n.alternate;return n===ze||i!==null&&i===ze}function Px(n,i){Ol=Fs=!0;var u=n.pending;u===null?i.next=i:(i.next=u.next,u.next=i),n.pending=i}function Gx(n,i,u){if((u&4194048)!==0){var f=i.lanes;f&=n.pendingLanes,u|=f,i.lanes=u,ds(n,u)}}var Qa={readContext:Ut,use:Qs,useCallback:xt,useContext:xt,useEffect:xt,useImperativeHandle:xt,useLayoutEffect:xt,useInsertionEffect:xt,useMemo:xt,useReducer:xt,useRef:xt,useState:xt,useDebugValue:xt,useDeferredValue:xt,useTransition:xt,useSyncExternalStore:xt,useId:xt,useHostTransitionStatus:xt,useFormState:xt,useActionState:xt,useOptimistic:xt,useMemoCache:xt,useCacheRefresh:xt};Qa.useEffectEvent=xt;var Fx={readContext:Ut,use:Qs,useCallback:function(n,i){return Kt().memoizedState=[n,i===void 0?null:i],n},useContext:Ut,useEffect:Tx,useImperativeHandle:function(n,i,u){u=u!=null?u.concat([n]):null,Ks(4194308,4,Dx.bind(null,i,n),u)},useLayoutEffect:function(n,i){return Ks(4194308,4,n,i)},useInsertionEffect:function(n,i){Ks(4,2,n,i)},useMemo:function(n,i){var u=Kt();i=i===void 0?null:i;var f=n();if(qi){Gt(!0);try{n()}finally{Gt(!1)}}return u.memoizedState=[f,i],f},useReducer:function(n,i,u){var f=Kt();if(u!==void 0){var g=u(i);if(qi){Gt(!0);try{u(i)}finally{Gt(!1)}}}else g=i;return f.memoizedState=f.baseState=g,n={pending:null,lanes:0,dispatch:null,lastRenderedReducer:n,lastRenderedState:g},f.queue=n,n=n.dispatch=$2.bind(null,ze,n),[f.memoizedState,n]},useRef:function(n){var i=Kt();return n={current:n},i.memoizedState=n},useState:function(n){n=Jf(n);var i=n.queue,u=Vx.bind(null,ze,i);return i.dispatch=u,[n.memoizedState,u]},useDebugValue:td,useDeferredValue:function(n,i){var u=Kt();return nd(u,n,i)},useTransition:function(){var n=Jf(!1);return n=Bx.bind(null,ze,n.queue,!0,!1),Kt().memoizedState=n,[!1,n]},useSyncExternalStore:function(n,i,u){var f=ze,g=Kt();if(Fe){if(u===void 0)throw Error(l(407));u=u()}else{if(u=i(),at===null)throw Error(l(349));(Pe&127)!==0||hx(f,i,u)}g.memoizedState=u;var v={value:u,getSnapshot:i};return g.queue=v,Tx(mx.bind(null,f,v,n),[n]),f.flags|=2048,Hl(9,{destroy:void 0},px.bind(null,f,v,u,i),null),u},useId:function(){var n=Kt(),i=at.identifierPrefix;if(Fe){var u=Jn,f=Kn;u=(f&~(1<<32-We(f)-1)).toString(32)+u,i="_"+i+"R_"+u,u=Ys++,0<\/script>",v=v.removeChild(v.firstChild);break;case"select":v=typeof f.is=="string"?j.createElement("select",{is:f.is}):j.createElement("select"),f.multiple?v.multiple=!0:f.size&&(v.size=f.size);break;default:v=typeof f.is=="string"?j.createElement(g,{is:f.is}):j.createElement(g)}}v[Ot]=i,v[Ft]=f;e:for(j=i.child;j!==null;){if(j.tag===5||j.tag===6)v.appendChild(j.stateNode);else if(j.tag!==4&&j.tag!==27&&j.child!==null){j.child.return=j,j=j.child;continue}if(j===i)break e;for(;j.sibling===null;){if(j.return===null||j.return===i)break e;j=j.return}j.sibling.return=j.return,j=j.sibling}i.stateNode=v;e:switch(Vt(v,g,f),g){case"button":case"input":case"select":case"textarea":f=!!f.autoFocus;break e;case"img":f=!0;break e;default:f=!1}f&&wr(i)}}return dt(i),vd(i,i.type,n===null?null:n.memoizedProps,i.pendingProps,u),null;case 6:if(n&&i.stateNode!=null)n.memoizedProps!==f&&wr(i);else{if(typeof f!="string"&&i.stateNode===null)throw Error(l(166));if(n=J.current,jl(i)){if(n=i.stateNode,u=i.memoizedProps,f=null,g=qt,g!==null)switch(g.tag){case 27:case 5:f=g.memoizedProps}n[Ot]=i,n=!!(n.nodeValue===u||f!==null&&f.suppressHydrationWarning===!0||fy(n.nodeValue,u)),n||Xr(i,!0)}else n=vu(n).createTextNode(f),n[Ot]=i,i.stateNode=n}return dt(i),null;case 31:if(u=i.memoizedState,n===null||n.memoizedState!==null){if(f=jl(i),u!==null){if(n===null){if(!f)throw Error(l(318));if(n=i.memoizedState,n=n!==null?n.dehydrated:null,!n)throw Error(l(557));n[Ot]=i}else Di(),(i.flags&128)===0&&(i.memoizedState=null),i.flags|=4;dt(i),n=!1}else u=Tf(),n!==null&&n.memoizedState!==null&&(n.memoizedState.hydrationErrors=u),n=!0;if(!n)return i.flags&256?(mn(i),i):(mn(i),null);if((i.flags&128)!==0)throw Error(l(558))}return dt(i),null;case 13:if(f=i.memoizedState,n===null||n.memoizedState!==null&&n.memoizedState.dehydrated!==null){if(g=jl(i),f!==null&&f.dehydrated!==null){if(n===null){if(!g)throw Error(l(318));if(g=i.memoizedState,g=g!==null?g.dehydrated:null,!g)throw Error(l(317));g[Ot]=i}else Di(),(i.flags&128)===0&&(i.memoizedState=null),i.flags|=4;dt(i),g=!1}else g=Tf(),n!==null&&n.memoizedState!==null&&(n.memoizedState.hydrationErrors=g),g=!0;if(!g)return i.flags&256?(mn(i),i):(mn(i),null)}return mn(i),(i.flags&128)!==0?(i.lanes=u,i):(u=f!==null,n=n!==null&&n.memoizedState!==null,u&&(f=i.child,g=null,f.alternate!==null&&f.alternate.memoizedState!==null&&f.alternate.memoizedState.cachePool!==null&&(g=f.alternate.memoizedState.cachePool.pool),v=null,f.memoizedState!==null&&f.memoizedState.cachePool!==null&&(v=f.memoizedState.cachePool.pool),v!==g&&(f.flags|=2048)),u!==n&&u&&(i.child.flags|=8192),iu(i,i.updateQueue),dt(i),null);case 4:return se(),n===null&&Ud(i.stateNode.containerInfo),dt(i),null;case 10:return xr(i.type),dt(i),null;case 19:if(Y(wt),f=i.memoizedState,f===null)return dt(i),null;if(g=(i.flags&128)!==0,v=f.rendering,v===null)if(g)Ka(f,!1);else{if(yt!==0||n!==null&&(n.flags&128)!==0)for(n=i.child;n!==null;){if(v=Gs(n),v!==null){for(i.flags|=128,Ka(f,!1),n=v.updateQueue,i.updateQueue=n,iu(i,n),i.subtreeFlags=0,n=u,u=i.child;u!==null;)Vg(u,n),u=u.sibling;return C(wt,wt.current&1|2),Fe&&mr(i,f.treeForkCount),i.child}n=n.sibling}f.tail!==null&&Rt()>uu&&(i.flags|=128,g=!0,Ka(f,!1),i.lanes=4194304)}else{if(!g)if(n=Gs(v),n!==null){if(i.flags|=128,g=!0,n=n.updateQueue,i.updateQueue=n,iu(i,n),Ka(f,!0),f.tail===null&&f.tailMode==="hidden"&&!v.alternate&&!Fe)return dt(i),null}else 2*Rt()-f.renderingStartTime>uu&&u!==536870912&&(i.flags|=128,g=!0,Ka(f,!1),i.lanes=4194304);f.isBackwards?(v.sibling=i.child,i.child=v):(n=f.last,n!==null?n.sibling=v:i.child=v,f.last=v)}return f.tail!==null?(n=f.tail,f.rendering=n,f.tail=n.sibling,f.renderingStartTime=Rt(),n.sibling=null,u=wt.current,C(wt,g?u&1|2:u&1),Fe&&mr(i,f.treeForkCount),n):(dt(i),null);case 22:case 23:return mn(i),$f(),f=i.memoizedState!==null,n!==null?n.memoizedState!==null!==f&&(i.flags|=8192):f&&(i.flags|=8192),f?(u&536870912)!==0&&(i.flags&128)===0&&(dt(i),i.subtreeFlags&6&&(i.flags|=8192)):dt(i),u=i.updateQueue,u!==null&&iu(i,u.retryQueue),u=null,n!==null&&n.memoizedState!==null&&n.memoizedState.cachePool!==null&&(u=n.memoizedState.cachePool.pool),f=null,i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(f=i.memoizedState.cachePool.pool),f!==u&&(i.flags|=2048),n!==null&&Y(Li),null;case 24:return u=null,n!==null&&(u=n.memoizedState.cache),i.memoizedState.cache!==u&&(i.flags|=2048),xr(kt),dt(i),null;case 25:return null;case 30:return null}throw Error(l(156,i.tag))}function Y2(n,i){switch(Cf(i),i.tag){case 1:return n=i.flags,n&65536?(i.flags=n&-65537|128,i):null;case 3:return xr(kt),se(),n=i.flags,(n&65536)!==0&&(n&128)===0?(i.flags=n&-65537|128,i):null;case 26:case 27:case 5:return be(i),null;case 31:if(i.memoizedState!==null){if(mn(i),i.alternate===null)throw Error(l(340));Di()}return n=i.flags,n&65536?(i.flags=n&-65537|128,i):null;case 13:if(mn(i),n=i.memoizedState,n!==null&&n.dehydrated!==null){if(i.alternate===null)throw Error(l(340));Di()}return n=i.flags,n&65536?(i.flags=n&-65537|128,i):null;case 19:return Y(wt),null;case 4:return se(),null;case 10:return xr(i.type),null;case 22:case 23:return mn(i),$f(),n!==null&&Y(Li),n=i.flags,n&65536?(i.flags=n&-65537|128,i):null;case 24:return xr(kt),null;case 25:return null;default:return null}}function g0(n,i){switch(Cf(i),i.tag){case 3:xr(kt),se();break;case 26:case 27:case 5:be(i);break;case 4:se();break;case 31:i.memoizedState!==null&&mn(i);break;case 13:mn(i);break;case 19:Y(wt);break;case 10:xr(i.type);break;case 22:case 23:mn(i),$f(),n!==null&&Y(Li);break;case 24:xr(kt)}}function Ja(n,i){try{var u=i.updateQueue,f=u!==null?u.lastEffect:null;if(f!==null){var g=f.next;u=g;do{if((u.tag&n)===n){f=void 0;var v=u.create,j=u.inst;f=v(),j.destroy=f}u=u.next}while(u!==g)}}catch(O){tt(i,i.return,O)}}function ti(n,i,u){try{var f=i.updateQueue,g=f!==null?f.lastEffect:null;if(g!==null){var v=g.next;f=v;do{if((f.tag&n)===n){var j=f.inst,O=j.destroy;if(O!==void 0){j.destroy=void 0,g=i;var Z=u,le=O;try{le()}catch(fe){tt(g,Z,fe)}}}f=f.next}while(f!==v)}}catch(fe){tt(i,i.return,fe)}}function x0(n){var i=n.updateQueue;if(i!==null){var u=n.stateNode;try{ox(i,u)}catch(f){tt(n,n.return,f)}}}function y0(n,i,u){u.props=Ui(n.type,n.memoizedProps),u.state=n.memoizedState;try{u.componentWillUnmount()}catch(f){tt(n,i,f)}}function Wa(n,i){try{var u=n.ref;if(u!==null){switch(n.tag){case 26:case 27:case 5:var f=n.stateNode;break;case 30:f=n.stateNode;break;default:f=n.stateNode}typeof u=="function"?n.refCleanup=u(f):u.current=f}}catch(g){tt(n,i,g)}}function Wn(n,i){var u=n.ref,f=n.refCleanup;if(u!==null)if(typeof f=="function")try{f()}catch(g){tt(n,i,g)}finally{n.refCleanup=null,n=n.alternate,n!=null&&(n.refCleanup=null)}else if(typeof u=="function")try{u(null)}catch(g){tt(n,i,g)}else u.current=null}function v0(n){var i=n.type,u=n.memoizedProps,f=n.stateNode;try{e:switch(i){case"button":case"input":case"select":case"textarea":u.autoFocus&&f.focus();break e;case"img":u.src?f.src=u.src:u.srcSet&&(f.srcset=u.srcSet)}}catch(g){tt(n,n.return,g)}}function bd(n,i,u){try{var f=n.stateNode;mE(f,n.type,u,i),f[Ft]=i}catch(g){tt(n,n.return,g)}}function b0(n){return n.tag===5||n.tag===3||n.tag===26||n.tag===27&&si(n.type)||n.tag===4}function wd(n){e:for(;;){for(;n.sibling===null;){if(n.return===null||b0(n.return))return null;n=n.return}for(n.sibling.return=n.return,n=n.sibling;n.tag!==5&&n.tag!==6&&n.tag!==18;){if(n.tag===27&&si(n.type)||n.flags&2||n.child===null||n.tag===4)continue e;n.child.return=n,n=n.child}if(!(n.flags&2))return n.stateNode}}function _d(n,i,u){var f=n.tag;if(f===5||f===6)n=n.stateNode,i?(u.nodeType===9?u.body:u.nodeName==="HTML"?u.ownerDocument.body:u).insertBefore(n,i):(i=u.nodeType===9?u.body:u.nodeName==="HTML"?u.ownerDocument.body:u,i.appendChild(n),u=u._reactRootContainer,u!=null||i.onclick!==null||(i.onclick=dr));else if(f!==4&&(f===27&&si(n.type)&&(u=n.stateNode,i=null),n=n.child,n!==null))for(_d(n,i,u),n=n.sibling;n!==null;)_d(n,i,u),n=n.sibling}function lu(n,i,u){var f=n.tag;if(f===5||f===6)n=n.stateNode,i?u.insertBefore(n,i):u.appendChild(n);else if(f!==4&&(f===27&&si(n.type)&&(u=n.stateNode),n=n.child,n!==null))for(lu(n,i,u),n=n.sibling;n!==null;)lu(n,i,u),n=n.sibling}function w0(n){var i=n.stateNode,u=n.memoizedProps;try{for(var f=n.type,g=i.attributes;g.length;)i.removeAttributeNode(g[0]);Vt(i,f,u),i[Ot]=n,i[Ft]=u}catch(v){tt(n,n.return,v)}}var _r=!1,Ct=!1,Sd=!1,_0=typeof WeakSet=="function"?WeakSet:Set,Ht=null;function X2(n,i){if(n=n.containerInfo,Pd=Nu,n=Rg(n),gf(n)){if("selectionStart"in n)var u={start:n.selectionStart,end:n.selectionEnd};else e:{u=(u=n.ownerDocument)&&u.defaultView||window;var f=u.getSelection&&u.getSelection();if(f&&f.rangeCount!==0){u=f.anchorNode;var g=f.anchorOffset,v=f.focusNode;f=f.focusOffset;try{u.nodeType,v.nodeType}catch{u=null;break e}var j=0,O=-1,Z=-1,le=0,fe=0,he=n,ae=null;t:for(;;){for(var oe;he!==u||g!==0&&he.nodeType!==3||(O=j+g),he!==v||f!==0&&he.nodeType!==3||(Z=j+f),he.nodeType===3&&(j+=he.nodeValue.length),(oe=he.firstChild)!==null;)ae=he,he=oe;for(;;){if(he===n)break t;if(ae===u&&++le===g&&(O=j),ae===v&&++fe===f&&(Z=j),(oe=he.nextSibling)!==null)break;he=ae,ae=he.parentNode}he=oe}u=O===-1||Z===-1?null:{start:O,end:Z}}else u=null}u=u||{start:0,end:0}}else u=null;for(Gd={focusedElem:n,selectionRange:u},Nu=!1,Ht=i;Ht!==null;)if(i=Ht,n=i.child,(i.subtreeFlags&1028)!==0&&n!==null)n.return=i,Ht=n;else for(;Ht!==null;){switch(i=Ht,v=i.alternate,n=i.flags,i.tag){case 0:if((n&4)!==0&&(n=i.updateQueue,n=n!==null?n.events:null,n!==null))for(u=0;u title"))),Vt(v,f,u),v[Ot]=n,St(v),f=v;break e;case"link":var j=jy("link","href",g).get(f+(u.href||""));if(j){for(var O=0;Olt&&(j=lt,lt=Ce,Ce=j);var te=Mg(O,Ce),W=Mg(O,lt);if(te&&W&&(oe.rangeCount!==1||oe.anchorNode!==te.node||oe.anchorOffset!==te.offset||oe.focusNode!==W.node||oe.focusOffset!==W.offset)){var ie=he.createRange();ie.setStart(te.node,te.offset),oe.removeAllRanges(),Ce>lt?(oe.addRange(ie),oe.extend(W.node,W.offset)):(ie.setEnd(W.node,W.offset),oe.addRange(ie))}}}}for(he=[],oe=O;oe=oe.parentNode;)oe.nodeType===1&&he.push({element:oe,left:oe.scrollLeft,top:oe.scrollTop});for(typeof O.focus=="function"&&O.focus(),O=0;Ou?32:u,z.T=null,u=Ad,Ad=null;var v=li,j=Cr;if(Lt=0,$l=li=null,Cr=0,(Je&6)!==0)throw Error(l(331));var O=Je;if(Je|=4,D0(v.current),A0(v,v.current,j,u),Je=O,lo(0,!1),bt&&typeof bt.onPostCommitFiberRoot=="function")try{bt.onPostCommitFiberRoot(It,v)}catch{}return!0}finally{G.p=g,z.T=f,K0(n,i)}}function W0(n,i,u){i=Nn(u,i),i=ud(n.stateNode,i,2),n=Jr(n,i,2),n!==null&&(ki(n,2),er(n))}function tt(n,i,u){if(n.tag===3)W0(n,n,u);else for(;i!==null;){if(i.tag===3){W0(i,n,u);break}else if(i.tag===1){var f=i.stateNode;if(typeof i.type.getDerivedStateFromError=="function"||typeof f.componentDidCatch=="function"&&(ii===null||!ii.has(f))){n=Nn(u,n),u=e0(2),f=Jr(i,u,2),f!==null&&(t0(u,f,i,n),ki(f,2),er(f));break}}i=i.return}}function Rd(n,i,u){var f=n.pingCache;if(f===null){f=n.pingCache=new K2;var g=new Set;f.set(i,g)}else g=f.get(i),g===void 0&&(g=new Set,f.set(i,g));g.has(u)||(Nd=!0,g.add(u),n=nE.bind(null,n,i,u),i.then(n,n))}function nE(n,i,u){var f=n.pingCache;f!==null&&f.delete(i),n.pingedLanes|=n.suspendedLanes&u,n.warmLanes&=~u,at===n&&(Pe&u)===u&&(yt===4||yt===3&&(Pe&62914560)===Pe&&300>Rt()-su?(Je&2)===0&&Vl(n,0):Cd|=u,Ul===Pe&&(Ul=0)),er(n)}function ey(n,i){i===0&&(i=cs()),n=zi(n,i),n!==null&&(ki(n,i),er(n))}function rE(n){var i=n.memoizedState,u=0;i!==null&&(u=i.retryLane),ey(n,u)}function iE(n,i){var u=0;switch(n.tag){case 31:case 13:var f=n.stateNode,g=n.memoizedState;g!==null&&(u=g.retryLane);break;case 19:f=n.stateNode;break;case 22:f=n.stateNode._retryCache;break;default:throw Error(l(314))}f!==null&&f.delete(i),ey(n,u)}function lE(n,i){return Pt(n,i)}var mu=null,Gl=null,Od=!1,gu=!1,Ld=!1,oi=0;function er(n){n!==Gl&&n.next===null&&(Gl===null?mu=Gl=n:Gl=Gl.next=n),gu=!0,Od||(Od=!0,oE())}function lo(n,i){if(!Ld&&gu){Ld=!0;do for(var u=!1,f=mu;f!==null;){if(n!==0){var g=f.pendingLanes;if(g===0)var v=0;else{var j=f.suspendedLanes,O=f.pingedLanes;v=(1<<31-We(42|n)+1)-1,v&=g&~(j&~O),v=v&201326741?v&201326741|1:v?v|2:0}v!==0&&(u=!0,iy(f,v))}else v=Pe,v=pl(f,f===at?v:0,f.cancelPendingCommit!==null||f.timeoutHandle!==-1),(v&3)===0||Si(f,v)||(u=!0,iy(f,v));f=f.next}while(u);Ld=!1}}function aE(){ty()}function ty(){gu=Od=!1;var n=0;oi!==0&&xE()&&(n=oi);for(var i=Rt(),u=null,f=mu;f!==null;){var g=f.next,v=ny(f,i);v===0?(f.next=null,u===null?mu=g:u.next=g,g===null&&(Gl=u)):(u=f,(n!==0||(v&3)!==0)&&(gu=!0)),f=g}Lt!==0&&Lt!==5||lo(n),oi!==0&&(oi=0)}function ny(n,i){for(var u=n.suspendedLanes,f=n.pingedLanes,g=n.expirationTimes,v=n.pendingLanes&-62914561;0O)break;var fe=Z.transferSize,he=Z.initiatorType;fe&&dy(he)&&(Z=Z.responseEnd,j+=fe*(Z"u"?null:document;function ky(n,i,u){var f=Fl;if(f&&typeof i=="string"&&i){var g=en(i);g='link[rel="'+n+'"][href="'+g+'"]',typeof u=="string"&&(g+='[crossorigin="'+u+'"]'),Sy.has(g)||(Sy.add(g),n={rel:n,crossOrigin:u,href:i},f.querySelector(g)===null&&(i=f.createElement("link"),Vt(i,"link",n),St(i),f.head.appendChild(i)))}}function NE(n){jr.D(n),ky("dns-prefetch",n,null)}function CE(n,i){jr.C(n,i),ky("preconnect",n,i)}function jE(n,i,u){jr.L(n,i,u);var f=Fl;if(f&&n&&i){var g='link[rel="preload"][as="'+en(i)+'"]';i==="image"&&u&&u.imageSrcSet?(g+='[imagesrcset="'+en(u.imageSrcSet)+'"]',typeof u.imageSizes=="string"&&(g+='[imagesizes="'+en(u.imageSizes)+'"]')):g+='[href="'+en(n)+'"]';var v=g;switch(i){case"style":v=Yl(n);break;case"script":v=Xl(n)}Mn.has(v)||(n=p({rel:"preload",href:i==="image"&&u&&u.imageSrcSet?void 0:n,as:i},u),Mn.set(v,n),f.querySelector(g)!==null||i==="style"&&f.querySelector(uo(v))||i==="script"&&f.querySelector(co(v))||(i=f.createElement("link"),Vt(i,"link",n),St(i),f.head.appendChild(i)))}}function TE(n,i){jr.m(n,i);var u=Fl;if(u&&n){var f=i&&typeof i.as=="string"?i.as:"script",g='link[rel="modulepreload"][as="'+en(f)+'"][href="'+en(n)+'"]',v=g;switch(f){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":v=Xl(n)}if(!Mn.has(v)&&(n=p({rel:"modulepreload",href:n},i),Mn.set(v,n),u.querySelector(g)===null)){switch(f){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(u.querySelector(co(v)))return}f=u.createElement("link"),Vt(f,"link",n),St(f),u.head.appendChild(f)}}}function AE(n,i,u){jr.S(n,i,u);var f=Fl;if(f&&n){var g=$r(f).hoistableStyles,v=Yl(n);i=i||"default";var j=g.get(v);if(!j){var O={loading:0,preload:null};if(j=f.querySelector(uo(v)))O.loading=5;else{n=p({rel:"stylesheet",href:n,"data-precedence":i},u),(u=Mn.get(v))&&Jd(n,u);var Z=j=f.createElement("link");St(Z),Vt(Z,"link",n),Z._p=new Promise(function(le,fe){Z.onload=le,Z.onerror=fe}),Z.addEventListener("load",function(){O.loading|=1}),Z.addEventListener("error",function(){O.loading|=2}),O.loading|=4,wu(j,i,f)}j={type:"stylesheet",instance:j,count:1,state:O},g.set(v,j)}}}function zE(n,i){jr.X(n,i);var u=Fl;if(u&&n){var f=$r(u).hoistableScripts,g=Xl(n),v=f.get(g);v||(v=u.querySelector(co(g)),v||(n=p({src:n,async:!0},i),(i=Mn.get(g))&&Wd(n,i),v=u.createElement("script"),St(v),Vt(v,"link",n),u.head.appendChild(v)),v={type:"script",instance:v,count:1,state:null},f.set(g,v))}}function ME(n,i){jr.M(n,i);var u=Fl;if(u&&n){var f=$r(u).hoistableScripts,g=Xl(n),v=f.get(g);v||(v=u.querySelector(co(g)),v||(n=p({src:n,async:!0,type:"module"},i),(i=Mn.get(g))&&Wd(n,i),v=u.createElement("script"),St(v),Vt(v,"link",n),u.head.appendChild(v)),v={type:"script",instance:v,count:1,state:null},f.set(g,v))}}function Ey(n,i,u,f){var g=(g=J.current)?bu(g):null;if(!g)throw Error(l(446));switch(n){case"meta":case"title":return null;case"style":return typeof u.precedence=="string"&&typeof u.href=="string"?(i=Yl(u.href),u=$r(g).hoistableStyles,f=u.get(i),f||(f={type:"style",instance:null,count:0,state:null},u.set(i,f)),f):{type:"void",instance:null,count:0,state:null};case"link":if(u.rel==="stylesheet"&&typeof u.href=="string"&&typeof u.precedence=="string"){n=Yl(u.href);var v=$r(g).hoistableStyles,j=v.get(n);if(j||(g=g.ownerDocument||g,j={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},v.set(n,j),(v=g.querySelector(uo(n)))&&!v._p&&(j.instance=v,j.state.loading=5),Mn.has(n)||(u={rel:"preload",as:"style",href:u.href,crossOrigin:u.crossOrigin,integrity:u.integrity,media:u.media,hrefLang:u.hrefLang,referrerPolicy:u.referrerPolicy},Mn.set(n,u),v||DE(g,n,u,j.state))),i&&f===null)throw Error(l(528,""));return j}if(i&&f!==null)throw Error(l(529,""));return null;case"script":return i=u.async,u=u.src,typeof u=="string"&&i&&typeof i!="function"&&typeof i!="symbol"?(i=Xl(u),u=$r(g).hoistableScripts,f=u.get(i),f||(f={type:"script",instance:null,count:0,state:null},u.set(i,f)),f):{type:"void",instance:null,count:0,state:null};default:throw Error(l(444,n))}}function Yl(n){return'href="'+en(n)+'"'}function uo(n){return'link[rel="stylesheet"]['+n+"]"}function Ny(n){return p({},n,{"data-precedence":n.precedence,precedence:null})}function DE(n,i,u,f){n.querySelector('link[rel="preload"][as="style"]['+i+"]")?f.loading=1:(i=n.createElement("link"),f.preload=i,i.addEventListener("load",function(){return f.loading|=1}),i.addEventListener("error",function(){return f.loading|=2}),Vt(i,"link",u),St(i),n.head.appendChild(i))}function Xl(n){return'[src="'+en(n)+'"]'}function co(n){return"script[async]"+n}function Cy(n,i,u){if(i.count++,i.instance===null)switch(i.type){case"style":var f=n.querySelector('style[data-href~="'+en(u.href)+'"]');if(f)return i.instance=f,St(f),f;var g=p({},u,{"data-href":u.href,"data-precedence":u.precedence,href:null,precedence:null});return f=(n.ownerDocument||n).createElement("style"),St(f),Vt(f,"style",g),wu(f,u.precedence,n),i.instance=f;case"stylesheet":g=Yl(u.href);var v=n.querySelector(uo(g));if(v)return i.state.loading|=4,i.instance=v,St(v),v;f=Ny(u),(g=Mn.get(g))&&Jd(f,g),v=(n.ownerDocument||n).createElement("link"),St(v);var j=v;return j._p=new Promise(function(O,Z){j.onload=O,j.onerror=Z}),Vt(v,"link",f),i.state.loading|=4,wu(v,u.precedence,n),i.instance=v;case"script":return v=Xl(u.src),(g=n.querySelector(co(v)))?(i.instance=g,St(g),g):(f=u,(g=Mn.get(v))&&(f=p({},u),Wd(f,g)),n=n.ownerDocument||n,g=n.createElement("script"),St(g),Vt(g,"link",f),n.head.appendChild(g),i.instance=g);case"void":return null;default:throw Error(l(443,i.type))}else i.type==="stylesheet"&&(i.state.loading&4)===0&&(f=i.instance,i.state.loading|=4,wu(f,u.precedence,n));return i.instance}function wu(n,i,u){for(var f=u.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),g=f.length?f[f.length-1]:null,v=g,j=0;j title"):null)}function RE(n,i,u){if(u===1||i.itemProp!=null)return!1;switch(n){case"meta":case"title":return!0;case"style":if(typeof i.precedence!="string"||typeof i.href!="string"||i.href==="")break;return!0;case"link":if(typeof i.rel!="string"||typeof i.href!="string"||i.href===""||i.onLoad||i.onError)break;switch(i.rel){case"stylesheet":return n=i.disabled,typeof i.precedence=="string"&&n==null;default:return!0}case"script":if(i.async&&typeof i.async!="function"&&typeof i.async!="symbol"&&!i.onLoad&&!i.onError&&i.src&&typeof i.src=="string")return!0}return!1}function Ay(n){return!(n.type==="stylesheet"&&(n.state.loading&3)===0)}function OE(n,i,u,f){if(u.type==="stylesheet"&&(typeof f.media!="string"||matchMedia(f.media).matches!==!1)&&(u.state.loading&4)===0){if(u.instance===null){var g=Yl(f.href),v=i.querySelector(uo(g));if(v){i=v._p,i!==null&&typeof i=="object"&&typeof i.then=="function"&&(n.count++,n=Su.bind(n),i.then(n,n)),u.state.loading|=4,u.instance=v,St(v);return}v=i.ownerDocument||i,f=Ny(f),(g=Mn.get(g))&&Jd(f,g),v=v.createElement("link"),St(v);var j=v;j._p=new Promise(function(O,Z){j.onload=O,j.onerror=Z}),Vt(v,"link",f),u.instance=v}n.stylesheets===null&&(n.stylesheets=new Map),n.stylesheets.set(u,i),(i=u.state.preload)&&(u.state.loading&3)===0&&(n.count++,u=Su.bind(n),i.addEventListener("load",u),i.addEventListener("error",u))}}var eh=0;function LE(n,i){return n.stylesheets&&n.count===0&&Eu(n,n.stylesheets),0eh?50:800)+i);return n.unsuspend=u,function(){n.unsuspend=null,clearTimeout(f),clearTimeout(g)}}:null}function Su(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Eu(this,this.stylesheets);else if(this.unsuspend){var n=this.unsuspend;this.unsuspend=null,n()}}}var ku=null;function Eu(n,i){n.stylesheets=null,n.unsuspend!==null&&(n.count++,ku=new Map,i.forEach(HE,n),ku=null,Su.call(n))}function HE(n,i){if(!(i.state.loading&4)){var u=ku.get(n);if(u)var f=u.get(null);else{u=new Map,ku.set(n,u);for(var g=n.querySelectorAll("link[data-precedence],style[data-precedence]"),v=0;v"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),uh.exports=nN(),uh.exports}var iN=rN();/** + * @license lucide-react v0.469.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const lN=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),mw=(...e)=>e.filter((t,r,l)=>!!t&&t.trim()!==""&&l.indexOf(t)===r).join(" ").trim();/** + * @license lucide-react v0.469.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */var aN={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/** + * @license lucide-react v0.469.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const oN=U.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:r=2,absoluteStrokeWidth:l,className:a="",children:o,iconNode:s,...c},h)=>U.createElement("svg",{ref:h,...aN,width:t,height:t,stroke:e,strokeWidth:l?Number(r)*24/Number(t):r,className:mw("lucide",a),...c},[...s.map(([d,m])=>U.createElement(d,m)),...Array.isArray(o)?o:[o]]));/** + * @license lucide-react v0.469.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const qe=(e,t)=>{const r=U.forwardRef(({className:l,...a},o)=>U.createElement(oN,{ref:o,iconNode:t,className:mw(`lucide-${lN(e)}`,l),...a}));return r.displayName=`${e}`,r};/** + * @license lucide-react v0.469.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const gw=qe("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"}]]);/** + * @license lucide-react v0.469.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const sN=qe("ArrowDownToLine",[["path",{d:"M12 17V3",key:"1cwfxf"}],["path",{d:"m6 11 6 6 6-6",key:"12ii2o"}],["path",{d:"M19 21H5",key:"150jfl"}]]);/** + * @license lucide-react v0.469.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const uN=qe("ArrowUpFromLine",[["path",{d:"m18 9-6-6-6 6",key:"kcunyi"}],["path",{d:"M12 3v14",key:"7cf3v8"}],["path",{d:"M5 21h14",key:"11awu3"}]]);/** + * @license lucide-react v0.469.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const cN=qe("Bot",[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]]);/** + * @license lucide-react v0.469.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Zi=qe("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);/** + * @license lucide-react v0.469.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const ol=qe("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);/** + * @license lucide-react v0.469.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Rr=qe("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);/** + * @license lucide-react v0.469.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const fN=qe("ChevronUp",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]);/** + * @license lucide-react v0.469.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const dN=qe("CircleCheck",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);/** + * @license lucide-react v0.469.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const hN=qe("CircleStop",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["rect",{x:"9",y:"9",width:"6",height:"6",rx:"1",key:"1ssd4o"}]]);/** + * @license lucide-react v0.469.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const xw=qe("Clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]]);/** + * @license lucide-react v0.469.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const yw=qe("Coins",[["circle",{cx:"8",cy:"8",r:"6",key:"3yglwk"}],["path",{d:"M18.09 10.37A6 6 0 1 1 10.34 18",key:"t5s6rm"}],["path",{d:"M7 6h1v4",key:"1obek4"}],["path",{d:"m16.71 13.88.7.71-2.82 2.82",key:"1rbuyh"}]]);/** + * @license lucide-react v0.469.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const vw=qe("Copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);/** + * @license lucide-react v0.469.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const pN=qe("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"}]]);/** + * @license lucide-react v0.469.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const mN=qe("Eye",[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);/** + * @license lucide-react v0.469.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const gN=qe("FileCode",[["path",{d:"M10 12.5 8 15l2 2.5",key:"1tg20x"}],["path",{d:"m14 12.5 2 2.5-2 2.5",key:"yinavb"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7z",key:"1mlx9k"}]]);/** + * @license lucide-react v0.469.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const xN=qe("FileOutput",[["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M4 7V4a2 2 0 0 1 2-2 2 2 0 0 0-2 2",key:"1vk7w2"}],["path",{d:"M4.063 20.999a2 2 0 0 0 2 1L18 22a2 2 0 0 0 2-2V7l-5-5H6",key:"1jink5"}],["path",{d:"m5 11-3 3",key:"1dgrs4"}],["path",{d:"m5 17-3-3h10",key:"1mvvaf"}]]);/** + * @license lucide-react v0.469.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const bw=qe("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"}]]);/** + * @license lucide-react v0.469.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const yN=qe("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"}]]);/** + * @license lucide-react v0.469.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const ww=qe("Hash",[["line",{x1:"4",x2:"20",y1:"9",y2:"9",key:"4lhtct"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15",key:"vyu0kd"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21",key:"1ggp8o"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21",key:"weycgp"}]]);/** + * @license lucide-react v0.469.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const kc=qe("Layers",[["path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z",key:"zw3jo"}],["path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12",key:"1wduqc"}],["path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",key:"kqbvx6"}]]);/** + * @license lucide-react v0.469.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const fa=qe("LoaderCircle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);/** + * @license lucide-react v0.469.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const vN=qe("Maximize",[["path",{d:"M8 3H5a2 2 0 0 0-2 2v3",key:"1dcmit"}],["path",{d:"M21 8V5a2 2 0 0 0-2-2h-3",key:"1e4gt3"}],["path",{d:"M3 16v3a2 2 0 0 0 2 2h3",key:"wsl5sc"}],["path",{d:"M16 21h3a2 2 0 0 0 2-2v-3",key:"18trek"}]]);/** + * @license lucide-react v0.469.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const ym=qe("MessageCircle",[["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z",key:"vv11sd"}]]);/** + * @license lucide-react v0.469.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const bN=qe("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"}]]);/** + * @license lucide-react v0.469.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Ec=qe("Play",[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]]);/** + * @license lucide-react v0.469.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const wN=qe("Repeat",[["path",{d:"m17 2 4 4-4 4",key:"nntrym"}],["path",{d:"M3 11v-1a4 4 0 0 1 4-4h14",key:"84bu3i"}],["path",{d:"m7 22-4-4 4-4",key:"1wqhfi"}],["path",{d:"M21 13v1a4 4 0 0 1-4 4H3",key:"1rx37r"}]]);/** + * @license lucide-react v0.469.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const _N=qe("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]);/** + * @license lucide-react v0.469.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const _w=qe("Send",[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]]);/** + * @license lucide-react v0.469.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const SN=qe("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"}]]);/** + * @license lucide-react v0.469.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const ev=qe("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"}]]);/** + * @license lucide-react v0.469.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Sw=qe("Square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);/** + * @license lucide-react v0.469.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const kN=qe("Terminal",[["polyline",{points:"4 17 10 11 4 5",key:"akl6gq"}],["line",{x1:"12",x2:"20",y1:"19",y2:"19",key:"q2wloq"}]]);/** + * @license lucide-react v0.469.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const lc=qe("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"}]]);/** + * @license lucide-react v0.469.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const EN=qe("WifiOff",[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}],["path",{d:"M5 12.859a10 10 0 0 1 5.17-2.69",key:"1dl1wf"}],["path",{d:"M19 12.859a10 10 0 0 0-2.007-1.523",key:"4k23kn"}],["path",{d:"M2 8.82a15 15 0 0 1 4.177-2.643",key:"1grhjp"}],["path",{d:"M22 8.82a15 15 0 0 0-11.288-3.764",key:"z3jwby"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/** + * @license lucide-react v0.469.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const NN=qe("Wifi",[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M2 8.82a15 15 0 0 1 20 0",key:"dnpr2z"}],["path",{d:"M5 12.859a10 10 0 0 1 14 0",key:"1x1e6c"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}]]);/** + * @license lucide-react v0.469.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const sl=qe("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);/** + * @license lucide-react v0.469.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const CN=qe("Zap",[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]]),tv=e=>{let t;const r=new Set,l=(d,m)=>{const p=typeof d=="function"?d(t):d;if(!Object.is(p,t)){const x=t;t=m??(typeof p!="object"||p===null)?p:Object.assign({},t,p),r.forEach(b=>b(t,x))}},a=()=>t,c={setState:l,getState:a,getInitialState:()=>h,subscribe:d=>(r.add(d),()=>r.delete(d))},h=t=e(l,a,c);return c},jN=(e=>e?tv(e):tv),TN=e=>e;function AN(e,t=TN){const r=na.useSyncExternalStore(e.subscribe,na.useCallback(()=>t(e.getState()),[e,t]),na.useCallback(()=>t(e.getInitialState()),[e,t]));return na.useDebugValue(r),r}const nv=e=>{const t=jN(e),r=l=>AN(t,l);return Object.assign(r,t),r},zN=(e=>e?nv(e):nv);function Le(e,t,r="agent"){return e[t]||(e[t]={name:t,status:"pending",type:r,activity:[]}),e[t].activity||(e[t].activity=[]),e[t]}function Du(e,t,r){Le(e,t).activity.push(r)}function Ae(e,t){e[t]&&(e[t]={...e[t]})}function yo(e,t,r,l){const a=e[t];if(!(a!=null&&a.for_each_items))return;const o=a.for_each_items.find(s=>s.key===r);o&&o.activity.push(l)}function MN(e,t,r,l){return{parentAgent:e,iteration:t,slotKey:l??e,workflowFile:r,workflowName:"",status:"pending",agents:[],routes:[],parallelGroups:[],forEachGroups:[],nodes:{},groupProgress:{},highlightedEdges:[],entryPoint:null,children:[],agentsCompleted:0,agentsTotal:0,totalCost:0,totalTokens:0,eventLog:[],activityLog:[],workflowOutput:null,workflowFailure:null}}function tr(e,t){if(t.length===0)return null;let r=e[t[0]];for(let l=1;l=0;c--)if(l[c].slotKey===o){s=c;break}if(s===-1)return null;r.push(s),a=l[s],l=a.children}return{indexPath:r,ctx:a}}function DN(e,t){for(let r=e.length-1;r>=0;r--){const l=e[r];if(l.slotKey===t)return{ctx:l,index:r}}return null}const ue=zN((e,t)=>({workflowName:"",workflowStatus:"pending",workflowStartTime:null,workflowFailure:null,workflowFailedAgent:null,workflowYaml:null,conductorVersion:null,entryPoint:null,agents:[],routes:[],parallelGroups:[],forEachGroups:[],nodes:{},groupProgress:{},highlightedEdges:[],agentsCompleted:0,agentsTotal:0,totalCost:0,totalTokens:0,selectedNode:null,wsStatus:"connecting",eventLog:[],activityLog:[],workflowOutput:null,lastEventTime:null,isPaused:!1,iterationLimitGate:null,wfDepth:0,subworkflowContexts:[],activeContextPath:[],viewContextPath:[],replayMode:!1,replayEvents:[],replayPosition:0,replayTotalEvents:0,replayPlaying:!1,replaySpeed:1,_wsSend:null,setWsSend:r=>{e({_wsSend:r})},sendGateResponse:(r,l,a)=>{const o=ue.getState()._wsSend;o&&o({type:"gate_response",agent_name:r,selected_value:l,additional_input:a||{}})},activeDialog:null,dialogEngaged:!1,engageDialog:()=>{e({dialogEngaged:!0})},sendDialogMessage:(r,l,a)=>{const o=ue.getState()._wsSend;o&&o({type:"dialog_message",agent_name:r,dialog_id:l,content:a})},sendDialogDecline:(r,l)=>{const a=ue.getState()._wsSend;a&&a({type:"dialog_decline",agent_name:r,dialog_id:l})},sendIterationLimitResponse:(r,l,a)=>{const o=ue.getState()._wsSend;if(!o)return;const s=Math.max(0,Math.floor(Number(a)||0)),c="agent_name"in r?{agent_name:r.agent_name}:{group_name:r.group_name};o({type:"iteration_limit_response",gate_id:l,...c,additional_iterations:s})},processEvent:r=>{const l=Ru[r.type];e(a=>{const o={...a,nodes:{...a.nodes},groupProgress:{...a.groupProgress},eventLog:[...a.eventLog],activityLog:[...a.activityLog],lastEventTime:r.timestamp};l&&l(o,r.data,r.timestamp);const s=Ou(r);s&&o.eventLog.push(s);const c=Lu(r);return c&&o.activityLog.push(c),o})},replayState:r=>{e(l=>{const a={...l,agentsCompleted:0,totalCost:0,totalTokens:0,nodes:{},groupProgress:{},highlightedEdges:[],eventLog:[],activityLog:[],workflowOutput:null,workflowFailedAgent:null,activeDialog:null,dialogEngaged:!1,wfDepth:0,subworkflowContexts:[],activeContextPath:[]};for(const o of r){const s=Ru[o.type];s&&s(a,o.data,o.timestamp);const c=Ou(o);c&&a.eventLog.push(c);const h=Lu(o);h&&a.activityLog.push(h),a.lastEventTime=o.timestamp}return a})},selectNode:r=>{e({selectedNode:r})},setReplayMode:r=>{e(l=>{const a={...l,replayMode:!0,replayEvents:r,replayTotalEvents:r.length,replayPosition:r.length,replayPlaying:!1,replaySpeed:1,agentsCompleted:0,totalCost:0,totalTokens:0,nodes:{},groupProgress:{},highlightedEdges:[],eventLog:[],activityLog:[],workflowOutput:null,workflowFailedAgent:null,activeDialog:null,dialogEngaged:!1,wfDepth:0,subworkflowContexts:[],activeContextPath:[],viewContextPath:[]};for(const o of r){const s=Ru[o.type];s&&s(a,o.data,o.timestamp);const c=Ou(o);c&&a.eventLog.push(c);const h=Lu(o);h&&a.activityLog.push(h),a.lastEventTime=o.timestamp}return a})},setReplayPosition:r=>{e(l=>{const a=l.replayEvents.slice(0,r),o={...l,replayPosition:r,agentsCompleted:0,totalCost:0,totalTokens:0,nodes:{},groupProgress:{},highlightedEdges:[],eventLog:[],activityLog:[],workflowOutput:null,workflowFailedAgent:null,workflowStatus:"pending",workflowStartTime:null,workflowName:"",workflowFailure:null,entryPoint:null,agents:[],routes:[],parallelGroups:[],forEachGroups:[],isPaused:!1,iterationLimitGate:null,lastEventTime:null,activeDialog:null,dialogEngaged:!1,wfDepth:0,subworkflowContexts:[],activeContextPath:[],viewContextPath:[]};for(const s of a){const c=Ru[s.type];c&&c(o,s.data,s.timestamp);const h=Ou(s);h&&o.eventLog.push(h);const d=Lu(s);d&&o.activityLog.push(d),o.lastEventTime=s.timestamp}return o})},setReplayPlaying:r=>{e({replayPlaying:r})},setReplaySpeed:r=>{e({replaySpeed:r})},setWsStatus:r=>{e({wsStatus:r})},setEdgeHighlight:(r,l,a)=>{e(o=>({highlightedEdges:[...o.highlightedEdges.filter(s=>!(s.from===r&&s.to===l)),{from:r,to:l,state:a}]}))},clearEdgeHighlight:(r,l)=>{e(a=>({highlightedEdges:a.highlightedEdges.filter(o=>!(o.from===r&&o.to===l))}))},navigateToContext:r=>{e({viewContextPath:r,selectedNode:null})},navigateUp:()=>{e(r=>({viewContextPath:r.viewContextPath.slice(0,-1),selectedNode:null}))},navigateIntoSubworkflow:r=>{const l=t(),a=l.viewContextPath;let o;if(a.length===0)o=l.subworkflowContexts;else{const c=tr(l.subworkflowContexts,a);if(!c)return;o=c.children}const s=DN(o,r);s&&e({viewContextPath:[...a,s.index],selectedNode:null})},getViewedContext:()=>{const r=t();if(r.viewContextPath.length===0)return{workflowName:r.workflowName,agents:r.agents,routes:r.routes,parallelGroups:r.parallelGroups,forEachGroups:r.forEachGroups,nodes:r.nodes,groupProgress:r.groupProgress,highlightedEdges:r.highlightedEdges,entryPoint:r.entryPoint,subworkflowContexts:r.subworkflowContexts};const l=tr(r.subworkflowContexts,r.viewContextPath);return l?{workflowName:l.workflowName,agents:l.agents,routes:l.routes,parallelGroups:l.parallelGroups,forEachGroups:l.forEachGroups,nodes:l.nodes,groupProgress:l.groupProgress,highlightedEdges:l.highlightedEdges,entryPoint:l.entryPoint,subworkflowContexts:l.children}:{workflowName:r.workflowName,agents:r.agents,routes:r.routes,parallelGroups:r.parallelGroups,forEachGroups:r.forEachGroups,nodes:r.nodes,groupProgress:r.groupProgress,highlightedEdges:r.highlightedEdges,entryPoint:r.entryPoint,subworkflowContexts:r.subworkflowContexts}},getBreadcrumbs:()=>{const r=t(),l=[{label:r.workflowName||"Root",path:[]}];let a=r.subworkflowContexts;for(let o=0;o0&&(r=((a=Fi(e.subworkflowContexts,l))==null?void 0:a.ctx)??null),r){const o=r;return{nodes:o.nodes,groupProgress:o.groupProgress,routes:o.routes,highlightedEdges:o.highlightedEdges,addCost:s=>{o.totalCost+=s,e.totalCost+=s},addTokens:s=>{o.totalTokens+=s,e.totalTokens+=s},incrCompleted:()=>{o.agentsCompleted++,e.agentsCompleted++}}}return{nodes:e.nodes,groupProgress:e.groupProgress,routes:e.routes,highlightedEdges:e.highlightedEdges,addCost:o=>{e.totalCost+=o},addTokens:o=>{e.totalTokens+=o},incrCompleted:()=>{e.agentsCompleted++}}}const Ru={workflow_started:(e,t,r)=>{var a;const l=t;if(e.wfDepth===0){e.workflowStatus="running",e.workflowStartTime=r??Date.now()/1e3,e.workflowName=l.name||"",e.workflowYaml=t.yaml_source??null,e.conductorVersion=t.version??null,e.entryPoint=l.entry_point||null,e.agents=l.agents||[],e.routes=l.routes||[],e.parallelGroups=l.parallel_groups||[],e.forEachGroups=l.for_each_groups||[],Le(e.nodes,"$start","start"),e.nodes.$start.status="running",Ae(e.nodes,"$start");const o=new Set,s=new Set;for(const c of e.parallelGroups){for(const h of c.agents)o.add(h);s.add(c.name),Le(e.nodes,c.name,"parallel_group"),e.groupProgress[c.name]={total:c.agents.length,completed:0,failed:0};for(const h of c.agents)Le(e.nodes,h,"agent")}for(const c of e.forEachGroups)s.add(c.name),Le(e.nodes,c.name,"for_each_group"),e.groupProgress[c.name]={total:0,completed:0,failed:0};for(const c of e.agents)if(!s.has(c.name)&&!o.has(c.name)){const h=c.type||"agent";Le(e.nodes,c.name,h),c.model&&(e.nodes[c.name].model=c.model),c.reasoning_effort&&(e.nodes[c.name].reasoning_effort=c.reasoning_effort),s.add(c.name)}e.agentsTotal=s.size}else{const o=t.subworkflow_path,s=Array.isArray(o)&&o.length>0?((a=Fi(e.subworkflowContexts,o))==null?void 0:a.ctx)??null:tr(e.subworkflowContexts,e.activeContextPath);if(s){s.workflowName=l.name||"",s.status="running",s.entryPoint=l.entry_point||null,s.agents=l.agents||[],s.routes=l.routes||[],s.parallelGroups=l.parallel_groups||[],s.forEachGroups=l.for_each_groups||[],Le(s.nodes,"$start","start"),s.nodes.$start.status="running";const c=new Set,h=new Set;for(const d of s.parallelGroups){for(const m of d.agents)c.add(m);h.add(d.name),Le(s.nodes,d.name,"parallel_group"),s.groupProgress[d.name]={total:d.agents.length,completed:0,failed:0};for(const m of d.agents)Le(s.nodes,m,"agent")}for(const d of s.forEachGroups)h.add(d.name),Le(s.nodes,d.name,"for_each_group"),s.groupProgress[d.name]={total:0,completed:0,failed:0};for(const d of s.agents)if(!h.has(d.name)&&!c.has(d.name)){const m=d.type||"agent";Le(s.nodes,d.name,m),d.model&&(s.nodes[d.name].model=d.model),d.reasoning_effort&&(s.nodes[d.name].reasoning_effort=d.reasoning_effort),h.add(d.name)}s.agentsTotal=h.size}}e.wfDepth++},agent_started:(e,t,r)=>{const l=t,a=ot(e,t),o=Le(a.nodes,l.agent_name);o.iteration!=null&&(o.output!=null||o.error_type!=null)&&(o.iterationHistory||(o.iterationHistory=[]),o.iterationHistory.push({iteration:o.iteration,prompt:o.prompt,output:o.output,elapsed:o.elapsed,model:o.model,reasoning_effort:o.reasoning_effort,tokens:o.tokens,input_tokens:o.input_tokens,output_tokens:o.output_tokens,cost_usd:o.cost_usd,activity:o.activity,error_type:o.error_type,error_message:o.error_message})),o.status="running",o.iteration=l.iteration,o.startedAt=r??Date.now()/1e3,o.activity=[],l.context_window_max!=null&&(o.context_window_max=l.context_window_max),o.prompt=void 0,o.output=void 0,o.error_type=void 0,o.error_message=void 0,Ae(a.nodes,l.agent_name)},agent_completed:(e,t)=>{const r=t,l=ot(e,t),a=Le(l.nodes,r.agent_name);a.status="completed",l.incrCompleted(),a.elapsed=r.elapsed,a.model=r.model,a.tokens=r.tokens,a.input_tokens=r.input_tokens,a.output_tokens=r.output_tokens,a.cost_usd=r.cost_usd,a.output=r.output,a.output_keys=r.output_keys,a.context_window_used=r.context_window_used,a.context_window_max=r.context_window_max,r.context_window_used!=null&&r.context_window_max!=null&&r.context_window_max>0&&(a.context_pct=Math.round(r.context_window_used/r.context_window_max*100)),r.cost_usd&&l.addCost(r.cost_usd),r.tokens&&l.addTokens(r.tokens),Ae(l.nodes,r.agent_name)},agent_failed:(e,t)=>{const r=t,l=ot(e,t),a=Le(l.nodes,r.agent_name);a.status="failed",a.elapsed=r.elapsed,a.error_type=r.error_type,a.error_message=r.message;for(const o of l.routes)o.to===r.agent_name&&l.highlightedEdges.push({from:o.from,to:o.to,state:"failed"});Ae(l.nodes,r.agent_name)},agent_prompt_rendered:(e,t)=>{var s;const r=t,l=t.item_key,a=ot(e,t),o=Le(a.nodes,r.agent_name);if(o.prompt=r.rendered_prompt,o.context_keys=r.context_keys,l){yo(a.nodes,r.agent_name,l,{type:"prompt",icon:"📝",label:"prompt",text:"Prompt rendered",detail:((s=r.rendered_prompt)==null?void 0:s.slice(0,500))||null});const c=a.nodes[r.agent_name];if(c!=null&&c.for_each_items){const h=c.for_each_items.find(d=>d.key===l);h&&(h.prompt=r.rendered_prompt)}}Ae(a.nodes,r.agent_name)},agent_reasoning:(e,t)=>{const r=t,l=t.item_key,a=ot(e,t),o={type:"reasoning",icon:"💭",label:"thinking",text:r.content};Du(a.nodes,r.agent_name,o),l&&yo(a.nodes,r.agent_name,l,o),Ae(a.nodes,r.agent_name)},agent_tool_start:(e,t)=>{const r=t,l=t.item_key,a=ot(e,t),o={type:"tool-start",icon:"🔧",label:"tool",text:r.tool_name,detail:r.arguments||null};Du(a.nodes,r.agent_name,o),l&&yo(a.nodes,r.agent_name,l,o),Ae(a.nodes,r.agent_name)},agent_tool_complete:(e,t)=>{const r=t,l=t.item_key,a=ot(e,t),o={type:"tool-complete",icon:"✓",label:"result",text:r.tool_name||"done",detail:r.result||null};Du(a.nodes,r.agent_name,o),l&&yo(a.nodes,r.agent_name,l,o),Ae(a.nodes,r.agent_name)},agent_turn_start:(e,t)=>{const r=t,l=t.item_key,a=ot(e,t),o={type:"turn",icon:"⏳",label:"turn",text:`Turn ${r.turn??"?"}`};Du(a.nodes,r.agent_name,o),l&&yo(a.nodes,r.agent_name,l,o),Ae(a.nodes,r.agent_name)},agent_message:(e,t)=>{const r=t,l=ot(e,t),a=Le(l.nodes,r.agent_name);a.latest_message=r.content,Ae(l.nodes,r.agent_name)},script_started:(e,t,r)=>{const l=t,a=ot(e,t),o=Le(a.nodes,l.agent_name);o.status="running",o.startedAt=r??Date.now()/1e3,Ae(a.nodes,l.agent_name)},script_completed:(e,t)=>{const r=t,l=ot(e,t),a=Le(l.nodes,r.agent_name);a.status="completed",l.incrCompleted(),a.elapsed=r.elapsed,a.stdout=r.stdout,a.stderr=r.stderr,a.exit_code=r.exit_code,Ae(l.nodes,r.agent_name)},script_failed:(e,t)=>{const r=t,l=ot(e,t),a=Le(l.nodes,r.agent_name);a.status="failed",a.elapsed=r.elapsed,a.error_type=r.error_type,a.error_message=r.message,Ae(l.nodes,r.agent_name)},wait_started:(e,t,r)=>{const l=t,a=ot(e,t),o=Le(a.nodes,l.agent_name);o.status="running",o.startedAt=r??Date.now()/1e3,o.duration_seconds=l.duration_seconds??null,o.reason=l.reason??null,o.iteration=l.iteration,Ae(a.nodes,l.agent_name)},wait_completed:(e,t)=>{const r=t,l=ot(e,t),a=Le(l.nodes,r.agent_name);a.status="completed",l.incrCompleted(),a.elapsed=r.elapsed,a.waited_seconds=r.waited_seconds,a.requested_seconds=r.requested_seconds,a.reason=r.reason??null,a.interrupted=r.interrupted,Ae(l.nodes,r.agent_name)},wait_failed:(e,t)=>{const r=t,l=ot(e,t),a=Le(l.nodes,r.agent_name);a.status="failed",a.elapsed=r.elapsed,a.error_type=r.error_type,a.error_message=r.message,Ae(l.nodes,r.agent_name)},gate_presented:(e,t)=>{const r=t,l=ot(e,t),a=Le(l.nodes,r.agent_name);a.status="waiting",a.options=r.options,a.option_details=r.option_details,a.prompt=r.prompt,Ae(l.nodes,r.agent_name)},gate_resolved:(e,t)=>{const r=t,l=ot(e,t),a=Le(l.nodes,r.agent_name);a.status="completed",l.incrCompleted(),a.selected_option=r.selected_option,a.route=r.route,a.additional_input=r.additional_input,Ae(l.nodes,r.agent_name)},route_taken:(e,t)=>{const r=t;ot(e,t).highlightedEdges.push({from:r.from_agent,to:r.to_agent,state:"taken"})},parallel_started:(e,t)=>{const r=t,l=ot(e,t),a=Le(l.nodes,r.group_name,"parallel_group");a.status="running",l.groupProgress[r.group_name]&&(l.groupProgress[r.group_name].total=r.agents.length,l.groupProgress[r.group_name].completed=0,l.groupProgress[r.group_name].failed=0),Ae(l.nodes,r.group_name)},parallel_agent_completed:(e,t)=>{const r=t,l=ot(e,t);l.groupProgress[r.group_name]&&l.groupProgress[r.group_name].completed++;const a=Le(l.nodes,r.agent_name);a.status="completed",a.elapsed=r.elapsed,a.model=r.model,a.tokens=r.tokens,a.cost_usd=r.cost_usd,a.context_window_used=r.context_window_used,a.context_window_max=r.context_window_max,r.context_window_used!=null&&r.context_window_max!=null&&r.context_window_max>0&&(a.context_pct=Math.round(r.context_window_used/r.context_window_max*100)),r.cost_usd&&l.addCost(r.cost_usd),r.tokens&&l.addTokens(r.tokens),Ae(l.nodes,r.agent_name),Ae(l.nodes,r.group_name)},parallel_agent_failed:(e,t)=>{const r=t,l=ot(e,t);l.groupProgress[r.group_name]&&l.groupProgress[r.group_name].failed++;const a=Le(l.nodes,r.agent_name);a.status="failed",a.elapsed=r.elapsed,a.error_type=r.error_type,a.error_message=r.message,Ae(l.nodes,r.agent_name),Ae(l.nodes,r.group_name)},parallel_completed:(e,t)=>{const r=t,l=ot(e,t);l.incrCompleted();const a=Le(l.nodes,r.group_name,"parallel_group");a.status=r.failure_count===0?"completed":"failed",Ae(l.nodes,r.group_name)},for_each_started:(e,t)=>{const r=t,l=ot(e,t),a=Le(l.nodes,r.group_name,"for_each_group");a.status="running",a.for_each_items=[],l.groupProgress[r.group_name]&&(l.groupProgress[r.group_name].total=r.item_count,l.groupProgress[r.group_name].completed=0,l.groupProgress[r.group_name].failed=0),Ae(l.nodes,r.group_name)},for_each_item_started:(e,t)=>{const r=t,l=ot(e,t),a=Le(l.nodes,r.group_name,"for_each_group");a.for_each_items||(a.for_each_items=[]),a.for_each_items.push({key:r.item_key??String(r.index),index:r.index,status:"running",activity:[]}),Ae(l.nodes,r.group_name)},for_each_item_completed:(e,t)=>{const r=t,l=ot(e,t);l.groupProgress[r.group_name]&&l.groupProgress[r.group_name].completed++;const a=Le(l.nodes,r.group_name,"for_each_group");if(a.for_each_items){const o=r.item_key??String(r.index),s=a.for_each_items.find(c=>c.key===o);s&&(s.status="completed",s.elapsed=r.elapsed,s.tokens=r.tokens,s.cost_usd=r.cost_usd,s.output=r.output)}Ae(l.nodes,r.group_name)},for_each_item_failed:(e,t)=>{const r=t,l=ot(e,t);l.groupProgress[r.group_name]&&l.groupProgress[r.group_name].failed++;const a=Le(l.nodes,r.group_name,"for_each_group");if(a.for_each_items){const o=r.item_key??String(r.index),s=a.for_each_items.find(c=>c.key===o);s&&(s.status="failed",s.elapsed=r.elapsed,s.error_type=r.error_type,s.error_message=r.message)}Ae(l.nodes,r.group_name)},for_each_completed:(e,t)=>{const r=t,l=ot(e,t);l.incrCompleted();const a=Le(l.nodes,r.group_name,"for_each_group");a.status=(r.failure_count??0)===0?"completed":"failed",a.elapsed=r.elapsed,a.success_count=r.success_count,a.failure_count=r.failure_count,Ae(l.nodes,r.group_name)},workflow_completed:(e,t)=>{var r;if(e.wfDepth=Math.max(0,e.wfDepth-1),e.wfDepth===0){const l=t;e.workflowStatus="completed",e.isPaused=!1,e.iterationLimitGate=null,e.workflowOutput=l.output??null,e.nodes.$end&&(e.nodes.$end.status="completed",Ae(e.nodes,"$end")),e.nodes.$start&&(e.nodes.$start.status="completed",Ae(e.nodes,"$start")),e.highlightedEdges=[]}else{const l=t,a=l.subworkflow_path?(r=Fi(e.subworkflowContexts,l.subworkflow_path))==null?void 0:r.ctx:tr(e.subworkflowContexts,e.activeContextPath);a&&(a.status="completed",a.workflowOutput=l.output??null,a.nodes.$end&&(a.nodes.$end.status="completed"),a.nodes.$start&&(a.nodes.$start.status="completed"),a.highlightedEdges=[])}},workflow_failed:(e,t)=>{var l;e.wfDepth=Math.max(0,e.wfDepth-1);const r=t;if(e.wfDepth===0){if(e.workflowStatus="failed",e.isPaused=!1,e.iterationLimitGate=null,e.workflowFailedAgent=r.agent_name||null,r.agent_name&&e.nodes[r.agent_name]){e.nodes[r.agent_name].status="failed",Ae(e.nodes,r.agent_name);for(const a of e.routes)a.to===r.agent_name&&e.highlightedEdges.push({from:a.from,to:a.to,state:"failed"})}e.workflowFailure={error_type:r.error_type,message:r.message,elapsed_seconds:r.elapsed_seconds,timeout_seconds:r.timeout_seconds,current_agent:r.current_agent},e.nodes.$start&&(e.nodes.$start.status="completed",Ae(e.nodes,"$start"))}else{const a=r.subworkflow_path?(l=Fi(e.subworkflowContexts,r.subworkflow_path))==null?void 0:l.ctx:tr(e.subworkflowContexts,e.activeContextPath);a&&(a.status="failed",a.workflowFailure={error_type:r.error_type,message:r.message})}},subworkflow_started:(e,t)=>{const r=t,l=r.slot_key??(r.item_key!=null?`${r.agent_name}[${r.item_key}]`:r.agent_name),a=MN(r.agent_name,r.iteration??1,r.workflow,l);let o;if(r.parent_path!==void 0){const c=Fi(e.subworkflowContexts,r.parent_path);if(!c)return;o=c.indexPath}else o=e.activeContextPath;let s;if(o.length===0)e.subworkflowContexts.push(a),s=[e.subworkflowContexts.length-1];else{const c=tr(e.subworkflowContexts,o);if(!c)return;c.children.push(a),s=[...o,c.children.length-1]}if(e.activeContextPath=s,o.length===0){const c=e.nodes[r.agent_name];c&&(c.status="running",Ae(e.nodes,r.agent_name))}else{const c=tr(e.subworkflowContexts,o);if(c){const h=c.nodes[r.agent_name];h&&(h.status="running",Ae(c.nodes,r.agent_name))}}},subworkflow_completed:(e,t)=>{var o;const r=t;let l;if(r.parent_path!==void 0){const s=Fi(e.subworkflowContexts,r.parent_path);if(!s)return;l=s.indexPath}else l=e.activeContextPath;const a=l.length===0?e.nodes:(o=tr(e.subworkflowContexts,l))==null?void 0:o.nodes;if(a){const s=a[r.agent_name];if(s){if(r.item_key==null)if(s.status="completed",s.elapsed=r.elapsed,l.length===0)e.agentsCompleted++;else{const c=tr(e.subworkflowContexts,l);c&&c.agentsCompleted++}Ae(a,r.agent_name)}}e.activeContextPath=l},subworkflow_failed:(e,t)=>{var o;const r=t;let l;if(r.parent_path!==void 0){const s=Fi(e.subworkflowContexts,r.parent_path);if(!s)return;l=s.indexPath}else l=e.activeContextPath;const a=l.length===0?e.nodes:(o=tr(e.subworkflowContexts,l))==null?void 0:o.nodes;if(a){const s=a[r.agent_name];s&&r.item_key==null&&(s.status="failed",s.elapsed=r.elapsed,s.error_type=r.error_type,s.error_message=r.message,Ae(a,r.agent_name))}e.activeContextPath=l},checkpoint_saved:(e,t)=>{const r=t;r.path&&e.workflowFailure&&(e.workflowFailure={...e.workflowFailure,checkpoint_path:r.path})},agent_paused:(e,t)=>{const r=t,l=Le(e.nodes,r.agent_name);l.status="waiting",l.activity.push({type:"agent_paused",icon:"⏸",label:"Paused",text:"Agent paused — click Resume to re-execute"}),Ae(e.nodes,r.agent_name),e.isPaused=!0},agent_resumed:(e,t)=>{const r=t,l=Le(e.nodes,r.agent_name);l.status="running",l.activity.push({type:"agent_resumed",icon:"▶",label:"Resumed",text:"Agent resumed — re-executing"}),Ae(e.nodes,r.agent_name),e.isPaused=!1},iteration_limit_reached:(e,t)=>{const r=t;e.iterationLimitGate=r;const l=r.agent_name??r.group_name;l?(Le(e.nodes,l).activity.push({type:"iteration_limit_reached",icon:"⚠",label:"Iteration limit",text:`Reached ${r.current_iteration}/${r.max_iterations} iterations — ${r.skip_gates?"auto-stopping (--skip-gates)":"awaiting decision"}`}),Ae(e.nodes,l)):typeof console<"u"&&console.warn("[workflow-store] iteration_limit_reached event missing both agent_name and group_name",r)},iteration_limit_resolved:(e,t)=>{const r=t;e.iterationLimitGate=null;const l=r.agent_name??r.group_name;l?(Le(e.nodes,l).activity.push({type:"iteration_limit_resolved",icon:r.continue_execution?"▶":"■",label:"Iteration limit",text:r.aborted?"Gate aborted unexpectedly — stopping workflow":r.continue_execution?`Continuing with ${r.additional_iterations} more iteration(s)`:"Stopping workflow"}),Ae(e.nodes,l)):typeof console<"u"&&console.warn("[workflow-store] iteration_limit_resolved event missing both agent_name and group_name",r)},dialog_started:(e,t)=>{const r=t,l=Le(e.nodes,r.agent_name);l.dialog_id=r.dialog_id,l.dialog_messages=[],l.dialog_active=!0,l.dialog_awaiting_response=!1,e.activeDialog={agentName:r.agent_name,dialogId:r.dialog_id},e.dialogEngaged=!1,Ae(e.nodes,r.agent_name)},dialog_message:(e,t)=>{const r=t,l=Le(e.nodes,r.agent_name);l.dialog_messages||(l.dialog_messages=[]),l.dialog_messages.push({role:r.role,content:r.content}),r.role==="user"?l.dialog_awaiting_response=!0:r.role==="agent"&&(l.dialog_awaiting_response=!1),Ae(e.nodes,r.agent_name)},dialog_completed:(e,t)=>{const r=t,l=Le(e.nodes,r.agent_name);l.dialog_active=!1,l.dialog_awaiting_response=!1,e.activeDialog=null,e.dialogEngaged=!1,Ae(e.nodes,r.agent_name)}};function Ou(e){var l,a;const t=e.timestamp,r=e.data;switch(e.type){case"workflow_started":return{timestamp:t,level:"info",source:"workflow",message:`Workflow "${r.name||""}" started`};case"agent_started":return{timestamp:t,level:"info",source:String(r.agent_name),message:`Agent started${r.iteration!=null?` (iteration ${r.iteration})`:""}`};case"agent_completed":return{timestamp:t,level:"success",source:String(r.agent_name),message:`Agent completed${r.elapsed!=null?` in ${xi(r.elapsed)}`:""}${r.tokens!=null?` · ${r.tokens.toLocaleString()} tokens`:""}${r.cost_usd!=null?` · $${r.cost_usd.toFixed(4)}`:""}`};case"agent_failed":return{timestamp:t,level:"error",source:String(r.agent_name),message:`Agent failed: ${r.message||r.error_type||"unknown error"}`};case"script_started":return{timestamp:t,level:"info",source:String(r.agent_name),message:"Script started"};case"script_completed":return{timestamp:t,level:"success",source:String(r.agent_name),message:`Script completed (exit ${r.exit_code??"?"})${r.elapsed!=null?` in ${xi(r.elapsed)}`:""}`};case"script_failed":return{timestamp:t,level:"error",source:String(r.agent_name),message:`Script failed: ${r.message||r.error_type||"unknown error"}`};case"wait_started":{const o=r.duration_seconds,s=r.reason,c=typeof o=="number"?xi(o):"?";return{timestamp:t,level:"info",source:String(r.agent_name),message:`Waiting ${c}${s?` — ${s}`:""}`}}case"wait_completed":{const o=r.waited_seconds,s=r.interrupted;return{timestamp:t,level:"success",source:String(r.agent_name),message:`Wait completed${o!=null?` (${xi(o)})`:""}${s?" — interrupted":""}`}}case"wait_failed":return{timestamp:t,level:"error",source:String(r.agent_name),message:`Wait failed: ${r.message||r.error_type||"unknown error"}`};case"gate_presented":return{timestamp:t,level:"warning",source:String(r.agent_name),message:"Waiting for human input…"};case"gate_resolved":return{timestamp:t,level:"success",source:String(r.agent_name),message:`Gate resolved → ${r.selected_option||"continue"}`};case"route_taken":return{timestamp:t,level:"debug",source:"router",message:`${r.from_agent} → ${r.to_agent}`};case"parallel_started":return{timestamp:t,level:"info",source:String(r.group_name),message:`Parallel group started (${((l=r.agents)==null?void 0:l.length)||"?"} agents)`};case"parallel_completed":return{timestamp:t,level:r.failure_count===0?"success":"error",source:String(r.group_name),message:`Parallel group completed${r.failure_count>0?` with ${r.failure_count} failure(s)`:""}`};case"for_each_started":return{timestamp:t,level:"info",source:String(r.group_name),message:`For-each started (${r.item_count} items)`};case"for_each_completed":return{timestamp:t,level:(r.failure_count??0)===0?"success":"error",source:String(r.group_name),message:`For-each completed · ${r.success_count} succeeded${r.failure_count>0?` · ${r.failure_count} failed`:""}`};case"workflow_completed":return{timestamp:t,level:"success",source:"workflow",message:`Workflow completed${r.elapsed!=null?` in ${xi(r.elapsed)}`:""}`};case"workflow_failed":return{timestamp:t,level:"error",source:"workflow",message:`Workflow failed: ${r.message||r.error_type||"unknown error"}`};case"checkpoint_saved":return{timestamp:t,level:"info",source:"workflow",message:`Checkpoint saved: ${((a=r.path)==null?void 0:a.split("/").pop())||"unknown"}`};case"agent_paused":return{timestamp:t,level:"warning",source:String(r.agent_name),message:"Agent paused — waiting for resume"};case"agent_resumed":return{timestamp:t,level:"info",source:String(r.agent_name),message:"Agent resumed — re-executing"};case"iteration_limit_reached":{const o=r.agent_name??r.group_name??"workflow",s=r.skip_gates?" — auto-stopping (--skip-gates)":" — awaiting decision";return{timestamp:t,level:"warning",source:String(o),message:`Iteration limit reached (${r.current_iteration}/${r.max_iterations})${s}`}}case"iteration_limit_resolved":{const o=r.agent_name??r.group_name??"workflow",s=!!r.continue_execution,c=r.additional_iterations??0;return{timestamp:t,level:s?"info":"warning",source:String(o),message:s?`Iteration limit resolved — continuing with ${c} more`:"Iteration limit resolved — stopping workflow"}}case"dialog_started":return{timestamp:t,level:"warning",source:String(r.agent_name),message:"Dialog started — waiting for user…"};case"dialog_completed":return{timestamp:t,level:"success",source:String(r.agent_name),message:`Dialog completed (${r.turn_count||0} messages)`};default:return null}}function xi(e){if(e<1)return`${(e*1e3).toFixed(0)}ms`;if(e<60)return`${e.toFixed(1)}s`;const t=Math.floor(e/60),r=(e%60).toFixed(0);return`${t}m ${r}s`}function Lu(e){const t=e.timestamp,r=e.data;switch(e.type){case"agent_started":return{timestamp:t,source:String(r.agent_name),type:"turn",message:`Agent started${r.iteration!=null?` (iteration ${r.iteration})`:""}`};case"agent_prompt_rendered":return{timestamp:t,source:String(r.agent_name),type:"prompt",message:"Prompt rendered",detail:vo(String(r.rendered_prompt||""),500)};case"agent_reasoning":return{timestamp:t,source:String(r.agent_name),type:"reasoning",message:String(r.content||"")};case"agent_tool_start":return{timestamp:t,source:String(r.agent_name),type:"tool-start",message:`→ ${r.tool_name}`,detail:r.arguments?vo(String(r.arguments),300):null};case"agent_tool_complete":return{timestamp:t,source:String(r.agent_name),type:"tool-complete",message:`← ${r.tool_name||"done"}`,detail:r.result?vo(String(r.result),300):null};case"agent_turn_start":return{timestamp:t,source:String(r.agent_name),type:"turn",message:`Turn ${r.turn??"?"}`};case"agent_message":return{timestamp:t,source:String(r.agent_name),type:"message",message:vo(String(r.content||""),500)};case"agent_completed":return{timestamp:t,source:String(r.agent_name),type:"turn",message:`Completed${r.elapsed!=null?` in ${xi(r.elapsed)}`:""}${r.tokens!=null?` · ${r.tokens.toLocaleString()} tokens`:""}`};case"agent_failed":return{timestamp:t,source:String(r.agent_name),type:"turn",message:`Failed: ${r.message||r.error_type||"unknown"}`};case"script_started":return{timestamp:t,source:String(r.agent_name),type:"turn",message:"Script started"};case"script_completed":return{timestamp:t,source:String(r.agent_name),type:"tool-complete",message:`Script completed (exit ${r.exit_code??"?"})`,detail:r.stdout?vo(String(r.stdout),300):null};case"script_failed":return{timestamp:t,source:String(r.agent_name),type:"turn",message:`Script failed: ${r.message||r.error_type||"unknown"}`};case"wait_started":{const l=r.duration_seconds,a=r.reason,o=typeof l=="number"?xi(l):"?";return{timestamp:t,source:String(r.agent_name),type:"turn",message:`Waiting ${o}${a?` — ${a}`:""}`}}case"wait_completed":{const l=r.waited_seconds,a=r.interrupted;return{timestamp:t,source:String(r.agent_name),type:"tool-complete",message:`Wait completed${l!=null?` (${xi(l)})`:""}${a?" — interrupted":""}`}}case"wait_failed":return{timestamp:t,source:String(r.agent_name),type:"turn",message:`Wait failed: ${r.message||r.error_type||"unknown"}`};default:return null}}function vo(e,t){return e.length<=t?e:e.slice(0,t)+"…"}function rv(e){const t=e.match(/^(\s*)/);return t?t[1].length:0}function RN(e){const t=new Map;for(let r=0;ra)o=s;else break}o>r&&t.set(r,o)}return t}function ON(e){if(/^\s*#/.test(e))return y.jsx("span",{className:"text-emerald-500/70",children:e});const t=e.match(/^(\s*)(- )?([a-zA-Z_][\w.-]*)(:\s*)(.*)/);if(t){const[,l,a,o,s,c]=t;return y.jsxs("span",{children:[l,a??"",y.jsx("span",{className:"text-sky-400",children:o}),y.jsx("span",{className:"text-[var(--text-muted)]",children:s}),iv(c??"")]})}const r=e.match(/^(\s*)(- )(.*)/);if(r){const[,l,a,o]=r;return y.jsxs("span",{children:[l,y.jsx("span",{className:"text-[var(--text-muted)]",children:a}),iv(o??"")]})}return y.jsx("span",{children:e})}function iv(e){if(!e)return"";const t=e.indexOf(" #"),r=t>=0?e.slice(0,t):e,l=t>=0?e.slice(t):"";let a=r;return/^(true|false|null|yes|no)$/i.test(r.trim())?a=y.jsx("span",{className:"text-amber-400",children:r}):/^\d+(\.\d+)?$/.test(r.trim())?a=y.jsx("span",{className:"text-amber-400",children:r}):/^["'].*["']$/.test(r.trim())?a=y.jsx("span",{className:"text-green-400",children:r}):(r.includes("|")||r.includes(">"))&&(a=y.jsx("span",{className:"text-[var(--text-secondary)]",children:r})),y.jsxs(y.Fragment,{children:[a,l&&y.jsx("span",{className:"text-emerald-500/70",children:l})]})}function LN({yaml:e,onClose:t}){const[r,l]=U.useState(new Set);U.useEffect(()=>{const h=d=>{d.key==="Escape"&&t()};return window.addEventListener("keydown",h),()=>window.removeEventListener("keydown",h)},[t]);const a=U.useMemo(()=>e.split(` +`),[e]),o=U.useMemo(()=>RN(a),[a]),s=U.useCallback(h=>{l(d=>{const m=new Set(d);return m.has(h)?m.delete(h):m.add(h),m})},[]),c=U.useMemo(()=>{const h=[];let d=-1;for(let m=0;my.jsxs("div",{className:"flex",children:[y.jsx("span",{className:"inline-flex items-center justify-center flex-shrink-0",style:{width:"1.25rem"},children:m?y.jsx("button",{onClick:()=>s(h),className:"text-[var(--text-muted)] hover:text-[var(--text)] p-0 leading-none",style:{background:"none",border:"none",cursor:"pointer"},children:p?y.jsx(Rr,{className:"w-3 h-3"}):y.jsx(ol,{className:"w-3 h-3"})}):null}),y.jsxs("span",{className:"flex-1",children:[ON(d),p&&y.jsx("span",{className:"text-[var(--text-muted)] text-[11px] ml-2 px-1.5 py-0.5 rounded bg-[var(--surface-hover)] cursor-pointer",onClick:()=>s(h),children:"···"})]})]},h))})})]})]})}function HN(){const e=ue(_=>_.workflowName),t=ue(_=>_.workflowStatus),r=ue(_=>_.isPaused),l=ue(_=>_.workflowYaml),a=ue(_=>_.conductorVersion),[o,s]=U.useState(!1),[c,h]=U.useState(!1),[d,m]=U.useState(!1),[p,x]=U.useState(!1),b=t==="running"||t==="pending";U.useEffect(()=>{r||(s(!1),h(!1),m(!1))},[r]);const w=async()=>{s(!0);try{await fetch("/api/stop",{method:"POST"})}catch(_){console.error("Failed to stop agent:",_),s(!1)}},E=async()=>{h(!0);try{await fetch("/api/resume",{method:"POST"})}catch(_){console.error("Failed to resume agent:",_),h(!1)}},S=async()=>{m(!0);try{await fetch("/api/kill",{method:"POST"})}catch(_){console.error("Failed to kill workflow:",_),m(!1)}};return y.jsxs("header",{className:"flex items-center justify-between px-4 py-2 bg-[var(--surface)] border-b border-[var(--border)] flex-shrink-0",children:[y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx(gw,{className:"w-4 h-4 text-[var(--running)]"}),y.jsx("h1",{className:"text-sm font-semibold text-[var(--text)]",children:"Conductor"}),e&&y.jsxs("span",{className:"text-sm text-[var(--text-muted)] font-normal",children:["— ",e]})]}),y.jsxs("div",{className:"flex items-center gap-3",children:[r?y.jsxs(y.Fragment,{children:[y.jsxs("button",{onClick:E,disabled:c,className:`flex items-center gap-1.5 px-2.5 py-1 text-xs font-medium rounded + bg-emerald-500/10 text-emerald-400 border border-emerald-500/20 + hover:bg-emerald-500/20 hover:border-emerald-500/30 + disabled:opacity-50 disabled:cursor-not-allowed + transition-colors`,title:"Re-execute the paused agent",children:[y.jsx(Ec,{className:"w-3 h-3"}),c?"Resuming...":"Resume"]}),y.jsxs("button",{onClick:S,disabled:d,className:`flex items-center gap-1.5 px-2.5 py-1 text-xs font-medium rounded + bg-red-500/10 text-red-400 border border-red-500/20 + hover:bg-red-500/20 hover:border-red-500/30 + disabled:opacity-50 disabled:cursor-not-allowed + transition-colors`,title:"Stop workflow entirely (checkpoint saved for CLI resume)",children:[y.jsx(sl,{className:"w-3 h-3"}),d?"Killing...":"Kill"]})]}):b?y.jsxs("button",{onClick:w,disabled:o,className:`flex items-center gap-1.5 px-2.5 py-1 text-xs font-medium rounded + bg-red-500/10 text-red-400 border border-red-500/20 + hover:bg-red-500/20 hover:border-red-500/30 + disabled:opacity-50 disabled:cursor-not-allowed + transition-colors`,children:[y.jsx(Sw,{className:"w-3 h-3"}),o?"Stopping...":"Stop"]}):null,l&&y.jsxs("button",{onClick:()=>x(!0),className:`flex items-center gap-1.5 px-2.5 py-1 text-xs font-medium rounded + bg-[var(--surface-hover)] text-[var(--text-secondary)] border border-[var(--border)] + hover:text-[var(--text)] hover:bg-[var(--surface)] + transition-colors`,title:"View workflow YAML configuration",children:[y.jsx(gN,{className:"w-3 h-3"}),"YAML"]}),y.jsxs("a",{href:"/api/logs",download:"conductor-logs.json",className:`flex items-center gap-1.5 px-2.5 py-1 text-xs font-medium rounded + bg-[var(--surface-hover)] text-[var(--text-secondary)] border border-[var(--border)] + hover:text-[var(--text)] hover:bg-[var(--surface)] + transition-colors`,title:"Download full event log as JSON",children:[y.jsx(pN,{className:"w-3 h-3"}),"Logs"]}),y.jsxs("span",{className:"text-xs text-[var(--text-muted)]",children:["v",a??"—"]})]}),p&&l&&y.jsx(LN,{yaml:l,onClose:()=>x(!1)})]})}function BN(){const e=ue(o=>o.getBreadcrumbs),t=ue(o=>o.navigateToContext),r=ue(o=>o.viewContextPath);if(ue(o=>o.subworkflowContexts).length===0&&r.length===0)return null;const a=e();return y.jsxs("div",{className:"flex items-center gap-1 px-4 py-1.5 bg-[var(--surface)] border-b border-[var(--border)] text-xs flex-shrink-0",children:[y.jsx(kc,{className:"w-3 h-3 text-[var(--text-muted)] mr-1"}),a.map((o,s)=>{const c=s===a.length-1,h=JSON.stringify(o.path)===JSON.stringify(r);return y.jsxs("span",{className:"flex items-center gap-1",children:[s>0&&y.jsx(Rr,{className:"w-3 h-3 text-[var(--text-muted)]"}),c?y.jsx("span",{className:"font-semibold text-[var(--text)]",children:o.label}):y.jsx("button",{onClick:()=>t(o.path),className:`hover:text-[var(--running)] transition-colors ${h?"text-[var(--text)] font-medium":"text-[var(--text-muted)]"}`,children:o.label})]},s)})]})}function Me(...e){return e.filter(Boolean).join(" ")}function pt(e){if(e==null)return"";if(e<60)return`${e.toFixed(1)}s`;const t=Math.floor(e/60),r=(e%60).toFixed(0);return`${t}m ${r}s`}function Pn(e){return e==null?"":e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:`${e}`}function bi(e){return e==null?"":`$${e.toFixed(4)}`}function kw(e){return e==null?"":typeof e=="string"?e:JSON.stringify(e,null,2)}function IN(e,t){if(t<=0)return`${e.toLocaleString()} tokens (limit unknown)`;const r=a=>a.toLocaleString(),l=(e/t*100).toFixed(1);return`${r(e)} / ${r(t)} (${l}%)`}function Ew(){const e=ue(c=>c.workflowStatus),t=ue(c=>c.workflowStartTime),r=ue(c=>c.replayMode),l=ue(c=>c.lastEventTime),[a,o]=U.useState("—"),s=U.useRef(null);return U.useEffect(()=>{if(t!=null){if(r){s.current&&(clearInterval(s.current),s.current=null),o(pt((l??t)-t));return}if(e==="running"){const c=()=>{const h=Date.now()/1e3-t;o(pt(h))};return c(),s.current=setInterval(c,500),()=>{s.current&&clearInterval(s.current)}}else(e==="completed"||e==="failed")&&s.current&&(clearInterval(s.current),s.current=null)}},[e,t,r,l]),a}function qN(){const e=ue(_=>_.workflowStatus),t=ue(_=>_.agentsCompleted),r=ue(_=>_.agentsTotal),l=ue(_=>_.totalCost),a=ue(_=>_.totalTokens),o=ue(_=>_.wsStatus),s=ue(_=>_.workflowFailure),c=ue(_=>_.lastEventTime),h=ue(_=>_.iterationLimitGate),d=Ew(),[m,p]=U.useState(null);U.useEffect(()=>{if(e!=="running"||c==null){p(null);return}const _=()=>{p(Math.floor(Date.now()/1e3-c))};_();const N=setInterval(_,1e3);return()=>clearInterval(N)},[e,c]);const x=e==="failed",b=(()=>{if(h&&e==="running"){const _=h.agent_name??h.group_name??"workflow",N=h.skip_gates?" — auto-stopping":" — awaiting decision";return`Iteration limit reached: ${_} ${h.current_iteration}/${h.max_iterations}${N}`}switch(e){case"pending":return"Waiting for workflow…";case"running":return"Running";case"completed":return"Completed";case"failed":{if(!s)return"Failed";const _=s.error_type||"";return _==="MaxIterationsError"?"Failed: exceeded maximum iterations":_==="TimeoutError"?"Failed: workflow timed out":s.message?`Failed: ${s.message.length>60?s.message.slice(0,57)+"...":s.message}`:`Failed: ${_}`}}})(),w=h!=null&&e==="running",E=w?"bg-[var(--waiting)] animate-pulse":{pending:"bg-[var(--pending)]",running:"bg-[var(--running)] animate-pulse",completed:"bg-[var(--completed)]",failed:"bg-[var(--failed)]"}[e],S=(()=>{switch(o){case"connected":return y.jsxs("span",{className:"flex items-center gap-1 text-[var(--completed)]",children:[y.jsx(NN,{className:"w-3 h-3"}),y.jsx("span",{children:"Connected"})]});case"disconnected":return y.jsxs("span",{className:"flex items-center gap-1 text-[var(--failed)]",children:[y.jsx(EN,{className:"w-3 h-3"}),y.jsx("span",{children:"Disconnected"})]});case"reconnecting":return y.jsxs("span",{className:"flex items-center gap-1 text-[var(--waiting)]",children:[y.jsx(fa,{className:"w-3 h-3 animate-spin"}),y.jsx("span",{children:"Reconnecting\\u2026"})]});case"connecting":return y.jsxs("span",{className:"flex items-center gap-1 text-[var(--text-muted)]",children:[y.jsx(fa,{className:"w-3 h-3 animate-spin"}),y.jsx("span",{children:"Connecting\\u2026"})]})}})();return y.jsxs("footer",{className:Me("flex items-center gap-4 px-4 py-1.5 border-t text-xs flex-shrink-0 transition-colors duration-300",x?"bg-red-950/50 border-red-500/30":w?"bg-amber-950/30 border-amber-500/30":"bg-[var(--surface)] border-[var(--border)]"),children:[y.jsx("span",{className:Me("w-2 h-2 rounded-full flex-shrink-0",E)}),y.jsx("span",{className:Me(x?"text-red-300":w?"text-amber-200":"text-[var(--text)]"),children:b}),r>0&&y.jsxs("span",{className:Me(x?"text-red-400/60":"text-[var(--text-muted)]"),children:[t,"/",r," agents"]}),e!=="pending"&&y.jsx("span",{className:Me("font-mono",x?"text-red-400/60":"text-[var(--text-muted)]"),children:d}),a>0&&y.jsxs("span",{className:Me("flex items-center gap-1",x?"text-red-400/60":"text-[var(--text-muted)]"),title:"Total tokens used",children:[y.jsx(ww,{className:"w-3 h-3"}),y.jsx("span",{className:"font-mono",children:a.toLocaleString()})]}),l>0&&y.jsxs("span",{className:Me("flex items-center gap-1",x?"text-red-400/60":"text-[var(--text-muted)]"),title:"Total cost",children:[y.jsx(yw,{className:"w-3 h-3"}),y.jsxs("span",{className:"font-mono",children:["$",l.toFixed(4)]})]}),m!=null&&m>=5&&y.jsxs("span",{className:Me("flex items-center gap-1 font-mono",m>=60?"text-amber-400":"text-[var(--text-muted)]"),title:"Time since last event from the provider",children:[y.jsx(xw,{className:"w-3 h-3"}),y.jsx("span",{children:m>=60?`${Math.floor(m/60)}m ${m%60}s idle`:`${m}s idle`})]}),y.jsx("span",{className:"flex-1"}),S]})}const UN=[1,5,10,20,50];function $N(e,t){if(t===0||e.length===0)return"+0.0s";const r=e[0].timestamp,a=e[Math.min(t,e.length)-1].timestamp-r;if(a<60)return`+${a.toFixed(1)}s`;const o=Math.floor(a/60),s=a%60;return`+${o}m${s.toFixed(0)}s`}function VN(){const e=ue(p=>p.replayPosition),t=ue(p=>p.replayTotalEvents),r=ue(p=>p.replayPlaying),l=ue(p=>p.replaySpeed),a=ue(p=>p.replayEvents),o=ue(p=>p.setReplayPosition),s=ue(p=>p.setReplayPlaying),c=ue(p=>p.setReplaySpeed),h=p=>{const x=parseInt(p.target.value,10);o(x),r&&s(!1)},d=()=>{!r&&e>=t&&o(0),s(!r)},m=t>0?e/t*100:0;return y.jsxs("footer",{className:"flex items-center gap-3 px-4 py-1.5 border-t bg-[var(--surface)] border-[var(--border)] text-xs flex-shrink-0",children:[y.jsx("button",{onClick:d,className:"flex items-center justify-center w-6 h-6 rounded hover:bg-[var(--surface-hover)] text-[var(--text-secondary)] hover:text-[var(--text)] transition-colors",title:r?"Pause":"Play",children:r?y.jsx(bN,{className:"w-3.5 h-3.5"}):y.jsx(Ec,{className:"w-3.5 h-3.5"})}),y.jsxs("div",{className:"flex-1 relative flex items-center",children:[y.jsx("input",{type:"range",min:0,max:t,value:e,onChange:h,className:"w-full h-1 appearance-none rounded-full cursor-pointer",style:{background:`linear-gradient(to right, var(--accent) 0%, var(--accent) ${m}%, var(--border) ${m}%, var(--border) 100%)`,WebkitAppearance:"none"}}),y.jsx("style",{children:` + footer input[type="range"]::-webkit-slider-thumb { + -webkit-appearance: none; + width: 12px; + height: 12px; + border-radius: 50%; + background: var(--accent); + border: 2px solid var(--surface); + cursor: pointer; + box-shadow: 0 0 4px rgba(99, 102, 241, 0.4); + } + footer input[type="range"]::-moz-range-thumb { + width: 12px; + height: 12px; + border-radius: 50%; + background: var(--accent); + border: 2px solid var(--surface); + cursor: pointer; + box-shadow: 0 0 4px rgba(99, 102, 241, 0.4); + } + `})]}),y.jsx("span",{className:"text-[var(--text-muted)] font-mono whitespace-nowrap",children:$N(a,e)}),y.jsxs("span",{className:"text-[var(--text-muted)] font-mono whitespace-nowrap",children:["Event ",e,"/",t]}),y.jsx("div",{className:"flex items-center gap-0.5",children:UN.map(p=>y.jsxs("button",{onClick:()=>c(p),className:Me("px-1.5 py-0.5 rounded text-xs font-mono transition-colors",l===p?"bg-[var(--accent)] text-white":"text-[var(--text-muted)] hover:text-[var(--text-secondary)] hover:bg-[var(--surface-hover)]"),children:[p,"×"]},p))})]})}const Nc=U.createContext(null);Nc.displayName="PanelGroupContext";const vt={group:"data-panel-group",groupDirection:"data-panel-group-direction",groupId:"data-panel-group-id",panel:"data-panel",panelCollapsible:"data-panel-collapsible",panelId:"data-panel-id",panelSize:"data-panel-size",resizeHandle:"data-resize-handle",resizeHandleActive:"data-resize-handle-active",resizeHandleEnabled:"data-panel-resize-handle-enabled",resizeHandleId:"data-panel-resize-handle-id",resizeHandleState:"data-resize-handle-state"},vm=10,Ki=U.useLayoutEffect,lv=JE.useId,PN=typeof lv=="function"?lv:()=>null;let GN=0;function bm(e=null){const t=PN(),r=U.useRef(e||t||null);return r.current===null&&(r.current=""+GN++),e??r.current}function Nw({children:e,className:t="",collapsedSize:r,collapsible:l,defaultSize:a,forwardedRef:o,id:s,maxSize:c,minSize:h,onCollapse:d,onExpand:m,onResize:p,order:x,style:b,tagName:w="div",...E}){const S=U.useContext(Nc);if(S===null)throw Error("Panel components must be rendered within a PanelGroup container");const{collapsePanel:_,expandPanel:N,getPanelSize:k,getPanelStyle:T,groupId:M,isPanelCollapsed:A,reevaluatePanelConstraints:L,registerPanel:R,resizePanel:V,unregisterPanel:H}=S,B=bm(s),$=U.useRef({callbacks:{onCollapse:d,onExpand:m,onResize:p},constraints:{collapsedSize:r,collapsible:l,defaultSize:a,maxSize:c,minSize:h},id:B,idIsFromProps:s!==void 0,order:x});U.useRef({didLogMissingDefaultSizeWarning:!1}),Ki(()=>{const{callbacks:I,constraints:F}=$.current,z={...F};$.current.id=B,$.current.idIsFromProps=s!==void 0,$.current.order=x,I.onCollapse=d,I.onExpand=m,I.onResize=p,F.collapsedSize=r,F.collapsible=l,F.defaultSize=a,F.maxSize=c,F.minSize=h,(z.collapsedSize!==F.collapsedSize||z.collapsible!==F.collapsible||z.maxSize!==F.maxSize||z.minSize!==F.minSize)&&L($.current,z)}),Ki(()=>{const I=$.current;return R(I),()=>{H(I)}},[x,B,R,H]),U.useImperativeHandle(o,()=>({collapse:()=>{_($.current)},expand:I=>{N($.current,I)},getId(){return B},getSize(){return k($.current)},isCollapsed(){return A($.current)},isExpanded(){return!A($.current)},resize:I=>{V($.current,I)}}),[_,N,k,A,B,V]);const ee=T($.current,a);return U.createElement(w,{...E,children:e,className:t,id:B,style:{...ee,...b},[vt.groupId]:M,[vt.panel]:"",[vt.panelCollapsible]:l||void 0,[vt.panelId]:B,[vt.panelSize]:parseFloat(""+ee.flexGrow).toFixed(1)})}const No=U.forwardRef((e,t)=>U.createElement(Nw,{...e,forwardedRef:t}));Nw.displayName="Panel";No.displayName="forwardRef(Panel)";let Vp=null,Ku=-1,yi=null;function FN(e,t){if(t){const r=(t&zw)!==0,l=(t&Mw)!==0,a=(t&Dw)!==0,o=(t&Rw)!==0;if(r)return a?"se-resize":o?"ne-resize":"e-resize";if(l)return a?"sw-resize":o?"nw-resize":"w-resize";if(a)return"s-resize";if(o)return"n-resize"}switch(e){case"horizontal":return"ew-resize";case"intersection":return"move";case"vertical":return"ns-resize"}}function YN(){yi!==null&&(document.head.removeChild(yi),Vp=null,yi=null,Ku=-1)}function hh(e,t){var r,l;const a=FN(e,t);if(Vp!==a){if(Vp=a,yi===null&&(yi=document.createElement("style"),document.head.appendChild(yi)),Ku>=0){var o;(o=yi.sheet)===null||o===void 0||o.removeRule(Ku)}Ku=(r=(l=yi.sheet)===null||l===void 0?void 0:l.insertRule(`*{cursor: ${a} !important;}`))!==null&&r!==void 0?r:-1}}function Cw(e){return e.type==="keydown"}function jw(e){return e.type.startsWith("pointer")}function Tw(e){return e.type.startsWith("mouse")}function Cc(e){if(jw(e)){if(e.isPrimary)return{x:e.clientX,y:e.clientY}}else if(Tw(e))return{x:e.clientX,y:e.clientY};return{x:1/0,y:1/0}}function XN(){if(typeof matchMedia=="function")return matchMedia("(pointer:coarse)").matches?"coarse":"fine"}function QN(e,t,r){return e.xt.x&&e.yt.y}function ZN(e,t){if(e===t)throw new Error("Cannot compare node with itself");const r={a:sv(e),b:sv(t)};let l;for(;r.a.at(-1)===r.b.at(-1);)e=r.a.pop(),t=r.b.pop(),l=e;He(l,"Stacking order can only be calculated for elements with a common ancestor");const a={a:ov(av(r.a)),b:ov(av(r.b))};if(a.a===a.b){const o=l.childNodes,s={a:r.a.at(-1),b:r.b.at(-1)};let c=o.length;for(;c--;){const h=o[c];if(h===s.a)return 1;if(h===s.b)return-1}}return Math.sign(a.a-a.b)}const KN=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function JN(e){var t;const r=getComputedStyle((t=Aw(e))!==null&&t!==void 0?t:e).display;return r==="flex"||r==="inline-flex"}function WN(e){const t=getComputedStyle(e);return!!(t.position==="fixed"||t.zIndex!=="auto"&&(t.position!=="static"||JN(e))||+t.opacity<1||"transform"in t&&t.transform!=="none"||"webkitTransform"in t&&t.webkitTransform!=="none"||"mixBlendMode"in t&&t.mixBlendMode!=="normal"||"filter"in t&&t.filter!=="none"||"webkitFilter"in t&&t.webkitFilter!=="none"||"isolation"in t&&t.isolation==="isolate"||KN.test(t.willChange)||t.webkitOverflowScrolling==="touch")}function av(e){let t=e.length;for(;t--;){const r=e[t];if(He(r,"Missing node"),WN(r))return r}return null}function ov(e){return e&&Number(getComputedStyle(e).zIndex)||0}function sv(e){const t=[];for(;e;)t.push(e),e=Aw(e);return t}function Aw(e){const{parentNode:t}=e;return t&&t instanceof ShadowRoot?t.host:t}const zw=1,Mw=2,Dw=4,Rw=8,eC=XN()==="coarse";let Gn=[],oa=!1,Xi=new Map,jc=new Map;const Ho=new Set;function tC(e,t,r,l,a){var o;const{ownerDocument:s}=t,c={direction:r,element:t,hitAreaMargins:l,setResizeHandlerState:a},h=(o=Xi.get(s))!==null&&o!==void 0?o:0;return Xi.set(s,h+1),Ho.add(c),ac(),function(){var m;jc.delete(e),Ho.delete(c);const p=(m=Xi.get(s))!==null&&m!==void 0?m:1;if(Xi.set(s,p-1),ac(),p===1&&Xi.delete(s),Gn.includes(c)){const x=Gn.indexOf(c);x>=0&&Gn.splice(x,1),_m(),a("up",!0,null)}}}function nC(e){const{target:t}=e,{x:r,y:l}=Cc(e);oa=!0,wm({target:t,x:r,y:l}),ac(),Gn.length>0&&(oc("down",e),e.preventDefault(),Ow(t)||e.stopImmediatePropagation())}function ph(e){const{x:t,y:r}=Cc(e);if(oa&&e.buttons===0&&(oa=!1,oc("up",e)),!oa){const{target:l}=e;wm({target:l,x:t,y:r})}oc("move",e),_m(),Gn.length>0&&e.preventDefault()}function mh(e){const{target:t}=e,{x:r,y:l}=Cc(e);jc.clear(),oa=!1,Gn.length>0&&(e.preventDefault(),Ow(t)||e.stopImmediatePropagation()),oc("up",e),wm({target:t,x:r,y:l}),_m(),ac()}function Ow(e){let t=e;for(;t;){if(t.hasAttribute(vt.resizeHandle))return!0;t=t.parentElement}return!1}function wm({target:e,x:t,y:r}){Gn.splice(0);let l=null;(e instanceof HTMLElement||e instanceof SVGElement)&&(l=e),Ho.forEach(a=>{const{element:o,hitAreaMargins:s}=a,c=o.getBoundingClientRect(),{bottom:h,left:d,right:m,top:p}=c,x=eC?s.coarse:s.fine;if(t>=d-x&&t<=m+x&&r>=p-x&&r<=h+x){if(l!==null&&document.contains(l)&&o!==l&&!o.contains(l)&&!l.contains(o)&&ZN(l,o)>0){let w=l,E=!1;for(;w&&!w.contains(o);){if(QN(w.getBoundingClientRect(),c)){E=!0;break}w=w.parentElement}if(E)return}Gn.push(a)}})}function gh(e,t){jc.set(e,t)}function _m(){let e=!1,t=!1;Gn.forEach(l=>{const{direction:a}=l;a==="horizontal"?e=!0:t=!0});let r=0;jc.forEach(l=>{r|=l}),e&&t?hh("intersection",r):e?hh("horizontal",r):t?hh("vertical",r):YN()}let xh=new AbortController;function ac(){xh.abort(),xh=new AbortController;const e={capture:!0,signal:xh.signal};Ho.size&&(oa?(Gn.length>0&&Xi.forEach((t,r)=>{const{body:l}=r;t>0&&(l.addEventListener("contextmenu",mh,e),l.addEventListener("pointerleave",ph,e),l.addEventListener("pointermove",ph,e))}),window.addEventListener("pointerup",mh,e),window.addEventListener("pointercancel",mh,e)):Xi.forEach((t,r)=>{const{body:l}=r;t>0&&(l.addEventListener("pointerdown",nC,e),l.addEventListener("pointermove",ph,e))}))}function oc(e,t){Ho.forEach(r=>{const{setResizeHandlerState:l}=r,a=Gn.includes(r);l(e,a,t)})}function rC(){const[e,t]=U.useState(0);return U.useCallback(()=>t(r=>r+1),[])}function He(e,t){if(!e)throw console.error(t),Error(t)}function el(e,t,r=vm){return e.toFixed(r)===t.toFixed(r)?0:e>t?1:-1}function Ar(e,t,r=vm){return el(e,t,r)===0}function bn(e,t,r){return el(e,t,r)===0}function iC(e,t,r){if(e.length!==t.length)return!1;for(let l=0;l0&&(e=e<0?0-_:_)}}}{const p=e<0?c:h,x=r[p];He(x,`No panel constraints found for index ${p}`);const{collapsedSize:b=0,collapsible:w,minSize:E=0}=x;if(w){const S=t[p];if(He(S!=null,`Previous layout not found for panel index ${p}`),bn(S,E)){const _=S-b;el(_,Math.abs(e))>0&&(e=e<0?0-_:_)}}}}{const p=e<0?1:-1;let x=e<0?h:c,b=0;for(;;){const E=t[x];He(E!=null,`Previous layout not found for panel index ${x}`);const _=ra({panelConstraints:r,panelIndex:x,size:100})-E;if(b+=_,x+=p,x<0||x>=r.length)break}const w=Math.min(Math.abs(e),Math.abs(b));e=e<0?0-w:w}{let x=e<0?c:h;for(;x>=0&&x=0))break;e<0?x--:x++}}if(iC(a,s))return a;{const p=e<0?h:c,x=t[p];He(x!=null,`Previous layout not found for panel index ${p}`);const b=x+d,w=ra({panelConstraints:r,panelIndex:p,size:b});if(s[p]=w,!bn(w,b)){let E=b-w,_=e<0?h:c;for(;_>=0&&_0?_--:_++}}}const m=s.reduce((p,x)=>x+p,0);return bn(m,100)?s:a}function lC({layout:e,panelsArray:t,pivotIndices:r}){let l=0,a=100,o=0,s=0;const c=r[0];He(c!=null,"No pivot index found"),t.forEach((p,x)=>{const{constraints:b}=p,{maxSize:w=100,minSize:E=0}=b;x===c?(l=E,a=w):(o+=E,s+=w)});const h=Math.min(a,100-o),d=Math.max(l,100-s),m=e[c];return{valueMax:h,valueMin:d,valueNow:m}}function Bo(e,t=document){return Array.from(t.querySelectorAll(`[${vt.resizeHandleId}][data-panel-group-id="${e}"]`))}function Lw(e,t,r=document){const a=Bo(e,r).findIndex(o=>o.getAttribute(vt.resizeHandleId)===t);return a??null}function Hw(e,t,r){const l=Lw(e,t,r);return l!=null?[l,l+1]:[-1,-1]}function Bw(e,t=document){var r;if(t instanceof HTMLElement&&(t==null||(r=t.dataset)===null||r===void 0?void 0:r.panelGroupId)==e)return t;const l=t.querySelector(`[data-panel-group][data-panel-group-id="${e}"]`);return l||null}function Tc(e,t=document){const r=t.querySelector(`[${vt.resizeHandleId}="${e}"]`);return r||null}function aC(e,t,r,l=document){var a,o,s,c;const h=Tc(t,l),d=Bo(e,l),m=h?d.indexOf(h):-1,p=(a=(o=r[m])===null||o===void 0?void 0:o.id)!==null&&a!==void 0?a:null,x=(s=(c=r[m+1])===null||c===void 0?void 0:c.id)!==null&&s!==void 0?s:null;return[p,x]}function oC({committedValuesRef:e,eagerValuesRef:t,groupId:r,layout:l,panelDataArray:a,panelGroupElement:o,setLayout:s}){U.useRef({didWarnAboutMissingResizeHandle:!1}),Ki(()=>{if(!o)return;const c=Bo(r,o);for(let h=0;h{c.forEach((h,d)=>{h.removeAttribute("aria-controls"),h.removeAttribute("aria-valuemax"),h.removeAttribute("aria-valuemin"),h.removeAttribute("aria-valuenow")})}},[r,l,a,o]),U.useEffect(()=>{if(!o)return;const c=t.current;He(c,"Eager values not found");const{panelDataArray:h}=c,d=Bw(r,o);He(d!=null,`No group found for id "${r}"`);const m=Bo(r,o);He(m,`No resize handles found for group id "${r}"`);const p=m.map(x=>{const b=x.getAttribute(vt.resizeHandleId);He(b,"Resize handle element has no handle id attribute");const[w,E]=aC(r,b,h,o);if(w==null||E==null)return()=>{};const S=_=>{if(!_.defaultPrevented)switch(_.key){case"Enter":{_.preventDefault();const N=h.findIndex(k=>k.id===w);if(N>=0){const k=h[N];He(k,`No panel data found for index ${N}`);const T=l[N],{collapsedSize:M=0,collapsible:A,minSize:L=0}=k.constraints;if(T!=null&&A){const R=Co({delta:bn(T,M)?L-M:M-T,initialLayout:l,panelConstraints:h.map(V=>V.constraints),pivotIndices:Hw(r,b,o),prevLayout:l,trigger:"keyboard"});l!==R&&s(R)}}break}}};return x.addEventListener("keydown",S),()=>{x.removeEventListener("keydown",S)}});return()=>{p.forEach(x=>x())}},[o,e,t,r,l,a,s])}function uv(e,t){if(e.length!==t.length)return!1;for(let r=0;ro.constraints);let l=0,a=100;for(let o=0;o{const o=e[a];He(o,`Panel data not found for index ${a}`);const{callbacks:s,constraints:c,id:h}=o,{collapsedSize:d=0,collapsible:m}=c,p=r[h];if(p==null||l!==p){r[h]=l;const{onCollapse:x,onExpand:b,onResize:w}=s;w&&w(l,p),m&&(x||b)&&(b&&(p==null||Ar(p,d))&&!Ar(l,d)&&b(),x&&(p==null||!Ar(p,d))&&Ar(l,d)&&x())}})}function Hu(e,t){if(e.length!==t.length)return!1;for(let r=0;r{r!==null&&clearTimeout(r),r=setTimeout(()=>{e(...a)},t)}}function cv(e){try{if(typeof localStorage<"u")e.getItem=t=>localStorage.getItem(t),e.setItem=(t,r)=>{localStorage.setItem(t,r)};else throw new Error("localStorage not supported in this environment")}catch(t){console.error(t),e.getItem=()=>null,e.setItem=()=>{}}}function qw(e){return`react-resizable-panels:${e}`}function Uw(e){return e.map(t=>{const{constraints:r,id:l,idIsFromProps:a,order:o}=t;return a?l:o?`${o}:${JSON.stringify(r)}`:JSON.stringify(r)}).sort((t,r)=>t.localeCompare(r)).join(",")}function $w(e,t){try{const r=qw(e),l=t.getItem(r);if(l){const a=JSON.parse(l);if(typeof a=="object"&&a!=null)return a}}catch{}return null}function hC(e,t,r){var l,a;const o=(l=$w(e,r))!==null&&l!==void 0?l:{},s=Uw(t);return(a=o[s])!==null&&a!==void 0?a:null}function pC(e,t,r,l,a){var o;const s=qw(e),c=Uw(t),h=(o=$w(e,a))!==null&&o!==void 0?o:{};h[c]={expandToSizes:Object.fromEntries(r.entries()),layout:l};try{a.setItem(s,JSON.stringify(h))}catch(d){console.error(d)}}function fv({layout:e,panelConstraints:t}){const r=[...e],l=r.reduce((o,s)=>o+s,0);if(r.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${r.map(o=>`${o}%`).join(", ")}`);if(!bn(l,100)&&r.length>0)for(let o=0;o(cv(jo),jo.getItem(e)),setItem:(e,t)=>{cv(jo),jo.setItem(e,t)}},dv={};function Vw({autoSaveId:e=null,children:t,className:r="",direction:l,forwardedRef:a,id:o=null,onLayout:s=null,keyboardResizeBy:c=null,storage:h=jo,style:d,tagName:m="div",...p}){const x=bm(o),b=U.useRef(null),[w,E]=U.useState(null),[S,_]=U.useState([]),N=rC(),k=U.useRef({}),T=U.useRef(new Map),M=U.useRef(0),A=U.useRef({autoSaveId:e,direction:l,dragState:w,id:x,keyboardResizeBy:c,onLayout:s,storage:h}),L=U.useRef({layout:S,panelDataArray:[],panelDataArrayChanged:!1});U.useRef({didLogIdAndOrderWarning:!1,didLogPanelConstraintsWarning:!1,prevPanelIds:[]}),U.useImperativeHandle(a,()=>({getId:()=>A.current.id,getLayout:()=>{const{layout:C}=L.current;return C},setLayout:C=>{const{onLayout:P}=A.current,{layout:X,panelDataArray:J}=L.current,ne=fv({layout:C,panelConstraints:J.map(re=>re.constraints)});uv(X,ne)||(_(ne),L.current.layout=ne,P&&P(ne),Zl(J,ne,k.current))}}),[]),Ki(()=>{A.current.autoSaveId=e,A.current.direction=l,A.current.dragState=w,A.current.id=x,A.current.onLayout=s,A.current.storage=h}),oC({committedValuesRef:A,eagerValuesRef:L,groupId:x,layout:S,panelDataArray:L.current.panelDataArray,setLayout:_,panelGroupElement:b.current}),U.useEffect(()=>{const{panelDataArray:C}=L.current;if(e){if(S.length===0||S.length!==C.length)return;let P=dv[e];P==null&&(P=dC(pC,mC),dv[e]=P);const X=[...C],J=new Map(T.current);P(e,X,J,S,h)}},[e,S,h]),U.useEffect(()=>{});const R=U.useCallback(C=>{const{onLayout:P}=A.current,{layout:X,panelDataArray:J}=L.current;if(C.constraints.collapsible){const ne=J.map(be=>be.constraints),{collapsedSize:re=0,panelSize:se,pivotIndices:xe}=Pi(J,C,X);if(He(se!=null,`Panel size not found for panel "${C.id}"`),!Ar(se,re)){T.current.set(C.id,se);const ye=ea(J,C)===J.length-1?se-re:re-se,pe=Co({delta:ye,initialLayout:X,panelConstraints:ne,pivotIndices:xe,prevLayout:X,trigger:"imperative-api"});Hu(X,pe)||(_(pe),L.current.layout=pe,P&&P(pe),Zl(J,pe,k.current))}}},[]),V=U.useCallback((C,P)=>{const{onLayout:X}=A.current,{layout:J,panelDataArray:ne}=L.current;if(C.constraints.collapsible){const re=ne.map(Se=>Se.constraints),{collapsedSize:se=0,panelSize:xe=0,minSize:be=0,pivotIndices:ye}=Pi(ne,C,J),pe=P??be;if(Ar(xe,se)){const Se=T.current.get(C.id),De=Se!=null&&Se>=pe?Se:pe,ct=ea(ne,C)===ne.length-1?xe-De:De-xe,nt=Co({delta:ct,initialLayout:J,panelConstraints:re,pivotIndices:ye,prevLayout:J,trigger:"imperative-api"});Hu(J,nt)||(_(nt),L.current.layout=nt,X&&X(nt),Zl(ne,nt,k.current))}}},[]),H=U.useCallback(C=>{const{layout:P,panelDataArray:X}=L.current,{panelSize:J}=Pi(X,C,P);return He(J!=null,`Panel size not found for panel "${C.id}"`),J},[]),B=U.useCallback((C,P)=>{const{panelDataArray:X}=L.current,J=ea(X,C);return fC({defaultSize:P,dragState:w,layout:S,panelData:X,panelIndex:J})},[w,S]),$=U.useCallback(C=>{const{layout:P,panelDataArray:X}=L.current,{collapsedSize:J=0,collapsible:ne,panelSize:re}=Pi(X,C,P);return He(re!=null,`Panel size not found for panel "${C.id}"`),ne===!0&&Ar(re,J)},[]),ee=U.useCallback(C=>{const{layout:P,panelDataArray:X}=L.current,{collapsedSize:J=0,collapsible:ne,panelSize:re}=Pi(X,C,P);return He(re!=null,`Panel size not found for panel "${C.id}"`),!ne||el(re,J)>0},[]),I=U.useCallback(C=>{const{panelDataArray:P}=L.current;P.push(C),P.sort((X,J)=>{const ne=X.order,re=J.order;return ne==null&&re==null?0:ne==null?-1:re==null?1:ne-re}),L.current.panelDataArrayChanged=!0,N()},[N]);Ki(()=>{if(L.current.panelDataArrayChanged){L.current.panelDataArrayChanged=!1;const{autoSaveId:C,onLayout:P,storage:X}=A.current,{layout:J,panelDataArray:ne}=L.current;let re=null;if(C){const xe=hC(C,ne,X);xe&&(T.current=new Map(Object.entries(xe.expandToSizes)),re=xe.layout)}re==null&&(re=cC({panelDataArray:ne}));const se=fv({layout:re,panelConstraints:ne.map(xe=>xe.constraints)});uv(J,se)||(_(se),L.current.layout=se,P&&P(se),Zl(ne,se,k.current))}}),Ki(()=>{const C=L.current;return()=>{C.layout=[]}},[]);const F=U.useCallback(C=>{let P=!1;const X=b.current;return X&&window.getComputedStyle(X,null).getPropertyValue("direction")==="rtl"&&(P=!0),function(ne){ne.preventDefault();const re=b.current;if(!re)return()=>null;const{direction:se,dragState:xe,id:be,keyboardResizeBy:ye,onLayout:pe}=A.current,{layout:Se,panelDataArray:De}=L.current,{initialLayout:je}=xe??{},ct=Hw(be,C,re);let nt=uC(ne,C,se,xe,ye,re);const Dt=se==="horizontal";Dt&&P&&(nt=-nt);const Pt=De.map(Rn=>Rn.constraints),Bt=Co({delta:nt,initialLayout:je??Se,panelConstraints:Pt,pivotIndices:ct,prevLayout:Se,trigger:Cw(ne)?"keyboard":"mouse-or-touch"}),kn=!Hu(Se,Bt);(jw(ne)||Tw(ne))&&M.current!=nt&&(M.current=nt,!kn&&nt!==0?Dt?gh(C,nt<0?zw:Mw):gh(C,nt<0?Dw:Rw):gh(C,0)),kn&&(_(Bt),L.current.layout=Bt,pe&&pe(Bt),Zl(De,Bt,k.current))}},[]),z=U.useCallback((C,P)=>{const{onLayout:X}=A.current,{layout:J,panelDataArray:ne}=L.current,re=ne.map(Se=>Se.constraints),{panelSize:se,pivotIndices:xe}=Pi(ne,C,J);He(se!=null,`Panel size not found for panel "${C.id}"`);const ye=ea(ne,C)===ne.length-1?se-P:P-se,pe=Co({delta:ye,initialLayout:J,panelConstraints:re,pivotIndices:xe,prevLayout:J,trigger:"imperative-api"});Hu(J,pe)||(_(pe),L.current.layout=pe,X&&X(pe),Zl(ne,pe,k.current))},[]),G=U.useCallback((C,P)=>{const{layout:X,panelDataArray:J}=L.current,{collapsedSize:ne=0,collapsible:re}=P,{collapsedSize:se=0,collapsible:xe,maxSize:be=100,minSize:ye=0}=C.constraints,{panelSize:pe}=Pi(J,C,X);pe!=null&&(re&&xe&&Ar(pe,ne)?Ar(ne,se)||z(C,se):pebe&&z(C,be))},[z]),Q=U.useCallback((C,P)=>{const{direction:X}=A.current,{layout:J}=L.current;if(!b.current)return;const ne=Tc(C,b.current);He(ne,`Drag handle element not found for id "${C}"`);const re=Iw(X,P);E({dragHandleId:C,dragHandleRect:ne.getBoundingClientRect(),initialCursorPosition:re,initialLayout:J})},[]),K=U.useCallback(()=>{E(null)},[]),D=U.useCallback(C=>{const{panelDataArray:P}=L.current,X=ea(P,C);X>=0&&(P.splice(X,1),delete k.current[C.id],L.current.panelDataArrayChanged=!0,N())},[N]),q=U.useMemo(()=>({collapsePanel:R,direction:l,dragState:w,expandPanel:V,getPanelSize:H,getPanelStyle:B,groupId:x,isPanelCollapsed:$,isPanelExpanded:ee,reevaluatePanelConstraints:G,registerPanel:I,registerResizeHandle:F,resizePanel:z,startDragging:Q,stopDragging:K,unregisterPanel:D,panelGroupElement:b.current}),[R,w,l,V,H,B,x,$,ee,G,I,F,z,Q,K,D]),Y={display:"flex",flexDirection:l==="horizontal"?"row":"column",height:"100%",overflow:"hidden",width:"100%"};return U.createElement(Nc.Provider,{value:q},U.createElement(m,{...p,children:t,className:r,id:o,ref:b,style:{...Y,...d},[vt.group]:"",[vt.groupDirection]:l,[vt.groupId]:x}))}const Pp=U.forwardRef((e,t)=>U.createElement(Vw,{...e,forwardedRef:t}));Vw.displayName="PanelGroup";Pp.displayName="forwardRef(PanelGroup)";function ea(e,t){return e.findIndex(r=>r===t||r.id===t.id)}function Pi(e,t,r){const l=ea(e,t),o=l===e.length-1?[l-1,l]:[l,l+1],s=r[l];return{...t.constraints,panelSize:s,pivotIndices:o}}function gC({disabled:e,handleId:t,resizeHandler:r,panelGroupElement:l}){U.useEffect(()=>{if(e||r==null||l==null)return;const a=Tc(t,l);if(a==null)return;const o=s=>{if(!s.defaultPrevented)switch(s.key){case"ArrowDown":case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"End":case"Home":{s.preventDefault(),r(s);break}case"F6":{s.preventDefault();const c=a.getAttribute(vt.groupId);He(c,`No group element found for id "${c}"`);const h=Bo(c,l),d=Lw(c,t,l);He(d!==null,`No resize element found for id "${t}"`);const m=s.shiftKey?d>0?d-1:h.length-1:d+1{a.removeEventListener("keydown",o)}},[l,e,t,r])}function Gp({children:e=null,className:t="",disabled:r=!1,hitAreaMargins:l,id:a,onBlur:o,onClick:s,onDragging:c,onFocus:h,onPointerDown:d,onPointerUp:m,style:p={},tabIndex:x=0,tagName:b="div",...w}){var E,S;const _=U.useRef(null),N=U.useRef({onClick:s,onDragging:c,onPointerDown:d,onPointerUp:m});U.useEffect(()=>{N.current.onClick=s,N.current.onDragging=c,N.current.onPointerDown=d,N.current.onPointerUp=m});const k=U.useContext(Nc);if(k===null)throw Error("PanelResizeHandle components must be rendered within a PanelGroup container");const{direction:T,groupId:M,registerResizeHandle:A,startDragging:L,stopDragging:R,panelGroupElement:V}=k,H=bm(a),[B,$]=U.useState("inactive"),[ee,I]=U.useState(!1),[F,z]=U.useState(null),G=U.useRef({state:B});Ki(()=>{G.current.state=B}),U.useEffect(()=>{if(r)z(null);else{const q=A(H);z(()=>q)}},[r,H,A]);const Q=(E=l==null?void 0:l.coarse)!==null&&E!==void 0?E:15,K=(S=l==null?void 0:l.fine)!==null&&S!==void 0?S:5;U.useEffect(()=>{if(r||F==null)return;const q=_.current;He(q,"Element ref not attached");let Y=!1;return tC(H,q,T,{coarse:Q,fine:K},(P,X,J)=>{if(!X){$("inactive");return}switch(P){case"down":{$("drag"),Y=!1,He(J,'Expected event to be defined for "down" action'),L(H,J);const{onDragging:ne,onPointerDown:re}=N.current;ne==null||ne(!0),re==null||re();break}case"move":{const{state:ne}=G.current;Y=!0,ne!=="drag"&&$("hover"),He(J,'Expected event to be defined for "move" action'),F(J);break}case"up":{$("hover"),R();const{onClick:ne,onDragging:re,onPointerUp:se}=N.current;re==null||re(!1),se==null||se(),Y||ne==null||ne();break}}})},[Q,T,r,K,A,H,F,L,R]),gC({disabled:r,handleId:H,resizeHandler:F,panelGroupElement:V});const D={touchAction:"none",userSelect:"none"};return U.createElement(b,{...w,children:e,className:t,id:a,onBlur:()=>{I(!1),o==null||o()},onFocus:()=>{I(!0),h==null||h()},ref:_,role:"separator",style:{...D,...p},tabIndex:x,[vt.groupDirection]:T,[vt.groupId]:M,[vt.resizeHandle]:"",[vt.resizeHandleActive]:B==="drag"?"pointer":ee?"keyboard":void 0,[vt.resizeHandleEnabled]:!r,[vt.resizeHandleId]:H,[vt.resizeHandleState]:B})}Gp.displayName="PanelResizeHandle";function Mt(e){if(typeof e=="string"||typeof e=="number")return""+e;let t="";if(Array.isArray(e))for(let r=0,l;r{}};function Ac(){for(var e=0,t=arguments.length,r={},l;e=0&&(l=r.slice(a+1),r=r.slice(0,a)),r&&!t.hasOwnProperty(r))throw new Error("unknown type: "+r);return{type:r,name:l}})}Ju.prototype=Ac.prototype={constructor:Ju,on:function(e,t){var r=this._,l=yC(e+"",r),a,o=-1,s=l.length;if(arguments.length<2){for(;++o0)for(var r=new Array(a),l=0,a,o;l=0&&(t=e.slice(0,r))!=="xmlns"&&(e=e.slice(r+1)),pv.hasOwnProperty(t)?{space:pv[t],local:e}:e}function bC(e){return function(){var t=this.ownerDocument,r=this.namespaceURI;return r===Fp&&t.documentElement.namespaceURI===Fp?t.createElement(e):t.createElementNS(r,e)}}function wC(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Pw(e){var t=zc(e);return(t.local?wC:bC)(t)}function _C(){}function Sm(e){return e==null?_C:function(){return this.querySelector(e)}}function SC(e){typeof e!="function"&&(e=Sm(e));for(var t=this._groups,r=t.length,l=new Array(r),a=0;a=k&&(k=N+1);!(M=S[k])&&++k=0;)(s=l[a])&&(o&&s.compareDocumentPosition(o)^4&&o.parentNode.insertBefore(s,o),o=s);return this}function XC(e){e||(e=QC);function t(p,x){return p&&x?e(p.__data__,x.__data__):!p-!x}for(var r=this._groups,l=r.length,a=new Array(l),o=0;ot?1:e>=t?0:NaN}function ZC(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function KC(){return Array.from(this)}function JC(){for(var e=this._groups,t=0,r=e.length;t1?this.each((t==null?u3:typeof t=="function"?f3:c3)(e,t,r??"")):da(this.node(),e)}function da(e,t){return e.style.getPropertyValue(t)||Qw(e).getComputedStyle(e,null).getPropertyValue(t)}function h3(e){return function(){delete this[e]}}function p3(e,t){return function(){this[e]=t}}function m3(e,t){return function(){var r=t.apply(this,arguments);r==null?delete this[e]:this[e]=r}}function g3(e,t){return arguments.length>1?this.each((t==null?h3:typeof t=="function"?m3:p3)(e,t)):this.node()[e]}function Zw(e){return e.trim().split(/^|\s+/)}function km(e){return e.classList||new Kw(e)}function Kw(e){this._node=e,this._names=Zw(e.getAttribute("class")||"")}Kw.prototype={add:function(e){var t=this._names.indexOf(e);t<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 Jw(e,t){for(var r=km(e),l=-1,a=t.length;++l=0&&(r=t.slice(l+1),t=t.slice(0,l)),{type:t,name:r}})}function P3(e){return function(){var t=this.__on;if(t){for(var r=0,l=-1,a=t.length,o;r()=>e;function Yp(e,{sourceEvent:t,subject:r,target:l,identifier:a,active:o,x:s,y:c,dx:h,dy:d,dispatch:m}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:r,enumerable:!0,configurable:!0},target:{value:l,enumerable:!0,configurable:!0},identifier:{value:a,enumerable:!0,configurable:!0},active:{value:o,enumerable:!0,configurable:!0},x:{value:s,enumerable:!0,configurable:!0},y:{value:c,enumerable:!0,configurable:!0},dx:{value:h,enumerable:!0,configurable:!0},dy:{value:d,enumerable:!0,configurable:!0},_:{value:m}})}Yp.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function ej(e){return!e.ctrlKey&&!e.button}function tj(){return this.parentNode}function nj(e,t){return t??{x:e.x,y:e.y}}function rj(){return navigator.maxTouchPoints||"ontouchstart"in this}function i_(){var e=ej,t=tj,r=nj,l=rj,a={},o=Ac("start","drag","end"),s=0,c,h,d,m,p=0;function x(T){T.on("mousedown.drag",b).filter(l).on("touchstart.drag",S).on("touchmove.drag",_,W3).on("touchend.drag touchcancel.drag",N).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function b(T,M){if(!(m||!e.call(this,T,M))){var A=k(this,t.call(this,T,M),T,M,"mouse");A&&(wn(T.view).on("mousemove.drag",w,Io).on("mouseup.drag",E,Io),n_(T.view),yh(T),d=!1,c=T.clientX,h=T.clientY,A("start",T))}}function w(T){if(sa(T),!d){var M=T.clientX-c,A=T.clientY-h;d=M*M+A*A>p}a.mouse("drag",T)}function E(T){wn(T.view).on("mousemove.drag mouseup.drag",null),r_(T.view,d),sa(T),a.mouse("end",T)}function S(T,M){if(e.call(this,T,M)){var A=T.changedTouches,L=t.call(this,T,M),R=A.length,V,H;for(V=0;V>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):r===8?Iu(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):r===4?Iu(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=lj.exec(e))?new un(t[1],t[2],t[3],1):(t=aj.exec(e))?new un(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=oj.exec(e))?Iu(t[1],t[2],t[3],t[4]):(t=sj.exec(e))?Iu(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=uj.exec(e))?wv(t[1],t[2]/100,t[3]/100,1):(t=cj.exec(e))?wv(t[1],t[2]/100,t[3]/100,t[4]):mv.hasOwnProperty(e)?yv(mv[e]):e==="transparent"?new un(NaN,NaN,NaN,0):null}function yv(e){return new un(e>>16&255,e>>8&255,e&255,1)}function Iu(e,t,r,l){return l<=0&&(e=t=r=NaN),new un(e,t,r,l)}function hj(e){return e instanceof Wo||(e=tl(e)),e?(e=e.rgb(),new un(e.r,e.g,e.b,e.opacity)):new un}function Xp(e,t,r,l){return arguments.length===1?hj(e):new un(e,t,r,l??1)}function un(e,t,r,l){this.r=+e,this.g=+t,this.b=+r,this.opacity=+l}Em(un,Xp,l_(Wo,{brighter(e){return e=e==null?uc:Math.pow(uc,e),new un(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?qo:Math.pow(qo,e),new un(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new un(Ji(this.r),Ji(this.g),Ji(this.b),cc(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:vv,formatHex:vv,formatHex8:pj,formatRgb:bv,toString:bv}));function vv(){return`#${Qi(this.r)}${Qi(this.g)}${Qi(this.b)}`}function pj(){return`#${Qi(this.r)}${Qi(this.g)}${Qi(this.b)}${Qi((isNaN(this.opacity)?1:this.opacity)*255)}`}function bv(){const e=cc(this.opacity);return`${e===1?"rgb(":"rgba("}${Ji(this.r)}, ${Ji(this.g)}, ${Ji(this.b)}${e===1?")":`, ${e})`}`}function cc(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Ji(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Qi(e){return e=Ji(e),(e<16?"0":"")+e.toString(16)}function wv(e,t,r,l){return l<=0?e=t=r=NaN:r<=0||r>=1?e=t=NaN:t<=0&&(e=NaN),new Un(e,t,r,l)}function a_(e){if(e instanceof Un)return new Un(e.h,e.s,e.l,e.opacity);if(e instanceof Wo||(e=tl(e)),!e)return new Un;if(e instanceof Un)return e;e=e.rgb();var t=e.r/255,r=e.g/255,l=e.b/255,a=Math.min(t,r,l),o=Math.max(t,r,l),s=NaN,c=o-a,h=(o+a)/2;return c?(t===o?s=(r-l)/c+(r0&&h<1?0:s,new Un(s,c,h,e.opacity)}function mj(e,t,r,l){return arguments.length===1?a_(e):new Un(e,t,r,l??1)}function Un(e,t,r,l){this.h=+e,this.s=+t,this.l=+r,this.opacity=+l}Em(Un,mj,l_(Wo,{brighter(e){return e=e==null?uc:Math.pow(uc,e),new Un(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?qo:Math.pow(qo,e),new Un(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,r=this.l,l=r+(r<.5?r:1-r)*t,a=2*r-l;return new un(vh(e>=240?e-240:e+120,a,l),vh(e,a,l),vh(e<120?e+240:e-120,a,l),this.opacity)},clamp(){return new Un(_v(this.h),qu(this.s),qu(this.l),cc(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=cc(this.opacity);return`${e===1?"hsl(":"hsla("}${_v(this.h)}, ${qu(this.s)*100}%, ${qu(this.l)*100}%${e===1?")":`, ${e})`}`}}));function _v(e){return e=(e||0)%360,e<0?e+360:e}function qu(e){return Math.max(0,Math.min(1,e||0))}function vh(e,t,r){return(e<60?t+(r-t)*e/60:e<180?r:e<240?t+(r-t)*(240-e)/60:t)*255}const Nm=e=>()=>e;function gj(e,t){return function(r){return e+r*t}}function xj(e,t,r){return e=Math.pow(e,r),t=Math.pow(t,r)-e,r=1/r,function(l){return Math.pow(e+l*t,r)}}function yj(e){return(e=+e)==1?o_:function(t,r){return r-t?xj(t,r,e):Nm(isNaN(t)?r:t)}}function o_(e,t){var r=t-e;return r?gj(e,r):Nm(isNaN(e)?t:e)}const fc=(function e(t){var r=yj(t);function l(a,o){var s=r((a=Xp(a)).r,(o=Xp(o)).r),c=r(a.g,o.g),h=r(a.b,o.b),d=o_(a.opacity,o.opacity);return function(m){return a.r=s(m),a.g=c(m),a.b=h(m),a.opacity=d(m),a+""}}return l.gamma=e,l})(1);function vj(e,t){t||(t=[]);var r=e?Math.min(t.length,e.length):0,l=t.slice(),a;return function(o){for(a=0;ar&&(o=t.slice(r,o),c[s]?c[s]+=o:c[++s]=o),(l=l[0])===(a=a[0])?c[s]?c[s]+=a:c[++s]=a:(c[++s]=null,h.push({i:s,x:rr(l,a)})),r=bh.lastIndex;return r180?m+=360:m-d>180&&(d+=360),x.push({i:p.push(a(p)+"rotate(",null,l)-2,x:rr(d,m)})):m&&p.push(a(p)+"rotate("+m+l)}function c(d,m,p,x){d!==m?x.push({i:p.push(a(p)+"skewX(",null,l)-2,x:rr(d,m)}):m&&p.push(a(p)+"skewX("+m+l)}function h(d,m,p,x,b,w){if(d!==p||m!==x){var E=b.push(a(b)+"scale(",null,",",null,")");w.push({i:E-4,x:rr(d,p)},{i:E-2,x:rr(m,x)})}else(p!==1||x!==1)&&b.push(a(b)+"scale("+p+","+x+")")}return function(d,m){var p=[],x=[];return d=e(d),m=e(m),o(d.translateX,d.translateY,m.translateX,m.translateY,p,x),s(d.rotate,m.rotate,p,x),c(d.skewX,m.skewX,p,x),h(d.scaleX,d.scaleY,m.scaleX,m.scaleY,p,x),d=m=null,function(b){for(var w=-1,E=x.length,S;++w=0&&e._call.call(void 0,t),e=e._next;--ha}function Ev(){nl=(hc=$o.now())+Mc,ha=To=0;try{Rj()}finally{ha=0,Lj(),nl=0}}function Oj(){var e=$o.now(),t=e-hc;t>f_&&(Mc-=t,hc=e)}function Lj(){for(var e,t=dc,r,l=1/0;t;)t._call?(l>t._time&&(l=t._time),e=t,t=t._next):(r=t._next,t._next=null,t=e?e._next=r:dc=r);Ao=e,Kp(l)}function Kp(e){if(!ha){To&&(To=clearTimeout(To));var t=e-nl;t>24?(e<1/0&&(To=setTimeout(Ev,e-$o.now()-Mc)),bo&&(bo=clearInterval(bo))):(bo||(hc=$o.now(),bo=setInterval(Oj,f_)),ha=1,d_(Ev))}}function Nv(e,t,r){var l=new pc;return t=t==null?0:+t,l.restart(a=>{l.stop(),e(a+t)},t,r),l}var Hj=Ac("start","end","cancel","interrupt"),Bj=[],p_=0,Cv=1,Jp=2,ec=3,jv=4,Wp=5,tc=6;function Dc(e,t,r,l,a,o){var s=e.__transition;if(!s)e.__transition={};else if(r in s)return;Ij(e,r,{name:t,index:l,group:a,on:Hj,tween:Bj,time:o.time,delay:o.delay,duration:o.duration,ease:o.ease,timer:null,state:p_})}function jm(e,t){var r=Xn(e,t);if(r.state>p_)throw new Error("too late; already scheduled");return r}function ar(e,t){var r=Xn(e,t);if(r.state>ec)throw new Error("too late; already running");return r}function Xn(e,t){var r=e.__transition;if(!r||!(r=r[t]))throw new Error("transition not found");return r}function Ij(e,t,r){var l=e.__transition,a;l[t]=r,r.timer=h_(o,0,r.time);function o(d){r.state=Cv,r.timer.restart(s,r.delay,r.time),r.delay<=d&&s(d-r.delay)}function s(d){var m,p,x,b;if(r.state!==Cv)return h();for(m in l)if(b=l[m],b.name===r.name){if(b.state===ec)return Nv(s);b.state===jv?(b.state=tc,b.timer.stop(),b.on.call("interrupt",e,e.__data__,b.index,b.group),delete l[m]):+mJp&&l.state=0&&(t=t.slice(0,r)),!t||t==="start"})}function mT(e,t,r){var l,a,o=pT(t)?jm:ar;return function(){var s=o(this,e),c=s.on;c!==l&&(a=(l=c).copy()).on(t,r),s.on=a}}function gT(e,t){var r=this._id;return arguments.length<2?Xn(this.node(),r).on.on(e):this.each(mT(r,e,t))}function xT(e){return function(){var t=this.parentNode;for(var r in this.__transition)if(+r!==e)return;t&&t.removeChild(this)}}function yT(){return this.on("end.remove",xT(this._id))}function vT(e){var t=this._name,r=this._id;typeof e!="function"&&(e=Sm(e));for(var l=this._groups,a=l.length,o=new Array(a),s=0;s()=>e;function PT(e,{sourceEvent:t,target:r,transform:l,dispatch:a}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},transform:{value:l,enumerable:!0,configurable:!0},_:{value:a}})}function zr(e,t,r){this.k=e,this.x=t,this.y=r}zr.prototype={constructor:zr,scale:function(e){return e===1?this:new zr(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new zr(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 Rc=new zr(1,0,0);y_.prototype=zr.prototype;function y_(e){for(;!e.__zoom;)if(!(e=e.parentNode))return Rc;return e.__zoom}function wh(e){e.stopImmediatePropagation()}function wo(e){e.preventDefault(),e.stopImmediatePropagation()}function GT(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function FT(){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 Tv(){return this.__zoom||Rc}function YT(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function XT(){return navigator.maxTouchPoints||"ontouchstart"in this}function QT(e,t,r){var l=e.invertX(t[0][0])-r[0][0],a=e.invertX(t[1][0])-r[1][0],o=e.invertY(t[0][1])-r[0][1],s=e.invertY(t[1][1])-r[1][1];return e.translate(a>l?(l+a)/2:Math.min(0,l)||Math.max(0,a),s>o?(o+s)/2:Math.min(0,o)||Math.max(0,s))}function v_(){var e=GT,t=FT,r=QT,l=YT,a=XT,o=[0,1/0],s=[[-1/0,-1/0],[1/0,1/0]],c=250,h=Wu,d=Ac("start","zoom","end"),m,p,x,b=500,w=150,E=0,S=10;function _(I){I.property("__zoom",Tv).on("wheel.zoom",R,{passive:!1}).on("mousedown.zoom",V).on("dblclick.zoom",H).filter(a).on("touchstart.zoom",B).on("touchmove.zoom",$).on("touchend.zoom touchcancel.zoom",ee).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}_.transform=function(I,F,z,G){var Q=I.selection?I.selection():I;Q.property("__zoom",Tv),I!==Q?M(I,F,z,G):Q.interrupt().each(function(){A(this,arguments).event(G).start().zoom(null,typeof F=="function"?F.apply(this,arguments):F).end()})},_.scaleBy=function(I,F,z,G){_.scaleTo(I,function(){var Q=this.__zoom.k,K=typeof F=="function"?F.apply(this,arguments):F;return Q*K},z,G)},_.scaleTo=function(I,F,z,G){_.transform(I,function(){var Q=t.apply(this,arguments),K=this.__zoom,D=z==null?T(Q):typeof z=="function"?z.apply(this,arguments):z,q=K.invert(D),Y=typeof F=="function"?F.apply(this,arguments):F;return r(k(N(K,Y),D,q),Q,s)},z,G)},_.translateBy=function(I,F,z,G){_.transform(I,function(){return r(this.__zoom.translate(typeof F=="function"?F.apply(this,arguments):F,typeof z=="function"?z.apply(this,arguments):z),t.apply(this,arguments),s)},null,G)},_.translateTo=function(I,F,z,G,Q){_.transform(I,function(){var K=t.apply(this,arguments),D=this.__zoom,q=G==null?T(K):typeof G=="function"?G.apply(this,arguments):G;return r(Rc.translate(q[0],q[1]).scale(D.k).translate(typeof F=="function"?-F.apply(this,arguments):-F,typeof z=="function"?-z.apply(this,arguments):-z),K,s)},G,Q)};function N(I,F){return F=Math.max(o[0],Math.min(o[1],F)),F===I.k?I:new zr(F,I.x,I.y)}function k(I,F,z){var G=F[0]-z[0]*I.k,Q=F[1]-z[1]*I.k;return G===I.x&&Q===I.y?I:new zr(I.k,G,Q)}function T(I){return[(+I[0][0]+ +I[1][0])/2,(+I[0][1]+ +I[1][1])/2]}function M(I,F,z,G){I.on("start.zoom",function(){A(this,arguments).event(G).start()}).on("interrupt.zoom end.zoom",function(){A(this,arguments).event(G).end()}).tween("zoom",function(){var Q=this,K=arguments,D=A(Q,K).event(G),q=t.apply(Q,K),Y=z==null?T(q):typeof z=="function"?z.apply(Q,K):z,C=Math.max(q[1][0]-q[0][0],q[1][1]-q[0][1]),P=Q.__zoom,X=typeof F=="function"?F.apply(Q,K):F,J=h(P.invert(Y).concat(C/P.k),X.invert(Y).concat(C/X.k));return function(ne){if(ne===1)ne=X;else{var re=J(ne),se=C/re[2];ne=new zr(se,Y[0]-re[0]*se,Y[1]-re[1]*se)}D.zoom(null,ne)}})}function A(I,F,z){return!z&&I.__zooming||new L(I,F)}function L(I,F){this.that=I,this.args=F,this.active=0,this.sourceEvent=null,this.extent=t.apply(I,F),this.taps=0}L.prototype={event:function(I){return I&&(this.sourceEvent=I),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(I,F){return this.mouse&&I!=="mouse"&&(this.mouse[1]=F.invert(this.mouse[0])),this.touch0&&I!=="touch"&&(this.touch0[1]=F.invert(this.touch0[0])),this.touch1&&I!=="touch"&&(this.touch1[1]=F.invert(this.touch1[0])),this.that.__zoom=F,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(I){var F=wn(this.that).datum();d.call(I,this.that,new PT(I,{sourceEvent:this.sourceEvent,target:_,transform:this.that.__zoom,dispatch:d}),F)}};function R(I,...F){if(!e.apply(this,arguments))return;var z=A(this,F).event(I),G=this.__zoom,Q=Math.max(o[0],Math.min(o[1],G.k*Math.pow(2,l.apply(this,arguments)))),K=qn(I);if(z.wheel)(z.mouse[0][0]!==K[0]||z.mouse[0][1]!==K[1])&&(z.mouse[1]=G.invert(z.mouse[0]=K)),clearTimeout(z.wheel);else{if(G.k===Q)return;z.mouse=[K,G.invert(K)],nc(this),z.start()}wo(I),z.wheel=setTimeout(D,w),z.zoom("mouse",r(k(N(G,Q),z.mouse[0],z.mouse[1]),z.extent,s));function D(){z.wheel=null,z.end()}}function V(I,...F){if(x||!e.apply(this,arguments))return;var z=I.currentTarget,G=A(this,F,!0).event(I),Q=wn(I.view).on("mousemove.zoom",Y,!0).on("mouseup.zoom",C,!0),K=qn(I,z),D=I.clientX,q=I.clientY;n_(I.view),wh(I),G.mouse=[K,this.__zoom.invert(K)],nc(this),G.start();function Y(P){if(wo(P),!G.moved){var X=P.clientX-D,J=P.clientY-q;G.moved=X*X+J*J>E}G.event(P).zoom("mouse",r(k(G.that.__zoom,G.mouse[0]=qn(P,z),G.mouse[1]),G.extent,s))}function C(P){Q.on("mousemove.zoom mouseup.zoom",null),r_(P.view,G.moved),wo(P),G.event(P).end()}}function H(I,...F){if(e.apply(this,arguments)){var z=this.__zoom,G=qn(I.changedTouches?I.changedTouches[0]:I,this),Q=z.invert(G),K=z.k*(I.shiftKey?.5:2),D=r(k(N(z,K),G,Q),t.apply(this,F),s);wo(I),c>0?wn(this).transition().duration(c).call(M,D,G,I):wn(this).call(_.transform,D,G,I)}}function B(I,...F){if(e.apply(this,arguments)){var z=I.touches,G=z.length,Q=A(this,F,I.changedTouches.length===G).event(I),K,D,q,Y;for(wh(I),D=0;D"[React Flow]: Seems like you have not used zustand provider as an ancestor. Help: https://reactflow.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 React Flow 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:r,targetHandle:l})=>`Couldn't create edge for ${e} handle id: "${e==="source"?r:l}", 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."},Vo=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],b_=["Enter"," ","Escape"],w_={"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:r})=>`Moved selected node ${e}. New position, x: ${t}, y: ${r}`,"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"};var pa;(function(e){e.Strict="strict",e.Loose="loose"})(pa||(pa={}));var Wi;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Wi||(Wi={}));var Po;(function(e){e.Partial="partial",e.Full="full"})(Po||(Po={}));const __={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var vi;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(vi||(vi={}));var mc;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(mc||(mc={}));var ve;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(ve||(ve={}));const Av={[ve.Left]:ve.Right,[ve.Right]:ve.Left,[ve.Top]:ve.Bottom,[ve.Bottom]:ve.Top};function S_(e){return e===null?null:e?"valid":"invalid"}const k_=e=>"id"in e&&"source"in e&&"target"in e,ZT=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),Am=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),es=(e,t=[0,0])=>{const{width:r,height:l}=Or(e),a=e.origin??t,o=r*a[0],s=l*a[1];return{x:e.position.x-o,y:e.position.y-s}},KT=(e,t={nodeOrigin:[0,0]})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};const r=e.reduce((l,a)=>{const o=typeof a=="string";let s=!t.nodeLookup&&!o?a:void 0;t.nodeLookup&&(s=o?t.nodeLookup.get(a):Am(a)?a:t.nodeLookup.get(a.id));const c=s?gc(s,t.nodeOrigin):{x:0,y:0,x2:0,y2:0};return Oc(l,c)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return Lc(r)},ts=(e,t={})=>{let r={x:1/0,y:1/0,x2:-1/0,y2:-1/0},l=!1;return e.forEach(a=>{(t.filter===void 0||t.filter(a))&&(r=Oc(r,gc(a)),l=!0)}),l?Lc(r):{x:0,y:0,width:0,height:0}},zm=(e,t,[r,l,a]=[0,0,1],o=!1,s=!1)=>{const c={...rs(t,[r,l,a]),width:t.width/a,height:t.height/a},h=[];for(const d of e.values()){const{measured:m,selectable:p=!0,hidden:x=!1}=d;if(s&&!p||x)continue;const b=m.width??d.width??d.initialWidth??null,w=m.height??d.height??d.initialHeight??null,E=Go(c,ga(d)),S=(b??0)*(w??0),_=o&&E>0;(!d.internals.handleBounds||_||E>=S||d.dragging)&&h.push(d)}return h},JT=(e,t)=>{const r=new Set;return e.forEach(l=>{r.add(l.id)}),t.filter(l=>r.has(l.source)||r.has(l.target))};function WT(e,t){const r=new Map,l=t!=null&&t.nodes?new Set(t.nodes.map(a=>a.id)):null;return e.forEach(a=>{a.measured.width&&a.measured.height&&((t==null?void 0:t.includeHiddenNodes)||!a.hidden)&&(!l||l.has(a.id))&&r.set(a.id,a)}),r}async function eA({nodes:e,width:t,height:r,panZoom:l,minZoom:a,maxZoom:o},s){if(e.size===0)return Promise.resolve(!0);const c=WT(e,s),h=ts(c),d=Mm(h,t,r,(s==null?void 0:s.minZoom)??a,(s==null?void 0:s.maxZoom)??o,(s==null?void 0:s.padding)??.1);return await l.setViewport(d,{duration:s==null?void 0:s.duration,ease:s==null?void 0:s.ease,interpolate:s==null?void 0:s.interpolate}),Promise.resolve(!0)}function E_({nodeId:e,nextPosition:t,nodeLookup:r,nodeOrigin:l=[0,0],nodeExtent:a,onError:o}){const s=r.get(e),c=s.parentId?r.get(s.parentId):void 0,{x:h,y:d}=c?c.internals.positionAbsolute:{x:0,y:0},m=s.origin??l;let p=s.extent||a;if(s.extent==="parent"&&!s.expandParent)if(!c)o==null||o("005",lr.error005());else{const b=c.measured.width,w=c.measured.height;b&&w&&(p=[[h,d],[h+b,d+w]])}else c&&xa(s.extent)&&(p=[[s.extent[0][0]+h,s.extent[0][1]+d],[s.extent[1][0]+h,s.extent[1][1]+d]]);const x=xa(p)?rl(t,p,s.measured):t;return(s.measured.width===void 0||s.measured.height===void 0)&&(o==null||o("015",lr.error015())),{position:{x:x.x-h+(s.measured.width??0)*m[0],y:x.y-d+(s.measured.height??0)*m[1]},positionAbsolute:x}}async function tA({nodesToRemove:e=[],edgesToRemove:t=[],nodes:r,edges:l,onBeforeDelete:a}){const o=new Set(e.map(x=>x.id)),s=[];for(const x of r){if(x.deletable===!1)continue;const b=o.has(x.id),w=!b&&x.parentId&&s.find(E=>E.id===x.parentId);(b||w)&&s.push(x)}const c=new Set(t.map(x=>x.id)),h=l.filter(x=>x.deletable!==!1),m=JT(s,h);for(const x of h)c.has(x.id)&&!m.find(w=>w.id===x.id)&&m.push(x);if(!a)return{edges:m,nodes:s};const p=await a({nodes:s,edges:m});return typeof p=="boolean"?p?{edges:m,nodes:s}:{edges:[],nodes:[]}:p}const ma=(e,t=0,r=1)=>Math.min(Math.max(e,t),r),rl=(e={x:0,y:0},t,r)=>({x:ma(e.x,t[0][0],t[1][0]-((r==null?void 0:r.width)??0)),y:ma(e.y,t[0][1],t[1][1]-((r==null?void 0:r.height)??0))});function N_(e,t,r){const{width:l,height:a}=Or(r),{x:o,y:s}=r.internals.positionAbsolute;return rl(e,[[o,s],[o+l,s+a]],t)}const zv=(e,t,r)=>er?-ma(Math.abs(e-r),1,t)/t:0,C_=(e,t,r=15,l=40)=>{const a=zv(e.x,l,t.width-l)*r,o=zv(e.y,l,t.height-l)*r;return[a,o]},Oc=(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)}),em=({x:e,y:t,width:r,height:l})=>({x:e,y:t,x2:e+r,y2:t+l}),Lc=({x:e,y:t,x2:r,y2:l})=>({x:e,y:t,width:r-e,height:l-t}),ga=(e,t=[0,0])=>{var a,o;const{x:r,y:l}=Am(e)?e.internals.positionAbsolute:es(e,t);return{x:r,y:l,width:((a=e.measured)==null?void 0:a.width)??e.width??e.initialWidth??0,height:((o=e.measured)==null?void 0:o.height)??e.height??e.initialHeight??0}},gc=(e,t=[0,0])=>{var a,o;const{x:r,y:l}=Am(e)?e.internals.positionAbsolute:es(e,t);return{x:r,y:l,x2:r+(((a=e.measured)==null?void 0:a.width)??e.width??e.initialWidth??0),y2:l+(((o=e.measured)==null?void 0:o.height)??e.height??e.initialHeight??0)}},j_=(e,t)=>Lc(Oc(em(e),em(t))),Go=(e,t)=>{const r=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),l=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return Math.ceil(r*l)},Mv=e=>$n(e.width)&&$n(e.height)&&$n(e.x)&&$n(e.y),$n=e=>!isNaN(e)&&isFinite(e),nA=(e,t)=>{},ns=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),rs=({x:e,y:t},[r,l,a],o=!1,s=[1,1])=>{const c={x:(e-r)/a,y:(t-l)/a};return o?ns(c,s):c},xc=({x:e,y:t},[r,l,a])=>({x:e*a+r,y:t*a+l});function Kl(e,t){if(typeof e=="number")return Math.floor((t-t/(1+e))*.5);if(typeof e=="string"&&e.endsWith("px")){const r=parseFloat(e);if(!Number.isNaN(r))return Math.floor(r)}if(typeof e=="string"&&e.endsWith("%")){const r=parseFloat(e);if(!Number.isNaN(r))return Math.floor(t*r*.01)}return console.error(`[React Flow] The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function rA(e,t,r){if(typeof e=="string"||typeof e=="number"){const l=Kl(e,r),a=Kl(e,t);return{top:l,right:a,bottom:l,left:a,x:a*2,y:l*2}}if(typeof e=="object"){const l=Kl(e.top??e.y??0,r),a=Kl(e.bottom??e.y??0,r),o=Kl(e.left??e.x??0,t),s=Kl(e.right??e.x??0,t);return{top:l,right:s,bottom:a,left:o,x:o+s,y:l+a}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function iA(e,t,r,l,a,o){const{x:s,y:c}=xc(e,[t,r,l]),{x:h,y:d}=xc({x:e.x+e.width,y:e.y+e.height},[t,r,l]),m=a-h,p=o-d;return{left:Math.floor(s),top:Math.floor(c),right:Math.floor(m),bottom:Math.floor(p)}}const Mm=(e,t,r,l,a,o)=>{const s=rA(o,t,r),c=(t-s.x)/e.width,h=(r-s.y)/e.height,d=Math.min(c,h),m=ma(d,l,a),p=e.x+e.width/2,x=e.y+e.height/2,b=t/2-p*m,w=r/2-x*m,E=iA(e,b,w,m,t,r),S={left:Math.min(E.left-s.left,0),top:Math.min(E.top-s.top,0),right:Math.min(E.right-s.right,0),bottom:Math.min(E.bottom-s.bottom,0)};return{x:b-S.left+S.right,y:w-S.top+S.bottom,zoom:m}},Fo=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0};function xa(e){return e!=null&&e!=="parent"}function Or(e){var t,r;return{width:((t=e.measured)==null?void 0:t.width)??e.width??e.initialWidth??0,height:((r=e.measured)==null?void 0:r.height)??e.height??e.initialHeight??0}}function T_(e){var t,r;return(((t=e.measured)==null?void 0:t.width)??e.width??e.initialWidth)!==void 0&&(((r=e.measured)==null?void 0:r.height)??e.height??e.initialHeight)!==void 0}function A_(e,t={width:0,height:0},r,l,a){const o={...e},s=l.get(r);if(s){const c=s.origin||a;o.x+=s.internals.positionAbsolute.x-(t.width??0)*c[0],o.y+=s.internals.positionAbsolute.y-(t.height??0)*c[1]}return o}function Dv(e,t){if(e.size!==t.size)return!1;for(const r of e)if(!t.has(r))return!1;return!0}function lA(){let e,t;return{promise:new Promise((l,a)=>{e=l,t=a}),resolve:e,reject:t}}function aA(e){return{...w_,...e||{}}}function Do(e,{snapGrid:t=[0,0],snapToGrid:r=!1,transform:l,containerBounds:a}){const{x:o,y:s}=Vn(e),c=rs({x:o-((a==null?void 0:a.left)??0),y:s-((a==null?void 0:a.top)??0)},l),{x:h,y:d}=r?ns(c,t):c;return{xSnapped:h,ySnapped:d,...c}}const Dm=e=>({width:e.offsetWidth,height:e.offsetHeight}),z_=e=>{var t;return((t=e==null?void 0:e.getRootNode)==null?void 0:t.call(e))||(window==null?void 0:window.document)},oA=["INPUT","SELECT","TEXTAREA"];function M_(e){var l,a;const t=((a=(l=e.composedPath)==null?void 0:l.call(e))==null?void 0:a[0])||e.target;return(t==null?void 0:t.nodeType)!==1?!1:oA.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const D_=e=>"clientX"in e,Vn=(e,t)=>{var o,s;const r=D_(e),l=r?e.clientX:(o=e.touches)==null?void 0:o[0].clientX,a=r?e.clientY:(s=e.touches)==null?void 0:s[0].clientY;return{x:l-((t==null?void 0:t.left)??0),y:a-((t==null?void 0:t.top)??0)}},Rv=(e,t,r,l,a)=>{const o=t.querySelectorAll(`.${e}`);return!o||!o.length?null:Array.from(o).map(s=>{const c=s.getBoundingClientRect();return{id:s.getAttribute("data-handleid"),type:e,nodeId:a,position:s.getAttribute("data-handlepos"),x:(c.left-r.left)/l,y:(c.top-r.top)/l,...Dm(s)}})};function R_({sourceX:e,sourceY:t,targetX:r,targetY:l,sourceControlX:a,sourceControlY:o,targetControlX:s,targetControlY:c}){const h=e*.125+a*.375+s*.375+r*.125,d=t*.125+o*.375+c*.375+l*.125,m=Math.abs(h-e),p=Math.abs(d-t);return[h,d,m,p]}function Vu(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function Ov({pos:e,x1:t,y1:r,x2:l,y2:a,c:o}){switch(e){case ve.Left:return[t-Vu(t-l,o),r];case ve.Right:return[t+Vu(l-t,o),r];case ve.Top:return[t,r-Vu(r-a,o)];case ve.Bottom:return[t,r+Vu(a-r,o)]}}function Rm({sourceX:e,sourceY:t,sourcePosition:r=ve.Bottom,targetX:l,targetY:a,targetPosition:o=ve.Top,curvature:s=.25}){const[c,h]=Ov({pos:r,x1:e,y1:t,x2:l,y2:a,c:s}),[d,m]=Ov({pos:o,x1:l,y1:a,x2:e,y2:t,c:s}),[p,x,b,w]=R_({sourceX:e,sourceY:t,targetX:l,targetY:a,sourceControlX:c,sourceControlY:h,targetControlX:d,targetControlY:m});return[`M${e},${t} C${c},${h} ${d},${m} ${l},${a}`,p,x,b,w]}function O_({sourceX:e,sourceY:t,targetX:r,targetY:l}){const a=Math.abs(r-e)/2,o=r0}const cA=({source:e,sourceHandle:t,target:r,targetHandle:l})=>`xy-edge__${e}${t||""}-${r}${l||""}`,fA=(e,t)=>t.some(r=>r.source===e.source&&r.target===e.target&&(r.sourceHandle===e.sourceHandle||!r.sourceHandle&&!e.sourceHandle)&&(r.targetHandle===e.targetHandle||!r.targetHandle&&!e.targetHandle)),dA=(e,t,r={})=>{if(!e.source||!e.target)return t;const l=r.getEdgeId||cA;let a;return k_(e)?a={...e}:a={...e,id:l(e)},fA(a,t)?t:(a.sourceHandle===null&&delete a.sourceHandle,a.targetHandle===null&&delete a.targetHandle,t.concat(a))};function L_({sourceX:e,sourceY:t,targetX:r,targetY:l}){const[a,o,s,c]=O_({sourceX:e,sourceY:t,targetX:r,targetY:l});return[`M ${e},${t}L ${r},${l}`,a,o,s,c]}const Lv={[ve.Left]:{x:-1,y:0},[ve.Right]:{x:1,y:0},[ve.Top]:{x:0,y:-1},[ve.Bottom]:{x:0,y:1}},hA=({source:e,sourcePosition:t=ve.Bottom,target:r})=>t===ve.Left||t===ve.Right?e.xMath.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function pA({source:e,sourcePosition:t=ve.Bottom,target:r,targetPosition:l=ve.Top,center:a,offset:o,stepPosition:s}){const c=Lv[t],h=Lv[l],d={x:e.x+c.x*o,y:e.y+c.y*o},m={x:r.x+h.x*o,y:r.y+h.y*o},p=hA({source:d,sourcePosition:t,target:m}),x=p.x!==0?"x":"y",b=p[x];let w=[],E,S;const _={x:0,y:0},N={x:0,y:0},[,,k,T]=O_({sourceX:e.x,sourceY:e.y,targetX:r.x,targetY:r.y});if(c[x]*h[x]===-1){x==="x"?(E=a.x??d.x+(m.x-d.x)*s,S=a.y??(d.y+m.y)/2):(E=a.x??(d.x+m.x)/2,S=a.y??d.y+(m.y-d.y)*s);const A=[{x:E,y:d.y},{x:E,y:m.y}],L=[{x:d.x,y:S},{x:m.x,y:S}];c[x]===b?w=x==="x"?A:L:w=x==="x"?L:A}else{const A=[{x:d.x,y:m.y}],L=[{x:m.x,y:d.y}];if(x==="x"?w=c.x===b?L:A:w=c.y===b?A:L,t===l){const $=Math.abs(e[x]-r[x]);if($<=o){const ee=Math.min(o-1,o-$);c[x]===b?_[x]=(d[x]>e[x]?-1:1)*ee:N[x]=(m[x]>r[x]?-1:1)*ee}}if(t!==l){const $=x==="x"?"y":"x",ee=c[x]===h[$],I=d[$]>m[$],F=d[$]=B?(E=(R.x+V.x)/2,S=w[0].y):(E=w[0].x,S=(R.y+V.y)/2)}return[[e,{x:d.x+_.x,y:d.y+_.y},...w,{x:m.x+N.x,y:m.y+N.y},r],E,S,k,T]}function mA(e,t,r,l){const a=Math.min(Hv(e,t)/2,Hv(t,r)/2,l),{x:o,y:s}=t;if(e.x===o&&o===r.x||e.y===s&&s===r.y)return`L${o} ${s}`;if(e.y===s){const d=e.x{let T="";return k>0&&kr.id===t):e[0])||null}function nm(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(l=>`${l}=${e[l]}`).join("&")}`:""}function xA(e,{id:t,defaultColor:r,defaultMarkerStart:l,defaultMarkerEnd:a}){const o=new Set;return e.reduce((s,c)=>([c.markerStart||l,c.markerEnd||a].forEach(h=>{if(h&&typeof h=="object"){const d=nm(h,t);o.has(d)||(s.push({id:d,color:h.color||r,...h}),o.add(d))}}),s),[]).sort((s,c)=>s.id.localeCompare(c.id))}const H_=1e3,yA=10,Om={nodeOrigin:[0,0],nodeExtent:Vo,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},vA={...Om,checkEquality:!0};function Lm(e,t){const r={...e};for(const l in t)t[l]!==void 0&&(r[l]=t[l]);return r}function bA(e,t,r){const l=Lm(Om,r);for(const a of e.values())if(a.parentId)Bm(a,e,t,l);else{const o=es(a,l.nodeOrigin),s=xa(a.extent)?a.extent:l.nodeExtent,c=rl(o,s,Or(a));a.internals.positionAbsolute=c}}function wA(e,t){if(!e.handles)return e.measured?t==null?void 0:t.internals.handleBounds:void 0;const r=[],l=[];for(const a of e.handles){const o={id:a.id,width:a.width??1,height:a.height??1,nodeId:e.id,x:a.x,y:a.y,position:a.position,type:a.type};a.type==="source"?r.push(o):a.type==="target"&&l.push(o)}return{source:r,target:l}}function Hm(e){return e==="manual"}function rm(e,t,r,l={}){var d,m;const a=Lm(vA,l),o={i:0},s=new Map(t),c=a!=null&&a.elevateNodesOnSelect&&!Hm(a.zIndexMode)?H_:0;let h=e.length>0;t.clear(),r.clear();for(const p of e){let x=s.get(p.id);if(a.checkEquality&&p===(x==null?void 0:x.internals.userNode))t.set(p.id,x);else{const b=es(p,a.nodeOrigin),w=xa(p.extent)?p.extent:a.nodeExtent,E=rl(b,w,Or(p));x={...a.defaults,...p,measured:{width:(d=p.measured)==null?void 0:d.width,height:(m=p.measured)==null?void 0:m.height},internals:{positionAbsolute:E,handleBounds:wA(p,x),z:B_(p,c,a.zIndexMode),userNode:p}},t.set(p.id,x)}(x.measured===void 0||x.measured.width===void 0||x.measured.height===void 0)&&!x.hidden&&(h=!1),p.parentId&&Bm(x,t,r,l,o)}return h}function _A(e,t){if(!e.parentId)return;const r=t.get(e.parentId);r?r.set(e.id,e):t.set(e.parentId,new Map([[e.id,e]]))}function Bm(e,t,r,l,a){const{elevateNodesOnSelect:o,nodeOrigin:s,nodeExtent:c,zIndexMode:h}=Lm(Om,l),d=e.parentId,m=t.get(d);if(!m){console.warn(`Parent node ${d} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}_A(e,r),a&&!m.parentId&&m.internals.rootParentIndex===void 0&&h==="auto"&&(m.internals.rootParentIndex=++a.i,m.internals.z=m.internals.z+a.i*yA),a&&m.internals.rootParentIndex!==void 0&&(a.i=m.internals.rootParentIndex);const p=o&&!Hm(h)?H_:0,{x,y:b,z:w}=SA(e,m,s,c,p,h),{positionAbsolute:E}=e.internals,S=x!==E.x||b!==E.y;(S||w!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:S?{x,y:b}:E,z:w}})}function B_(e,t,r){const l=$n(e.zIndex)?e.zIndex:0;return Hm(r)?l:l+(e.selected?t:0)}function SA(e,t,r,l,a,o){const{x:s,y:c}=t.internals.positionAbsolute,h=Or(e),d=es(e,r),m=xa(e.extent)?rl(d,e.extent,h):d;let p=rl({x:s+m.x,y:c+m.y},l,h);e.extent==="parent"&&(p=N_(p,h,t));const x=B_(e,a,o),b=t.internals.z??0;return{x:p.x,y:p.y,z:b>=x?b+1:x}}function Im(e,t,r,l=[0,0]){var s;const a=[],o=new Map;for(const c of e){const h=t.get(c.parentId);if(!h)continue;const d=((s=o.get(c.parentId))==null?void 0:s.expandedRect)??ga(h),m=j_(d,c.rect);o.set(c.parentId,{expandedRect:m,parent:h})}return o.size>0&&o.forEach(({expandedRect:c,parent:h},d)=>{var k;const m=h.internals.positionAbsolute,p=Or(h),x=h.origin??l,b=c.x0||w>0||_||N)&&(a.push({id:d,type:"position",position:{x:h.position.x-b+_,y:h.position.y-w+N}}),(k=r.get(d))==null||k.forEach(T=>{e.some(M=>M.id===T.id)||a.push({id:T.id,type:"position",position:{x:T.position.x+b,y:T.position.y+w}})})),(p.width0){const b=Im(x,t,r,a);d.push(...b)}return{changes:d,updatedInternals:h}}async function EA({delta:e,panZoom:t,transform:r,translateExtent:l,width:a,height:o}){if(!t||!e.x&&!e.y)return Promise.resolve(!1);const s=await t.setViewportConstrained({x:r[0]+e.x,y:r[1]+e.y,zoom:r[2]},[[0,0],[a,o]],l),c=!!s&&(s.x!==r[0]||s.y!==r[1]||s.k!==r[2]);return Promise.resolve(c)}function Uv(e,t,r,l,a,o){let s=a;const c=l.get(s)||new Map;l.set(s,c.set(r,t)),s=`${a}-${e}`;const h=l.get(s)||new Map;if(l.set(s,h.set(r,t)),o){s=`${a}-${e}-${o}`;const d=l.get(s)||new Map;l.set(s,d.set(r,t))}}function I_(e,t,r){e.clear(),t.clear();for(const l of r){const{source:a,target:o,sourceHandle:s=null,targetHandle:c=null}=l,h={edgeId:l.id,source:a,target:o,sourceHandle:s,targetHandle:c},d=`${a}-${s}--${o}-${c}`,m=`${o}-${c}--${a}-${s}`;Uv("source",h,m,e,a,s),Uv("target",h,d,e,o,c),t.set(l.id,l)}}function q_(e,t){if(!e.parentId)return!1;const r=t.get(e.parentId);return r?r.selected?!0:q_(r,t):!1}function $v(e,t,r){var a;let l=e;do{if((a=l==null?void 0:l.matches)!=null&&a.call(l,t))return!0;if(l===r)return!1;l=l==null?void 0:l.parentElement}while(l);return!1}function NA(e,t,r,l){const a=new Map;for(const[o,s]of e)if((s.selected||s.id===l)&&(!s.parentId||!q_(s,e))&&(s.draggable||t&&typeof s.draggable>"u")){const c=e.get(o);c&&a.set(o,{id:o,position:c.position||{x:0,y:0},distance:{x:r.x-c.internals.positionAbsolute.x,y:r.y-c.internals.positionAbsolute.y},extent:c.extent,parentId:c.parentId,origin:c.origin,expandParent:c.expandParent,internals:{positionAbsolute:c.internals.positionAbsolute||{x:0,y:0}},measured:{width:c.measured.width??0,height:c.measured.height??0}})}return a}function _h({nodeId:e,dragItems:t,nodeLookup:r,dragging:l=!0}){var s,c,h;const a=[];for(const[d,m]of t){const p=(s=r.get(d))==null?void 0:s.internals.userNode;p&&a.push({...p,position:m.position,dragging:l})}if(!e)return[a[0],a];const o=(c=r.get(e))==null?void 0:c.internals.userNode;return[o?{...o,position:((h=t.get(e))==null?void 0:h.position)||o.position,dragging:l}:a[0],a]}function CA({dragItems:e,snapGrid:t,x:r,y:l}){const a=e.values().next().value;if(!a)return null;const o={x:r-a.distance.x,y:l-a.distance.y},s=ns(o,t);return{x:s.x-o.x,y:s.y-o.y}}function jA({onNodeMouseDown:e,getStoreItems:t,onDragStart:r,onDrag:l,onDragStop:a}){let o={x:null,y:null},s=0,c=new Map,h=!1,d={x:0,y:0},m=null,p=!1,x=null,b=!1,w=!1,E=null;function S({noDragClassName:N,handleSelector:k,domNode:T,isSelectable:M,nodeId:A,nodeClickDistance:L=0}){x=wn(T);function R({x:$,y:ee}){const{nodeLookup:I,nodeExtent:F,snapGrid:z,snapToGrid:G,nodeOrigin:Q,onNodeDrag:K,onSelectionDrag:D,onError:q,updateNodePositions:Y}=t();o={x:$,y:ee};let C=!1;const P=c.size>1,X=P&&F?em(ts(c)):null,J=P&&G?CA({dragItems:c,snapGrid:z,x:$,y:ee}):null;for(const[ne,re]of c){if(!I.has(ne))continue;let se={x:$-re.distance.x,y:ee-re.distance.y};G&&(se=J?{x:Math.round(se.x+J.x),y:Math.round(se.y+J.y)}:ns(se,z));let xe=null;if(P&&F&&!re.extent&&X){const{positionAbsolute:pe}=re.internals,Se=pe.x-X.x+F[0][0],De=pe.x+re.measured.width-X.x2+F[1][0],je=pe.y-X.y+F[0][1],ct=pe.y+re.measured.height-X.y2+F[1][1];xe=[[Se,je],[De,ct]]}const{position:be,positionAbsolute:ye}=E_({nodeId:ne,nextPosition:se,nodeLookup:I,nodeExtent:xe||F,nodeOrigin:Q,onError:q});C=C||re.position.x!==be.x||re.position.y!==be.y,re.position=be,re.internals.positionAbsolute=ye}if(w=w||C,!!C&&(Y(c,!0),E&&(l||K||!A&&D))){const[ne,re]=_h({nodeId:A,dragItems:c,nodeLookup:I});l==null||l(E,c,ne,re),K==null||K(E,ne,re),A||D==null||D(E,re)}}async function V(){if(!m)return;const{transform:$,panBy:ee,autoPanSpeed:I,autoPanOnNodeDrag:F}=t();if(!F){h=!1,cancelAnimationFrame(s);return}const[z,G]=C_(d,m,I);(z!==0||G!==0)&&(o.x=(o.x??0)-z/$[2],o.y=(o.y??0)-G/$[2],await ee({x:z,y:G})&&R(o)),s=requestAnimationFrame(V)}function H($){var P;const{nodeLookup:ee,multiSelectionActive:I,nodesDraggable:F,transform:z,snapGrid:G,snapToGrid:Q,selectNodesOnDrag:K,onNodeDragStart:D,onSelectionDragStart:q,unselectNodesAndEdges:Y}=t();p=!0,(!K||!M)&&!I&&A&&((P=ee.get(A))!=null&&P.selected||Y()),M&&K&&A&&(e==null||e(A));const C=Do($.sourceEvent,{transform:z,snapGrid:G,snapToGrid:Q,containerBounds:m});if(o=C,c=NA(ee,F,C,A),c.size>0&&(r||D||!A&&q)){const[X,J]=_h({nodeId:A,dragItems:c,nodeLookup:ee});r==null||r($.sourceEvent,c,X,J),D==null||D($.sourceEvent,X,J),A||q==null||q($.sourceEvent,J)}}const B=i_().clickDistance(L).on("start",$=>{const{domNode:ee,nodeDragThreshold:I,transform:F,snapGrid:z,snapToGrid:G}=t();m=(ee==null?void 0:ee.getBoundingClientRect())||null,b=!1,w=!1,E=$.sourceEvent,I===0&&H($),o=Do($.sourceEvent,{transform:F,snapGrid:z,snapToGrid:G,containerBounds:m}),d=Vn($.sourceEvent,m)}).on("drag",$=>{const{autoPanOnNodeDrag:ee,transform:I,snapGrid:F,snapToGrid:z,nodeDragThreshold:G,nodeLookup:Q}=t(),K=Do($.sourceEvent,{transform:I,snapGrid:F,snapToGrid:z,containerBounds:m});if(E=$.sourceEvent,($.sourceEvent.type==="touchmove"&&$.sourceEvent.touches.length>1||A&&!Q.has(A))&&(b=!0),!b){if(!h&&ee&&p&&(h=!0,V()),!p){const D=Vn($.sourceEvent,m),q=D.x-d.x,Y=D.y-d.y;Math.sqrt(q*q+Y*Y)>G&&H($)}(o.x!==K.xSnapped||o.y!==K.ySnapped)&&c&&p&&(d=Vn($.sourceEvent,m),R(K))}}).on("end",$=>{if(!(!p||b)&&(h=!1,p=!1,cancelAnimationFrame(s),c.size>0)){const{nodeLookup:ee,updateNodePositions:I,onNodeDragStop:F,onSelectionDragStop:z}=t();if(w&&(I(c,!1),w=!1),a||F||!A&&z){const[G,Q]=_h({nodeId:A,dragItems:c,nodeLookup:ee,dragging:!1});a==null||a($.sourceEvent,c,G,Q),F==null||F($.sourceEvent,G,Q),A||z==null||z($.sourceEvent,Q)}}}).filter($=>{const ee=$.target;return!$.button&&(!N||!$v(ee,`.${N}`,T))&&(!k||$v(ee,k,T))});x.call(B)}function _(){x==null||x.on(".drag",null)}return{update:S,destroy:_}}function TA(e,t,r){const l=[],a={x:e.x-r,y:e.y-r,width:r*2,height:r*2};for(const o of t.values())Go(a,ga(o))>0&&l.push(o);return l}const AA=250;function zA(e,t,r,l){var c,h;let a=[],o=1/0;const s=TA(e,r,t+AA);for(const d of s){const m=[...((c=d.internals.handleBounds)==null?void 0:c.source)??[],...((h=d.internals.handleBounds)==null?void 0:h.target)??[]];for(const p of m){if(l.nodeId===p.nodeId&&l.type===p.type&&l.id===p.id)continue;const{x,y:b}=il(d,p,p.position,!0),w=Math.sqrt(Math.pow(x-e.x,2)+Math.pow(b-e.y,2));w>t||(w1){const d=l.type==="source"?"target":"source";return a.find(m=>m.type===d)??a[0]}return a[0]}function U_(e,t,r,l,a,o=!1){var d,m,p;const s=l.get(e);if(!s)return null;const c=a==="strict"?(d=s.internals.handleBounds)==null?void 0:d[t]:[...((m=s.internals.handleBounds)==null?void 0:m.source)??[],...((p=s.internals.handleBounds)==null?void 0:p.target)??[]],h=(r?c==null?void 0:c.find(x=>x.id===r):c==null?void 0:c[0])??null;return h&&o?{...h,...il(s,h,h.position,!0)}:h}function $_(e,t){return e||(t!=null&&t.classList.contains("target")?"target":t!=null&&t.classList.contains("source")?"source":null)}function MA(e,t){let r=null;return t?r=!0:e&&!t&&(r=!1),r}const V_=()=>!0;function DA(e,{connectionMode:t,connectionRadius:r,handleId:l,nodeId:a,edgeUpdaterType:o,isTarget:s,domNode:c,nodeLookup:h,lib:d,autoPanOnConnect:m,flowId:p,panBy:x,cancelConnection:b,onConnectStart:w,onConnect:E,onConnectEnd:S,isValidConnection:_=V_,onReconnectEnd:N,updateConnection:k,getTransform:T,getFromHandle:M,autoPanSpeed:A,dragThreshold:L=1,handleDomNode:R}){const V=z_(e.target);let H=0,B;const{x:$,y:ee}=Vn(e),I=$_(o,R),F=c==null?void 0:c.getBoundingClientRect();let z=!1;if(!F||!I)return;const G=U_(a,I,l,h,t);if(!G)return;let Q=Vn(e,F),K=!1,D=null,q=!1,Y=null;function C(){if(!m||!F)return;const[be,ye]=C_(Q,F,A);x({x:be,y:ye}),H=requestAnimationFrame(C)}const P={...G,nodeId:a,type:I,position:G.position},X=h.get(a);let ne={inProgress:!0,isValid:null,from:il(X,P,ve.Left,!0),fromHandle:P,fromPosition:P.position,fromNode:X,to:Q,toHandle:null,toPosition:Av[P.position],toNode:null,pointer:Q};function re(){z=!0,k(ne),w==null||w(e,{nodeId:a,handleId:l,handleType:I})}L===0&&re();function se(be){if(!z){const{x:ct,y:nt}=Vn(be),Dt=ct-$,Pt=nt-ee;if(!(Dt*Dt+Pt*Pt>L*L))return;re()}if(!M()||!P){xe(be);return}const ye=T();Q=Vn(be,F),B=zA(rs(Q,ye,!1,[1,1]),r,h,P),K||(C(),K=!0);const pe=P_(be,{handle:B,connectionMode:t,fromNodeId:a,fromHandleId:l,fromType:s?"target":"source",isValidConnection:_,doc:V,lib:d,flowId:p,nodeLookup:h});Y=pe.handleDomNode,D=pe.connection,q=MA(!!B,pe.isValid);const Se=h.get(a),De=Se?il(Se,P,ve.Left,!0):ne.from,je={...ne,from:De,isValid:q,to:pe.toHandle&&q?xc({x:pe.toHandle.x,y:pe.toHandle.y},ye):Q,toHandle:pe.toHandle,toPosition:q&&pe.toHandle?pe.toHandle.position:Av[P.position],toNode:pe.toHandle?h.get(pe.toHandle.nodeId):null,pointer:Q};k(je),ne=je}function xe(be){if(!("touches"in be&&be.touches.length>0)){if(z){(B||Y)&&D&&q&&(E==null||E(D));const{inProgress:ye,...pe}=ne,Se={...pe,toPosition:ne.toHandle?ne.toPosition:null};S==null||S(be,Se),o&&(N==null||N(be,Se))}b(),cancelAnimationFrame(H),K=!1,q=!1,D=null,Y=null,V.removeEventListener("mousemove",se),V.removeEventListener("mouseup",xe),V.removeEventListener("touchmove",se),V.removeEventListener("touchend",xe)}}V.addEventListener("mousemove",se),V.addEventListener("mouseup",xe),V.addEventListener("touchmove",se),V.addEventListener("touchend",xe)}function P_(e,{handle:t,connectionMode:r,fromNodeId:l,fromHandleId:a,fromType:o,doc:s,lib:c,flowId:h,isValidConnection:d=V_,nodeLookup:m}){const p=o==="target",x=t?s.querySelector(`.${c}-flow__handle[data-id="${h}-${t==null?void 0:t.nodeId}-${t==null?void 0:t.id}-${t==null?void 0:t.type}"]`):null,{x:b,y:w}=Vn(e),E=s.elementFromPoint(b,w),S=E!=null&&E.classList.contains(`${c}-flow__handle`)?E:x,_={handleDomNode:S,isValid:!1,connection:null,toHandle:null};if(S){const N=$_(void 0,S),k=S.getAttribute("data-nodeid"),T=S.getAttribute("data-handleid"),M=S.classList.contains("connectable"),A=S.classList.contains("connectableend");if(!k||!N)return _;const L={source:p?k:l,sourceHandle:p?T:a,target:p?l:k,targetHandle:p?a:T};_.connection=L;const V=M&&A&&(r===pa.Strict?p&&N==="source"||!p&&N==="target":k!==l||T!==a);_.isValid=V&&d(L),_.toHandle=U_(k,N,T,m,r,!0)}return _}const im={onPointerDown:DA,isValid:P_};function RA({domNode:e,panZoom:t,getTransform:r,getViewScale:l}){const a=wn(e);function o({translateExtent:c,width:h,height:d,zoomStep:m=1,pannable:p=!0,zoomable:x=!0,inversePan:b=!1}){const w=k=>{if(k.sourceEvent.type!=="wheel"||!t)return;const T=r(),M=k.sourceEvent.ctrlKey&&Fo()?10:1,A=-k.sourceEvent.deltaY*(k.sourceEvent.deltaMode===1?.05:k.sourceEvent.deltaMode?1:.002)*m,L=T[2]*Math.pow(2,A*M);t.scaleTo(L)};let E=[0,0];const S=k=>{(k.sourceEvent.type==="mousedown"||k.sourceEvent.type==="touchstart")&&(E=[k.sourceEvent.clientX??k.sourceEvent.touches[0].clientX,k.sourceEvent.clientY??k.sourceEvent.touches[0].clientY])},_=k=>{const T=r();if(k.sourceEvent.type!=="mousemove"&&k.sourceEvent.type!=="touchmove"||!t)return;const M=[k.sourceEvent.clientX??k.sourceEvent.touches[0].clientX,k.sourceEvent.clientY??k.sourceEvent.touches[0].clientY],A=[M[0]-E[0],M[1]-E[1]];E=M;const L=l()*Math.max(T[2],Math.log(T[2]))*(b?-1:1),R={x:T[0]-A[0]*L,y:T[1]-A[1]*L},V=[[0,0],[h,d]];t.setViewportConstrained({x:R.x,y:R.y,zoom:T[2]},V,c)},N=v_().on("start",S).on("zoom",p?_:null).on("zoom.wheel",x?w:null);a.call(N,{})}function s(){a.on("zoom",null)}return{update:o,destroy:s,pointer:qn}}const Hc=e=>({x:e.x,y:e.y,zoom:e.k}),Sh=({x:e,y:t,zoom:r})=>Rc.translate(e,t).scale(r),ia=(e,t)=>e.target.closest(`.${t}`),G_=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),OA=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,kh=(e,t=0,r=OA,l=()=>{})=>{const a=typeof t=="number"&&t>0;return a||l(),a?e.transition().duration(t).ease(r).on("end",l):e},F_=e=>{const t=e.ctrlKey&&Fo()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function LA({zoomPanValues:e,noWheelClassName:t,d3Selection:r,d3Zoom:l,panOnScrollMode:a,panOnScrollSpeed:o,zoomOnPinch:s,onPanZoomStart:c,onPanZoom:h,onPanZoomEnd:d}){return m=>{if(ia(m,t))return m.ctrlKey&&m.preventDefault(),!1;m.preventDefault(),m.stopImmediatePropagation();const p=r.property("__zoom").k||1;if(m.ctrlKey&&s){const S=qn(m),_=F_(m),N=p*Math.pow(2,_);l.scaleTo(r,N,S,m);return}const x=m.deltaMode===1?20:1;let b=a===Wi.Vertical?0:m.deltaX*x,w=a===Wi.Horizontal?0:m.deltaY*x;!Fo()&&m.shiftKey&&a!==Wi.Vertical&&(b=m.deltaY*x,w=0),l.translateBy(r,-(b/p)*o,-(w/p)*o,{internal:!0});const E=Hc(r.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?(h==null||h(m,E),e.panScrollTimeout=setTimeout(()=>{d==null||d(m,E),e.isPanScrolling=!1},150)):(e.isPanScrolling=!0,c==null||c(m,E))}}function HA({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:r}){return function(l,a){const o=l.type==="wheel",s=!t&&o&&!l.ctrlKey,c=ia(l,e);if(l.ctrlKey&&o&&c&&l.preventDefault(),s||c)return null;l.preventDefault(),r.call(this,l,a)}}function BA({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:r}){return l=>{var o,s,c;if((o=l.sourceEvent)!=null&&o.internal)return;const a=Hc(l.transform);e.mouseButton=((s=l.sourceEvent)==null?void 0:s.button)||0,e.isZoomingOrPanning=!0,e.prevViewport=a,((c=l.sourceEvent)==null?void 0:c.type)==="mousedown"&&t(!0),r&&(r==null||r(l.sourceEvent,a))}}function IA({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:r,onTransformChange:l,onPanZoom:a}){return o=>{var s,c;e.usedRightMouseButton=!!(r&&G_(t,e.mouseButton??0)),(s=o.sourceEvent)!=null&&s.sync||l([o.transform.x,o.transform.y,o.transform.k]),a&&!((c=o.sourceEvent)!=null&&c.internal)&&(a==null||a(o.sourceEvent,Hc(o.transform)))}}function qA({zoomPanValues:e,panOnDrag:t,panOnScroll:r,onDraggingChange:l,onPanZoomEnd:a,onPaneContextMenu:o}){return s=>{var c;if(!((c=s.sourceEvent)!=null&&c.internal)&&(e.isZoomingOrPanning=!1,o&&G_(t,e.mouseButton??0)&&!e.usedRightMouseButton&&s.sourceEvent&&o(s.sourceEvent),e.usedRightMouseButton=!1,l(!1),a)){const h=Hc(s.transform);e.prevViewport=h,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{a==null||a(s.sourceEvent,h)},r?150:0)}}}function UA({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:r,panOnDrag:l,panOnScroll:a,zoomOnDoubleClick:o,userSelectionActive:s,noWheelClassName:c,noPanClassName:h,lib:d,connectionInProgress:m}){return p=>{var S;const x=e||t,b=r&&p.ctrlKey,w=p.type==="wheel";if(p.button===1&&p.type==="mousedown"&&(ia(p,`${d}-flow__node`)||ia(p,`${d}-flow__edge`)))return!0;if(!l&&!x&&!a&&!o&&!r||s||m&&!w||ia(p,c)&&w||ia(p,h)&&(!w||a&&w&&!e)||!r&&p.ctrlKey&&w)return!1;if(!r&&p.type==="touchstart"&&((S=p.touches)==null?void 0:S.length)>1)return p.preventDefault(),!1;if(!x&&!a&&!b&&w||!l&&(p.type==="mousedown"||p.type==="touchstart")||Array.isArray(l)&&!l.includes(p.button)&&p.type==="mousedown")return!1;const E=Array.isArray(l)&&l.includes(p.button)||!p.button||p.button<=1;return(!p.ctrlKey||w)&&E}}function $A({domNode:e,minZoom:t,maxZoom:r,translateExtent:l,viewport:a,onPanZoom:o,onPanZoomStart:s,onPanZoomEnd:c,onDraggingChange:h}){const d={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},m=e.getBoundingClientRect(),p=v_().scaleExtent([t,r]).translateExtent(l),x=wn(e).call(p);N({x:a.x,y:a.y,zoom:ma(a.zoom,t,r)},[[0,0],[m.width,m.height]],l);const b=x.on("wheel.zoom"),w=x.on("dblclick.zoom");p.wheelDelta(F_);function E(B,$){return x?new Promise(ee=>{p==null||p.interpolate(($==null?void 0:$.interpolate)==="linear"?Mo:Wu).transform(kh(x,$==null?void 0:$.duration,$==null?void 0:$.ease,()=>ee(!0)),B)}):Promise.resolve(!1)}function S({noWheelClassName:B,noPanClassName:$,onPaneContextMenu:ee,userSelectionActive:I,panOnScroll:F,panOnDrag:z,panOnScrollMode:G,panOnScrollSpeed:Q,preventScrolling:K,zoomOnPinch:D,zoomOnScroll:q,zoomOnDoubleClick:Y,zoomActivationKeyPressed:C,lib:P,onTransformChange:X,connectionInProgress:J,paneClickDistance:ne,selectionOnDrag:re}){I&&!d.isZoomingOrPanning&&_();const se=F&&!C&&!I;p.clickDistance(re?1/0:!$n(ne)||ne<0?0:ne);const xe=se?LA({zoomPanValues:d,noWheelClassName:B,d3Selection:x,d3Zoom:p,panOnScrollMode:G,panOnScrollSpeed:Q,zoomOnPinch:D,onPanZoomStart:s,onPanZoom:o,onPanZoomEnd:c}):HA({noWheelClassName:B,preventScrolling:K,d3ZoomHandler:b});if(x.on("wheel.zoom",xe,{passive:!1}),!I){const ye=BA({zoomPanValues:d,onDraggingChange:h,onPanZoomStart:s});p.on("start",ye);const pe=IA({zoomPanValues:d,panOnDrag:z,onPaneContextMenu:!!ee,onPanZoom:o,onTransformChange:X});p.on("zoom",pe);const Se=qA({zoomPanValues:d,panOnDrag:z,panOnScroll:F,onPaneContextMenu:ee,onPanZoomEnd:c,onDraggingChange:h});p.on("end",Se)}const be=UA({zoomActivationKeyPressed:C,panOnDrag:z,zoomOnScroll:q,panOnScroll:F,zoomOnDoubleClick:Y,zoomOnPinch:D,userSelectionActive:I,noPanClassName:$,noWheelClassName:B,lib:P,connectionInProgress:J});p.filter(be),Y?x.on("dblclick.zoom",w):x.on("dblclick.zoom",null)}function _(){p.on("zoom",null)}async function N(B,$,ee){const I=Sh(B),F=p==null?void 0:p.constrain()(I,$,ee);return F&&await E(F),new Promise(z=>z(F))}async function k(B,$){const ee=Sh(B);return await E(ee,$),new Promise(I=>I(ee))}function T(B){if(x){const $=Sh(B),ee=x.property("__zoom");(ee.k!==B.zoom||ee.x!==B.x||ee.y!==B.y)&&(p==null||p.transform(x,$,null,{sync:!0}))}}function M(){const B=x?y_(x.node()):{x:0,y:0,k:1};return{x:B.x,y:B.y,zoom:B.k}}function A(B,$){return x?new Promise(ee=>{p==null||p.interpolate(($==null?void 0:$.interpolate)==="linear"?Mo:Wu).scaleTo(kh(x,$==null?void 0:$.duration,$==null?void 0:$.ease,()=>ee(!0)),B)}):Promise.resolve(!1)}function L(B,$){return x?new Promise(ee=>{p==null||p.interpolate(($==null?void 0:$.interpolate)==="linear"?Mo:Wu).scaleBy(kh(x,$==null?void 0:$.duration,$==null?void 0:$.ease,()=>ee(!0)),B)}):Promise.resolve(!1)}function R(B){p==null||p.scaleExtent(B)}function V(B){p==null||p.translateExtent(B)}function H(B){const $=!$n(B)||B<0?0:B;p==null||p.clickDistance($)}return{update:S,destroy:_,setViewport:k,setViewportConstrained:N,getViewport:M,scaleTo:A,scaleBy:L,setScaleExtent:R,setTranslateExtent:V,syncViewport:T,setClickDistance:H}}var ya;(function(e){e.Line="line",e.Handle="handle"})(ya||(ya={}));function VA({width:e,prevWidth:t,height:r,prevHeight:l,affectsX:a,affectsY:o}){const s=e-t,c=r-l,h=[s>0?1:s<0?-1:0,c>0?1:c<0?-1:0];return s&&a&&(h[0]=h[0]*-1),c&&o&&(h[1]=h[1]*-1),h}function Vv(e){const t=e.includes("right")||e.includes("left"),r=e.includes("bottom")||e.includes("top"),l=e.includes("left"),a=e.includes("top");return{isHorizontal:t,isVertical:r,affectsX:l,affectsY:a}}function pi(e,t){return Math.max(0,t-e)}function mi(e,t){return Math.max(0,e-t)}function Pu(e,t,r){return Math.max(0,t-e,e-r)}function Pv(e,t){return e?!t:t}function PA(e,t,r,l,a,o,s,c){let{affectsX:h,affectsY:d}=t;const{isHorizontal:m,isVertical:p}=t,x=m&&p,{xSnapped:b,ySnapped:w}=r,{minWidth:E,maxWidth:S,minHeight:_,maxHeight:N}=l,{x:k,y:T,width:M,height:A,aspectRatio:L}=e;let R=Math.floor(m?b-e.pointerX:0),V=Math.floor(p?w-e.pointerY:0);const H=M+(h?-R:R),B=A+(d?-V:V),$=-o[0]*M,ee=-o[1]*A;let I=Pu(H,E,S),F=Pu(B,_,N);if(s){let Q=0,K=0;h&&R<0?Q=pi(k+R+$,s[0][0]):!h&&R>0&&(Q=mi(k+H+$,s[1][0])),d&&V<0?K=pi(T+V+ee,s[0][1]):!d&&V>0&&(K=mi(T+B+ee,s[1][1])),I=Math.max(I,Q),F=Math.max(F,K)}if(c){let Q=0,K=0;h&&R>0?Q=mi(k+R,c[0][0]):!h&&R<0&&(Q=pi(k+H,c[1][0])),d&&V>0?K=mi(T+V,c[0][1]):!d&&V<0&&(K=pi(T+B,c[1][1])),I=Math.max(I,Q),F=Math.max(F,K)}if(a){if(m){const Q=Pu(H/L,_,N)*L;if(I=Math.max(I,Q),s){let K=0;!h&&!d||h&&!d&&x?K=mi(T+ee+H/L,s[1][1])*L:K=pi(T+ee+(h?R:-R)/L,s[0][1])*L,I=Math.max(I,K)}if(c){let K=0;!h&&!d||h&&!d&&x?K=pi(T+H/L,c[1][1])*L:K=mi(T+(h?R:-R)/L,c[0][1])*L,I=Math.max(I,K)}}if(p){const Q=Pu(B*L,E,S)/L;if(F=Math.max(F,Q),s){let K=0;!h&&!d||d&&!h&&x?K=mi(k+B*L+$,s[1][0])/L:K=pi(k+(d?V:-V)*L+$,s[0][0])/L,F=Math.max(F,K)}if(c){let K=0;!h&&!d||d&&!h&&x?K=pi(k+B*L,c[1][0])/L:K=mi(k+(d?V:-V)*L,c[0][0])/L,F=Math.max(F,K)}}}V=V+(V<0?F:-F),R=R+(R<0?I:-I),a&&(x?H>B*L?V=(Pv(h,d)?-R:R)/L:R=(Pv(h,d)?-V:V)*L:m?(V=R/L,d=h):(R=V*L,h=d));const z=h?k+R:k,G=d?T+V:T;return{width:M+(h?-R:R),height:A+(d?-V:V),x:o[0]*R*(h?-1:1)+z,y:o[1]*V*(d?-1:1)+G}}const Y_={width:0,height:0,x:0,y:0},GA={...Y_,pointerX:0,pointerY:0,aspectRatio:1};function FA(e){return[[0,0],[e.measured.width,e.measured.height]]}function YA(e,t,r){const l=t.position.x+e.position.x,a=t.position.y+e.position.y,o=e.measured.width??0,s=e.measured.height??0,c=r[0]*o,h=r[1]*s;return[[l-c,a-h],[l+o-c,a+s-h]]}function XA({domNode:e,nodeId:t,getStoreItems:r,onChange:l,onEnd:a}){const o=wn(e);let s={controlDirection:Vv("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function c({controlPosition:d,boundaries:m,keepAspectRatio:p,resizeDirection:x,onResizeStart:b,onResize:w,onResizeEnd:E,shouldResize:S}){let _={...Y_},N={...GA};s={boundaries:m,resizeDirection:x,keepAspectRatio:p,controlDirection:Vv(d)};let k,T=null,M=[],A,L,R,V=!1;const H=i_().on("start",B=>{const{nodeLookup:$,transform:ee,snapGrid:I,snapToGrid:F,nodeOrigin:z,paneDomNode:G}=r();if(k=$.get(t),!k)return;T=(G==null?void 0:G.getBoundingClientRect())??null;const{xSnapped:Q,ySnapped:K}=Do(B.sourceEvent,{transform:ee,snapGrid:I,snapToGrid:F,containerBounds:T});_={width:k.measured.width??0,height:k.measured.height??0,x:k.position.x??0,y:k.position.y??0},N={..._,pointerX:Q,pointerY:K,aspectRatio:_.width/_.height},A=void 0,k.parentId&&(k.extent==="parent"||k.expandParent)&&(A=$.get(k.parentId),L=A&&k.extent==="parent"?FA(A):void 0),M=[],R=void 0;for(const[D,q]of $)if(q.parentId===t&&(M.push({id:D,position:{...q.position},extent:q.extent}),q.extent==="parent"||q.expandParent)){const Y=YA(q,k,q.origin??z);R?R=[[Math.min(Y[0][0],R[0][0]),Math.min(Y[0][1],R[0][1])],[Math.max(Y[1][0],R[1][0]),Math.max(Y[1][1],R[1][1])]]:R=Y}b==null||b(B,{..._})}).on("drag",B=>{const{transform:$,snapGrid:ee,snapToGrid:I,nodeOrigin:F}=r(),z=Do(B.sourceEvent,{transform:$,snapGrid:ee,snapToGrid:I,containerBounds:T}),G=[];if(!k)return;const{x:Q,y:K,width:D,height:q}=_,Y={},C=k.origin??F,{width:P,height:X,x:J,y:ne}=PA(N,s.controlDirection,z,s.boundaries,s.keepAspectRatio,C,L,R),re=P!==D,se=X!==q,xe=J!==Q&&re,be=ne!==K&&se;if(!xe&&!be&&!re&&!se)return;if((xe||be||C[0]===1||C[1]===1)&&(Y.x=xe?J:_.x,Y.y=be?ne:_.y,_.x=Y.x,_.y=Y.y,M.length>0)){const De=J-Q,je=ne-K;for(const ct of M)ct.position={x:ct.position.x-De+C[0]*(P-D),y:ct.position.y-je+C[1]*(X-q)},G.push(ct)}if((re||se)&&(Y.width=re&&(!s.resizeDirection||s.resizeDirection==="horizontal")?P:_.width,Y.height=se&&(!s.resizeDirection||s.resizeDirection==="vertical")?X:_.height,_.width=Y.width,_.height=Y.height),A&&k.expandParent){const De=C[0]*(Y.width??0);Y.x&&Y.x{V&&(E==null||E(B,{..._}),a==null||a({..._}),V=!1)});o.call(H)}function h(){o.on(".drag",null)}return{update:c,destroy:h}}var Eh={exports:{}},Nh={},Ch={exports:{}},jh={};/** + * @license React + * use-sync-external-store-shim.production.js + * + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var Gv;function QA(){if(Gv)return jh;Gv=1;var e=Ko();function t(p,x){return p===x&&(p!==0||1/p===1/x)||p!==p&&x!==x}var r=typeof Object.is=="function"?Object.is:t,l=e.useState,a=e.useEffect,o=e.useLayoutEffect,s=e.useDebugValue;function c(p,x){var b=x(),w=l({inst:{value:b,getSnapshot:x}}),E=w[0].inst,S=w[1];return o(function(){E.value=b,E.getSnapshot=x,h(E)&&S({inst:E})},[p,b,x]),a(function(){return h(E)&&S({inst:E}),p(function(){h(E)&&S({inst:E})})},[p]),s(b),b}function h(p){var x=p.getSnapshot;p=p.value;try{var b=x();return!r(p,b)}catch{return!0}}function d(p,x){return x()}var m=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?d:c;return jh.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:m,jh}var Fv;function ZA(){return Fv||(Fv=1,Ch.exports=QA()),Ch.exports}/** + * @license React + * use-sync-external-store-shim/with-selector.production.js + * + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var Yv;function KA(){if(Yv)return Nh;Yv=1;var e=Ko(),t=ZA();function r(d,m){return d===m&&(d!==0||1/d===1/m)||d!==d&&m!==m}var l=typeof Object.is=="function"?Object.is:r,a=t.useSyncExternalStore,o=e.useRef,s=e.useEffect,c=e.useMemo,h=e.useDebugValue;return Nh.useSyncExternalStoreWithSelector=function(d,m,p,x,b){var w=o(null);if(w.current===null){var E={hasValue:!1,value:null};w.current=E}else E=w.current;w=c(function(){function _(A){if(!N){if(N=!0,k=A,A=x(A),b!==void 0&&E.hasValue){var L=E.value;if(b(L,A))return T=L}return T=A}if(L=T,l(k,A))return L;var R=x(A);return b!==void 0&&b(L,R)?(k=A,L):(k=A,T=R)}var N=!1,k,T,M=p===void 0?null:p;return[function(){return _(m())},M===null?void 0:function(){return _(M())}]},[m,p,x,b]);var S=a(d,w[0],w[1]);return s(function(){E.hasValue=!0,E.value=S},[S]),h(S),S},Nh}var Xv;function JA(){return Xv||(Xv=1,Eh.exports=KA()),Eh.exports}var WA=JA();const ez=Zo(WA),tz={},Qv=e=>{let t;const r=new Set,l=(m,p)=>{const x=typeof m=="function"?m(t):m;if(!Object.is(x,t)){const b=t;t=p??(typeof x!="object"||x===null)?x:Object.assign({},t,x),r.forEach(w=>w(t,b))}},a=()=>t,h={setState:l,getState:a,getInitialState:()=>d,subscribe:m=>(r.add(m),()=>r.delete(m)),destroy:()=>{(tz?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),r.clear()}},d=t=e(l,a,h);return h},nz=e=>e?Qv(e):Qv,{useDebugValue:rz}=na,{useSyncExternalStoreWithSelector:iz}=ez,lz=e=>e;function X_(e,t=lz,r){const l=iz(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,r);return rz(l),l}const Zv=(e,t)=>{const r=nz(e),l=(a,o=t)=>X_(r,a,o);return Object.assign(l,r),l},az=(e,t)=>e?Zv(e,t):Zv;function mt(e,t){if(Object.is(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(const[l,a]of e)if(!Object.is(a,t.get(l)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const l of e)if(!t.has(l))return!1;return!0}const r=Object.keys(e);if(r.length!==Object.keys(t).length)return!1;for(const l of r)if(!Object.prototype.hasOwnProperty.call(t,l)||!Object.is(e[l],t[l]))return!1;return!0}var oz=pw();const Bc=U.createContext(null),sz=Bc.Provider,Q_=lr.error001();function Ye(e,t){const r=U.useContext(Bc);if(r===null)throw new Error(Q_);return X_(r,e,t)}function gt(){const e=U.useContext(Bc);if(e===null)throw new Error(Q_);return U.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const Kv={display:"none"},uz={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},Z_="react-flow__node-desc",K_="react-flow__edge-desc",cz="react-flow__aria-live",fz=e=>e.ariaLiveMessage,dz=e=>e.ariaLabelConfig;function hz({rfId:e}){const t=Ye(fz);return y.jsx("div",{id:`${cz}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:uz,children:t})}function pz({rfId:e,disableKeyboardA11y:t}){const r=Ye(dz);return y.jsxs(y.Fragment,{children:[y.jsx("div",{id:`${Z_}-${e}`,style:Kv,children:t?r["node.a11yDescription.default"]:r["node.a11yDescription.keyboardDisabled"]}),y.jsx("div",{id:`${K_}-${e}`,style:Kv,children:r["edge.a11yDescription.default"]}),!t&&y.jsx(hz,{rfId:e})]})}const Ic=U.forwardRef(({position:e="top-left",children:t,className:r,style:l,...a},o)=>{const s=`${e}`.split("-");return y.jsx("div",{className:Mt(["react-flow__panel",r,...s]),style:l,ref:o,...a,children:t})});Ic.displayName="Panel";function mz({proOptions:e,position:t="bottom-right"}){return e!=null&&e.hideAttribution?null:y.jsx(Ic,{position:t,className:"react-flow__attribution","data-message":"Please only hide this attribution when you are subscribed to React Flow Pro: https://pro.reactflow.dev",children:y.jsx("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const gz=e=>{const t=[],r=[];for(const[,l]of e.nodeLookup)l.selected&&t.push(l.internals.userNode);for(const[,l]of e.edgeLookup)l.selected&&r.push(l);return{selectedNodes:t,selectedEdges:r}},Gu=e=>e.id;function xz(e,t){return mt(e.selectedNodes.map(Gu),t.selectedNodes.map(Gu))&&mt(e.selectedEdges.map(Gu),t.selectedEdges.map(Gu))}function yz({onSelectionChange:e}){const t=gt(),{selectedNodes:r,selectedEdges:l}=Ye(gz,xz);return U.useEffect(()=>{const a={nodes:r,edges:l};e==null||e(a),t.getState().onSelectionChangeHandlers.forEach(o=>o(a))},[r,l,e]),null}const vz=e=>!!e.onSelectionChangeHandlers;function bz({onSelectionChange:e}){const t=Ye(vz);return e||t?y.jsx(yz,{onSelectionChange:e}):null}const J_=[0,0],wz={x:0,y:0,zoom:1},_z=["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"],Jv=[..._z,"rfId"],Sz=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}),Wv={translateExtent:Vo,nodeOrigin:J_,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function kz(e){const{setNodes:t,setEdges:r,setMinZoom:l,setMaxZoom:a,setTranslateExtent:o,setNodeExtent:s,reset:c,setDefaultNodesAndEdges:h}=Ye(Sz,mt),d=gt();U.useEffect(()=>(h(e.defaultNodes,e.defaultEdges),()=>{m.current=Wv,c()}),[]);const m=U.useRef(Wv);return U.useEffect(()=>{for(const p of Jv){const x=e[p],b=m.current[p];x!==b&&(typeof e[p]>"u"||(p==="nodes"?t(x):p==="edges"?r(x):p==="minZoom"?l(x):p==="maxZoom"?a(x):p==="translateExtent"?o(x):p==="nodeExtent"?s(x):p==="ariaLabelConfig"?d.setState({ariaLabelConfig:aA(x)}):p==="fitView"?d.setState({fitViewQueued:x}):p==="fitViewOptions"?d.setState({fitViewOptions:x}):d.setState({[p]:x})))}m.current=e},Jv.map(p=>e[p])),null}function eb(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function Ez(e){var l;const[t,r]=U.useState(e==="system"?null:e);return U.useEffect(()=>{if(e!=="system"){r(e);return}const a=eb(),o=()=>r(a!=null&&a.matches?"dark":"light");return o(),a==null||a.addEventListener("change",o),()=>{a==null||a.removeEventListener("change",o)}},[e]),t!==null?t:(l=eb())!=null&&l.matches?"dark":"light"}const tb=typeof document<"u"?document:null;function Yo(e=null,t={target:tb,actInsideInputWithModifier:!0}){const[r,l]=U.useState(!1),a=U.useRef(!1),o=U.useRef(new Set([])),[s,c]=U.useMemo(()=>{if(e!==null){const d=(Array.isArray(e)?e:[e]).filter(p=>typeof p=="string").map(p=>p.replace("+",` +`).replace(` + +`,` ++`).split(` +`)),m=d.reduce((p,x)=>p.concat(...x),[]);return[d,m]}return[[],[]]},[e]);return U.useEffect(()=>{const h=(t==null?void 0:t.target)??tb,d=(t==null?void 0:t.actInsideInputWithModifier)??!0;if(e!==null){const m=b=>{var S,_;if(a.current=b.ctrlKey||b.metaKey||b.shiftKey||b.altKey,(!a.current||a.current&&!d)&&M_(b))return!1;const E=rb(b.code,c);if(o.current.add(b[E]),nb(s,o.current,!1)){const N=((_=(S=b.composedPath)==null?void 0:S.call(b))==null?void 0:_[0])||b.target,k=(N==null?void 0:N.nodeName)==="BUTTON"||(N==null?void 0:N.nodeName)==="A";t.preventDefault!==!1&&(a.current||!k)&&b.preventDefault(),l(!0)}},p=b=>{const w=rb(b.code,c);nb(s,o.current,!0)?(l(!1),o.current.clear()):o.current.delete(b[w]),b.key==="Meta"&&o.current.clear(),a.current=!1},x=()=>{o.current.clear(),l(!1)};return h==null||h.addEventListener("keydown",m),h==null||h.addEventListener("keyup",p),window.addEventListener("blur",x),window.addEventListener("contextmenu",x),()=>{h==null||h.removeEventListener("keydown",m),h==null||h.removeEventListener("keyup",p),window.removeEventListener("blur",x),window.removeEventListener("contextmenu",x)}}},[e,l]),r}function nb(e,t,r){return e.filter(l=>r||l.length===t.size).some(l=>l.every(a=>t.has(a)))}function rb(e,t){return t.includes(e)?"code":"key"}const Nz=()=>{const e=gt();return U.useMemo(()=>({zoomIn:t=>{const{panZoom:r}=e.getState();return r?r.scaleBy(1.2,{duration:t==null?void 0:t.duration}):Promise.resolve(!1)},zoomOut:t=>{const{panZoom:r}=e.getState();return r?r.scaleBy(1/1.2,{duration:t==null?void 0:t.duration}):Promise.resolve(!1)},zoomTo:(t,r)=>{const{panZoom:l}=e.getState();return l?l.scaleTo(t,{duration:r==null?void 0:r.duration}):Promise.resolve(!1)},getZoom:()=>e.getState().transform[2],setViewport:async(t,r)=>{const{transform:[l,a,o],panZoom:s}=e.getState();return s?(await s.setViewport({x:t.x??l,y:t.y??a,zoom:t.zoom??o},r),Promise.resolve(!0)):Promise.resolve(!1)},getViewport:()=>{const[t,r,l]=e.getState().transform;return{x:t,y:r,zoom:l}},setCenter:async(t,r,l)=>e.getState().setCenter(t,r,l),fitBounds:async(t,r)=>{const{width:l,height:a,minZoom:o,maxZoom:s,panZoom:c}=e.getState(),h=Mm(t,l,a,o,s,(r==null?void 0:r.padding)??.1);return c?(await c.setViewport(h,{duration:r==null?void 0:r.duration,ease:r==null?void 0:r.ease,interpolate:r==null?void 0:r.interpolate}),Promise.resolve(!0)):Promise.resolve(!1)},screenToFlowPosition:(t,r={})=>{const{transform:l,snapGrid:a,snapToGrid:o,domNode:s}=e.getState();if(!s)return t;const{x:c,y:h}=s.getBoundingClientRect(),d={x:t.x-c,y:t.y-h},m=r.snapGrid??a,p=r.snapToGrid??o;return rs(d,l,p,m)},flowToScreenPosition:t=>{const{transform:r,domNode:l}=e.getState();if(!l)return t;const{x:a,y:o}=l.getBoundingClientRect(),s=xc(t,r);return{x:s.x+a,y:s.y+o}}}),[])};function W_(e,t){const r=[],l=new Map,a=[];for(const o of e)if(o.type==="add"){a.push(o);continue}else if(o.type==="remove"||o.type==="replace")l.set(o.id,[o]);else{const s=l.get(o.id);s?s.push(o):l.set(o.id,[o])}for(const o of t){const s=l.get(o.id);if(!s){r.push(o);continue}if(s[0].type==="remove")continue;if(s[0].type==="replace"){r.push({...s[0].item});continue}const c={...o};for(const h of s)Cz(h,c);r.push(c)}return a.length&&a.forEach(o=>{o.index!==void 0?r.splice(o.index,0,{...o.item}):r.push({...o.item})}),r}function Cz(e,t){switch(e.type){case"select":{t.selected=e.selected;break}case"position":{typeof e.position<"u"&&(t.position=e.position),typeof e.dragging<"u"&&(t.dragging=e.dragging);break}case"dimensions":{typeof e.dimensions<"u"&&(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);break}}}function eS(e,t){return W_(e,t)}function tS(e,t){return W_(e,t)}function Yi(e,t){return{id:e,type:"select",selected:t}}function la(e,t=new Set,r=!1){const l=[];for(const[a,o]of e){const s=t.has(a);!(o.selected===void 0&&!s)&&o.selected!==s&&(r&&(o.selected=s),l.push(Yi(o.id,s)))}return l}function ib({items:e=[],lookup:t}){var a;const r=[],l=new Map(e.map(o=>[o.id,o]));for(const[o,s]of e.entries()){const c=t.get(s.id),h=((a=c==null?void 0:c.internals)==null?void 0:a.userNode)??c;h!==void 0&&h!==s&&r.push({id:s.id,item:s,type:"replace"}),h===void 0&&r.push({item:s,type:"add",index:o})}for(const[o]of t)l.get(o)===void 0&&r.push({id:o,type:"remove"});return r}function lb(e){return{id:e.id,type:"remove"}}const ab=e=>ZT(e),jz=e=>k_(e);function nS(e){return U.forwardRef(e)}const Tz=typeof window<"u"?U.useLayoutEffect:U.useEffect;function ob(e){const[t,r]=U.useState(BigInt(0)),[l]=U.useState(()=>Az(()=>r(a=>a+BigInt(1))));return Tz(()=>{const a=l.get();a.length&&(e(a),l.reset())},[t]),l}function Az(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:r=>{t.push(r),e()}}}const rS=U.createContext(null);function zz({children:e}){const t=gt(),r=U.useCallback(c=>{const{nodes:h=[],setNodes:d,hasDefaultNodes:m,onNodesChange:p,nodeLookup:x,fitViewQueued:b,onNodesChangeMiddlewareMap:w}=t.getState();let E=h;for(const _ of c)E=typeof _=="function"?_(E):_;let S=ib({items:E,lookup:x});for(const _ of w.values())S=_(S);m&&d(E),S.length>0?p==null||p(S):b&&window.requestAnimationFrame(()=>{const{fitViewQueued:_,nodes:N,setNodes:k}=t.getState();_&&k(N)})},[]),l=ob(r),a=U.useCallback(c=>{const{edges:h=[],setEdges:d,hasDefaultEdges:m,onEdgesChange:p,edgeLookup:x}=t.getState();let b=h;for(const w of c)b=typeof w=="function"?w(b):w;m?d(b):p&&p(ib({items:b,lookup:x}))},[]),o=ob(a),s=U.useMemo(()=>({nodeQueue:l,edgeQueue:o}),[]);return y.jsx(rS.Provider,{value:s,children:e})}function Mz(){const e=U.useContext(rS);if(!e)throw new Error("useBatchContext must be used within a BatchProvider");return e}const Dz=e=>!!e.panZoom;function ul(){const e=Nz(),t=gt(),r=Mz(),l=Ye(Dz),a=U.useMemo(()=>{const o=p=>t.getState().nodeLookup.get(p),s=p=>{r.nodeQueue.push(p)},c=p=>{r.edgeQueue.push(p)},h=p=>{var _,N;const{nodeLookup:x,nodeOrigin:b}=t.getState(),w=ab(p)?p:x.get(p.id),E=w.parentId?A_(w.position,w.measured,w.parentId,x,b):w.position,S={...w,position:E,width:((_=w.measured)==null?void 0:_.width)??w.width,height:((N=w.measured)==null?void 0:N.height)??w.height};return ga(S)},d=(p,x,b={replace:!1})=>{s(w=>w.map(E=>{if(E.id===p){const S=typeof x=="function"?x(E):x;return b.replace&&ab(S)?S:{...E,...S}}return E}))},m=(p,x,b={replace:!1})=>{c(w=>w.map(E=>{if(E.id===p){const S=typeof x=="function"?x(E):x;return b.replace&&jz(S)?S:{...E,...S}}return E}))};return{getNodes:()=>t.getState().nodes.map(p=>({...p})),getNode:p=>{var x;return(x=o(p))==null?void 0:x.internals.userNode},getInternalNode:o,getEdges:()=>{const{edges:p=[]}=t.getState();return p.map(x=>({...x}))},getEdge:p=>t.getState().edgeLookup.get(p),setNodes:s,setEdges:c,addNodes:p=>{const x=Array.isArray(p)?p:[p];r.nodeQueue.push(b=>[...b,...x])},addEdges:p=>{const x=Array.isArray(p)?p:[p];r.edgeQueue.push(b=>[...b,...x])},toObject:()=>{const{nodes:p=[],edges:x=[],transform:b}=t.getState(),[w,E,S]=b;return{nodes:p.map(_=>({..._})),edges:x.map(_=>({..._})),viewport:{x:w,y:E,zoom:S}}},deleteElements:async({nodes:p=[],edges:x=[]})=>{const{nodes:b,edges:w,onNodesDelete:E,onEdgesDelete:S,triggerNodeChanges:_,triggerEdgeChanges:N,onDelete:k,onBeforeDelete:T}=t.getState(),{nodes:M,edges:A}=await tA({nodesToRemove:p,edgesToRemove:x,nodes:b,edges:w,onBeforeDelete:T}),L=A.length>0,R=M.length>0;if(L){const V=A.map(lb);S==null||S(A),N(V)}if(R){const V=M.map(lb);E==null||E(M),_(V)}return(R||L)&&(k==null||k({nodes:M,edges:A})),{deletedNodes:M,deletedEdges:A}},getIntersectingNodes:(p,x=!0,b)=>{const w=Mv(p),E=w?p:h(p),S=b!==void 0;return E?(b||t.getState().nodes).filter(_=>{const N=t.getState().nodeLookup.get(_.id);if(N&&!w&&(_.id===p.id||!N.internals.positionAbsolute))return!1;const k=ga(S?_:N),T=Go(k,E);return x&&T>0||T>=k.width*k.height||T>=E.width*E.height}):[]},isNodeIntersecting:(p,x,b=!0)=>{const E=Mv(p)?p:h(p);if(!E)return!1;const S=Go(E,x);return b&&S>0||S>=x.width*x.height||S>=E.width*E.height},updateNode:d,updateNodeData:(p,x,b={replace:!1})=>{d(p,w=>{const E=typeof x=="function"?x(w):x;return b.replace?{...w,data:E}:{...w,data:{...w.data,...E}}},b)},updateEdge:m,updateEdgeData:(p,x,b={replace:!1})=>{m(p,w=>{const E=typeof x=="function"?x(w):x;return b.replace?{...w,data:E}:{...w,data:{...w.data,...E}}},b)},getNodesBounds:p=>{const{nodeLookup:x,nodeOrigin:b}=t.getState();return KT(p,{nodeLookup:x,nodeOrigin:b})},getHandleConnections:({type:p,id:x,nodeId:b})=>{var w;return Array.from(((w=t.getState().connectionLookup.get(`${b}-${p}${x?`-${x}`:""}`))==null?void 0:w.values())??[])},getNodeConnections:({type:p,handleId:x,nodeId:b})=>{var w;return Array.from(((w=t.getState().connectionLookup.get(`${b}${p?x?`-${p}-${x}`:`-${p}`:""}`))==null?void 0:w.values())??[])},fitView:async p=>{const x=t.getState().fitViewResolver??lA();return t.setState({fitViewQueued:!0,fitViewOptions:p,fitViewResolver:x}),r.nodeQueue.push(b=>[...b]),x.promise}}},[]);return U.useMemo(()=>({...a,...e,viewportInitialized:l}),[l])}const sb=e=>e.selected,Rz=typeof window<"u"?window:void 0;function Oz({deleteKeyCode:e,multiSelectionKeyCode:t}){const r=gt(),{deleteElements:l}=ul(),a=Yo(e,{actInsideInputWithModifier:!1}),o=Yo(t,{target:Rz});U.useEffect(()=>{if(a){const{edges:s,nodes:c}=r.getState();l({nodes:c.filter(sb),edges:s.filter(sb)}),r.setState({nodesSelectionActive:!1})}},[a]),U.useEffect(()=>{r.setState({multiSelectionActive:o})},[o])}function Lz(e){const t=gt();U.useEffect(()=>{const r=()=>{var a,o,s,c;if(!e.current||!(((o=(a=e.current).checkVisibility)==null?void 0:o.call(a))??!0))return!1;const l=Dm(e.current);(l.height===0||l.width===0)&&((c=(s=t.getState()).onError)==null||c.call(s,"004",lr.error004())),t.setState({width:l.width||500,height:l.height||500})};if(e.current){r(),window.addEventListener("resize",r);const l=new ResizeObserver(()=>r());return l.observe(e.current),()=>{window.removeEventListener("resize",r),l&&e.current&&l.unobserve(e.current)}}},[])}const qc={position:"absolute",width:"100%",height:"100%",top:0,left:0},Hz=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function Bz({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:r=!0,panOnScroll:l=!1,panOnScrollSpeed:a=.5,panOnScrollMode:o=Wi.Free,zoomOnDoubleClick:s=!0,panOnDrag:c=!0,defaultViewport:h,translateExtent:d,minZoom:m,maxZoom:p,zoomActivationKeyCode:x,preventScrolling:b=!0,children:w,noWheelClassName:E,noPanClassName:S,onViewportChange:_,isControlledViewport:N,paneClickDistance:k,selectionOnDrag:T}){const M=gt(),A=U.useRef(null),{userSelectionActive:L,lib:R,connectionInProgress:V}=Ye(Hz,mt),H=Yo(x),B=U.useRef();Lz(A);const $=U.useCallback(ee=>{_==null||_({x:ee[0],y:ee[1],zoom:ee[2]}),N||M.setState({transform:ee})},[_,N]);return U.useEffect(()=>{if(A.current){B.current=$A({domNode:A.current,minZoom:m,maxZoom:p,translateExtent:d,viewport:h,onDraggingChange:z=>M.setState(G=>G.paneDragging===z?G:{paneDragging:z}),onPanZoomStart:(z,G)=>{const{onViewportChangeStart:Q,onMoveStart:K}=M.getState();K==null||K(z,G),Q==null||Q(G)},onPanZoom:(z,G)=>{const{onViewportChange:Q,onMove:K}=M.getState();K==null||K(z,G),Q==null||Q(G)},onPanZoomEnd:(z,G)=>{const{onViewportChangeEnd:Q,onMoveEnd:K}=M.getState();K==null||K(z,G),Q==null||Q(G)}});const{x:ee,y:I,zoom:F}=B.current.getViewport();return M.setState({panZoom:B.current,transform:[ee,I,F],domNode:A.current.closest(".react-flow")}),()=>{var z;(z=B.current)==null||z.destroy()}}},[]),U.useEffect(()=>{var ee;(ee=B.current)==null||ee.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:r,panOnScroll:l,panOnScrollSpeed:a,panOnScrollMode:o,zoomOnDoubleClick:s,panOnDrag:c,zoomActivationKeyPressed:H,preventScrolling:b,noPanClassName:S,userSelectionActive:L,noWheelClassName:E,lib:R,onTransformChange:$,connectionInProgress:V,selectionOnDrag:T,paneClickDistance:k})},[e,t,r,l,a,o,s,c,H,b,S,L,E,R,$,V,T,k]),y.jsx("div",{className:"react-flow__renderer",ref:A,style:qc,children:w})}const Iz=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function qz(){const{userSelectionActive:e,userSelectionRect:t}=Ye(Iz,mt);return e&&t?y.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}const Th=(e,t)=>r=>{r.target===t.current&&(e==null||e(r))},Uz=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,connectionInProgress:e.connection.inProgress,dragging:e.paneDragging});function $z({isSelecting:e,selectionKeyPressed:t,selectionMode:r=Po.Full,panOnDrag:l,paneClickDistance:a,selectionOnDrag:o,onSelectionStart:s,onSelectionEnd:c,onPaneClick:h,onPaneContextMenu:d,onPaneScroll:m,onPaneMouseEnter:p,onPaneMouseMove:x,onPaneMouseLeave:b,children:w}){const E=gt(),{userSelectionActive:S,elementsSelectable:_,dragging:N,connectionInProgress:k}=Ye(Uz,mt),T=_&&(e||S),M=U.useRef(null),A=U.useRef(),L=U.useRef(new Set),R=U.useRef(new Set),V=U.useRef(!1),H=Q=>{if(V.current||k){V.current=!1;return}h==null||h(Q),E.getState().resetSelectedElements(),E.setState({nodesSelectionActive:!1})},B=Q=>{if(Array.isArray(l)&&(l!=null&&l.includes(2))){Q.preventDefault();return}d==null||d(Q)},$=m?Q=>m(Q):void 0,ee=Q=>{V.current&&(Q.stopPropagation(),V.current=!1)},I=Q=>{var X,J;const{domNode:K}=E.getState();if(A.current=K==null?void 0:K.getBoundingClientRect(),!A.current)return;const D=Q.target===M.current;if(!D&&!!Q.target.closest(".nokey")||!e||!(o&&D||t)||Q.button!==0||!Q.isPrimary)return;(J=(X=Q.target)==null?void 0:X.setPointerCapture)==null||J.call(X,Q.pointerId),V.current=!1;const{x:C,y:P}=Vn(Q.nativeEvent,A.current);E.setState({userSelectionRect:{width:0,height:0,startX:C,startY:P,x:C,y:P}}),D||(Q.stopPropagation(),Q.preventDefault())},F=Q=>{const{userSelectionRect:K,transform:D,nodeLookup:q,edgeLookup:Y,connectionLookup:C,triggerNodeChanges:P,triggerEdgeChanges:X,defaultEdgeOptions:J,resetSelectedElements:ne}=E.getState();if(!A.current||!K)return;const{x:re,y:se}=Vn(Q.nativeEvent,A.current),{startX:xe,startY:be}=K;if(!V.current){const je=t?0:a;if(Math.hypot(re-xe,se-be)<=je)return;ne(),s==null||s(Q)}V.current=!0;const ye={startX:xe,startY:be,x:reje.id)),R.current=new Set;const De=(J==null?void 0:J.selectable)??!0;for(const je of L.current){const ct=C.get(je);if(ct)for(const{edgeId:nt}of ct.values()){const Dt=Y.get(nt);Dt&&(Dt.selectable??De)&&R.current.add(nt)}}if(!Dv(pe,L.current)){const je=la(q,L.current,!0);P(je)}if(!Dv(Se,R.current)){const je=la(Y,R.current);X(je)}E.setState({userSelectionRect:ye,userSelectionActive:!0,nodesSelectionActive:!1})},z=Q=>{var K,D;Q.button===0&&((D=(K=Q.target)==null?void 0:K.releasePointerCapture)==null||D.call(K,Q.pointerId),!S&&Q.target===M.current&&E.getState().userSelectionRect&&(H==null||H(Q)),E.setState({userSelectionActive:!1,userSelectionRect:null}),V.current&&(c==null||c(Q),E.setState({nodesSelectionActive:L.current.size>0})))},G=l===!0||Array.isArray(l)&&l.includes(0);return y.jsxs("div",{className:Mt(["react-flow__pane",{draggable:G,dragging:N,selection:e}]),onClick:T?void 0:Th(H,M),onContextMenu:Th(B,M),onWheel:Th($,M),onPointerEnter:T?void 0:p,onPointerMove:T?F:x,onPointerUp:T?z:void 0,onPointerDownCapture:T?I:void 0,onClickCapture:T?ee:void 0,onPointerLeave:b,ref:M,style:qc,children:[w,y.jsx(qz,{})]})}function lm({id:e,store:t,unselect:r=!1,nodeRef:l}){const{addSelectedNodes:a,unselectNodesAndEdges:o,multiSelectionActive:s,nodeLookup:c,onError:h}=t.getState(),d=c.get(e);if(!d){h==null||h("012",lr.error012(e));return}t.setState({nodesSelectionActive:!1}),d.selected?(r||d.selected&&s)&&(o({nodes:[d],edges:[]}),requestAnimationFrame(()=>{var m;return(m=l==null?void 0:l.current)==null?void 0:m.blur()})):a([e])}function iS({nodeRef:e,disabled:t=!1,noDragClassName:r,handleSelector:l,nodeId:a,isSelectable:o,nodeClickDistance:s}){const c=gt(),[h,d]=U.useState(!1),m=U.useRef();return U.useEffect(()=>{m.current=jA({getStoreItems:()=>c.getState(),onNodeMouseDown:p=>{lm({id:p,store:c,nodeRef:e})},onDragStart:()=>{d(!0)},onDragStop:()=>{d(!1)}})},[]),U.useEffect(()=>{if(!(t||!e.current||!m.current))return m.current.update({noDragClassName:r,handleSelector:l,domNode:e.current,isSelectable:o,nodeId:a,nodeClickDistance:s}),()=>{var p;(p=m.current)==null||p.destroy()}},[r,l,t,o,e,a,s]),h}const Vz=e=>t=>t.selected&&(t.draggable||e&&typeof t.draggable>"u");function lS(){const e=gt();return U.useCallback(r=>{const{nodeExtent:l,snapToGrid:a,snapGrid:o,nodesDraggable:s,onError:c,updateNodePositions:h,nodeLookup:d,nodeOrigin:m}=e.getState(),p=new Map,x=Vz(s),b=a?o[0]:5,w=a?o[1]:5,E=r.direction.x*b*r.factor,S=r.direction.y*w*r.factor;for(const[,_]of d){if(!x(_))continue;let N={x:_.internals.positionAbsolute.x+E,y:_.internals.positionAbsolute.y+S};a&&(N=ns(N,o));const{position:k,positionAbsolute:T}=E_({nodeId:_.id,nextPosition:N,nodeLookup:d,nodeExtent:l,nodeOrigin:m,onError:c});_.position=k,_.internals.positionAbsolute=T,p.set(_.id,_)}h(p)},[])}const qm=U.createContext(null),Pz=qm.Provider;qm.Consumer;const aS=()=>U.useContext(qm),Gz=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),Fz=(e,t,r)=>l=>{const{connectionClickStartHandle:a,connectionMode:o,connection:s}=l,{fromHandle:c,toHandle:h,isValid:d}=s,m=(h==null?void 0:h.nodeId)===e&&(h==null?void 0:h.id)===t&&(h==null?void 0:h.type)===r;return{connectingFrom:(c==null?void 0:c.nodeId)===e&&(c==null?void 0:c.id)===t&&(c==null?void 0:c.type)===r,connectingTo:m,clickConnecting:(a==null?void 0:a.nodeId)===e&&(a==null?void 0:a.id)===t&&(a==null?void 0:a.type)===r,isPossibleEndHandle:o===pa.Strict?(c==null?void 0:c.type)!==r:e!==(c==null?void 0:c.nodeId)||t!==(c==null?void 0:c.id),connectionInProcess:!!c,clickConnectionInProcess:!!a,valid:m&&d}};function Yz({type:e="source",position:t=ve.Top,isValidConnection:r,isConnectable:l=!0,isConnectableStart:a=!0,isConnectableEnd:o=!0,id:s,onConnect:c,children:h,className:d,onMouseDown:m,onTouchStart:p,...x},b){var F,z;const w=s||null,E=e==="target",S=gt(),_=aS(),{connectOnClick:N,noPanClassName:k,rfId:T}=Ye(Gz,mt),{connectingFrom:M,connectingTo:A,clickConnecting:L,isPossibleEndHandle:R,connectionInProcess:V,clickConnectionInProcess:H,valid:B}=Ye(Fz(_,w,e),mt);_||(z=(F=S.getState()).onError)==null||z.call(F,"010",lr.error010());const $=G=>{const{defaultEdgeOptions:Q,onConnect:K,hasDefaultEdges:D}=S.getState(),q={...Q,...G};if(D){const{edges:Y,setEdges:C}=S.getState();C(dA(q,Y))}K==null||K(q),c==null||c(q)},ee=G=>{if(!_)return;const Q=D_(G.nativeEvent);if(a&&(Q&&G.button===0||!Q)){const K=S.getState();im.onPointerDown(G.nativeEvent,{handleDomNode:G.currentTarget,autoPanOnConnect:K.autoPanOnConnect,connectionMode:K.connectionMode,connectionRadius:K.connectionRadius,domNode:K.domNode,nodeLookup:K.nodeLookup,lib:K.lib,isTarget:E,handleId:w,nodeId:_,flowId:K.rfId,panBy:K.panBy,cancelConnection:K.cancelConnection,onConnectStart:K.onConnectStart,onConnectEnd:(...D)=>{var q,Y;return(Y=(q=S.getState()).onConnectEnd)==null?void 0:Y.call(q,...D)},updateConnection:K.updateConnection,onConnect:$,isValidConnection:r||((...D)=>{var q,Y;return((Y=(q=S.getState()).isValidConnection)==null?void 0:Y.call(q,...D))??!0}),getTransform:()=>S.getState().transform,getFromHandle:()=>S.getState().connection.fromHandle,autoPanSpeed:K.autoPanSpeed,dragThreshold:K.connectionDragThreshold})}Q?m==null||m(G):p==null||p(G)},I=G=>{const{onClickConnectStart:Q,onClickConnectEnd:K,connectionClickStartHandle:D,connectionMode:q,isValidConnection:Y,lib:C,rfId:P,nodeLookup:X,connection:J}=S.getState();if(!_||!D&&!a)return;if(!D){Q==null||Q(G.nativeEvent,{nodeId:_,handleId:w,handleType:e}),S.setState({connectionClickStartHandle:{nodeId:_,type:e,id:w}});return}const ne=z_(G.target),re=r||Y,{connection:se,isValid:xe}=im.isValid(G.nativeEvent,{handle:{nodeId:_,id:w,type:e},connectionMode:q,fromNodeId:D.nodeId,fromHandleId:D.id||null,fromType:D.type,isValidConnection:re,flowId:P,doc:ne,lib:C,nodeLookup:X});xe&&se&&$(se);const be=structuredClone(J);delete be.inProgress,be.toPosition=be.toHandle?be.toHandle.position:null,K==null||K(G,be),S.setState({connectionClickStartHandle:null})};return y.jsx("div",{"data-handleid":w,"data-nodeid":_,"data-handlepos":t,"data-id":`${T}-${_}-${w}-${e}`,className:Mt(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",k,d,{source:!E,target:E,connectable:l,connectablestart:a,connectableend:o,clickconnecting:L,connectingfrom:M,connectingto:A,valid:B,connectionindicator:l&&(!V||R)&&(V||H?o:a)}]),onMouseDown:ee,onTouchStart:ee,onClick:N?I:void 0,ref:b,...x,children:h})}const zt=U.memo(nS(Yz));function Xz({data:e,isConnectable:t,sourcePosition:r=ve.Bottom}){return y.jsxs(y.Fragment,{children:[e==null?void 0:e.label,y.jsx(zt,{type:"source",position:r,isConnectable:t})]})}function Qz({data:e,isConnectable:t,targetPosition:r=ve.Top,sourcePosition:l=ve.Bottom}){return y.jsxs(y.Fragment,{children:[y.jsx(zt,{type:"target",position:r,isConnectable:t}),e==null?void 0:e.label,y.jsx(zt,{type:"source",position:l,isConnectable:t})]})}function Zz(){return null}function Kz({data:e,isConnectable:t,targetPosition:r=ve.Top}){return y.jsxs(y.Fragment,{children:[y.jsx(zt,{type:"target",position:r,isConnectable:t}),e==null?void 0:e.label]})}const yc={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},ub={input:Xz,default:Qz,output:Kz,group:Zz};function Jz(e){var t,r,l,a;return e.internals.handleBounds===void 0?{width:e.width??e.initialWidth??((t=e.style)==null?void 0:t.width),height:e.height??e.initialHeight??((r=e.style)==null?void 0:r.height)}:{width:e.width??((l=e.style)==null?void 0:l.width),height:e.height??((a=e.style)==null?void 0:a.height)}}const Wz=e=>{const{width:t,height:r,x:l,y:a}=ts(e.nodeLookup,{filter:o=>!!o.selected});return{width:$n(t)?t:null,height:$n(r)?r:null,userSelectionActive:e.userSelectionActive,transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]}) translate(${l}px,${a}px)`}};function eM({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:r}){const l=gt(),{width:a,height:o,transformString:s,userSelectionActive:c}=Ye(Wz,mt),h=lS(),d=U.useRef(null);U.useEffect(()=>{var b;r||(b=d.current)==null||b.focus({preventScroll:!0})},[r]);const m=!c&&a!==null&&o!==null;if(iS({nodeRef:d,disabled:!m}),!m)return null;const p=e?b=>{const w=l.getState().nodes.filter(E=>E.selected);e(b,w)}:void 0,x=b=>{Object.prototype.hasOwnProperty.call(yc,b.key)&&(b.preventDefault(),h({direction:yc[b.key],factor:b.shiftKey?4:1}))};return y.jsx("div",{className:Mt(["react-flow__nodesselection","react-flow__container",t]),style:{transform:s},children:y.jsx("div",{ref:d,className:"react-flow__nodesselection-rect",onContextMenu:p,tabIndex:r?void 0:-1,onKeyDown:r?void 0:x,style:{width:a,height:o}})})}const cb=typeof window<"u"?window:void 0,tM=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function oS({children:e,onPaneClick:t,onPaneMouseEnter:r,onPaneMouseMove:l,onPaneMouseLeave:a,onPaneContextMenu:o,onPaneScroll:s,paneClickDistance:c,deleteKeyCode:h,selectionKeyCode:d,selectionOnDrag:m,selectionMode:p,onSelectionStart:x,onSelectionEnd:b,multiSelectionKeyCode:w,panActivationKeyCode:E,zoomActivationKeyCode:S,elementsSelectable:_,zoomOnScroll:N,zoomOnPinch:k,panOnScroll:T,panOnScrollSpeed:M,panOnScrollMode:A,zoomOnDoubleClick:L,panOnDrag:R,defaultViewport:V,translateExtent:H,minZoom:B,maxZoom:$,preventScrolling:ee,onSelectionContextMenu:I,noWheelClassName:F,noPanClassName:z,disableKeyboardA11y:G,onViewportChange:Q,isControlledViewport:K}){const{nodesSelectionActive:D,userSelectionActive:q}=Ye(tM,mt),Y=Yo(d,{target:cb}),C=Yo(E,{target:cb}),P=C||R,X=C||T,J=m&&P!==!0,ne=Y||q||J;return Oz({deleteKeyCode:h,multiSelectionKeyCode:w}),y.jsx(Bz,{onPaneContextMenu:o,elementsSelectable:_,zoomOnScroll:N,zoomOnPinch:k,panOnScroll:X,panOnScrollSpeed:M,panOnScrollMode:A,zoomOnDoubleClick:L,panOnDrag:!Y&&P,defaultViewport:V,translateExtent:H,minZoom:B,maxZoom:$,zoomActivationKeyCode:S,preventScrolling:ee,noWheelClassName:F,noPanClassName:z,onViewportChange:Q,isControlledViewport:K,paneClickDistance:c,selectionOnDrag:J,children:y.jsxs($z,{onSelectionStart:x,onSelectionEnd:b,onPaneClick:t,onPaneMouseEnter:r,onPaneMouseMove:l,onPaneMouseLeave:a,onPaneContextMenu:o,onPaneScroll:s,panOnDrag:P,isSelecting:!!ne,selectionMode:p,selectionKeyPressed:Y,paneClickDistance:c,selectionOnDrag:J,children:[e,D&&y.jsx(eM,{onSelectionContextMenu:I,noPanClassName:z,disableKeyboardA11y:G})]})})}oS.displayName="FlowRenderer";const nM=U.memo(oS),rM=e=>t=>e?zm(t.nodeLookup,{x:0,y:0,width:t.width,height:t.height},t.transform,!0).map(r=>r.id):Array.from(t.nodeLookup.keys());function iM(e){return Ye(U.useCallback(rM(e),[e]),mt)}const lM=e=>e.updateNodeInternals;function aM(){const e=Ye(lM),[t]=U.useState(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(r=>{const l=new Map;r.forEach(a=>{const o=a.target.getAttribute("data-id");l.set(o,{id:o,nodeElement:a.target,force:!0})}),e(l)}));return U.useEffect(()=>()=>{t==null||t.disconnect()},[t]),t}function oM({node:e,nodeType:t,hasDimensions:r,resizeObserver:l}){const a=gt(),o=U.useRef(null),s=U.useRef(null),c=U.useRef(e.sourcePosition),h=U.useRef(e.targetPosition),d=U.useRef(t),m=r&&!!e.internals.handleBounds;return U.useEffect(()=>{o.current&&!e.hidden&&(!m||s.current!==o.current)&&(s.current&&(l==null||l.unobserve(s.current)),l==null||l.observe(o.current),s.current=o.current)},[m,e.hidden]),U.useEffect(()=>()=>{s.current&&(l==null||l.unobserve(s.current),s.current=null)},[]),U.useEffect(()=>{if(o.current){const p=d.current!==t,x=c.current!==e.sourcePosition,b=h.current!==e.targetPosition;(p||x||b)&&(d.current=t,c.current=e.sourcePosition,h.current=e.targetPosition,a.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:o.current,force:!0}]])))}},[e.id,t,e.sourcePosition,e.targetPosition]),o}function sM({id:e,onClick:t,onMouseEnter:r,onMouseMove:l,onMouseLeave:a,onContextMenu:o,onDoubleClick:s,nodesDraggable:c,elementsSelectable:h,nodesConnectable:d,nodesFocusable:m,resizeObserver:p,noDragClassName:x,noPanClassName:b,disableKeyboardA11y:w,rfId:E,nodeTypes:S,nodeClickDistance:_,onError:N}){const{node:k,internals:T,isParent:M}=Ye(re=>{const se=re.nodeLookup.get(e),xe=re.parentLookup.has(e);return{node:se,internals:se.internals,isParent:xe}},mt);let A=k.type||"default",L=(S==null?void 0:S[A])||ub[A];L===void 0&&(N==null||N("003",lr.error003(A)),A="default",L=(S==null?void 0:S.default)||ub.default);const R=!!(k.draggable||c&&typeof k.draggable>"u"),V=!!(k.selectable||h&&typeof k.selectable>"u"),H=!!(k.connectable||d&&typeof k.connectable>"u"),B=!!(k.focusable||m&&typeof k.focusable>"u"),$=gt(),ee=T_(k),I=oM({node:k,nodeType:A,hasDimensions:ee,resizeObserver:p}),F=iS({nodeRef:I,disabled:k.hidden||!R,noDragClassName:x,handleSelector:k.dragHandle,nodeId:e,isSelectable:V,nodeClickDistance:_}),z=lS();if(k.hidden)return null;const G=Or(k),Q=Jz(k),K=V||R||t||r||l||a,D=r?re=>r(re,{...T.userNode}):void 0,q=l?re=>l(re,{...T.userNode}):void 0,Y=a?re=>a(re,{...T.userNode}):void 0,C=o?re=>o(re,{...T.userNode}):void 0,P=s?re=>s(re,{...T.userNode}):void 0,X=re=>{const{selectNodesOnDrag:se,nodeDragThreshold:xe}=$.getState();V&&(!se||!R||xe>0)&&lm({id:e,store:$,nodeRef:I}),t&&t(re,{...T.userNode})},J=re=>{if(!(M_(re.nativeEvent)||w)){if(b_.includes(re.key)&&V){const se=re.key==="Escape";lm({id:e,store:$,unselect:se,nodeRef:I})}else if(R&&k.selected&&Object.prototype.hasOwnProperty.call(yc,re.key)){re.preventDefault();const{ariaLabelConfig:se}=$.getState();$.setState({ariaLiveMessage:se["node.a11yDescription.ariaLiveMessage"]({direction:re.key.replace("Arrow","").toLowerCase(),x:~~T.positionAbsolute.x,y:~~T.positionAbsolute.y})}),z({direction:yc[re.key],factor:re.shiftKey?4:1})}}},ne=()=>{var Se;if(w||!((Se=I.current)!=null&&Se.matches(":focus-visible")))return;const{transform:re,width:se,height:xe,autoPanOnNodeFocus:be,setCenter:ye}=$.getState();if(!be)return;zm(new Map([[e,k]]),{x:0,y:0,width:se,height:xe},re,!0).length>0||ye(k.position.x+G.width/2,k.position.y+G.height/2,{zoom:re[2]})};return y.jsx("div",{className:Mt(["react-flow__node",`react-flow__node-${A}`,{[b]:R},k.className,{selected:k.selected,selectable:V,parent:M,draggable:R,dragging:F}]),ref:I,style:{zIndex:T.z,transform:`translate(${T.positionAbsolute.x}px,${T.positionAbsolute.y}px)`,pointerEvents:K?"all":"none",visibility:ee?"visible":"hidden",...k.style,...Q},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:D,onMouseMove:q,onMouseLeave:Y,onContextMenu:C,onClick:X,onDoubleClick:P,onKeyDown:B?J:void 0,tabIndex:B?0:void 0,onFocus:B?ne:void 0,role:k.ariaRole??(B?"group":void 0),"aria-roledescription":"node","aria-describedby":w?void 0:`${Z_}-${E}`,"aria-label":k.ariaLabel,...k.domAttributes,children:y.jsx(Pz,{value:e,children:y.jsx(L,{id:e,data:k.data,type:A,positionAbsoluteX:T.positionAbsolute.x,positionAbsoluteY:T.positionAbsolute.y,selected:k.selected??!1,selectable:V,draggable:R,deletable:k.deletable??!0,isConnectable:H,sourcePosition:k.sourcePosition,targetPosition:k.targetPosition,dragging:F,dragHandle:k.dragHandle,zIndex:T.z,parentId:k.parentId,...G})})})}var uM=U.memo(sM);const cM=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function sS(e){const{nodesDraggable:t,nodesConnectable:r,nodesFocusable:l,elementsSelectable:a,onError:o}=Ye(cM,mt),s=iM(e.onlyRenderVisibleElements),c=aM();return y.jsx("div",{className:"react-flow__nodes",style:qc,children:s.map(h=>y.jsx(uM,{id:h,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:c,nodesDraggable:t,nodesConnectable:r,nodesFocusable:l,elementsSelectable:a,nodeClickDistance:e.nodeClickDistance,onError:o},h))})}sS.displayName="NodeRenderer";const fM=U.memo(sS);function dM(e){return Ye(U.useCallback(r=>{if(!e)return r.edges.map(a=>a.id);const l=[];if(r.width&&r.height)for(const a of r.edges){const o=r.nodeLookup.get(a.source),s=r.nodeLookup.get(a.target);o&&s&&uA({sourceNode:o,targetNode:s,width:r.width,height:r.height,transform:r.transform})&&l.push(a.id)}return l},[e]),mt)}const hM=({color:e="none",strokeWidth:t=1})=>{const r={strokeWidth:t,...e&&{stroke:e}};return y.jsx("polyline",{className:"arrow",style:r,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},pM=({color:e="none",strokeWidth:t=1})=>{const r={strokeWidth:t,...e&&{stroke:e,fill:e}};return y.jsx("polyline",{className:"arrowclosed",style:r,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},fb={[mc.Arrow]:hM,[mc.ArrowClosed]:pM};function mM(e){const t=gt();return U.useMemo(()=>{var a,o;return Object.prototype.hasOwnProperty.call(fb,e)?fb[e]:((o=(a=t.getState()).onError)==null||o.call(a,"009",lr.error009(e)),null)},[e])}const gM=({id:e,type:t,color:r,width:l=12.5,height:a=12.5,markerUnits:o="strokeWidth",strokeWidth:s,orient:c="auto-start-reverse"})=>{const h=mM(t);return h?y.jsx("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${l}`,markerHeight:`${a}`,viewBox:"-10 -10 20 20",markerUnits:o,orient:c,refX:"0",refY:"0",children:y.jsx(h,{color:r,strokeWidth:s})}):null},uS=({defaultColor:e,rfId:t})=>{const r=Ye(o=>o.edges),l=Ye(o=>o.defaultEdgeOptions),a=U.useMemo(()=>xA(r,{id:t,defaultColor:e,defaultMarkerStart:l==null?void 0:l.markerStart,defaultMarkerEnd:l==null?void 0:l.markerEnd}),[r,l,t,e]);return a.length?y.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:y.jsx("defs",{children:a.map(o=>y.jsx(gM,{id:o.id,type:o.type,color:o.color,width:o.width,height:o.height,markerUnits:o.markerUnits,strokeWidth:o.strokeWidth,orient:o.orient},o.id))})}):null};uS.displayName="MarkerDefinitions";var xM=U.memo(uS);function cS({x:e,y:t,label:r,labelStyle:l,labelShowBg:a=!0,labelBgStyle:o,labelBgPadding:s=[2,4],labelBgBorderRadius:c=2,children:h,className:d,...m}){const[p,x]=U.useState({x:1,y:0,width:0,height:0}),b=Mt(["react-flow__edge-textwrapper",d]),w=U.useRef(null);return U.useEffect(()=>{if(w.current){const E=w.current.getBBox();x({x:E.x,y:E.y,width:E.width,height:E.height})}},[r]),r?y.jsxs("g",{transform:`translate(${e-p.width/2} ${t-p.height/2})`,className:b,visibility:p.width?"visible":"hidden",...m,children:[a&&y.jsx("rect",{width:p.width+2*s[0],x:-s[0],y:-s[1],height:p.height+2*s[1],className:"react-flow__edge-textbg",style:o,rx:c,ry:c}),y.jsx("text",{className:"react-flow__edge-text",y:p.height/2,dy:"0.3em",ref:w,style:l,children:r}),h]}):null}cS.displayName="EdgeText";const yM=U.memo(cS);function is({path:e,labelX:t,labelY:r,label:l,labelStyle:a,labelShowBg:o,labelBgStyle:s,labelBgPadding:c,labelBgBorderRadius:h,interactionWidth:d=20,...m}){return y.jsxs(y.Fragment,{children:[y.jsx("path",{...m,d:e,fill:"none",className:Mt(["react-flow__edge-path",m.className])}),d?y.jsx("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:d,className:"react-flow__edge-interaction"}):null,l&&$n(t)&&$n(r)?y.jsx(yM,{x:t,y:r,label:l,labelStyle:a,labelShowBg:o,labelBgStyle:s,labelBgPadding:c,labelBgBorderRadius:h}):null]})}function db({pos:e,x1:t,y1:r,x2:l,y2:a}){return e===ve.Left||e===ve.Right?[.5*(t+l),r]:[t,.5*(r+a)]}function fS({sourceX:e,sourceY:t,sourcePosition:r=ve.Bottom,targetX:l,targetY:a,targetPosition:o=ve.Top}){const[s,c]=db({pos:r,x1:e,y1:t,x2:l,y2:a}),[h,d]=db({pos:o,x1:l,y1:a,x2:e,y2:t}),[m,p,x,b]=R_({sourceX:e,sourceY:t,targetX:l,targetY:a,sourceControlX:s,sourceControlY:c,targetControlX:h,targetControlY:d});return[`M${e},${t} C${s},${c} ${h},${d} ${l},${a}`,m,p,x,b]}function dS(e){return U.memo(({id:t,sourceX:r,sourceY:l,targetX:a,targetY:o,sourcePosition:s,targetPosition:c,label:h,labelStyle:d,labelShowBg:m,labelBgStyle:p,labelBgPadding:x,labelBgBorderRadius:b,style:w,markerEnd:E,markerStart:S,interactionWidth:_})=>{const[N,k,T]=fS({sourceX:r,sourceY:l,sourcePosition:s,targetX:a,targetY:o,targetPosition:c}),M=e.isInternal?void 0:t;return y.jsx(is,{id:M,path:N,labelX:k,labelY:T,label:h,labelStyle:d,labelShowBg:m,labelBgStyle:p,labelBgPadding:x,labelBgBorderRadius:b,style:w,markerEnd:E,markerStart:S,interactionWidth:_})})}const vM=dS({isInternal:!1}),hS=dS({isInternal:!0});vM.displayName="SimpleBezierEdge";hS.displayName="SimpleBezierEdgeInternal";function pS(e){return U.memo(({id:t,sourceX:r,sourceY:l,targetX:a,targetY:o,label:s,labelStyle:c,labelShowBg:h,labelBgStyle:d,labelBgPadding:m,labelBgBorderRadius:p,style:x,sourcePosition:b=ve.Bottom,targetPosition:w=ve.Top,markerEnd:E,markerStart:S,pathOptions:_,interactionWidth:N})=>{const[k,T,M]=tm({sourceX:r,sourceY:l,sourcePosition:b,targetX:a,targetY:o,targetPosition:w,borderRadius:_==null?void 0:_.borderRadius,offset:_==null?void 0:_.offset,stepPosition:_==null?void 0:_.stepPosition}),A=e.isInternal?void 0:t;return y.jsx(is,{id:A,path:k,labelX:T,labelY:M,label:s,labelStyle:c,labelShowBg:h,labelBgStyle:d,labelBgPadding:m,labelBgBorderRadius:p,style:x,markerEnd:E,markerStart:S,interactionWidth:N})})}const mS=pS({isInternal:!1}),gS=pS({isInternal:!0});mS.displayName="SmoothStepEdge";gS.displayName="SmoothStepEdgeInternal";function xS(e){return U.memo(({id:t,...r})=>{var a;const l=e.isInternal?void 0:t;return y.jsx(mS,{...r,id:l,pathOptions:U.useMemo(()=>{var o;return{borderRadius:0,offset:(o=r.pathOptions)==null?void 0:o.offset}},[(a=r.pathOptions)==null?void 0:a.offset])})})}const bM=xS({isInternal:!1}),yS=xS({isInternal:!0});bM.displayName="StepEdge";yS.displayName="StepEdgeInternal";function vS(e){return U.memo(({id:t,sourceX:r,sourceY:l,targetX:a,targetY:o,label:s,labelStyle:c,labelShowBg:h,labelBgStyle:d,labelBgPadding:m,labelBgBorderRadius:p,style:x,markerEnd:b,markerStart:w,interactionWidth:E})=>{const[S,_,N]=L_({sourceX:r,sourceY:l,targetX:a,targetY:o}),k=e.isInternal?void 0:t;return y.jsx(is,{id:k,path:S,labelX:_,labelY:N,label:s,labelStyle:c,labelShowBg:h,labelBgStyle:d,labelBgPadding:m,labelBgBorderRadius:p,style:x,markerEnd:b,markerStart:w,interactionWidth:E})})}const wM=vS({isInternal:!1}),bS=vS({isInternal:!0});wM.displayName="StraightEdge";bS.displayName="StraightEdgeInternal";function wS(e){return U.memo(({id:t,sourceX:r,sourceY:l,targetX:a,targetY:o,sourcePosition:s=ve.Bottom,targetPosition:c=ve.Top,label:h,labelStyle:d,labelShowBg:m,labelBgStyle:p,labelBgPadding:x,labelBgBorderRadius:b,style:w,markerEnd:E,markerStart:S,pathOptions:_,interactionWidth:N})=>{const[k,T,M]=Rm({sourceX:r,sourceY:l,sourcePosition:s,targetX:a,targetY:o,targetPosition:c,curvature:_==null?void 0:_.curvature}),A=e.isInternal?void 0:t;return y.jsx(is,{id:A,path:k,labelX:T,labelY:M,label:h,labelStyle:d,labelShowBg:m,labelBgStyle:p,labelBgPadding:x,labelBgBorderRadius:b,style:w,markerEnd:E,markerStart:S,interactionWidth:N})})}const _M=wS({isInternal:!1}),_S=wS({isInternal:!0});_M.displayName="BezierEdge";_S.displayName="BezierEdgeInternal";const hb={default:_S,straight:bS,step:yS,smoothstep:gS,simplebezier:hS},pb={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null},SM=(e,t,r)=>r===ve.Left?e-t:r===ve.Right?e+t:e,kM=(e,t,r)=>r===ve.Top?e-t:r===ve.Bottom?e+t:e,mb="react-flow__edgeupdater";function gb({position:e,centerX:t,centerY:r,radius:l=10,onMouseDown:a,onMouseEnter:o,onMouseOut:s,type:c}){return y.jsx("circle",{onMouseDown:a,onMouseEnter:o,onMouseOut:s,className:Mt([mb,`${mb}-${c}`]),cx:SM(t,l,e),cy:kM(r,l,e),r:l,stroke:"transparent",fill:"transparent"})}function EM({isReconnectable:e,reconnectRadius:t,edge:r,sourceX:l,sourceY:a,targetX:o,targetY:s,sourcePosition:c,targetPosition:h,onReconnect:d,onReconnectStart:m,onReconnectEnd:p,setReconnecting:x,setUpdateHover:b}){const w=gt(),E=(T,M)=>{if(T.button!==0)return;const{autoPanOnConnect:A,domNode:L,connectionMode:R,connectionRadius:V,lib:H,onConnectStart:B,cancelConnection:$,nodeLookup:ee,rfId:I,panBy:F,updateConnection:z}=w.getState(),G=M.type==="target",Q=(q,Y)=>{x(!1),p==null||p(q,r,M.type,Y)},K=q=>d==null?void 0:d(r,q),D=(q,Y)=>{x(!0),m==null||m(T,r,M.type),B==null||B(q,Y)};im.onPointerDown(T.nativeEvent,{autoPanOnConnect:A,connectionMode:R,connectionRadius:V,domNode:L,handleId:M.id,nodeId:M.nodeId,nodeLookup:ee,isTarget:G,edgeUpdaterType:M.type,lib:H,flowId:I,cancelConnection:$,panBy:F,isValidConnection:(...q)=>{var Y,C;return((C=(Y=w.getState()).isValidConnection)==null?void 0:C.call(Y,...q))??!0},onConnect:K,onConnectStart:D,onConnectEnd:(...q)=>{var Y,C;return(C=(Y=w.getState()).onConnectEnd)==null?void 0:C.call(Y,...q)},onReconnectEnd:Q,updateConnection:z,getTransform:()=>w.getState().transform,getFromHandle:()=>w.getState().connection.fromHandle,dragThreshold:w.getState().connectionDragThreshold,handleDomNode:T.currentTarget})},S=T=>E(T,{nodeId:r.target,id:r.targetHandle??null,type:"target"}),_=T=>E(T,{nodeId:r.source,id:r.sourceHandle??null,type:"source"}),N=()=>b(!0),k=()=>b(!1);return y.jsxs(y.Fragment,{children:[(e===!0||e==="source")&&y.jsx(gb,{position:c,centerX:l,centerY:a,radius:t,onMouseDown:S,onMouseEnter:N,onMouseOut:k,type:"source"}),(e===!0||e==="target")&&y.jsx(gb,{position:h,centerX:o,centerY:s,radius:t,onMouseDown:_,onMouseEnter:N,onMouseOut:k,type:"target"})]})}function NM({id:e,edgesFocusable:t,edgesReconnectable:r,elementsSelectable:l,onClick:a,onDoubleClick:o,onContextMenu:s,onMouseEnter:c,onMouseMove:h,onMouseLeave:d,reconnectRadius:m,onReconnect:p,onReconnectStart:x,onReconnectEnd:b,rfId:w,edgeTypes:E,noPanClassName:S,onError:_,disableKeyboardA11y:N}){let k=Ye(ye=>ye.edgeLookup.get(e));const T=Ye(ye=>ye.defaultEdgeOptions);k=T?{...T,...k}:k;let M=k.type||"default",A=(E==null?void 0:E[M])||hb[M];A===void 0&&(_==null||_("011",lr.error011(M)),M="default",A=(E==null?void 0:E.default)||hb.default);const L=!!(k.focusable||t&&typeof k.focusable>"u"),R=typeof p<"u"&&(k.reconnectable||r&&typeof k.reconnectable>"u"),V=!!(k.selectable||l&&typeof k.selectable>"u"),H=U.useRef(null),[B,$]=U.useState(!1),[ee,I]=U.useState(!1),F=gt(),{zIndex:z,sourceX:G,sourceY:Q,targetX:K,targetY:D,sourcePosition:q,targetPosition:Y}=Ye(U.useCallback(ye=>{const pe=ye.nodeLookup.get(k.source),Se=ye.nodeLookup.get(k.target);if(!pe||!Se)return{zIndex:k.zIndex,...pb};const De=gA({id:e,sourceNode:pe,targetNode:Se,sourceHandle:k.sourceHandle||null,targetHandle:k.targetHandle||null,connectionMode:ye.connectionMode,onError:_});return{zIndex:sA({selected:k.selected,zIndex:k.zIndex,sourceNode:pe,targetNode:Se,elevateOnSelect:ye.elevateEdgesOnSelect,zIndexMode:ye.zIndexMode}),...De||pb}},[k.source,k.target,k.sourceHandle,k.targetHandle,k.selected,k.zIndex]),mt),C=U.useMemo(()=>k.markerStart?`url('#${nm(k.markerStart,w)}')`:void 0,[k.markerStart,w]),P=U.useMemo(()=>k.markerEnd?`url('#${nm(k.markerEnd,w)}')`:void 0,[k.markerEnd,w]);if(k.hidden||G===null||Q===null||K===null||D===null)return null;const X=ye=>{var je;const{addSelectedEdges:pe,unselectNodesAndEdges:Se,multiSelectionActive:De}=F.getState();V&&(F.setState({nodesSelectionActive:!1}),k.selected&&De?(Se({nodes:[],edges:[k]}),(je=H.current)==null||je.blur()):pe([e])),a&&a(ye,k)},J=o?ye=>{o(ye,{...k})}:void 0,ne=s?ye=>{s(ye,{...k})}:void 0,re=c?ye=>{c(ye,{...k})}:void 0,se=h?ye=>{h(ye,{...k})}:void 0,xe=d?ye=>{d(ye,{...k})}:void 0,be=ye=>{var pe;if(!N&&b_.includes(ye.key)&&V){const{unselectNodesAndEdges:Se,addSelectedEdges:De}=F.getState();ye.key==="Escape"?((pe=H.current)==null||pe.blur(),Se({edges:[k]})):De([e])}};return y.jsx("svg",{style:{zIndex:z},children:y.jsxs("g",{className:Mt(["react-flow__edge",`react-flow__edge-${M}`,k.className,S,{selected:k.selected,animated:k.animated,inactive:!V&&!a,updating:B,selectable:V}]),onClick:X,onDoubleClick:J,onContextMenu:ne,onMouseEnter:re,onMouseMove:se,onMouseLeave:xe,onKeyDown:L?be:void 0,tabIndex:L?0:void 0,role:k.ariaRole??(L?"group":"img"),"aria-roledescription":"edge","data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":k.ariaLabel===null?void 0:k.ariaLabel||`Edge from ${k.source} to ${k.target}`,"aria-describedby":L?`${K_}-${w}`:void 0,ref:H,...k.domAttributes,children:[!ee&&y.jsx(A,{id:e,source:k.source,target:k.target,type:k.type,selected:k.selected,animated:k.animated,selectable:V,deletable:k.deletable??!0,label:k.label,labelStyle:k.labelStyle,labelShowBg:k.labelShowBg,labelBgStyle:k.labelBgStyle,labelBgPadding:k.labelBgPadding,labelBgBorderRadius:k.labelBgBorderRadius,sourceX:G,sourceY:Q,targetX:K,targetY:D,sourcePosition:q,targetPosition:Y,data:k.data,style:k.style,sourceHandleId:k.sourceHandle,targetHandleId:k.targetHandle,markerStart:C,markerEnd:P,pathOptions:"pathOptions"in k?k.pathOptions:void 0,interactionWidth:k.interactionWidth}),R&&y.jsx(EM,{edge:k,isReconnectable:R,reconnectRadius:m,onReconnect:p,onReconnectStart:x,onReconnectEnd:b,sourceX:G,sourceY:Q,targetX:K,targetY:D,sourcePosition:q,targetPosition:Y,setUpdateHover:$,setReconnecting:I})]})})}var CM=U.memo(NM);const jM=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function SS({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:r,edgeTypes:l,noPanClassName:a,onReconnect:o,onEdgeContextMenu:s,onEdgeMouseEnter:c,onEdgeMouseMove:h,onEdgeMouseLeave:d,onEdgeClick:m,reconnectRadius:p,onEdgeDoubleClick:x,onReconnectStart:b,onReconnectEnd:w,disableKeyboardA11y:E}){const{edgesFocusable:S,edgesReconnectable:_,elementsSelectable:N,onError:k}=Ye(jM,mt),T=dM(t);return y.jsxs("div",{className:"react-flow__edges",children:[y.jsx(xM,{defaultColor:e,rfId:r}),T.map(M=>y.jsx(CM,{id:M,edgesFocusable:S,edgesReconnectable:_,elementsSelectable:N,noPanClassName:a,onReconnect:o,onContextMenu:s,onMouseEnter:c,onMouseMove:h,onMouseLeave:d,onClick:m,reconnectRadius:p,onDoubleClick:x,onReconnectStart:b,onReconnectEnd:w,rfId:r,onError:k,edgeTypes:l,disableKeyboardA11y:E},M))]})}SS.displayName="EdgeRenderer";const TM=U.memo(SS),AM=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function zM({children:e}){const t=Ye(AM);return y.jsx("div",{className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:t},children:e})}function MM(e){const t=ul(),r=U.useRef(!1);U.useEffect(()=>{!r.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),r.current=!0)},[e,t.viewportInitialized])}const DM=e=>{var t;return(t=e.panZoom)==null?void 0:t.syncViewport};function RM(e){const t=Ye(DM),r=gt();return U.useEffect(()=>{e&&(t==null||t(e),r.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function OM(e){return e.connection.inProgress?{...e.connection,to:rs(e.connection.to,e.transform)}:{...e.connection}}function LM(e){return OM}function HM(e){const t=LM();return Ye(t,mt)}const BM=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function IM({containerStyle:e,style:t,type:r,component:l}){const{nodesConnectable:a,width:o,height:s,isValid:c,inProgress:h}=Ye(BM,mt);return!(o&&a&&h)?null:y.jsx("svg",{style:e,width:o,height:s,className:"react-flow__connectionline react-flow__container",children:y.jsx("g",{className:Mt(["react-flow__connection",S_(c)]),children:y.jsx(kS,{style:t,type:r,CustomComponent:l,isValid:c})})})}const kS=({style:e,type:t=vi.Bezier,CustomComponent:r,isValid:l})=>{const{inProgress:a,from:o,fromNode:s,fromHandle:c,fromPosition:h,to:d,toNode:m,toHandle:p,toPosition:x,pointer:b}=HM();if(!a)return;if(r)return y.jsx(r,{connectionLineType:t,connectionLineStyle:e,fromNode:s,fromHandle:c,fromX:o.x,fromY:o.y,toX:d.x,toY:d.y,fromPosition:h,toPosition:x,connectionStatus:S_(l),toNode:m,toHandle:p,pointer:b});let w="";const E={sourceX:o.x,sourceY:o.y,sourcePosition:h,targetX:d.x,targetY:d.y,targetPosition:x};switch(t){case vi.Bezier:[w]=Rm(E);break;case vi.SimpleBezier:[w]=fS(E);break;case vi.Step:[w]=tm({...E,borderRadius:0});break;case vi.SmoothStep:[w]=tm(E);break;default:[w]=L_(E)}return y.jsx("path",{d:w,fill:"none",className:"react-flow__connection-path",style:e})};kS.displayName="ConnectionLine";const qM={};function xb(e=qM){U.useRef(e),gt(),U.useEffect(()=>{},[e])}function UM(){gt(),U.useRef(!1),U.useEffect(()=>{},[])}function ES({nodeTypes:e,edgeTypes:t,onInit:r,onNodeClick:l,onEdgeClick:a,onNodeDoubleClick:o,onEdgeDoubleClick:s,onNodeMouseEnter:c,onNodeMouseMove:h,onNodeMouseLeave:d,onNodeContextMenu:m,onSelectionContextMenu:p,onSelectionStart:x,onSelectionEnd:b,connectionLineType:w,connectionLineStyle:E,connectionLineComponent:S,connectionLineContainerStyle:_,selectionKeyCode:N,selectionOnDrag:k,selectionMode:T,multiSelectionKeyCode:M,panActivationKeyCode:A,zoomActivationKeyCode:L,deleteKeyCode:R,onlyRenderVisibleElements:V,elementsSelectable:H,defaultViewport:B,translateExtent:$,minZoom:ee,maxZoom:I,preventScrolling:F,defaultMarkerColor:z,zoomOnScroll:G,zoomOnPinch:Q,panOnScroll:K,panOnScrollSpeed:D,panOnScrollMode:q,zoomOnDoubleClick:Y,panOnDrag:C,onPaneClick:P,onPaneMouseEnter:X,onPaneMouseMove:J,onPaneMouseLeave:ne,onPaneScroll:re,onPaneContextMenu:se,paneClickDistance:xe,nodeClickDistance:be,onEdgeContextMenu:ye,onEdgeMouseEnter:pe,onEdgeMouseMove:Se,onEdgeMouseLeave:De,reconnectRadius:je,onReconnect:ct,onReconnectStart:nt,onReconnectEnd:Dt,noDragClassName:Pt,noWheelClassName:Bt,noPanClassName:kn,disableKeyboardA11y:Rn,nodeExtent:Rt,rfId:Br,viewport:ce,onViewportChange:ge}){return xb(e),xb(t),UM(),MM(r),RM(ce),y.jsx(nM,{onPaneClick:P,onPaneMouseEnter:X,onPaneMouseMove:J,onPaneMouseLeave:ne,onPaneContextMenu:se,onPaneScroll:re,paneClickDistance:xe,deleteKeyCode:R,selectionKeyCode:N,selectionOnDrag:k,selectionMode:T,onSelectionStart:x,onSelectionEnd:b,multiSelectionKeyCode:M,panActivationKeyCode:A,zoomActivationKeyCode:L,elementsSelectable:H,zoomOnScroll:G,zoomOnPinch:Q,zoomOnDoubleClick:Y,panOnScroll:K,panOnScrollSpeed:D,panOnScrollMode:q,panOnDrag:C,defaultViewport:B,translateExtent:$,minZoom:ee,maxZoom:I,onSelectionContextMenu:p,preventScrolling:F,noDragClassName:Pt,noWheelClassName:Bt,noPanClassName:kn,disableKeyboardA11y:Rn,onViewportChange:ge,isControlledViewport:!!ce,children:y.jsxs(zM,{children:[y.jsx(TM,{edgeTypes:t,onEdgeClick:a,onEdgeDoubleClick:s,onReconnect:ct,onReconnectStart:nt,onReconnectEnd:Dt,onlyRenderVisibleElements:V,onEdgeContextMenu:ye,onEdgeMouseEnter:pe,onEdgeMouseMove:Se,onEdgeMouseLeave:De,reconnectRadius:je,defaultMarkerColor:z,noPanClassName:kn,disableKeyboardA11y:Rn,rfId:Br}),y.jsx(IM,{style:E,type:w,component:S,containerStyle:_}),y.jsx("div",{className:"react-flow__edgelabel-renderer"}),y.jsx(fM,{nodeTypes:e,onNodeClick:l,onNodeDoubleClick:o,onNodeMouseEnter:c,onNodeMouseMove:h,onNodeMouseLeave:d,onNodeContextMenu:m,nodeClickDistance:be,onlyRenderVisibleElements:V,noPanClassName:kn,noDragClassName:Pt,disableKeyboardA11y:Rn,nodeExtent:Rt,rfId:Br}),y.jsx("div",{className:"react-flow__viewport-portal"})]})})}ES.displayName="GraphView";const $M=U.memo(ES),yb=({nodes:e,edges:t,defaultNodes:r,defaultEdges:l,width:a,height:o,fitView:s,fitViewOptions:c,minZoom:h=.5,maxZoom:d=2,nodeOrigin:m,nodeExtent:p,zIndexMode:x="basic"}={})=>{const b=new Map,w=new Map,E=new Map,S=new Map,_=l??t??[],N=r??e??[],k=m??[0,0],T=p??Vo;I_(E,S,_);const M=rm(N,b,w,{nodeOrigin:k,nodeExtent:T,zIndexMode:x});let A=[0,0,1];if(s&&a&&o){const L=ts(b,{filter:B=>!!((B.width||B.initialWidth)&&(B.height||B.initialHeight))}),{x:R,y:V,zoom:H}=Mm(L,a,o,h,d,(c==null?void 0:c.padding)??.1);A=[R,V,H]}return{rfId:"1",width:a??0,height:o??0,transform:A,nodes:N,nodesInitialized:M,nodeLookup:b,parentLookup:w,edges:_,edgeLookup:S,connectionLookup:E,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:r!==void 0,hasDefaultEdges:l!==void 0,panZoom:null,minZoom:h,maxZoom:d,translateExtent:Vo,nodeExtent:T,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:pa.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:k,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:s??!1,fitViewOptions:c,fitViewResolver:null,connection:{...__},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:nA,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:w_,zIndexMode:x,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},VM=({nodes:e,edges:t,defaultNodes:r,defaultEdges:l,width:a,height:o,fitView:s,fitViewOptions:c,minZoom:h,maxZoom:d,nodeOrigin:m,nodeExtent:p,zIndexMode:x})=>az((b,w)=>{async function E(){const{nodeLookup:S,panZoom:_,fitViewOptions:N,fitViewResolver:k,width:T,height:M,minZoom:A,maxZoom:L}=w();_&&(await eA({nodes:S,width:T,height:M,panZoom:_,minZoom:A,maxZoom:L},N),k==null||k.resolve(!0),b({fitViewResolver:null}))}return{...yb({nodes:e,edges:t,width:a,height:o,fitView:s,fitViewOptions:c,minZoom:h,maxZoom:d,nodeOrigin:m,nodeExtent:p,defaultNodes:r,defaultEdges:l,zIndexMode:x}),setNodes:S=>{const{nodeLookup:_,parentLookup:N,nodeOrigin:k,elevateNodesOnSelect:T,fitViewQueued:M,zIndexMode:A}=w(),L=rm(S,_,N,{nodeOrigin:k,nodeExtent:p,elevateNodesOnSelect:T,checkEquality:!0,zIndexMode:A});M&&L?(E(),b({nodes:S,nodesInitialized:L,fitViewQueued:!1,fitViewOptions:void 0})):b({nodes:S,nodesInitialized:L})},setEdges:S=>{const{connectionLookup:_,edgeLookup:N}=w();I_(_,N,S),b({edges:S})},setDefaultNodesAndEdges:(S,_)=>{if(S){const{setNodes:N}=w();N(S),b({hasDefaultNodes:!0})}if(_){const{setEdges:N}=w();N(_),b({hasDefaultEdges:!0})}},updateNodeInternals:S=>{const{triggerNodeChanges:_,nodeLookup:N,parentLookup:k,domNode:T,nodeOrigin:M,nodeExtent:A,debug:L,fitViewQueued:R,zIndexMode:V}=w(),{changes:H,updatedInternals:B}=kA(S,N,k,T,M,A,V);B&&(bA(N,k,{nodeOrigin:M,nodeExtent:A,zIndexMode:V}),R?(E(),b({fitViewQueued:!1,fitViewOptions:void 0})):b({}),(H==null?void 0:H.length)>0&&(L&&console.log("React Flow: trigger node changes",H),_==null||_(H)))},updateNodePositions:(S,_=!1)=>{const N=[];let k=[];const{nodeLookup:T,triggerNodeChanges:M,connection:A,updateConnection:L,onNodesChangeMiddlewareMap:R}=w();for(const[V,H]of S){const B=T.get(V),$=!!(B!=null&&B.expandParent&&(B!=null&&B.parentId)&&(H!=null&&H.position)),ee={id:V,type:"position",position:$?{x:Math.max(0,H.position.x),y:Math.max(0,H.position.y)}:H.position,dragging:_};if(B&&A.inProgress&&A.fromNode.id===B.id){const I=il(B,A.fromHandle,ve.Left,!0);L({...A,from:I})}$&&B.parentId&&N.push({id:V,parentId:B.parentId,rect:{...H.internals.positionAbsolute,width:H.measured.width??0,height:H.measured.height??0}}),k.push(ee)}if(N.length>0){const{parentLookup:V,nodeOrigin:H}=w(),B=Im(N,T,V,H);k.push(...B)}for(const V of R.values())k=V(k);M(k)},triggerNodeChanges:S=>{const{onNodesChange:_,setNodes:N,nodes:k,hasDefaultNodes:T,debug:M}=w();if(S!=null&&S.length){if(T){const A=eS(S,k);N(A)}M&&console.log("React Flow: trigger node changes",S),_==null||_(S)}},triggerEdgeChanges:S=>{const{onEdgesChange:_,setEdges:N,edges:k,hasDefaultEdges:T,debug:M}=w();if(S!=null&&S.length){if(T){const A=tS(S,k);N(A)}M&&console.log("React Flow: trigger edge changes",S),_==null||_(S)}},addSelectedNodes:S=>{const{multiSelectionActive:_,edgeLookup:N,nodeLookup:k,triggerNodeChanges:T,triggerEdgeChanges:M}=w();if(_){const A=S.map(L=>Yi(L,!0));T(A);return}T(la(k,new Set([...S]),!0)),M(la(N))},addSelectedEdges:S=>{const{multiSelectionActive:_,edgeLookup:N,nodeLookup:k,triggerNodeChanges:T,triggerEdgeChanges:M}=w();if(_){const A=S.map(L=>Yi(L,!0));M(A);return}M(la(N,new Set([...S]))),T(la(k,new Set,!0))},unselectNodesAndEdges:({nodes:S,edges:_}={})=>{const{edges:N,nodes:k,nodeLookup:T,triggerNodeChanges:M,triggerEdgeChanges:A}=w(),L=S||k,R=_||N,V=[];for(const B of L){if(!B.selected)continue;const $=T.get(B.id);$&&($.selected=!1),V.push(Yi(B.id,!1))}const H=[];for(const B of R)B.selected&&H.push(Yi(B.id,!1));M(V),A(H)},setMinZoom:S=>{const{panZoom:_,maxZoom:N}=w();_==null||_.setScaleExtent([S,N]),b({minZoom:S})},setMaxZoom:S=>{const{panZoom:_,minZoom:N}=w();_==null||_.setScaleExtent([N,S]),b({maxZoom:S})},setTranslateExtent:S=>{var _;(_=w().panZoom)==null||_.setTranslateExtent(S),b({translateExtent:S})},resetSelectedElements:()=>{const{edges:S,nodes:_,triggerNodeChanges:N,triggerEdgeChanges:k,elementsSelectable:T}=w();if(!T)return;const M=_.reduce((L,R)=>R.selected?[...L,Yi(R.id,!1)]:L,[]),A=S.reduce((L,R)=>R.selected?[...L,Yi(R.id,!1)]:L,[]);N(M),k(A)},setNodeExtent:S=>{const{nodes:_,nodeLookup:N,parentLookup:k,nodeOrigin:T,elevateNodesOnSelect:M,nodeExtent:A,zIndexMode:L}=w();S[0][0]===A[0][0]&&S[0][1]===A[0][1]&&S[1][0]===A[1][0]&&S[1][1]===A[1][1]||(rm(_,N,k,{nodeOrigin:T,nodeExtent:S,elevateNodesOnSelect:M,checkEquality:!1,zIndexMode:L}),b({nodeExtent:S}))},panBy:S=>{const{transform:_,width:N,height:k,panZoom:T,translateExtent:M}=w();return EA({delta:S,panZoom:T,transform:_,translateExtent:M,width:N,height:k})},setCenter:async(S,_,N)=>{const{width:k,height:T,maxZoom:M,panZoom:A}=w();if(!A)return Promise.resolve(!1);const L=typeof(N==null?void 0:N.zoom)<"u"?N.zoom:M;return await A.setViewport({x:k/2-S*L,y:T/2-_*L,zoom:L},{duration:N==null?void 0:N.duration,ease:N==null?void 0:N.ease,interpolate:N==null?void 0:N.interpolate}),Promise.resolve(!0)},cancelConnection:()=>{b({connection:{...__}})},updateConnection:S=>{b({connection:S})},reset:()=>b({...yb()})}},Object.is);function PM({initialNodes:e,initialEdges:t,defaultNodes:r,defaultEdges:l,initialWidth:a,initialHeight:o,initialMinZoom:s,initialMaxZoom:c,initialFitViewOptions:h,fitView:d,nodeOrigin:m,nodeExtent:p,zIndexMode:x,children:b}){const[w]=U.useState(()=>VM({nodes:e,edges:t,defaultNodes:r,defaultEdges:l,width:a,height:o,fitView:d,minZoom:s,maxZoom:c,fitViewOptions:h,nodeOrigin:m,nodeExtent:p,zIndexMode:x}));return y.jsx(sz,{value:w,children:y.jsx(zz,{children:b})})}function GM({children:e,nodes:t,edges:r,defaultNodes:l,defaultEdges:a,width:o,height:s,fitView:c,fitViewOptions:h,minZoom:d,maxZoom:m,nodeOrigin:p,nodeExtent:x,zIndexMode:b}){return U.useContext(Bc)?y.jsx(y.Fragment,{children:e}):y.jsx(PM,{initialNodes:t,initialEdges:r,defaultNodes:l,defaultEdges:a,initialWidth:o,initialHeight:s,fitView:c,initialFitViewOptions:h,initialMinZoom:d,initialMaxZoom:m,nodeOrigin:p,nodeExtent:x,zIndexMode:b,children:e})}const FM={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function YM({nodes:e,edges:t,defaultNodes:r,defaultEdges:l,className:a,nodeTypes:o,edgeTypes:s,onNodeClick:c,onEdgeClick:h,onInit:d,onMove:m,onMoveStart:p,onMoveEnd:x,onConnect:b,onConnectStart:w,onConnectEnd:E,onClickConnectStart:S,onClickConnectEnd:_,onNodeMouseEnter:N,onNodeMouseMove:k,onNodeMouseLeave:T,onNodeContextMenu:M,onNodeDoubleClick:A,onNodeDragStart:L,onNodeDrag:R,onNodeDragStop:V,onNodesDelete:H,onEdgesDelete:B,onDelete:$,onSelectionChange:ee,onSelectionDragStart:I,onSelectionDrag:F,onSelectionDragStop:z,onSelectionContextMenu:G,onSelectionStart:Q,onSelectionEnd:K,onBeforeDelete:D,connectionMode:q,connectionLineType:Y=vi.Bezier,connectionLineStyle:C,connectionLineComponent:P,connectionLineContainerStyle:X,deleteKeyCode:J="Backspace",selectionKeyCode:ne="Shift",selectionOnDrag:re=!1,selectionMode:se=Po.Full,panActivationKeyCode:xe="Space",multiSelectionKeyCode:be=Fo()?"Meta":"Control",zoomActivationKeyCode:ye=Fo()?"Meta":"Control",snapToGrid:pe,snapGrid:Se,onlyRenderVisibleElements:De=!1,selectNodesOnDrag:je,nodesDraggable:ct,autoPanOnNodeFocus:nt,nodesConnectable:Dt,nodesFocusable:Pt,nodeOrigin:Bt=J_,edgesFocusable:kn,edgesReconnectable:Rn,elementsSelectable:Rt=!0,defaultViewport:Br=wz,minZoom:ce=.5,maxZoom:ge=2,translateExtent:Ne=Vo,preventScrolling:Be=!0,nodeExtent:Xe,defaultMarkerColor:Zt="#b1b1b7",zoomOnScroll:On=!0,zoomOnPinch:It=!0,panOnScroll:bt=!1,panOnScrollSpeed:Gt=.5,panOnScrollMode:We=Wi.Free,zoomOnDoubleClick:Qn=!0,panOnDrag:fn=!0,onPaneClick:Xc,onPaneMouseEnter:fl,onPaneMouseMove:dl,onPaneMouseLeave:hl,onPaneScroll:sr,onPaneContextMenu:pl,paneClickDistance:Si=1,nodeClickDistance:Qc=0,children:cs,onReconnect:_a,onReconnectStart:ki,onReconnectEnd:Zc,onEdgeContextMenu:fs,onEdgeDoubleClick:ds,onEdgeMouseEnter:hs,onEdgeMouseMove:Sa,onEdgeMouseLeave:ka,reconnectRadius:ps=10,onNodesChange:ms,onEdgesChange:Zn,noDragClassName:Ot="nodrag",noWheelClassName:Ft="nowheel",noPanClassName:ur="nopan",fitView:ml,fitViewOptions:gs,connectOnClick:Kc,attributionPosition:xs,proOptions:Ei,defaultEdgeOptions:Ea,elevateNodesOnSelect:Ir=!0,elevateEdgesOnSelect:qr=!1,disableKeyboardA11y:Ur=!1,autoPanOnConnect:$r,autoPanOnNodeDrag:St,autoPanSpeed:ys,connectionRadius:vs,isValidConnection:cr,onError:Vr,style:Jc,id:Na,nodeDragThreshold:bs,connectionDragThreshold:Wc,viewport:gl,onViewportChange:xl,width:Ln,height:Wt,colorMode:ws="light",debug:ef,onScroll:Pr,ariaLabelConfig:_s,zIndexMode:Ni="basic",...tf},en){const Ci=Na||"1",Ss=Ez(ws),Ca=U.useCallback(fr=>{fr.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),Pr==null||Pr(fr)},[Pr]);return y.jsx("div",{"data-testid":"rf__wrapper",...tf,onScroll:Ca,style:{...Jc,...FM},ref:en,className:Mt(["react-flow",a,Ss]),id:Na,role:"application",children:y.jsxs(GM,{nodes:e,edges:t,width:Ln,height:Wt,fitView:ml,fitViewOptions:gs,minZoom:ce,maxZoom:ge,nodeOrigin:Bt,nodeExtent:Xe,zIndexMode:Ni,children:[y.jsx($M,{onInit:d,onNodeClick:c,onEdgeClick:h,onNodeMouseEnter:N,onNodeMouseMove:k,onNodeMouseLeave:T,onNodeContextMenu:M,onNodeDoubleClick:A,nodeTypes:o,edgeTypes:s,connectionLineType:Y,connectionLineStyle:C,connectionLineComponent:P,connectionLineContainerStyle:X,selectionKeyCode:ne,selectionOnDrag:re,selectionMode:se,deleteKeyCode:J,multiSelectionKeyCode:be,panActivationKeyCode:xe,zoomActivationKeyCode:ye,onlyRenderVisibleElements:De,defaultViewport:Br,translateExtent:Ne,minZoom:ce,maxZoom:ge,preventScrolling:Be,zoomOnScroll:On,zoomOnPinch:It,zoomOnDoubleClick:Qn,panOnScroll:bt,panOnScrollSpeed:Gt,panOnScrollMode:We,panOnDrag:fn,onPaneClick:Xc,onPaneMouseEnter:fl,onPaneMouseMove:dl,onPaneMouseLeave:hl,onPaneScroll:sr,onPaneContextMenu:pl,paneClickDistance:Si,nodeClickDistance:Qc,onSelectionContextMenu:G,onSelectionStart:Q,onSelectionEnd:K,onReconnect:_a,onReconnectStart:ki,onReconnectEnd:Zc,onEdgeContextMenu:fs,onEdgeDoubleClick:ds,onEdgeMouseEnter:hs,onEdgeMouseMove:Sa,onEdgeMouseLeave:ka,reconnectRadius:ps,defaultMarkerColor:Zt,noDragClassName:Ot,noWheelClassName:Ft,noPanClassName:ur,rfId:Ci,disableKeyboardA11y:Ur,nodeExtent:Xe,viewport:gl,onViewportChange:xl}),y.jsx(kz,{nodes:e,edges:t,defaultNodes:r,defaultEdges:l,onConnect:b,onConnectStart:w,onConnectEnd:E,onClickConnectStart:S,onClickConnectEnd:_,nodesDraggable:ct,autoPanOnNodeFocus:nt,nodesConnectable:Dt,nodesFocusable:Pt,edgesFocusable:kn,edgesReconnectable:Rn,elementsSelectable:Rt,elevateNodesOnSelect:Ir,elevateEdgesOnSelect:qr,minZoom:ce,maxZoom:ge,nodeExtent:Xe,onNodesChange:ms,onEdgesChange:Zn,snapToGrid:pe,snapGrid:Se,connectionMode:q,translateExtent:Ne,connectOnClick:Kc,defaultEdgeOptions:Ea,fitView:ml,fitViewOptions:gs,onNodesDelete:H,onEdgesDelete:B,onDelete:$,onNodeDragStart:L,onNodeDrag:R,onNodeDragStop:V,onSelectionDrag:F,onSelectionDragStart:I,onSelectionDragStop:z,onMove:m,onMoveStart:p,onMoveEnd:x,noPanClassName:ur,nodeOrigin:Bt,rfId:Ci,autoPanOnConnect:$r,autoPanOnNodeDrag:St,autoPanSpeed:ys,onError:Vr,connectionRadius:vs,isValidConnection:cr,selectNodesOnDrag:je,nodeDragThreshold:bs,connectionDragThreshold:Wc,onBeforeDelete:D,debug:ef,ariaLabelConfig:_s,zIndexMode:Ni}),y.jsx(bz,{onSelectionChange:ee}),cs,y.jsx(mz,{proOptions:Ei,position:xs}),y.jsx(pz,{rfId:Ci,disableKeyboardA11y:Ur})]})})}var XM=nS(YM);const QM=e=>{var t;return(t=e.domNode)==null?void 0:t.querySelector(".react-flow__edgelabel-renderer")};function ZM({children:e}){const t=Ye(QM);return t?oz.createPortal(e,t):null}function KM(e){const[t,r]=U.useState(e),l=U.useCallback(a=>r(o=>eS(a,o)),[]);return[t,r,l]}function JM(e){const[t,r]=U.useState(e),l=U.useCallback(a=>r(o=>tS(a,o)),[]);return[t,r,l]}function WM({dimensions:e,lineWidth:t,variant:r,className:l}){return y.jsx("path",{strokeWidth:t,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:Mt(["react-flow__background-pattern",r,l])})}function e5({radius:e,className:t}){return y.jsx("circle",{cx:e,cy:e,r:e,className:Mt(["react-flow__background-pattern","dots",t])})}var Mr;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(Mr||(Mr={}));const t5={[Mr.Dots]:1,[Mr.Lines]:1,[Mr.Cross]:6},n5=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function NS({id:e,variant:t=Mr.Dots,gap:r=20,size:l,lineWidth:a=1,offset:o=0,color:s,bgColor:c,style:h,className:d,patternClassName:m}){const p=U.useRef(null),{transform:x,patternId:b}=Ye(n5,mt),w=l||t5[t],E=t===Mr.Dots,S=t===Mr.Cross,_=Array.isArray(r)?r:[r,r],N=[_[0]*x[2]||1,_[1]*x[2]||1],k=w*x[2],T=Array.isArray(o)?o:[o,o],M=S?[k,k]:N,A=[T[0]*x[2]||1+M[0]/2,T[1]*x[2]||1+M[1]/2],L=`${b}${e||""}`;return y.jsxs("svg",{className:Mt(["react-flow__background",d]),style:{...h,...qc,"--xy-background-color-props":c,"--xy-background-pattern-color-props":s},ref:p,"data-testid":"rf__background",children:[y.jsx("pattern",{id:L,x:x[0]%N[0],y:x[1]%N[1],width:N[0],height:N[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${A[0]},-${A[1]})`,children:E?y.jsx(e5,{radius:k/2,className:m}):y.jsx(WM,{dimensions:M,lineWidth:a,variant:t,className:m})}),y.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${L})`})]})}NS.displayName="Background";const r5=U.memo(NS);function i5(){return y.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:y.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function l5(){return y.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:y.jsx("path",{d:"M0 0h32v4.2H0z"})})}function a5(){return y.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:y.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 o5(){return y.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:y.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 s5(){return y.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:y.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 Fu({children:e,className:t,...r}){return y.jsx("button",{type:"button",className:Mt(["react-flow__controls-button",t]),...r,children:e})}const u5=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function CS({style:e,showZoom:t=!0,showFitView:r=!0,showInteractive:l=!0,fitViewOptions:a,onZoomIn:o,onZoomOut:s,onFitView:c,onInteractiveChange:h,className:d,children:m,position:p="bottom-left",orientation:x="vertical","aria-label":b}){const w=gt(),{isInteractive:E,minZoomReached:S,maxZoomReached:_,ariaLabelConfig:N}=Ye(u5,mt),{zoomIn:k,zoomOut:T,fitView:M}=ul(),A=()=>{k(),o==null||o()},L=()=>{T(),s==null||s()},R=()=>{M(a),c==null||c()},V=()=>{w.setState({nodesDraggable:!E,nodesConnectable:!E,elementsSelectable:!E}),h==null||h(!E)},H=x==="horizontal"?"horizontal":"vertical";return y.jsxs(Ic,{className:Mt(["react-flow__controls",H,d]),position:p,style:e,"data-testid":"rf__controls","aria-label":b??N["controls.ariaLabel"],children:[t&&y.jsxs(y.Fragment,{children:[y.jsx(Fu,{onClick:A,className:"react-flow__controls-zoomin",title:N["controls.zoomIn.ariaLabel"],"aria-label":N["controls.zoomIn.ariaLabel"],disabled:_,children:y.jsx(i5,{})}),y.jsx(Fu,{onClick:L,className:"react-flow__controls-zoomout",title:N["controls.zoomOut.ariaLabel"],"aria-label":N["controls.zoomOut.ariaLabel"],disabled:S,children:y.jsx(l5,{})})]}),r&&y.jsx(Fu,{className:"react-flow__controls-fitview",onClick:R,title:N["controls.fitView.ariaLabel"],"aria-label":N["controls.fitView.ariaLabel"],children:y.jsx(a5,{})}),l&&y.jsx(Fu,{className:"react-flow__controls-interactive",onClick:V,title:N["controls.interactive.ariaLabel"],"aria-label":N["controls.interactive.ariaLabel"],children:E?y.jsx(s5,{}):y.jsx(o5,{})}),m]})}CS.displayName="Controls";const c5=U.memo(CS);function f5({id:e,x:t,y:r,width:l,height:a,style:o,color:s,strokeColor:c,strokeWidth:h,className:d,borderRadius:m,shapeRendering:p,selected:x,onClick:b}){const{background:w,backgroundColor:E}=o||{},S=s||w||E;return y.jsx("rect",{className:Mt(["react-flow__minimap-node",{selected:x},d]),x:t,y:r,rx:m,ry:m,width:l,height:a,style:{fill:S,stroke:c,strokeWidth:h},shapeRendering:p,onClick:b?_=>b(_,e):void 0})}const d5=U.memo(f5),h5=e=>e.nodes.map(t=>t.id),Ah=e=>e instanceof Function?e:()=>e;function p5({nodeStrokeColor:e,nodeColor:t,nodeClassName:r="",nodeBorderRadius:l=5,nodeStrokeWidth:a,nodeComponent:o=d5,onClick:s}){const c=Ye(h5,mt),h=Ah(t),d=Ah(e),m=Ah(r),p=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return y.jsx(y.Fragment,{children:c.map(x=>y.jsx(g5,{id:x,nodeColorFunc:h,nodeStrokeColorFunc:d,nodeClassNameFunc:m,nodeBorderRadius:l,nodeStrokeWidth:a,NodeComponent:o,onClick:s,shapeRendering:p},x))})}function m5({id:e,nodeColorFunc:t,nodeStrokeColorFunc:r,nodeClassNameFunc:l,nodeBorderRadius:a,nodeStrokeWidth:o,shapeRendering:s,NodeComponent:c,onClick:h}){const{node:d,x:m,y:p,width:x,height:b}=Ye(w=>{const E=w.nodeLookup.get(e);if(!E)return{node:void 0,x:0,y:0,width:0,height:0};const S=E.internals.userNode,{x:_,y:N}=E.internals.positionAbsolute,{width:k,height:T}=Or(S);return{node:S,x:_,y:N,width:k,height:T}},mt);return!d||d.hidden||!T_(d)?null:y.jsx(c,{x:m,y:p,width:x,height:b,style:d.style,selected:!!d.selected,className:l(d),color:t(d),borderRadius:a,strokeColor:r(d),strokeWidth:o,shapeRendering:s,onClick:h,id:d.id})}const g5=U.memo(m5);var x5=U.memo(p5);const y5=200,v5=150,b5=e=>!e.hidden,w5=e=>{const 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?j_(ts(e.nodeLookup,{filter:b5}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},_5="react-flow__minimap-desc";function jS({style:e,className:t,nodeStrokeColor:r,nodeColor:l,nodeClassName:a="",nodeBorderRadius:o=5,nodeStrokeWidth:s,nodeComponent:c,bgColor:h,maskColor:d,maskStrokeColor:m,maskStrokeWidth:p,position:x="bottom-right",onClick:b,onNodeClick:w,pannable:E=!1,zoomable:S=!1,ariaLabel:_,inversePan:N,zoomStep:k=1,offsetScale:T=5}){const M=gt(),A=U.useRef(null),{boundingRect:L,viewBB:R,rfId:V,panZoom:H,translateExtent:B,flowWidth:$,flowHeight:ee,ariaLabelConfig:I}=Ye(w5,mt),F=(e==null?void 0:e.width)??y5,z=(e==null?void 0:e.height)??v5,G=L.width/F,Q=L.height/z,K=Math.max(G,Q),D=K*F,q=K*z,Y=T*K,C=L.x-(D-L.width)/2-Y,P=L.y-(q-L.height)/2-Y,X=D+Y*2,J=q+Y*2,ne=`${_5}-${V}`,re=U.useRef(0),se=U.useRef();re.current=K,U.useEffect(()=>{if(A.current&&H)return se.current=RA({domNode:A.current,panZoom:H,getTransform:()=>M.getState().transform,getViewScale:()=>re.current}),()=>{var pe;(pe=se.current)==null||pe.destroy()}},[H]),U.useEffect(()=>{var pe;(pe=se.current)==null||pe.update({translateExtent:B,width:$,height:ee,inversePan:N,pannable:E,zoomStep:k,zoomable:S})},[E,S,N,k,B,$,ee]);const xe=b?pe=>{var je;const[Se,De]=((je=se.current)==null?void 0:je.pointer(pe))||[0,0];b(pe,{x:Se,y:De})}:void 0,be=w?U.useCallback((pe,Se)=>{const De=M.getState().nodeLookup.get(Se).internals.userNode;w(pe,De)},[]):void 0,ye=_??I["minimap.ariaLabel"];return y.jsx(Ic,{position:x,style:{...e,"--xy-minimap-background-color-props":typeof h=="string"?h:void 0,"--xy-minimap-mask-background-color-props":typeof d=="string"?d:void 0,"--xy-minimap-mask-stroke-color-props":typeof m=="string"?m:void 0,"--xy-minimap-mask-stroke-width-props":typeof p=="number"?p*K:void 0,"--xy-minimap-node-background-color-props":typeof l=="string"?l:void 0,"--xy-minimap-node-stroke-color-props":typeof r=="string"?r:void 0,"--xy-minimap-node-stroke-width-props":typeof s=="number"?s:void 0},className:Mt(["react-flow__minimap",t]),"data-testid":"rf__minimap",children:y.jsxs("svg",{width:F,height:z,viewBox:`${C} ${P} ${X} ${J}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":ne,ref:A,onClick:xe,children:[ye&&y.jsx("title",{id:ne,children:ye}),y.jsx(x5,{onClick:be,nodeColor:l,nodeStrokeColor:r,nodeBorderRadius:o,nodeClassName:a,nodeStrokeWidth:s,nodeComponent:c}),y.jsx("path",{className:"react-flow__minimap-mask",d:`M${C-Y},${P-Y}h${X+Y*2}v${J+Y*2}h${-X-Y*2}z + M${R.x},${R.y}h${R.width}v${R.height}h${-R.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}jS.displayName="MiniMap";const S5=U.memo(jS),k5=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,E5={[ya.Line]:"right",[ya.Handle]:"bottom-right"};function N5({nodeId:e,position:t,variant:r=ya.Handle,className:l,style:a=void 0,children:o,color:s,minWidth:c=10,minHeight:h=10,maxWidth:d=Number.MAX_VALUE,maxHeight:m=Number.MAX_VALUE,keepAspectRatio:p=!1,resizeDirection:x,autoScale:b=!0,shouldResize:w,onResizeStart:E,onResize:S,onResizeEnd:_}){const N=aS(),k=typeof e=="string"?e:N,T=gt(),M=U.useRef(null),A=r===ya.Handle,L=Ye(U.useCallback(k5(A&&b),[A,b]),mt),R=U.useRef(null),V=t??E5[r];U.useEffect(()=>{if(!(!M.current||!k))return R.current||(R.current=XA({domNode:M.current,nodeId:k,getStoreItems:()=>{const{nodeLookup:B,transform:$,snapGrid:ee,snapToGrid:I,nodeOrigin:F,domNode:z}=T.getState();return{nodeLookup:B,transform:$,snapGrid:ee,snapToGrid:I,nodeOrigin:F,paneDomNode:z}},onChange:(B,$)=>{const{triggerNodeChanges:ee,nodeLookup:I,parentLookup:F,nodeOrigin:z}=T.getState(),G=[],Q={x:B.x,y:B.y},K=I.get(k);if(K&&K.expandParent&&K.parentId){const D=K.origin??z,q=B.width??K.measured.width??0,Y=B.height??K.measured.height??0,C={id:K.id,parentId:K.parentId,rect:{width:q,height:Y,...A_({x:B.x??K.position.x,y:B.y??K.position.y},{width:q,height:Y},K.parentId,I,D)}},P=Im([C],I,F,z);G.push(...P),Q.x=B.x?Math.max(D[0]*q,B.x):void 0,Q.y=B.y?Math.max(D[1]*Y,B.y):void 0}if(Q.x!==void 0&&Q.y!==void 0){const D={id:k,type:"position",position:{...Q}};G.push(D)}if(B.width!==void 0&&B.height!==void 0){const q={id:k,type:"dimensions",resizing:!0,setAttributes:x?x==="horizontal"?"width":"height":!0,dimensions:{width:B.width,height:B.height}};G.push(q)}for(const D of $){const q={...D,type:"position"};G.push(q)}ee(G)},onEnd:({width:B,height:$})=>{const ee={id:k,type:"dimensions",resizing:!1,dimensions:{width:B,height:$}};T.getState().triggerNodeChanges([ee])}})),R.current.update({controlPosition:V,boundaries:{minWidth:c,minHeight:h,maxWidth:d,maxHeight:m},keepAspectRatio:p,resizeDirection:x,onResizeStart:E,onResize:S,onResizeEnd:_,shouldResize:w}),()=>{var B;(B=R.current)==null||B.destroy()}},[V,c,h,d,m,p,E,S,_,w]);const H=V.split("-");return y.jsx("div",{className:Mt(["react-flow__resize-control","nodrag",...H,r,l]),ref:M,style:{...a,scale:L,...s&&{[A?"backgroundColor":"borderColor"]:s}},children:o})}U.memo(N5);function ls(e,t){if(t.length===0)return null;let r=e[t[0]];for(let l=1;ll.viewContextPath),t=ue(l=>l.nodes),r=ue(l=>l.subworkflowContexts);return U.useMemo(()=>{var l;return e.length===0?t:((l=ls(r,e))==null?void 0:l.nodes)??t},[e,t,r])}function C5(){const e=ue(l=>l.viewContextPath),t=ue(l=>l.groupProgress),r=ue(l=>l.subworkflowContexts);return U.useMemo(()=>{var l;return e.length===0?t:((l=ls(r,e))==null?void 0:l.groupProgress)??t},[e,t,r])}function j5(){const e=ue(l=>l.viewContextPath),t=ue(l=>l.highlightedEdges),r=ue(l=>l.subworkflowContexts);return U.useMemo(()=>{var l;return e.length===0?t:((l=ls(r,e))==null?void 0:l.highlightedEdges)??t},[e,t,r])}function Um(){const e=ue(r=>r.viewContextPath),t=ue(r=>r.subworkflowContexts);return U.useMemo(()=>{var r;return e.length===0?t:((r=ls(t,e))==null?void 0:r.children)??[]},[e,t])}function T5(){const e=ue(d=>d.viewContextPath),t=ue(d=>d.agents),r=ue(d=>d.routes),l=ue(d=>d.parallelGroups),a=ue(d=>d.forEachGroups),o=ue(d=>d.nodes),s=ue(d=>d.groupProgress),c=ue(d=>d.entryPoint),h=ue(d=>d.subworkflowContexts);return U.useMemo(()=>{if(e.length===0)return{agents:t,routes:r,parallelGroups:l,forEachGroups:a,nodes:o,groupProgress:s,entryPoint:c,subworkflowContexts:h,parentAgent:null};const d=ls(h,e);return d?{agents:d.agents,routes:d.routes,parallelGroups:d.parallelGroups,forEachGroups:d.forEachGroups,nodes:d.nodes,groupProgress:d.groupProgress,entryPoint:d.entryPoint,subworkflowContexts:d.children,parentAgent:d.parentAgent}:{agents:t,routes:r,parallelGroups:l,forEachGroups:a,nodes:o,groupProgress:s,entryPoint:c,subworkflowContexts:h,parentAgent:null}},[e,t,r,l,a,o,s,c,h])}function A5(){const e=new URLSearchParams(window.location.search);return{subworkflowPath:e.get("subworkflow"),agent:e.get("agent")}}function vb(e,t){const r=[];let l=e;for(const a of t){let o=-1;for(let s=l.length-1;s>=0;s--)if(l[s].slotKey===a){o=s;break}if(o===-1){for(let s=l.length-1;s>=0;s--)if(l[s].parentAgent===a){o=s;break}}if(o===-1)return{path:r,failedSegment:a};r.push(o),l=l[o].children}return{path:r,failedSegment:null}}function am(e,t,r=[]){const l=[];for(let a=0;ac.name===t)&&l.push({path:s,ctx:o}),o.children.length>0&&l.push(...am(o.children,t,s))}return l}function z5(e){return e.length===0?null:[...e].sort((t,r)=>{const l=t.ctx.status==="running"?1:0,a=r.ctx.status==="running"?1:0;if(l!==a)return a-l;if(t.path.length!==r.path.length)return r.path.length-t.path.length;for(let o=0;o{if(r.current||!s)return;let c=null,h=null,d=null;const m=()=>{if(r.current)return;r.current=!0,c&&clearTimeout(c),h&&clearTimeout(h),d&&d();const b=ue.getState();if(b.agents.length===0){t({message:"Workflow state did not load."});return}let w=[];if(a){const E=a.split("/").filter(Boolean),S=vb(b.subworkflowContexts,E);if(S.failedSegment){const _=E.slice(0,S.path.length).join("/");t({message:`Subworkflow "${S.failedSegment}" not found${_?` (resolved: ${_})`:""}. It may not have started yet.`});return}w=S.path}if(o){if((w.length===0?b.agents:(()=>{let S,_=b.subworkflowContexts;for(const N of w){if(S=_[N],!S)break;_=S.children}return(S==null?void 0:S.agents)??[]})()).some(S=>S.name===o))ue.setState({viewContextPath:w,selectedNode:o});else{const S=am(b.subworkflowContexts,o);if(S.length===0){const N=a||"root workflow";ue.setState({viewContextPath:w,selectedNode:null}),t({message:`Agent "${o}" not found in ${N}.`});return}if(a){const N=S.slice(0,5).map(T=>M5(b.subworkflowContexts,T.path)).join(", "),k=S.length>5?`, and ${S.length-5} more`:"";ue.setState({viewContextPath:w,selectedNode:null}),t({message:`Agent "${o}" not found in ${a}. Found in: ${N}${k}`});return}const _=z5(S);ue.setState({viewContextPath:_.path,selectedNode:o})}setTimeout(()=>{l({nodes:[{id:o}],padding:.5,duration:400})},200)}else a&&ue.setState({viewContextPath:w,selectedNode:null})},p=()=>{const b=ue.getState();if(b.agents.length===0)return!1;if(b.workflowStatus!=="running"&&b.workflowStatus!=="pending")return!0;if(a){const w=a.split("/").filter(Boolean),{failedSegment:E}=vb(b.subworkflowContexts,w);if(E)return!1}return!(o&&!a&&!b.agents.some(E=>E.name===o)&&am(b.subworkflowContexts,o).length===0)},x=()=>{c&&clearTimeout(c),c=setTimeout(()=>{r.current||p()&&m()},200)};return d=ue.subscribe(x),h=setTimeout(()=>{r.current||m()},5e3),x(),()=>{c&&clearTimeout(c),h&&clearTimeout(h),d&&d()}},[s,a,o,l]),e}var zh,bb;function $m(){if(bb)return zh;bb=1;var e="\0",t="\0",r="";class l{constructor(m){jt(this,"_isDirected",!0);jt(this,"_isMultigraph",!1);jt(this,"_isCompound",!1);jt(this,"_label");jt(this,"_defaultNodeLabelFn",()=>{});jt(this,"_defaultEdgeLabelFn",()=>{});jt(this,"_nodes",{});jt(this,"_in",{});jt(this,"_preds",{});jt(this,"_out",{});jt(this,"_sucs",{});jt(this,"_edgeObjs",{});jt(this,"_edgeLabels",{});jt(this,"_nodeCount",0);jt(this,"_edgeCount",0);jt(this,"_parent");jt(this,"_children");m&&(this._isDirected=Object.hasOwn(m,"directed")?m.directed:!0,this._isMultigraph=Object.hasOwn(m,"multigraph")?m.multigraph:!1,this._isCompound=Object.hasOwn(m,"compound")?m.compound:!1),this._isCompound&&(this._parent={},this._children={},this._children[t]={})}isDirected(){return this._isDirected}isMultigraph(){return this._isMultigraph}isCompound(){return this._isCompound}setGraph(m){return this._label=m,this}graph(){return this._label}setDefaultNodeLabel(m){return this._defaultNodeLabelFn=m,typeof m!="function"&&(this._defaultNodeLabelFn=()=>m),this}nodeCount(){return this._nodeCount}nodes(){return Object.keys(this._nodes)}sources(){var m=this;return this.nodes().filter(p=>Object.keys(m._in[p]).length===0)}sinks(){var m=this;return this.nodes().filter(p=>Object.keys(m._out[p]).length===0)}setNodes(m,p){var x=arguments,b=this;return m.forEach(function(w){x.length>1?b.setNode(w,p):b.setNode(w)}),this}setNode(m,p){return Object.hasOwn(this._nodes,m)?(arguments.length>1&&(this._nodes[m]=p),this):(this._nodes[m]=arguments.length>1?p:this._defaultNodeLabelFn(m),this._isCompound&&(this._parent[m]=t,this._children[m]={},this._children[t][m]=!0),this._in[m]={},this._preds[m]={},this._out[m]={},this._sucs[m]={},++this._nodeCount,this)}node(m){return this._nodes[m]}hasNode(m){return Object.hasOwn(this._nodes,m)}removeNode(m){var p=this;if(Object.hasOwn(this._nodes,m)){var x=b=>p.removeEdge(p._edgeObjs[b]);delete this._nodes[m],this._isCompound&&(this._removeFromParentsChildList(m),delete this._parent[m],this.children(m).forEach(function(b){p.setParent(b)}),delete this._children[m]),Object.keys(this._in[m]).forEach(x),delete this._in[m],delete this._preds[m],Object.keys(this._out[m]).forEach(x),delete this._out[m],delete this._sucs[m],--this._nodeCount}return this}setParent(m,p){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(p===void 0)p=t;else{p+="";for(var x=p;x!==void 0;x=this.parent(x))if(x===m)throw new Error("Setting "+p+" as parent of "+m+" would create a cycle");this.setNode(p)}return this.setNode(m),this._removeFromParentsChildList(m),this._parent[m]=p,this._children[p][m]=!0,this}_removeFromParentsChildList(m){delete this._children[this._parent[m]][m]}parent(m){if(this._isCompound){var p=this._parent[m];if(p!==t)return p}}children(m=t){if(this._isCompound){var p=this._children[m];if(p)return Object.keys(p)}else{if(m===t)return this.nodes();if(this.hasNode(m))return[]}}predecessors(m){var p=this._preds[m];if(p)return Object.keys(p)}successors(m){var p=this._sucs[m];if(p)return Object.keys(p)}neighbors(m){var p=this.predecessors(m);if(p){const b=new Set(p);for(var x of this.successors(m))b.add(x);return Array.from(b.values())}}isLeaf(m){var p;return this.isDirected()?p=this.successors(m):p=this.neighbors(m),p.length===0}filterNodes(m){var p=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});p.setGraph(this.graph());var x=this;Object.entries(this._nodes).forEach(function([E,S]){m(E)&&p.setNode(E,S)}),Object.values(this._edgeObjs).forEach(function(E){p.hasNode(E.v)&&p.hasNode(E.w)&&p.setEdge(E,x.edge(E))});var b={};function w(E){var S=x.parent(E);return S===void 0||p.hasNode(S)?(b[E]=S,S):S in b?b[S]:w(S)}return this._isCompound&&p.nodes().forEach(E=>p.setParent(E,w(E))),p}setDefaultEdgeLabel(m){return this._defaultEdgeLabelFn=m,typeof m!="function"&&(this._defaultEdgeLabelFn=()=>m),this}edgeCount(){return this._edgeCount}edges(){return Object.values(this._edgeObjs)}setPath(m,p){var x=this,b=arguments;return m.reduce(function(w,E){return b.length>1?x.setEdge(w,E,p):x.setEdge(w,E),E}),this}setEdge(){var m,p,x,b,w=!1,E=arguments[0];typeof E=="object"&&E!==null&&"v"in E?(m=E.v,p=E.w,x=E.name,arguments.length===2&&(b=arguments[1],w=!0)):(m=E,p=arguments[1],x=arguments[3],arguments.length>2&&(b=arguments[2],w=!0)),m=""+m,p=""+p,x!==void 0&&(x=""+x);var S=s(this._isDirected,m,p,x);if(Object.hasOwn(this._edgeLabels,S))return w&&(this._edgeLabels[S]=b),this;if(x!==void 0&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(m),this.setNode(p),this._edgeLabels[S]=w?b:this._defaultEdgeLabelFn(m,p,x);var _=c(this._isDirected,m,p,x);return m=_.v,p=_.w,Object.freeze(_),this._edgeObjs[S]=_,a(this._preds[p],m),a(this._sucs[m],p),this._in[p][S]=_,this._out[m][S]=_,this._edgeCount++,this}edge(m,p,x){var b=arguments.length===1?h(this._isDirected,arguments[0]):s(this._isDirected,m,p,x);return this._edgeLabels[b]}edgeAsObj(){const m=this.edge(...arguments);return typeof m!="object"?{label:m}:m}hasEdge(m,p,x){var b=arguments.length===1?h(this._isDirected,arguments[0]):s(this._isDirected,m,p,x);return Object.hasOwn(this._edgeLabels,b)}removeEdge(m,p,x){var b=arguments.length===1?h(this._isDirected,arguments[0]):s(this._isDirected,m,p,x),w=this._edgeObjs[b];return w&&(m=w.v,p=w.w,delete this._edgeLabels[b],delete this._edgeObjs[b],o(this._preds[p],m),o(this._sucs[m],p),delete this._in[p][b],delete this._out[m][b],this._edgeCount--),this}inEdges(m,p){var x=this._in[m];if(x){var b=Object.values(x);return p?b.filter(w=>w.v===p):b}}outEdges(m,p){var x=this._out[m];if(x){var b=Object.values(x);return p?b.filter(w=>w.w===p):b}}nodeEdges(m,p){var x=this.inEdges(m,p);if(x)return x.concat(this.outEdges(m,p))}}function a(d,m){d[m]?d[m]++:d[m]=1}function o(d,m){--d[m]||delete d[m]}function s(d,m,p,x){var b=""+m,w=""+p;if(!d&&b>w){var E=b;b=w,w=E}return b+r+w+r+(x===void 0?e:x)}function c(d,m,p,x){var b=""+m,w=""+p;if(!d&&b>w){var E=b;b=w,w=E}var S={v:b,w};return x&&(S.name=x),S}function h(d,m){return s(d,m.v,m.w,m.name)}return zh=l,zh}var Mh,wb;function R5(){return wb||(wb=1,Mh="2.2.4"),Mh}var Dh,_b;function O5(){return _b||(_b=1,Dh={Graph:$m(),version:R5()}),Dh}var Rh,Sb;function L5(){if(Sb)return Rh;Sb=1;var e=$m();Rh={write:t,read:a};function t(o){var s={options:{directed:o.isDirected(),multigraph:o.isMultigraph(),compound:o.isCompound()},nodes:r(o),edges:l(o)};return o.graph()!==void 0&&(s.value=structuredClone(o.graph())),s}function r(o){return o.nodes().map(function(s){var c=o.node(s),h=o.parent(s),d={v:s};return c!==void 0&&(d.value=c),h!==void 0&&(d.parent=h),d})}function l(o){return o.edges().map(function(s){var c=o.edge(s),h={v:s.v,w:s.w};return s.name!==void 0&&(h.name=s.name),c!==void 0&&(h.value=c),h})}function a(o){var s=new e(o.options).setGraph(o.value);return o.nodes.forEach(function(c){s.setNode(c.v,c.value),c.parent&&s.setParent(c.v,c.parent)}),o.edges.forEach(function(c){s.setEdge({v:c.v,w:c.w,name:c.name},c.value)}),s}return Rh}var Oh,kb;function H5(){if(kb)return Oh;kb=1,Oh=e;function e(t){var r={},l=[],a;function o(s){Object.hasOwn(r,s)||(r[s]=!0,a.push(s),t.successors(s).forEach(o),t.predecessors(s).forEach(o))}return t.nodes().forEach(function(s){a=[],o(s),a.length&&l.push(a)}),l}return Oh}var Lh,Eb;function TS(){if(Eb)return Lh;Eb=1;class e{constructor(){jt(this,"_arr",[]);jt(this,"_keyIndices",{})}size(){return this._arr.length}keys(){return this._arr.map(function(r){return r.key})}has(r){return Object.hasOwn(this._keyIndices,r)}priority(r){var l=this._keyIndices[r];if(l!==void 0)return this._arr[l].priority}min(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key}add(r,l){var a=this._keyIndices;if(r=String(r),!Object.hasOwn(a,r)){var o=this._arr,s=o.length;return a[r]=s,o.push({key:r,priority:l}),this._decrease(s),!0}return!1}removeMin(){this._swap(0,this._arr.length-1);var r=this._arr.pop();return delete this._keyIndices[r.key],this._heapify(0),r.key}decrease(r,l){var a=this._keyIndices[r];if(l>this._arr[a].priority)throw new Error("New priority is greater than current priority. Key: "+r+" Old: "+this._arr[a].priority+" New: "+l);this._arr[a].priority=l,this._decrease(a)}_heapify(r){var l=this._arr,a=2*r,o=a+1,s=r;a>1,!(l[o].priority1;function r(a,o,s,c){return l(a,String(o),s||t,c||function(h){return a.outEdges(h)})}function l(a,o,s,c){var h={},d=new e,m,p,x=function(b){var w=b.v!==m?b.v:b.w,E=h[w],S=s(b),_=p.distance+S;if(S<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+b+" Weight: "+S);_0&&(m=d.removeMin(),p=h[m],p.distance!==Number.POSITIVE_INFINITY);)c(m).forEach(x);return h}return Hh}var Bh,Cb;function B5(){if(Cb)return Bh;Cb=1;var e=AS();Bh=t;function t(r,l,a){return r.nodes().reduce(function(o,s){return o[s]=e(r,s,l,a),o},{})}return Bh}var Ih,jb;function zS(){if(jb)return Ih;jb=1,Ih=e;function e(t){var r=0,l=[],a={},o=[];function s(c){var h=a[c]={onStack:!0,lowlink:r,index:r++};if(l.push(c),t.successors(c).forEach(function(p){Object.hasOwn(a,p)?a[p].onStack&&(h.lowlink=Math.min(h.lowlink,a[p].index)):(s(p),h.lowlink=Math.min(h.lowlink,a[p].lowlink))}),h.lowlink===h.index){var d=[],m;do m=l.pop(),a[m].onStack=!1,d.push(m);while(c!==m);o.push(d)}}return t.nodes().forEach(function(c){Object.hasOwn(a,c)||s(c)}),o}return Ih}var qh,Tb;function I5(){if(Tb)return qh;Tb=1;var e=zS();qh=t;function t(r){return e(r).filter(function(l){return l.length>1||l.length===1&&r.hasEdge(l[0],l[0])})}return qh}var Uh,Ab;function q5(){if(Ab)return Uh;Ab=1,Uh=t;var e=()=>1;function t(l,a,o){return r(l,a||e,o||function(s){return l.outEdges(s)})}function r(l,a,o){var s={},c=l.nodes();return c.forEach(function(h){s[h]={},s[h][h]={distance:0},c.forEach(function(d){h!==d&&(s[h][d]={distance:Number.POSITIVE_INFINITY})}),o(h).forEach(function(d){var m=d.v===h?d.w:d.v,p=a(d);s[h][m]={distance:p,predecessor:h}})}),c.forEach(function(h){var d=s[h];c.forEach(function(m){var p=s[m];c.forEach(function(x){var b=p[h],w=d[x],E=p[x],S=b.distance+w.distance;Sa.successors(p):p=>a.neighbors(p),h=s==="post"?t:r,d=[],m={};return o.forEach(p=>{if(!a.hasNode(p))throw new Error("Graph does not have node: "+p);h(p,c,m,d)}),d}function t(a,o,s,c){for(var h=[[a,!1]];h.length>0;){var d=h.pop();d[1]?c.push(d[0]):Object.hasOwn(s,d[0])||(s[d[0]]=!0,h.push([d[0],!0]),l(o(d[0]),m=>h.push([m,!1])))}}function r(a,o,s,c){for(var h=[a];h.length>0;){var d=h.pop();Object.hasOwn(s,d)||(s[d]=!0,c.push(d),l(o(d),m=>h.push(m)))}}function l(a,o){for(var s=a.length;s--;)o(a[s],s,a);return a}return Ph}var Gh,Rb;function $5(){if(Rb)return Gh;Rb=1;var e=DS();Gh=t;function t(r,l){return e(r,l,"post")}return Gh}var Fh,Ob;function V5(){if(Ob)return Fh;Ob=1;var e=DS();Fh=t;function t(r,l){return e(r,l,"pre")}return Fh}var Yh,Lb;function P5(){if(Lb)return Yh;Lb=1;var e=$m(),t=TS();Yh=r;function r(l,a){var o=new e,s={},c=new t,h;function d(p){var x=p.v===h?p.w:p.v,b=c.priority(x);if(b!==void 0){var w=a(p);w0;){if(h=c.removeMin(),Object.hasOwn(s,h))o.setEdge(h,s[h]);else{if(m)throw new Error("Input graph is not connected: "+l);m=!0}l.nodeEdges(h).forEach(d)}return o}return Yh}var Xh,Hb;function G5(){return Hb||(Hb=1,Xh={components:H5(),dijkstra:AS(),dijkstraAll:B5(),findCycles:I5(),floydWarshall:q5(),isAcyclic:U5(),postorder:$5(),preorder:V5(),prim:P5(),tarjan:zS(),topsort:MS()}),Xh}var Qh,Bb;function Yn(){if(Bb)return Qh;Bb=1;var e=O5();return Qh={Graph:e.Graph,json:L5(),alg:G5(),version:e.version},Qh}var Zh,Ib;function F5(){if(Ib)return Zh;Ib=1;class e{constructor(){let a={};a._next=a._prev=a,this._sentinel=a}dequeue(){let a=this._sentinel,o=a._prev;if(o!==a)return t(o),o}enqueue(a){let o=this._sentinel;a._prev&&a._next&&t(a),a._next=o._next,o._next._prev=a,o._next=a,a._prev=o}toString(){let a=[],o=this._sentinel,s=o._prev;for(;s!==o;)a.push(JSON.stringify(s,r)),s=s._prev;return"["+a.join(", ")+"]"}}function t(l){l._prev._next=l._next,l._next._prev=l._prev,delete l._next,delete l._prev}function r(l,a){if(l!=="_next"&&l!=="_prev")return a}return Zh=e,Zh}var Kh,qb;function Y5(){if(qb)return Kh;qb=1;let e=Yn().Graph,t=F5();Kh=l;let r=()=>1;function l(d,m){if(d.nodeCount()<=1)return[];let p=s(d,m||r);return a(p.graph,p.buckets,p.zeroIdx).flatMap(b=>d.outEdges(b.v,b.w))}function a(d,m,p){let x=[],b=m[m.length-1],w=m[0],E;for(;d.nodeCount();){for(;E=w.dequeue();)o(d,m,p,E);for(;E=b.dequeue();)o(d,m,p,E);if(d.nodeCount()){for(let S=m.length-2;S>0;--S)if(E=m[S].dequeue(),E){x=x.concat(o(d,m,p,E,!0));break}}}return x}function o(d,m,p,x,b){let w=b?[]:void 0;return d.inEdges(x.v).forEach(E=>{let S=d.edge(E),_=d.node(E.v);b&&w.push({v:E.v,w:E.w}),_.out-=S,c(m,p,_)}),d.outEdges(x.v).forEach(E=>{let S=d.edge(E),_=E.w,N=d.node(_);N.in-=S,c(m,p,N)}),d.removeNode(x.v),w}function s(d,m){let p=new e,x=0,b=0;d.nodes().forEach(S=>{p.setNode(S,{v:S,in:0,out:0})}),d.edges().forEach(S=>{let _=p.edge(S.v,S.w)||0,N=m(S),k=_+N;p.setEdge(S.v,S.w,k),b=Math.max(b,p.node(S.v).out+=N),x=Math.max(x,p.node(S.w).in+=N)});let w=h(b+x+3).map(()=>new t),E=x+1;return p.nodes().forEach(S=>{c(w,E,p.node(S))}),{graph:p,buckets:w,zeroIdx:E}}function c(d,m,p){p.out?p.in?d[p.out-p.in+m].enqueue(p):d[d.length-1].enqueue(p):d[0].enqueue(p)}function h(d){const m=[];for(let p=0;pV.setNode(H,R.node(H))),R.edges().forEach(H=>{let B=V.edge(H.v,H.w)||{weight:0,minlen:1},$=R.edge(H);V.setEdge(H.v,H.w,{weight:B.weight+$.weight,minlen:Math.max(B.minlen,$.minlen)})}),V}function l(R){let V=new e({multigraph:R.isMultigraph()}).setGraph(R.graph());return R.nodes().forEach(H=>{R.children(H).length||V.setNode(H,R.node(H))}),R.edges().forEach(H=>{V.setEdge(H,R.edge(H))}),V}function a(R){let V=R.nodes().map(H=>{let B={};return R.outEdges(H).forEach($=>{B[$.w]=(B[$.w]||0)+R.edge($).weight}),B});return L(R.nodes(),V)}function o(R){let V=R.nodes().map(H=>{let B={};return R.inEdges(H).forEach($=>{B[$.v]=(B[$.v]||0)+R.edge($).weight}),B});return L(R.nodes(),V)}function s(R,V){let H=R.x,B=R.y,$=V.x-H,ee=V.y-B,I=R.width/2,F=R.height/2;if(!$&&!ee)throw new Error("Not possible to find intersection inside of the rectangle");let z,G;return Math.abs(ee)*I>Math.abs($)*F?(ee<0&&(F=-F),z=F*$/ee,G=F):($<0&&(I=-I),z=I,G=I*ee/$),{x:H+z,y:B+G}}function c(R){let V=T(w(R)+1).map(()=>[]);return R.nodes().forEach(H=>{let B=R.node(H),$=B.rank;$!==void 0&&(V[$][B.order]=H)}),V}function h(R){let V=R.nodes().map(B=>{let $=R.node(B).rank;return $===void 0?Number.MAX_VALUE:$}),H=b(Math.min,V);R.nodes().forEach(B=>{let $=R.node(B);Object.hasOwn($,"rank")&&($.rank-=H)})}function d(R){let V=R.nodes().map(I=>R.node(I).rank),H=b(Math.min,V),B=[];R.nodes().forEach(I=>{let F=R.node(I).rank-H;B[F]||(B[F]=[]),B[F].push(I)});let $=0,ee=R.graph().nodeRankFactor;Array.from(B).forEach((I,F)=>{I===void 0&&F%ee!==0?--$:I!==void 0&&$&&I.forEach(z=>R.node(z).rank+=$)})}function m(R,V,H,B){let $={width:0,height:0};return arguments.length>=4&&($.rank=H,$.order=B),t(R,"border",$,V)}function p(R,V=x){const H=[];for(let B=0;Bx){const H=p(V);return R.apply(null,H.map(B=>R.apply(null,B)))}else return R.apply(null,V)}function w(R){const H=R.nodes().map(B=>{let $=R.node(B).rank;return $===void 0?Number.MIN_VALUE:$});return b(Math.max,H)}function E(R,V){let H={lhs:[],rhs:[]};return R.forEach(B=>{V(B)?H.lhs.push(B):H.rhs.push(B)}),H}function S(R,V){let H=Date.now();try{return V()}finally{console.log(R+" time: "+(Date.now()-H)+"ms")}}function _(R,V){return V()}let N=0;function k(R){var V=++N;return R+(""+V)}function T(R,V,H=1){V==null&&(V=R,R=0);let B=ee=>eeVB[V]),Object.entries(R).reduce((B,[$,ee])=>(B[$]=H(ee,$),B),{})}function L(R,V){return R.reduce((H,B,$)=>(H[B]=V[$],H),{})}return Jh}var Wh,$b;function X5(){if($b)return Wh;$b=1;let e=Y5(),t=At().uniqueId;Wh={run:r,undo:a};function r(o){(o.graph().acyclicer==="greedy"?e(o,c(o)):l(o)).forEach(h=>{let d=o.edge(h);o.removeEdge(h),d.forwardName=h.name,d.reversed=!0,o.setEdge(h.w,h.v,d,t("rev"))});function c(h){return d=>h.edge(d).weight}}function l(o){let s=[],c={},h={};function d(m){Object.hasOwn(h,m)||(h[m]=!0,c[m]=!0,o.outEdges(m).forEach(p=>{Object.hasOwn(c,p.w)?s.push(p):d(p.w)}),delete c[m])}return o.nodes().forEach(d),s}function a(o){o.edges().forEach(s=>{let c=o.edge(s);if(c.reversed){o.removeEdge(s);let h=c.forwardName;delete c.reversed,delete c.forwardName,o.setEdge(s.w,s.v,c,h)}})}return Wh}var ep,Vb;function Q5(){if(Vb)return ep;Vb=1;let e=At();ep={run:t,undo:l};function t(a){a.graph().dummyChains=[],a.edges().forEach(o=>r(a,o))}function r(a,o){let s=o.v,c=a.node(s).rank,h=o.w,d=a.node(h).rank,m=o.name,p=a.edge(o),x=p.labelRank;if(d===c+1)return;a.removeEdge(o);let b,w,E;for(E=0,++c;c{let s=a.node(o),c=s.edgeLabel,h;for(a.setEdge(s.edgeObj,c);s.dummy;)h=a.successors(o)[0],a.removeNode(o),c.points.push({x:s.x,y:s.y}),s.dummy==="edge-label"&&(c.x=s.x,c.y=s.y,c.width=s.width,c.height=s.height),o=h,s=a.node(o)})}return ep}var tp,Pb;function vc(){if(Pb)return tp;Pb=1;const{applyWithChunking:e}=At();tp={longestPath:t,slack:r};function t(l){var a={};function o(s){var c=l.node(s);if(Object.hasOwn(a,s))return c.rank;a[s]=!0;let h=l.outEdges(s).map(m=>m==null?Number.POSITIVE_INFINITY:o(m.w)-l.edge(m).minlen);var d=e(Math.min,h);return d===Number.POSITIVE_INFINITY&&(d=0),c.rank=d}l.sources().forEach(o)}function r(l,a){return l.node(a.w).rank-l.node(a.v).rank-l.edge(a).minlen}return tp}var np,Gb;function RS(){if(Gb)return np;Gb=1;var e=Yn().Graph,t=vc().slack;np=r;function r(s){var c=new e({directed:!1}),h=s.nodes()[0],d=s.nodeCount();c.setNode(h,{});for(var m,p;l(c,s){var p=m.v,x=d===p?m.w:p;!s.hasNode(x)&&!t(c,m)&&(s.setNode(x,{}),s.setEdge(d,x,{}),h(x))})}return s.nodes().forEach(h),s.nodeCount()}function a(s,c){return c.edges().reduce((d,m)=>{let p=Number.POSITIVE_INFINITY;return s.hasNode(m.v)!==s.hasNode(m.w)&&(p=t(c,m)),pc.node(d).rank+=h)}return np}var rp,Fb;function Z5(){if(Fb)return rp;Fb=1;var e=RS(),t=vc().slack,r=vc().longestPath,l=Yn().alg.preorder,a=Yn().alg.postorder,o=At().simplify;rp=s,s.initLowLimValues=m,s.initCutValues=c,s.calcCutValue=d,s.leaveEdge=x,s.enterEdge=b,s.exchangeEdges=w;function s(N){N=o(N),r(N);var k=e(N);m(k),c(k,N);for(var T,M;T=x(k);)M=b(k,N,T),w(k,N,T,M)}function c(N,k){var T=a(N,N.nodes());T=T.slice(0,T.length-1),T.forEach(M=>h(N,k,M))}function h(N,k,T){var M=N.node(T),A=M.parent;N.edge(T,A).cutvalue=d(N,k,T)}function d(N,k,T){var M=N.node(T),A=M.parent,L=!0,R=k.edge(T,A),V=0;return R||(L=!1,R=k.edge(A,T)),V=R.weight,k.nodeEdges(T).forEach(H=>{var B=H.v===T,$=B?H.w:H.v;if($!==A){var ee=B===L,I=k.edge(H).weight;if(V+=ee?I:-I,S(N,T,$)){var F=N.edge(T,$).cutvalue;V+=ee?-F:F}}}),V}function m(N,k){arguments.length<2&&(k=N.nodes()[0]),p(N,{},1,k)}function p(N,k,T,M,A){var L=T,R=N.node(M);return k[M]=!0,N.neighbors(M).forEach(V=>{Object.hasOwn(k,V)||(T=p(N,k,T,V,M))}),R.low=L,R.lim=T++,A?R.parent=A:delete R.parent,T}function x(N){return N.edges().find(k=>N.edge(k).cutvalue<0)}function b(N,k,T){var M=T.v,A=T.w;k.hasEdge(M,A)||(M=T.w,A=T.v);var L=N.node(M),R=N.node(A),V=L,H=!1;L.lim>R.lim&&(V=R,H=!0);var B=k.edges().filter($=>H===_(N,N.node($.v),V)&&H!==_(N,N.node($.w),V));return B.reduce(($,ee)=>t(k,ee)!k.node(A).parent),M=l(N,T);M=M.slice(1),M.forEach(A=>{var L=N.node(A).parent,R=k.edge(A,L),V=!1;R||(R=k.edge(L,A),V=!0),k.node(A).rank=k.node(L).rank+(V?R.minlen:-R.minlen)})}function S(N,k,T){return N.hasEdge(k,T)}function _(N,k,T){return T.low<=k.lim&&k.lim<=T.lim}return rp}var ip,Yb;function K5(){if(Yb)return ip;Yb=1;var e=vc(),t=e.longestPath,r=RS(),l=Z5();ip=a;function a(h){var d=h.graph().ranker;if(d instanceof Function)return d(h);switch(h.graph().ranker){case"network-simplex":c(h);break;case"tight-tree":s(h);break;case"longest-path":o(h);break;case"none":break;default:c(h)}}var o=t;function s(h){t(h),r(h)}function c(h){l(h)}return ip}var lp,Xb;function J5(){if(Xb)return lp;Xb=1,lp=e;function e(l){let a=r(l);l.graph().dummyChains.forEach(o=>{let s=l.node(o),c=s.edgeObj,h=t(l,a,c.v,c.w),d=h.path,m=h.lca,p=0,x=d[p],b=!0;for(;o!==c.w;){if(s=l.node(o),b){for(;(x=d[p])!==m&&l.node(x).maxRankd||m>a[p].lim));for(x=p,p=s;(p=l.parent(p))!==x;)h.push(p);return{path:c.concat(h.reverse()),lca:x}}function r(l){let a={},o=0;function s(c){let h=o;l.children(c).forEach(s),a[c]={low:h,lim:o++}}return l.children().forEach(s),a}return lp}var ap,Qb;function W5(){if(Qb)return ap;Qb=1;let e=At();ap={run:t,cleanup:o};function t(s){let c=e.addDummyNode(s,"root",{},"_root"),h=l(s),d=Object.values(h),m=e.applyWithChunking(Math.max,d)-1,p=2*m+1;s.graph().nestingRoot=c,s.edges().forEach(b=>s.edge(b).minlen*=p);let x=a(s)+1;s.children().forEach(b=>r(s,c,p,x,m,h,b)),s.graph().nodeRankFactor=p}function r(s,c,h,d,m,p,x){let b=s.children(x);if(!b.length){x!==c&&s.setEdge(c,x,{weight:0,minlen:h});return}let w=e.addBorderNode(s,"_bt"),E=e.addBorderNode(s,"_bb"),S=s.node(x);s.setParent(w,x),S.borderTop=w,s.setParent(E,x),S.borderBottom=E,b.forEach(_=>{r(s,c,h,d,m,p,_);let N=s.node(_),k=N.borderTop?N.borderTop:_,T=N.borderBottom?N.borderBottom:_,M=N.borderTop?d:2*d,A=k!==T?1:m-p[x]+1;s.setEdge(w,k,{weight:M,minlen:A,nestingEdge:!0}),s.setEdge(T,E,{weight:M,minlen:A,nestingEdge:!0})}),s.parent(x)||s.setEdge(c,w,{weight:0,minlen:m+p[x]})}function l(s){var c={};function h(d,m){var p=s.children(d);p&&p.length&&p.forEach(x=>h(x,m+1)),c[d]=m}return s.children().forEach(d=>h(d,1)),c}function a(s){return s.edges().reduce((c,h)=>c+s.edge(h).weight,0)}function o(s){var c=s.graph();s.removeNode(c.nestingRoot),delete c.nestingRoot,s.edges().forEach(h=>{var d=s.edge(h);d.nestingEdge&&s.removeEdge(h)})}return ap}var op,Zb;function e4(){if(Zb)return op;Zb=1;let e=At();op=t;function t(l){function a(o){let s=l.children(o),c=l.node(o);if(s.length&&s.forEach(a),Object.hasOwn(c,"minRank")){c.borderLeft=[],c.borderRight=[];for(let h=c.minRank,d=c.maxRank+1;hl(h.node(d))),h.edges().forEach(d=>l(h.edge(d)))}function l(h){let d=h.width;h.width=h.height,h.height=d}function a(h){h.nodes().forEach(d=>o(h.node(d))),h.edges().forEach(d=>{let m=h.edge(d);m.points.forEach(o),Object.hasOwn(m,"y")&&o(m)})}function o(h){h.y=-h.y}function s(h){h.nodes().forEach(d=>c(h.node(d))),h.edges().forEach(d=>{let m=h.edge(d);m.points.forEach(c),Object.hasOwn(m,"x")&&c(m)})}function c(h){let d=h.x;h.x=h.y,h.y=d}return sp}var up,Jb;function n4(){if(Jb)return up;Jb=1;let e=At();up=t;function t(r){let l={},a=r.nodes().filter(m=>!r.children(m).length),o=a.map(m=>r.node(m).rank),s=e.applyWithChunking(Math.max,o),c=e.range(s+1).map(()=>[]);function h(m){if(l[m])return;l[m]=!0;let p=r.node(m);c[p.rank].push(m),r.successors(m).forEach(h)}return a.sort((m,p)=>r.node(m).rank-r.node(p).rank).forEach(h),c}return up}var cp,Wb;function r4(){if(Wb)return cp;Wb=1;let e=At().zipObject;cp=t;function t(l,a){let o=0;for(let s=1;sb)),c=a.flatMap(x=>l.outEdges(x).map(b=>({pos:s[b.w],weight:l.edge(b).weight})).sort((b,w)=>b.pos-w.pos)),h=1;for(;h{let b=x.pos+h;m[b]+=x.weight;let w=0;for(;b>0;)b%2&&(w+=m[b+1]),b=b-1>>1,m[b]+=x.weight;p+=x.weight*w}),p}return cp}var fp,e1;function i4(){if(e1)return fp;e1=1,fp=e;function e(t,r=[]){return r.map(l=>{let a=t.inEdges(l);if(a.length){let o=a.reduce((s,c)=>{let h=t.edge(c),d=t.node(c.v);return{sum:s.sum+h.weight*d.order,weight:s.weight+h.weight}},{sum:0,weight:0});return{v:l,barycenter:o.sum/o.weight,weight:o.weight}}else return{v:l}})}return fp}var dp,t1;function l4(){if(t1)return dp;t1=1;let e=At();dp=t;function t(a,o){let s={};a.forEach((h,d)=>{let m=s[h.v]={indegree:0,in:[],out:[],vs:[h.v],i:d};h.barycenter!==void 0&&(m.barycenter=h.barycenter,m.weight=h.weight)}),o.edges().forEach(h=>{let d=s[h.v],m=s[h.w];d!==void 0&&m!==void 0&&(m.indegree++,d.out.push(s[h.w]))});let c=Object.values(s).filter(h=>!h.indegree);return r(c)}function r(a){let o=[];function s(h){return d=>{d.merged||(d.barycenter===void 0||h.barycenter===void 0||d.barycenter>=h.barycenter)&&l(h,d)}}function c(h){return d=>{d.in.push(h),--d.indegree===0&&a.push(d)}}for(;a.length;){let h=a.pop();o.push(h),h.in.reverse().forEach(s(h)),h.out.forEach(c(h))}return o.filter(h=>!h.merged).map(h=>e.pick(h,["vs","i","barycenter","weight"]))}function l(a,o){let s=0,c=0;a.weight&&(s+=a.barycenter*a.weight,c+=a.weight),o.weight&&(s+=o.barycenter*o.weight,c+=o.weight),a.vs=o.vs.concat(a.vs),a.barycenter=s/c,a.weight=c,a.i=Math.min(o.i,a.i),o.merged=!0}return dp}var hp,n1;function a4(){if(n1)return hp;n1=1;let e=At();hp=t;function t(a,o){let s=e.partition(a,w=>Object.hasOwn(w,"barycenter")),c=s.lhs,h=s.rhs.sort((w,E)=>E.i-w.i),d=[],m=0,p=0,x=0;c.sort(l(!!o)),x=r(d,h,x),c.forEach(w=>{x+=w.vs.length,d.push(w.vs),m+=w.barycenter*w.weight,p+=w.weight,x=r(d,h,x)});let b={vs:d.flat(!0)};return p&&(b.barycenter=m/p,b.weight=p),b}function r(a,o,s){let c;for(;o.length&&(c=o[o.length-1]).i<=s;)o.pop(),a.push(c.vs),s++;return s}function l(a){return(o,s)=>o.barycenters.barycenter?1:a?s.i-o.i:o.i-s.i}return hp}var pp,r1;function o4(){if(r1)return pp;r1=1;let e=i4(),t=l4(),r=a4();pp=l;function l(s,c,h,d){let m=s.children(c),p=s.node(c),x=p?p.borderLeft:void 0,b=p?p.borderRight:void 0,w={};x&&(m=m.filter(N=>N!==x&&N!==b));let E=e(s,m);E.forEach(N=>{if(s.children(N.v).length){let k=l(s,N.v,h,d);w[N.v]=k,Object.hasOwn(k,"barycenter")&&o(N,k)}});let S=t(E,h);a(S,w);let _=r(S,d);if(x&&(_.vs=[x,_.vs,b].flat(!0),s.predecessors(x).length)){let N=s.node(s.predecessors(x)[0]),k=s.node(s.predecessors(b)[0]);Object.hasOwn(_,"barycenter")||(_.barycenter=0,_.weight=0),_.barycenter=(_.barycenter*_.weight+N.order+k.order)/(_.weight+2),_.weight+=2}return _}function a(s,c){s.forEach(h=>{h.vs=h.vs.flatMap(d=>c[d]?c[d].vs:d)})}function o(s,c){s.barycenter!==void 0?(s.barycenter=(s.barycenter*s.weight+c.barycenter*c.weight)/(s.weight+c.weight),s.weight+=c.weight):(s.barycenter=c.barycenter,s.weight=c.weight)}return pp}var mp,i1;function s4(){if(i1)return mp;i1=1;let e=Yn().Graph,t=At();mp=r;function r(a,o,s,c){c||(c=a.nodes());let h=l(a),d=new e({compound:!0}).setGraph({root:h}).setDefaultNodeLabel(m=>a.node(m));return c.forEach(m=>{let p=a.node(m),x=a.parent(m);(p.rank===o||p.minRank<=o&&o<=p.maxRank)&&(d.setNode(m),d.setParent(m,x||h),a[s](m).forEach(b=>{let w=b.v===m?b.w:b.v,E=d.edge(w,m),S=E!==void 0?E.weight:0;d.setEdge(w,m,{weight:a.edge(b).weight+S})}),Object.hasOwn(p,"minRank")&&d.setNode(m,{borderLeft:p.borderLeft[o],borderRight:p.borderRight[o]}))}),d}function l(a){for(var o;a.hasNode(o=t.uniqueId("_root")););return o}return mp}var gp,l1;function u4(){if(l1)return gp;l1=1,gp=e;function e(t,r,l){let a={},o;l.forEach(s=>{let c=t.parent(s),h,d;for(;c;){if(h=t.parent(c),h?(d=a[h],a[h]=c):(d=o,o=c),d&&d!==c){r.setEdge(d,c);return}c=h}})}return gp}var xp,a1;function c4(){if(a1)return xp;a1=1;let e=n4(),t=r4(),r=o4(),l=s4(),a=u4(),o=Yn().Graph,s=At();xp=c;function c(p,x){if(x&&typeof x.customOrder=="function"){x.customOrder(p,c);return}let b=s.maxRank(p),w=h(p,s.range(1,b+1),"inEdges"),E=h(p,s.range(b-1,-1,-1),"outEdges"),S=e(p);if(m(p,S),x&&x.disableOptimalOrderHeuristic)return;let _=Number.POSITIVE_INFINITY,N;for(let k=0,T=0;T<4;++k,++T){d(k%2?w:E,k%4>=2),S=s.buildLayerMatrix(p);let M=t(p,S);M<_&&(T=0,N=Object.assign({},S),_=M)}m(p,N)}function h(p,x,b){const w=new Map,E=(S,_)=>{w.has(S)||w.set(S,[]),w.get(S).push(_)};for(const S of p.nodes()){const _=p.node(S);if(typeof _.rank=="number"&&E(_.rank,S),typeof _.minRank=="number"&&typeof _.maxRank=="number")for(let N=_.minRank;N<=_.maxRank;N++)N!==_.rank&&E(N,S)}return x.map(function(S){return l(p,S,b,w.get(S)||[])})}function d(p,x){let b=new o;p.forEach(function(w){let E=w.graph().root,S=r(w,E,b,x);S.vs.forEach((_,N)=>w.node(_).order=N),a(w,b,S.vs)})}function m(p,x){Object.values(x).forEach(b=>b.forEach((w,E)=>p.node(w).order=E))}return xp}var yp,o1;function f4(){if(o1)return yp;o1=1;let e=Yn().Graph,t=At();yp={positionX:b,findType1Conflicts:r,findType2Conflicts:l,addConflict:o,hasConflict:s,verticalAlignment:c,horizontalCompaction:h,alignCoordinates:p,findSmallestWidthAlignment:m,balance:x};function r(S,_){let N={};function k(T,M){let A=0,L=0,R=T.length,V=M[M.length-1];return M.forEach((H,B)=>{let $=a(S,H),ee=$?S.node($).order:R;($||H===V)&&(M.slice(L,B+1).forEach(I=>{S.predecessors(I).forEach(F=>{let z=S.node(F),G=z.order;(G{H=M[B],S.node(H).dummy&&S.predecessors(H).forEach($=>{let ee=S.node($);ee.dummy&&(ee.orderV)&&o(N,$,H)})})}function T(M,A){let L=-1,R,V=0;return A.forEach((H,B)=>{if(S.node(H).dummy==="border"){let $=S.predecessors(H);$.length&&(R=S.node($[0]).order,k(A,V,B,L,R),V=B,L=R)}k(A,V,A.length,R,M.length)}),A}return _.length&&_.reduce(T),N}function a(S,_){if(S.node(_).dummy)return S.predecessors(_).find(N=>S.node(N).dummy)}function o(S,_,N){if(_>N){let T=_;_=N,N=T}let k=S[_];k||(S[_]=k={}),k[N]=!0}function s(S,_,N){if(_>N){let k=_;_=N,N=k}return!!S[_]&&Object.hasOwn(S[_],N)}function c(S,_,N,k){let T={},M={},A={};return _.forEach(L=>{L.forEach((R,V)=>{T[R]=R,M[R]=R,A[R]=V})}),_.forEach(L=>{let R=-1;L.forEach(V=>{let H=k(V);if(H.length){H=H.sort(($,ee)=>A[$]-A[ee]);let B=(H.length-1)/2;for(let $=Math.floor(B),ee=Math.ceil(B);$<=ee;++$){let I=H[$];M[V]===V&&RMath.max($,M[ee.v]+A.edge(ee)),0)}function H(B){let $=A.outEdges(B).reduce((I,F)=>Math.min(I,M[F.w]-A.edge(F)),Number.POSITIVE_INFINITY),ee=S.node(B);$!==Number.POSITIVE_INFINITY&&ee.borderType!==L&&(M[B]=Math.max(M[B],$))}return R(V,A.predecessors.bind(A)),R(H,A.successors.bind(A)),Object.keys(k).forEach(B=>M[B]=M[N[B]]),M}function d(S,_,N,k){let T=new e,M=S.graph(),A=w(M.nodesep,M.edgesep,k);return _.forEach(L=>{let R;L.forEach(V=>{let H=N[V];if(T.setNode(H),R){var B=N[R],$=T.edge(B,H);T.setEdge(B,H,Math.max(A(S,V,R),$||0))}R=V})}),T}function m(S,_){return Object.values(_).reduce((N,k)=>{let T=Number.NEGATIVE_INFINITY,M=Number.POSITIVE_INFINITY;Object.entries(k).forEach(([L,R])=>{let V=E(S,L)/2;T=Math.max(R+V,T),M=Math.min(R-V,M)});const A=T-M;return A{["l","r"].forEach(A=>{let L=M+A,R=S[L];if(R===_)return;let V=Object.values(R),H=k-t.applyWithChunking(Math.min,V);A!=="l"&&(H=T-t.applyWithChunking(Math.max,V)),H&&(S[L]=t.mapValues(R,B=>B+H))})})}function x(S,_){return t.mapValues(S.ul,(N,k)=>{if(_)return S[_.toLowerCase()][k];{let T=Object.values(S).map(M=>M[k]).sort((M,A)=>M-A);return(T[1]+T[2])/2}})}function b(S){let _=t.buildLayerMatrix(S),N=Object.assign(r(S,_),l(S,_)),k={},T;["u","d"].forEach(A=>{T=A==="u"?_:Object.values(_).reverse(),["l","r"].forEach(L=>{L==="r"&&(T=T.map(B=>Object.values(B).reverse()));let R=(A==="u"?S.predecessors:S.successors).bind(S),V=c(S,T,N,R),H=h(S,T,V.root,V.align,L==="r");L==="r"&&(H=t.mapValues(H,B=>-B)),k[A+L]=H})});let M=m(S,k);return p(k,M),x(k,S.graph().align)}function w(S,_,N){return(k,T,M)=>{let A=k.node(T),L=k.node(M),R=0,V;if(R+=A.width/2,Object.hasOwn(A,"labelpos"))switch(A.labelpos.toLowerCase()){case"l":V=-A.width/2;break;case"r":V=A.width/2;break}if(V&&(R+=N?V:-V),V=0,R+=(A.dummy?_:S)/2,R+=(L.dummy?_:S)/2,R+=L.width/2,Object.hasOwn(L,"labelpos"))switch(L.labelpos.toLowerCase()){case"l":V=L.width/2;break;case"r":V=-L.width/2;break}return V&&(R+=N?V:-V),V=0,R}}function E(S,_){return S.node(_).width}return yp}var vp,s1;function d4(){if(s1)return vp;s1=1;let e=At(),t=f4().positionX;vp=r;function r(a){a=e.asNonCompoundGraph(a),l(a),Object.entries(t(a)).forEach(([o,s])=>a.node(o).x=s)}function l(a){let o=e.buildLayerMatrix(a),s=a.graph().ranksep,c=0;o.forEach(h=>{const d=h.reduce((m,p)=>{const x=a.node(p).height;return m>x?m:x},0);h.forEach(m=>a.node(m).y=c+d/2),c+=d+s})}return vp}var bp,u1;function h4(){if(u1)return bp;u1=1;let e=X5(),t=Q5(),r=K5(),l=At().normalizeRanks,a=J5(),o=At().removeEmptyRanks,s=W5(),c=e4(),h=t4(),d=c4(),m=d4(),p=At(),x=Yn().Graph;bp=b;function b(C,P){let X=P&&P.debugTiming?p.time:p.notime;X("layout",()=>{let J=X(" buildLayoutGraph",()=>R(C));X(" runLayout",()=>w(J,X,P)),X(" updateInputGraph",()=>E(C,J))})}function w(C,P,X){P(" makeSpaceForEdgeLabels",()=>V(C)),P(" removeSelfEdges",()=>Q(C)),P(" acyclic",()=>e.run(C)),P(" nestingGraph.run",()=>s.run(C)),P(" rank",()=>r(p.asNonCompoundGraph(C))),P(" injectEdgeLabelProxies",()=>H(C)),P(" removeEmptyRanks",()=>o(C)),P(" nestingGraph.cleanup",()=>s.cleanup(C)),P(" normalizeRanks",()=>l(C)),P(" assignRankMinMax",()=>B(C)),P(" removeEdgeLabelProxies",()=>$(C)),P(" normalize.run",()=>t.run(C)),P(" parentDummyChains",()=>a(C)),P(" addBorderSegments",()=>c(C)),P(" order",()=>d(C,X)),P(" insertSelfEdges",()=>K(C)),P(" adjustCoordinateSystem",()=>h.adjust(C)),P(" position",()=>m(C)),P(" positionSelfEdges",()=>D(C)),P(" removeBorderNodes",()=>G(C)),P(" normalize.undo",()=>t.undo(C)),P(" fixupEdgeLabelCoords",()=>F(C)),P(" undoCoordinateSystem",()=>h.undo(C)),P(" translateGraph",()=>ee(C)),P(" assignNodeIntersects",()=>I(C)),P(" reversePoints",()=>z(C)),P(" acyclic.undo",()=>e.undo(C))}function E(C,P){C.nodes().forEach(X=>{let J=C.node(X),ne=P.node(X);J&&(J.x=ne.x,J.y=ne.y,J.rank=ne.rank,P.children(X).length&&(J.width=ne.width,J.height=ne.height))}),C.edges().forEach(X=>{let J=C.edge(X),ne=P.edge(X);J.points=ne.points,Object.hasOwn(ne,"x")&&(J.x=ne.x,J.y=ne.y)}),C.graph().width=P.graph().width,C.graph().height=P.graph().height}let S=["nodesep","edgesep","ranksep","marginx","marginy"],_={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},N=["acyclicer","ranker","rankdir","align"],k=["width","height","rank"],T={width:0,height:0},M=["minlen","weight","width","height","labeloffset"],A={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},L=["labelpos"];function R(C){let P=new x({multigraph:!0,compound:!0}),X=Y(C.graph());return P.setGraph(Object.assign({},_,q(X,S),p.pick(X,N))),C.nodes().forEach(J=>{let ne=Y(C.node(J));const re=q(ne,k);Object.keys(T).forEach(se=>{re[se]===void 0&&(re[se]=T[se])}),P.setNode(J,re),P.setParent(J,C.parent(J))}),C.edges().forEach(J=>{let ne=Y(C.edge(J));P.setEdge(J,Object.assign({},A,q(ne,M),p.pick(ne,L)))}),P}function V(C){let P=C.graph();P.ranksep/=2,C.edges().forEach(X=>{let J=C.edge(X);J.minlen*=2,J.labelpos.toLowerCase()!=="c"&&(P.rankdir==="TB"||P.rankdir==="BT"?J.width+=J.labeloffset:J.height+=J.labeloffset)})}function H(C){C.edges().forEach(P=>{let X=C.edge(P);if(X.width&&X.height){let J=C.node(P.v),re={rank:(C.node(P.w).rank-J.rank)/2+J.rank,e:P};p.addDummyNode(C,"edge-proxy",re,"_ep")}})}function B(C){let P=0;C.nodes().forEach(X=>{let J=C.node(X);J.borderTop&&(J.minRank=C.node(J.borderTop).rank,J.maxRank=C.node(J.borderBottom).rank,P=Math.max(P,J.maxRank))}),C.graph().maxRank=P}function $(C){C.nodes().forEach(P=>{let X=C.node(P);X.dummy==="edge-proxy"&&(C.edge(X.e).labelRank=X.rank,C.removeNode(P))})}function ee(C){let P=Number.POSITIVE_INFINITY,X=0,J=Number.POSITIVE_INFINITY,ne=0,re=C.graph(),se=re.marginx||0,xe=re.marginy||0;function be(ye){let pe=ye.x,Se=ye.y,De=ye.width,je=ye.height;P=Math.min(P,pe-De/2),X=Math.max(X,pe+De/2),J=Math.min(J,Se-je/2),ne=Math.max(ne,Se+je/2)}C.nodes().forEach(ye=>be(C.node(ye))),C.edges().forEach(ye=>{let pe=C.edge(ye);Object.hasOwn(pe,"x")&&be(pe)}),P-=se,J-=xe,C.nodes().forEach(ye=>{let pe=C.node(ye);pe.x-=P,pe.y-=J}),C.edges().forEach(ye=>{let pe=C.edge(ye);pe.points.forEach(Se=>{Se.x-=P,Se.y-=J}),Object.hasOwn(pe,"x")&&(pe.x-=P),Object.hasOwn(pe,"y")&&(pe.y-=J)}),re.width=X-P+se,re.height=ne-J+xe}function I(C){C.edges().forEach(P=>{let X=C.edge(P),J=C.node(P.v),ne=C.node(P.w),re,se;X.points?(re=X.points[0],se=X.points[X.points.length-1]):(X.points=[],re=ne,se=J),X.points.unshift(p.intersectRect(J,re)),X.points.push(p.intersectRect(ne,se))})}function F(C){C.edges().forEach(P=>{let X=C.edge(P);if(Object.hasOwn(X,"x"))switch((X.labelpos==="l"||X.labelpos==="r")&&(X.width-=X.labeloffset),X.labelpos){case"l":X.x-=X.width/2+X.labeloffset;break;case"r":X.x+=X.width/2+X.labeloffset;break}})}function z(C){C.edges().forEach(P=>{let X=C.edge(P);X.reversed&&X.points.reverse()})}function G(C){C.nodes().forEach(P=>{if(C.children(P).length){let X=C.node(P),J=C.node(X.borderTop),ne=C.node(X.borderBottom),re=C.node(X.borderLeft[X.borderLeft.length-1]),se=C.node(X.borderRight[X.borderRight.length-1]);X.width=Math.abs(se.x-re.x),X.height=Math.abs(ne.y-J.y),X.x=re.x+X.width/2,X.y=J.y+X.height/2}}),C.nodes().forEach(P=>{C.node(P).dummy==="border"&&C.removeNode(P)})}function Q(C){C.edges().forEach(P=>{if(P.v===P.w){var X=C.node(P.v);X.selfEdges||(X.selfEdges=[]),X.selfEdges.push({e:P,label:C.edge(P)}),C.removeEdge(P)}})}function K(C){var P=p.buildLayerMatrix(C);P.forEach(X=>{var J=0;X.forEach((ne,re)=>{var se=C.node(ne);se.order=re+J,(se.selfEdges||[]).forEach(xe=>{p.addDummyNode(C,"selfedge",{width:xe.label.width,height:xe.label.height,rank:se.rank,order:re+ ++J,e:xe.e,label:xe.label},"_se")}),delete se.selfEdges})})}function D(C){C.nodes().forEach(P=>{var X=C.node(P);if(X.dummy==="selfedge"){var J=C.node(X.e.v),ne=J.x+J.width/2,re=J.y,se=X.x-ne,xe=J.height/2;C.setEdge(X.e,X.label),C.removeNode(P),X.label.points=[{x:ne+2*se/3,y:re-xe},{x:ne+5*se/6,y:re-xe},{x:ne+se,y:re},{x:ne+5*se/6,y:re+xe},{x:ne+2*se/3,y:re+xe}],X.label.x=X.x,X.label.y=X.y}})}function q(C,P){return p.mapValues(p.pick(C,P),Number)}function Y(C){var P={};return C&&Object.entries(C).forEach(([X,J])=>{typeof X=="string"&&(X=X.toLowerCase()),P[X]=J}),P}return bp}var wp,c1;function p4(){if(c1)return wp;c1=1;let e=At(),t=Yn().Graph;wp={debugOrdering:r};function r(l){let a=e.buildLayerMatrix(l),o=new t({compound:!0,multigraph:!0}).setGraph({});return l.nodes().forEach(s=>{o.setNode(s,{label:s}),o.setParent(s,"layer"+l.node(s).rank)}),l.edges().forEach(s=>o.setEdge(s.v,s.w,{},s.name)),a.forEach((s,c)=>{let h="layer"+c;o.setNode(h,{rank:"same"}),s.reduce((d,m)=>(o.setEdge(d,m,{style:"invis"}),m))}),o}return wp}var _p,f1;function m4(){return f1||(f1=1,_p="1.1.8"),_p}var Sp,d1;function g4(){return d1||(d1=1,Sp={graphlib:Yn(),layout:h4(),debug:p4(),util:{time:At().time,notime:At().notime},version:m4()}),Sp}var x4=g4();const h1=Zo(x4),zo=200,aa=56,p1=20,m1=40,y4=20,g1=12;function v4(e,t,r,l,a,o,s,c){const h=[],d=[],m=new Set,p=new Set,x=new Map;for(const N of r)for(const k of N.agents)p.add(k),x.set(k,N.name);for(const N of r){const k=a[N.name],T=N.agents.length,M=zo+p1*2,A=m1+T*aa+(T-1)*g1+y4;h.push({id:N.name,type:"groupNode",position:{x:0,y:0},data:{label:N.name,type:"parallel_group",status:(k==null?void 0:k.status)||"pending",groupName:N.name,progress:o[N.name]},style:{width:M,height:A}});for(let L=0;L$entryPoint",source:"$start",target:s,type:"animatedEdge",data:{},animated:!1})}const w=new Set(h.map(N=>N.id)),E=new Map;for(const N of h)N.parentId&&E.set(N.id,N.parentId);const S=new Map;for(const N of t){const k=E.get(N.from)??N.from,T=E.get(N.to)??N.to;if(!w.has(k)||!w.has(T)||k===T)continue;const M=`${k}->${T}`,A=S.get(M);if(A){A.when!==N.when&&(d[A.idx].data={when:void 0});continue}const L=d.length;S.set(M,{when:N.when,idx:L});const R=`${M}${N.when?`[${N.when}]`:""}`;d.push({id:R,source:k,target:T,type:"animatedEdge",data:{when:N.when},animated:!1})}const _=b4(h,d,"$start");return w4(h,d,_),{nodes:h,edges:d}}function b4(e,t,r){const l=new Set(e.filter(d=>!d.parentId).map(d=>d.id)),a=new Map;for(const d of t)!l.has(d.source)||!l.has(d.target)||(a.has(d.source)||a.set(d.source,[]),a.get(d.source).push({target:d.target,edgeId:d.id}));for(const d of a.values())d.sort((m,p)=>m.targetp.target?1:0);const o=new Set,s=new Set,c=new Set,h=d=>{c.add(d),s.add(d);for(const{target:m,edgeId:p}of a.get(d)??[])s.has(m)?o.add(p):c.has(m)||h(m);s.delete(d)};l.has(r)&&h(r);for(const d of[...a.keys()].sort())c.has(d)||h(d);return o}function w4(e,t,r){var a,o,s,c;const l=new h1.graphlib.Graph;l.setDefaultEdgeLabel(()=>({})),l.setGraph({rankdir:"TB",nodesep:50,ranksep:70,marginx:30,marginy:30});for(const h of e){if(h.parentId)continue;const d=h.type==="groupNode",m=d&&((a=h.style)==null?void 0:a.width)||zo,p=d&&((o=h.style)==null?void 0:o.height)||aa;l.setNode(h.id,{width:m,height:p})}for(const h of t)!l.hasNode(h.source)||!l.hasNode(h.target)||(r.has(h.id)?l.setEdge(h.target,h.source):l.setEdge(h.source,h.target));h1.layout(l);for(const h of e){if(h.parentId)continue;const d=l.node(h.id);if(!d)continue;const m=h.type==="groupNode",p=m&&((s=h.style)==null?void 0:s.width)||zo,x=m&&((c=h.style)==null?void 0:c.height)||aa;h.position={x:d.x-p/2,y:d.y-x/2}}}const Ie={pending:"#6b7280",running:"#3b82f6",completed:"#22c55e",failed:"#ef4444",paused:"#f59e0b",idle:"#6b7280",waiting:"#a855f7"},_4=70,x1=90;function as({data:e,children:t}){const[r,l]=U.useState(!1),a=U.useRef(null),o=U.useCallback(()=>{a.current=setTimeout(()=>l(!0),200)},[]),s=U.useCallback(()=>{a.current&&clearTimeout(a.current),l(!1)},[]),c=Ie[e.status]||Ie.pending;return y.jsxs("div",{className:"relative",onMouseEnter:o,onMouseLeave:s,children:[t,r&&y.jsxs("div",{className:Me("absolute z-50 bottom-full left-1/2 -translate-x-1/2 mb-2","bg-[var(--surface-raised)] border border-[var(--border)] shadow-lg","rounded-lg px-3 py-2 max-w-[260px] pointer-events-none","animate-[tooltip-in_150ms_ease-out]"),children:[y.jsx("div",{className:"absolute top-full left-1/2 -translate-x-1/2 w-0 h-0 border-x-[6px] border-x-transparent border-t-[6px] border-t-[var(--border)]"}),y.jsxs("div",{className:"flex flex-col gap-1.5 text-[11px]",children:[y.jsxs("div",{className:"flex items-center gap-1.5",children:[y.jsx("span",{className:"w-2 h-2 rounded-full flex-shrink-0",style:{backgroundColor:c}}),y.jsx("span",{className:"font-medium text-[var(--text)] capitalize",children:e.status}),e.iteration!=null&&e.iteration>1&&y.jsxs("span",{className:"text-[var(--text-muted)] ml-auto",children:["iter ",e.iteration]})]}),y.jsx("div",{className:"h-px bg-[var(--border)]"}),y.jsxs("div",{className:"grid grid-cols-[auto_1fr] gap-x-3 gap-y-0.5",children:[e.elapsed!=null&&y.jsxs(y.Fragment,{children:[y.jsx("span",{className:"text-[var(--text-muted)]",children:"Elapsed"}),y.jsx("span",{className:"text-[var(--text)] font-mono",children:pt(e.elapsed)})]}),e.model&&y.jsxs(y.Fragment,{children:[y.jsx("span",{className:"text-[var(--text-muted)]",children:"Model"}),y.jsx("span",{className:"text-[var(--text)] truncate",children:e.model})]}),e.tokens!=null&&y.jsxs(y.Fragment,{children:[y.jsx("span",{className:"text-[var(--text-muted)]",children:"Tokens"}),y.jsxs("span",{className:"text-[var(--text)] font-mono",children:[Pn(e.tokens),e.inputTokens!=null&&e.outputTokens!=null&&y.jsxs("span",{className:"text-[var(--text-muted)]",children:[" ","(",Pn(e.inputTokens),"↑ ",Pn(e.outputTokens),"↓)"]})]})]}),e.costUsd!=null&&y.jsxs(y.Fragment,{children:[y.jsx("span",{className:"text-[var(--text-muted)]",children:"Cost"}),y.jsx("span",{className:"text-[var(--text)] font-mono",children:bi(e.costUsd)})]}),e.exitCode!=null&&y.jsxs(y.Fragment,{children:[y.jsx("span",{className:"text-[var(--text-muted)]",children:"Exit code"}),y.jsx("span",{className:Me("font-mono",e.exitCode===0?"text-[var(--completed)]":"text-[var(--failed)]"),children:e.exitCode})]}),e.selectedOption&&y.jsxs(y.Fragment,{children:[y.jsx("span",{className:"text-[var(--text-muted)]",children:"Selected"}),y.jsx("span",{className:"text-[var(--text)] truncate",children:e.selectedOption})]})]}),e.errorMessage&&y.jsxs(y.Fragment,{children:[y.jsx("div",{className:"h-px bg-[var(--border)]"}),y.jsxs("div",{className:"text-red-400 leading-tight",children:[e.errorType&&y.jsxs("span",{className:"font-medium",children:[e.errorType,": "]}),y.jsxs("span",{className:"break-words",children:[e.errorMessage.slice(0,120),e.errorMessage.length>120?"...":""]})]})]})]})]})]})}const S4=U.memo(function({data:t,id:r,selected:l}){var L;const a=t,o=Lr(),c=((L=o[r])==null?void 0:L.status)||a.status||"pending",h=Ie[c]||Ie.pending,d=o[r],m=d==null?void 0:d.elapsed,p=d==null?void 0:d.model,x=d==null?void 0:d.tokens,b=d==null?void 0:d.input_tokens,w=d==null?void 0:d.output_tokens,E=d==null?void 0:d.cost_usd,S=d==null?void 0:d.iteration,_=d==null?void 0:d.error_type,N=d==null?void 0:d.error_message,k=d==null?void 0:d.context_pct,T=k4(r,c),M=E4(c),A=(()=>{if(c==="failed"&&N)return{text:N.length>40?N.slice(0,37)+"...":N,className:"text-red-400"};if(c==="running")return{text:T,className:"text-[var(--text-muted)]"};if(c==="completed"){const R=[];return m!=null&&R.push(pt(m)),x!=null&&R.push(`${Pn(x)} tok`),E!=null&&R.push(bi(E)),{text:R.join(" · ")||null,className:"text-[var(--text-muted)]"}}return{text:null,className:""}})();return y.jsxs(y.Fragment,{children:[y.jsx(zt,{type:"target",position:ve.Top,className:"!bg-[var(--border)] !border-none !w-2 !h-2"}),y.jsx(as,{data:{status:c,elapsed:m,model:p,tokens:x,inputTokens:b,outputTokens:w,costUsd:E,iteration:S,errorType:_,errorMessage:N},children:y.jsxs("div",{className:Me("flex items-center gap-2 px-3 py-1.5 rounded-lg border-2 bg-[var(--node-bg)] min-w-[140px] max-w-[220px] transition-all duration-300",l&&"ring-2 ring-[var(--accent)] ring-offset-1 ring-offset-[var(--bg)]",c==="running"&&"shadow-[0_0_12px_var(--running-glow)]",M),style:{borderColor:h},children:[y.jsx("div",{className:Me("flex items-center justify-center w-6 h-6 rounded-md flex-shrink-0",c==="running"&&"animate-pulse"),style:{backgroundColor:`${h}20`},children:y.jsx(cN,{className:"w-3.5 h-3.5",style:{color:h}})}),y.jsxs("div",{className:"flex flex-col min-w-0 flex-1",children:[y.jsxs("div",{className:"flex items-center gap-1",children:[y.jsx("span",{className:"text-xs font-medium text-[var(--text)] truncate",children:a.label}),S!=null&&S>1&&y.jsxs("span",{className:"flex-shrink-0 inline-flex items-center justify-center px-1.5 py-0.5 rounded-full text-[9px] font-bold leading-none",style:{backgroundColor:`${h}25`,color:h},children:["x",S]})]}),A.text&&y.jsx("span",{className:Me("text-[10px] truncate leading-tight",A.className),children:A.text})]}),k!=null&&y.jsx("div",{className:"absolute bottom-0 left-0 right-0 h-[2px] rounded-b-lg overflow-hidden",style:{backgroundColor:"rgba(255,255,255,0.06)"},children:y.jsx("div",{className:Me("h-full transition-all duration-500",k>=x1?"animate-[context-pulse_2s_ease-in-out_infinite]":""),style:{width:`${Math.min(k,100)}%`,backgroundColor:k>=x1?"#ef4444":k>=_4?"#f59e0b":"#22c55e"}})})]})}),y.jsx(zt,{type:"source",position:ve.Bottom,className:"!bg-[var(--border)] !border-none !w-2 !h-2"})]})});function k4(e,t){var h;const r=(h=Lr()[e])==null?void 0:h.startedAt,l=ue(d=>d.replayMode),a=ue(d=>d.lastEventTime),[o,s]=U.useState("0.0s"),c=U.useRef(null);return U.useEffect(()=>{if(t==="running"){if(l){c.current&&clearInterval(c.current);const p=r??a??0;s(pt((a??p)-p));return}const d=r!=null?r*1e3:Date.now(),m=()=>{const p=(Date.now()-d)/1e3;s(pt(p))};return m(),c.current=setInterval(m,1e3),()=>{c.current&&clearInterval(c.current)}}else c.current&&clearInterval(c.current)},[t,r,l,a]),o}function E4(e){const t=U.useRef(e),[r,l]=U.useState("");return U.useEffect(()=>{const a=t.current;if(t.current=e,a===e)return;e==="running"?l("node-activate"):a==="running"&&(e==="completed"||e==="failed")&&l(e==="completed"?"node-complete":"node-fail");const o=setTimeout(()=>l(""),400);return()=>clearTimeout(o)},[e]),r}const N4=U.memo(function({data:t,id:r,selected:l}){var _;const a=t,o=Lr(),c=((_=o[r])==null?void 0:_.status)||a.status||"pending",h=Ie[c]||Ie.pending,d=o[r],m=d==null?void 0:d.elapsed,p=d==null?void 0:d.exit_code,x=d==null?void 0:d.error_type,b=d==null?void 0:d.error_message,w=C4(r,c),E=j4(c),S=(()=>{if(c==="failed"&&b)return{text:b.length>40?b.slice(0,37)+"...":b,className:"text-red-400"};if(c==="running")return{text:w,className:"text-[var(--text-muted)]"};if(c==="completed"){const N=[];return m!=null&&N.push(pt(m)),p!=null&&N.push(`exit ${p}`),{text:N.join(" · ")||null,className:"text-[var(--text-muted)]"}}return{text:null,className:""}})();return y.jsxs(y.Fragment,{children:[y.jsx(zt,{type:"target",position:ve.Top,className:"!bg-[var(--border)] !border-none !w-2 !h-2"}),y.jsx(as,{data:{status:c,elapsed:m,exitCode:p,errorType:x,errorMessage:b},children:y.jsxs("div",{className:Me("flex items-center gap-2 px-3 py-1.5 rounded-lg border-2 bg-[var(--node-bg)] min-w-[140px] max-w-[220px] transition-all duration-300",l&&"ring-2 ring-[var(--accent)] ring-offset-1 ring-offset-[var(--bg)]",c==="running"&&"shadow-[0_0_12px_var(--running-glow)]",E),style:{borderColor:h},children:[y.jsx("div",{className:Me("flex items-center justify-center w-6 h-6 rounded-md flex-shrink-0",c==="running"&&"animate-pulse"),style:{backgroundColor:`${h}20`},children:y.jsx(kN,{className:"w-3.5 h-3.5",style:{color:h}})}),y.jsxs("div",{className:"flex flex-col min-w-0 flex-1",children:[y.jsx("span",{className:"text-xs font-medium text-[var(--text)] truncate",children:a.label}),S.text&&y.jsx("span",{className:Me("text-[10px] truncate leading-tight",S.className),children:S.text})]})]})}),y.jsx(zt,{type:"source",position:ve.Bottom,className:"!bg-[var(--border)] !border-none !w-2 !h-2"})]})});function C4(e,t){var h;const r=(h=Lr()[e])==null?void 0:h.startedAt,l=ue(d=>d.replayMode),a=ue(d=>d.lastEventTime),[o,s]=U.useState("0.0s"),c=U.useRef(null);return U.useEffect(()=>{if(t==="running"){if(l){c.current&&clearInterval(c.current);const p=r??a??0;s(pt((a??p)-p));return}const d=r!=null?r*1e3:Date.now(),m=()=>{const p=(Date.now()-d)/1e3;s(pt(p))};return m(),c.current=setInterval(m,1e3),()=>{c.current&&clearInterval(c.current)}}else c.current&&clearInterval(c.current)},[t,r,l,a]),o}function j4(e){const t=U.useRef(e),[r,l]=U.useState("");return U.useEffect(()=>{const a=t.current;if(t.current=e,a===e)return;e==="running"?l("node-activate"):a==="running"&&(e==="completed"||e==="failed")&&l(e==="completed"?"node-complete":"node-fail");const o=setTimeout(()=>l(""),400);return()=>clearTimeout(o)},[e]),r}const T4=U.memo(function({data:t,id:r,selected:l}){var p,x;const a=t,o=Lr(),c=((p=o[r])==null?void 0:p.status)||a.status||"pending",h=Ie[c]||Ie.pending,d=(x=o[r])==null?void 0:x.selected_option,m=A4(c);return y.jsxs(y.Fragment,{children:[y.jsx(zt,{type:"target",position:ve.Top,className:"!bg-[var(--border)] !border-none !w-2 !h-2"}),y.jsx(as,{data:{status:c,selectedOption:d},children:y.jsxs("div",{className:Me("flex items-center gap-2 px-3 py-1.5 rounded-lg border-2 border-dashed bg-[var(--node-bg)] min-w-[140px] max-w-[220px] transition-all duration-300",l&&"ring-2 ring-[var(--accent)] ring-offset-1 ring-offset-[var(--bg)]",c==="waiting"&&"shadow-[0_0_12px_var(--waiting-muted)]",c==="running"&&"shadow-[0_0_12px_var(--running-glow)]",m),style:{borderColor:h},children:[y.jsx("div",{className:Me("flex items-center justify-center w-6 h-6 rounded-md flex-shrink-0",c==="waiting"&&"animate-pulse"),style:{backgroundColor:`${h}20`},children:y.jsx(SN,{className:"w-3.5 h-3.5",style:{color:h}})}),y.jsxs("div",{className:"flex flex-col min-w-0 flex-1",children:[y.jsx("span",{className:"text-xs font-medium text-[var(--text)] truncate",children:a.label}),c==="waiting"&&y.jsx("span",{className:"text-[10px] text-[var(--waiting)] truncate leading-tight",children:"Awaiting input..."}),c==="completed"&&d&&y.jsx("span",{className:"text-[10px] text-[var(--text-muted)] truncate leading-tight",children:d})]})]})}),y.jsx(zt,{type:"source",position:ve.Bottom,className:"!bg-[var(--border)] !border-none !w-2 !h-2"})]})});function A4(e){const t=U.useRef(e),[r,l]=U.useState("");return U.useEffect(()=>{const a=t.current;if(t.current=e,a===e)return;e==="running"||e==="waiting"?l("node-activate"):(a==="running"||a==="waiting")&&e==="completed"&&l("node-complete");const o=setTimeout(()=>l(""),400);return()=>clearTimeout(o)},[e]),r}const z4=U.memo(function({data:t,id:r,selected:l}){var S;const a=t,s=a.type==="for_each_group"?wN:yN,c=a.progress,m=((S=Lr()[r])==null?void 0:S.status)||a.status||"pending",p=Ie[m]||Ie.pending,x=M4(m),b=c?`${c.completed+c.failed}/${c.total}${c.failed>0?` (${c.failed} failed)`:""}`:null,w=c&&c.total>0?(c.completed+c.failed)/c.total*100:0,E=c!=null&&c.failed>0;return y.jsxs(y.Fragment,{children:[y.jsx(zt,{type:"target",position:ve.Top,className:"!bg-[var(--border)] !border-none !w-2 !h-2"}),y.jsxs("div",{className:Me("flex flex-col gap-1 px-4 py-3 rounded-xl border-2 border-dashed bg-[var(--surface)]/80 min-w-[180px] transition-all duration-300",l&&"ring-2 ring-[var(--accent)] ring-offset-1 ring-offset-[var(--bg)]",m==="running"&&"shadow-[0_0_16px_var(--running-glow)]",x),style:{borderColor:p,minHeight:"100%"},children:[y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx(s,{className:"w-3.5 h-3.5",style:{color:p}}),y.jsx("span",{className:"text-xs font-medium text-[var(--text-secondary)]",children:a.label})]}),b&&y.jsx("span",{className:"text-[10px] text-[var(--text-muted)] font-mono",children:b}),c&&c.total>0&&m==="running"&&y.jsx("div",{className:"w-full h-1 rounded-full bg-[var(--border)] overflow-hidden mt-0.5",children:y.jsx("div",{className:"h-full rounded-full transition-all duration-500 ease-out",style:{width:`${w}%`,backgroundColor:E?"var(--failed)":"var(--completed)"}})})]}),y.jsx(zt,{type:"source",position:ve.Bottom,className:"!bg-[var(--border)] !border-none !w-2 !h-2"})]})});function M4(e){const t=U.useRef(e),[r,l]=U.useState("");return U.useEffect(()=>{const a=t.current;if(t.current=e,a===e)return;e==="running"?l("node-activate"):a==="running"&&(e==="completed"||e==="failed")&&l(e==="completed"?"node-complete":"node-fail");const o=setTimeout(()=>l(""),400);return()=>clearTimeout(o)},[e]),r}const D4=U.memo(function({data:t,id:r,selected:l}){const a=t,s=ue(S=>{var _;return(_=S.nodes[r])==null?void 0:_.status})||a.status||"pending",c=Ie[s]||Ie.pending,h=ue(S=>{var _;return(_=S.nodes[r])==null?void 0:_.elapsed}),d=ue(S=>{var _;return(_=S.nodes[r])==null?void 0:_.error_message}),m=ue(S=>S.navigateIntoSubworkflow),p=Um(),x=p.some(S=>S.parentAgent===r),b=p.find(S=>S.parentAgent===r),w=b==null?void 0:b.workflowName,E=(()=>{if(s==="failed"&&d)return{text:d.length>35?d.slice(0,32)+"...":d,className:"text-red-400"};if(s==="running")return{text:w||"Running subworkflow…",className:"text-[var(--text-muted)]"};if(s==="completed"){const S=[];return w&&S.push(w),h!=null&&S.push(`${h.toFixed(1)}s`),{text:S.join(" · ")||"Done",className:"text-[var(--text-muted)]"}}return{text:w||null,className:"text-[var(--text-muted)]"}})();return y.jsxs(y.Fragment,{children:[y.jsx(zt,{type:"target",position:ve.Top,className:"!bg-[var(--border)] !border-none !w-2 !h-2"}),y.jsx(as,{data:{status:s,elapsed:h,errorType:void 0,errorMessage:d,iteration:void 0},children:y.jsxs("div",{className:Me("flex items-center gap-2 px-3 py-1.5 rounded-lg border-2 bg-[var(--node-bg)] min-w-[140px] max-w-[240px] transition-all duration-300 cursor-pointer",l&&"ring-2 ring-[var(--accent)] ring-offset-1 ring-offset-[var(--bg)]",s==="running"&&"shadow-[0_0_12px_var(--running-glow)]"),style:{borderColor:c,borderStyle:"dashed"},onDoubleClick:S=>{x&&(S.stopPropagation(),m(r))},children:[y.jsx("div",{className:Me("flex items-center justify-center w-6 h-6 rounded-md flex-shrink-0",s==="running"&&"animate-pulse"),style:{backgroundColor:`${c}20`},children:y.jsx(kc,{className:"w-3.5 h-3.5",style:{color:c}})}),y.jsxs("div",{className:"flex flex-col min-w-0 flex-1",children:[y.jsx("div",{className:"flex items-center gap-1",children:y.jsx("span",{className:"text-xs font-medium text-[var(--text)] truncate",children:a.label})}),E.text&&y.jsx("span",{className:Me("text-[10px] truncate leading-tight",E.className),children:E.text})]}),x&&y.jsx(Rr,{className:"w-3.5 h-3.5 flex-shrink-0 text-[var(--text-muted)]"})]})}),y.jsx(zt,{type:"source",position:ve.Bottom,className:"!bg-[var(--border)] !border-none !w-2 !h-2"})]})}),R4=U.memo(function({data:t,id:r,selected:l}){var k;const a=t,o=Lr(),c=((k=o[r])==null?void 0:k.status)||a.status||"pending",h=Ie[c]||Ie.pending,d=o[r],m=(d==null?void 0:d.duration_seconds)??(d==null?void 0:d.requested_seconds),p=d==null?void 0:d.waited_seconds,x=d==null?void 0:d.elapsed,b=d==null?void 0:d.interrupted,w=d==null?void 0:d.error_type,E=d==null?void 0:d.error_message,S=O4(r,c),_=L4(c),N=(()=>{if(c==="failed"&&E)return{text:E.length>40?E.slice(0,37)+"...":E,className:"text-red-400"};if(c==="running"){const T=typeof m=="number"?` / ${pt(m)}`:"";return{text:`${S}${T}`,className:"text-[var(--text-muted)]"}}if(c==="completed"){const T=[];return p!=null?T.push(pt(p)):x!=null&&T.push(pt(x)),b&&T.push("interrupted"),{text:T.join(" · ")||null,className:"text-[var(--text-muted)]"}}return c==="pending"&&typeof m=="number"?{text:pt(m),className:"text-[var(--text-muted)]"}:{text:null,className:""}})();return y.jsxs(y.Fragment,{children:[y.jsx(zt,{type:"target",position:ve.Top,className:"!bg-[var(--border)] !border-none !w-2 !h-2"}),y.jsx(as,{data:{status:c,elapsed:p??x,errorType:w,errorMessage:E},children:y.jsxs("div",{className:Me("flex items-center gap-2 px-3 py-1.5 rounded-lg border-2 bg-[var(--node-bg)] min-w-[140px] max-w-[220px] transition-all duration-300",l&&"ring-2 ring-[var(--accent)] ring-offset-1 ring-offset-[var(--bg)]",c==="running"&&"shadow-[0_0_12px_var(--running-glow)]",_),style:{borderColor:h},children:[y.jsx("div",{className:Me("flex items-center justify-center w-6 h-6 rounded-md flex-shrink-0",c==="running"&&"animate-pulse"),style:{backgroundColor:`${h}20`},children:y.jsx(xw,{className:"w-3.5 h-3.5",style:{color:h}})}),y.jsxs("div",{className:"flex flex-col min-w-0 flex-1",children:[y.jsx("span",{className:"text-xs font-medium text-[var(--text)] truncate",children:a.label}),N.text&&y.jsx("span",{className:Me("text-[10px] truncate leading-tight",N.className),children:N.text})]})]})}),y.jsx(zt,{type:"source",position:ve.Bottom,className:"!bg-[var(--border)] !border-none !w-2 !h-2"})]})});function O4(e,t){var h;const r=(h=Lr()[e])==null?void 0:h.startedAt,l=ue(d=>d.replayMode),a=ue(d=>d.lastEventTime),[o,s]=U.useState("0.0s"),c=U.useRef(null);return U.useEffect(()=>{if(t==="running"){if(l){c.current&&clearInterval(c.current);const p=r??a??0;s(pt((a??p)-p));return}const d=r!=null?r*1e3:Date.now(),m=()=>{const p=(Date.now()-d)/1e3;s(pt(p))};return m(),c.current=setInterval(m,1e3),()=>{c.current&&clearInterval(c.current)}}else c.current&&clearInterval(c.current)},[t,r,l,a]),o}function L4(e){const t=U.useRef(e),[r,l]=U.useState("");return U.useEffect(()=>{const a=t.current;if(t.current=e,a===e)return;e==="running"?l("node-activate"):a==="running"&&(e==="completed"||e==="failed")&&l(e==="completed"?"node-complete":"node-fail");const o=setTimeout(()=>l(""),400);return()=>clearTimeout(o)},[e]),r}const H4=U.memo(function({data:t,selected:r}){const a=t.status||"pending",o=a==="completed",s=a==="failed",c=!o&&!s,h=o?Ie.completed:s?Ie.failed:Ie.pending;return y.jsxs(y.Fragment,{children:[y.jsx(zt,{type:"target",position:ve.Top,className:"!bg-[var(--border)] !border-none !w-2 !h-2"}),y.jsx("div",{className:Me("flex items-center justify-center w-11 h-11 rounded-full border-2 transition-all duration-300",o?"bg-[var(--completed)] shadow-[0_0_16px_var(--completed-muted)]":s?"bg-[var(--failed)] shadow-[0_0_16px_var(--failed-muted)]":"bg-[var(--node-bg)]",r&&"ring-2 ring-[var(--accent)] ring-offset-1 ring-offset-[var(--bg)]"),style:{borderColor:h},children:o?y.jsx(Zi,{className:"w-5 h-5 text-white",strokeWidth:3}):s?y.jsx(Sw,{className:"w-3.5 h-3.5 text-white",fill:"white"}):y.jsx(Zi,{className:"w-5 h-5",strokeWidth:2.5,style:{color:c?Ie.pending:h}})})]})}),B4=U.memo(function({data:t,selected:r}){const a=t.status||"pending",o=Ie[a]||Ie.pending,s=a==="running"||a==="completed";return y.jsxs(y.Fragment,{children:[y.jsx("div",{className:Me("flex items-center justify-center w-11 h-11 rounded-full border-2 transition-all duration-300",s?"bg-[var(--completed)]":"bg-[var(--node-bg)]",r&&"ring-2 ring-[var(--accent)] ring-offset-1 ring-offset-[var(--bg)]",s&&"shadow-[0_0_12px_var(--completed-muted)]"),style:{borderColor:o},children:y.jsx(Ec,{className:"w-4 h-4 ml-0.5",style:{color:s?"white":o}})}),y.jsx(zt,{type:"source",position:ve.Bottom,className:"!bg-[var(--border)] !border-none !w-2 !h-2"})]})}),y1="#a78bfa",I4=U.memo(function({data:t,selected:r}){const l=t,a=l.status||"pending",o=a==="running"||a==="completed",s=o?y1:Ie[a]||y1,c=l.parentAgent,h=ue(d=>d.navigateUp);return y.jsxs(y.Fragment,{children:[y.jsxs("div",{className:"flex flex-col items-center gap-1",children:[y.jsx("div",{className:Me("flex items-center justify-center w-11 h-11 rounded-full border-2 border-dashed transition-all duration-300 cursor-pointer",o?"bg-[#a78bfa]":"bg-[var(--node-bg)]",r&&"ring-2 ring-[var(--accent)] ring-offset-1 ring-offset-[var(--bg)]",o&&"shadow-[0_0_12px_rgba(167,139,250,0.4)]"),style:{borderColor:s},onDoubleClick:d=>{d.stopPropagation(),h()},children:y.jsx(sN,{className:"w-4 h-4",style:{color:o?"white":s}})}),c&&y.jsxs("span",{className:"text-[10px] text-[var(--text-muted)] whitespace-nowrap",children:["from ",y.jsx("span",{className:"font-medium text-[var(--text)]",children:c})]})]}),y.jsx(zt,{type:"source",position:ve.Bottom,className:"!bg-[var(--border)] !border-none !w-2 !h-2"})]})}),v1="#a78bfa",q4=U.memo(function({data:t,selected:r}){const l=t,a=l.status||"pending",o=a==="completed",s=a==="failed",c=o?v1:s?Ie.failed:v1,h=l.parentAgent,d=ue(m=>m.navigateUp);return y.jsxs(y.Fragment,{children:[y.jsx(zt,{type:"target",position:ve.Top,className:"!bg-[var(--border)] !border-none !w-2 !h-2"}),y.jsxs("div",{className:"flex flex-col items-center gap-1",children:[y.jsx("div",{className:Me("flex items-center justify-center w-11 h-11 rounded-full border-2 border-dashed transition-all duration-300 cursor-pointer",o?"bg-[#a78bfa] shadow-[0_0_12px_rgba(167,139,250,0.4)]":s?"bg-[var(--failed)] shadow-[0_0_16px_var(--failed-muted)]":"bg-[var(--node-bg)]",r&&"ring-2 ring-[var(--accent)] ring-offset-1 ring-offset-[var(--bg)]"),style:{borderColor:c},onDoubleClick:m=>{m.stopPropagation(),d()},children:y.jsx(uN,{className:"w-4 h-4",style:{color:o||s?"white":c}})}),h&&y.jsxs("span",{className:"text-[10px] text-[var(--text-muted)] whitespace-nowrap",children:["return to ",y.jsx("span",{className:"font-medium text-[var(--text)]",children:h})]})]})]})}),U4=U.memo(function({id:t,sourceX:r,sourceY:l,targetX:a,targetY:o,sourcePosition:s,targetPosition:c,source:h,target:d,data:m}){const p=j5(),x=U.useMemo(()=>p.find(V=>V.from===h&&V.to===d),[p,h,d]),[b,w,E]=Rm({sourceX:r,sourceY:l,targetX:a,targetY:o,sourcePosition:s,targetPosition:c}),S=m==null?void 0:m.when,_=!!S,N=(x==null?void 0:x.state)==="taken",k=(x==null?void 0:x.state)==="highlighted",T=(x==null?void 0:x.state)==="failed";let M="var(--edge-color)",A=2,L;T?(M="var(--failed)",A=3):N?(M="var(--edge-taken)",A=3):k&&(M="var(--edge-active)",A=3),_&&!N&&!k&&!T&&(L="6 3");const R=T?"failed":N?"taken":k?"active":"default";return y.jsxs(y.Fragment,{children:[y.jsx(is,{id:t,path:b,style:{stroke:M,strokeWidth:A,strokeDasharray:L,transition:"stroke 0.3s ease, stroke-width 0.3s ease"},markerEnd:`url(#arrow-${R})`}),_&&y.jsx(ZM,{children:y.jsx("div",{className:"nodrag nopan",style:{position:"absolute",transform:`translate(-50%, -50%) translate(${w}px,${E}px)`,pointerEvents:"all"},children:y.jsx("span",{className:"inline-block px-1.5 py-0.5 rounded-full text-[9px] font-mono leading-tight max-w-[140px] truncate",style:{backgroundColor:T?"var(--failed)":N?"var(--edge-taken)":"var(--surface)",color:T||N?"var(--bg)":"var(--text-muted)",border:`1px solid ${T?"var(--failed)":N?"var(--edge-taken)":"var(--border)"}`},title:S,children:S})})}),N&&y.jsx("circle",{r:"3",fill:"var(--edge-taken)",children:y.jsx("animateMotion",{dur:"1s",repeatCount:"indefinite",path:b})}),T&&y.jsx("circle",{r:"3",fill:"var(--failed)",opacity:"0.8",children:y.jsx("animateMotion",{dur:"1.5s",repeatCount:"indefinite",path:b})})]})});function $4(){const e=ue(s=>s.workflowStatus),t=ue(s=>s.workflowFailure),r=ue(s=>s.workflowFailedAgent),l=ue(s=>s.selectNode);if(e!=="failed"||!t)return null;const a=t.message||t.error_type||"Unknown error",o=t.error_type==="TimeoutError";return y.jsx("div",{className:"absolute top-3 left-1/2 -translate-x-1/2 z-20 animate-[banner-in_200ms_ease-out]",children:y.jsxs("div",{className:Me("flex items-center gap-2 px-4 py-2 rounded-lg","bg-red-950/90 border border-red-500/40 shadow-lg shadow-red-500/10","backdrop-blur-sm max-w-[560px]"),children:[y.jsx(lc,{className:"w-4 h-4 text-red-400 flex-shrink-0"}),y.jsxs("div",{className:"flex flex-col min-w-0",children:[y.jsx("span",{className:"text-xs font-medium text-red-300",children:"Workflow Failed"}),y.jsx("span",{className:"text-[11px] text-red-400/80 truncate",children:a}),o&&t.current_agent&&y.jsxs("span",{className:"text-[10px] text-red-400/60 truncate",children:["Timed out on agent: ",t.current_agent]}),t.checkpoint_path&&y.jsxs("span",{className:"text-[10px] text-red-400/50 truncate",title:t.checkpoint_path,children:["Checkpoint: ",t.checkpoint_path.split("/").pop()]})]}),r&&y.jsxs("button",{onClick:()=>l(r),className:"flex items-center gap-1 px-2 py-1 rounded text-[10px] font-medium text-red-300 bg-red-500/20 hover:bg-red-500/30 transition-colors flex-shrink-0 ml-1",children:[y.jsx(mN,{className:"w-3 h-3"}),"View"]})]})})}function V4(){const[e,t]=U.useState(!1),r=ue(h=>h.workflowStatus),l=ue(h=>h.totalCost),a=ue(h=>h.totalTokens),o=ue(h=>h.agentsCompleted),s=ue(h=>h.agentsTotal),c=Ew();return r!=="completed"||e?null:y.jsx("div",{className:"absolute top-3 left-1/2 -translate-x-1/2 z-20 animate-[banner-in_200ms_ease-out]",children:y.jsxs("div",{className:Me("flex items-center gap-3 px-4 py-2 rounded-lg","bg-green-950/90 border border-green-500/40 shadow-lg shadow-green-500/10","backdrop-blur-sm"),children:[y.jsx(dN,{className:"w-4 h-4 text-green-400 flex-shrink-0"}),y.jsx("span",{className:"text-xs font-medium text-green-300",children:"Completed"}),y.jsxs("div",{className:"flex items-center gap-3 text-[11px] text-green-400/80 font-mono",children:[y.jsx("span",{children:c}),s>0&&y.jsxs("span",{children:[o,"/",s," agents"]}),a>0&&y.jsxs("span",{children:[Pn(a)," tok"]}),l>0&&y.jsx("span",{children:bi(l)})]}),y.jsx("button",{onClick:()=>t(!0),className:"p-0.5 rounded text-green-500/60 hover:text-green-300 transition-colors flex-shrink-0 ml-1",children:y.jsx(sl,{className:"w-3.5 h-3.5"})})]})})}const P4={agentNode:S4,scriptNode:N4,gateNode:T4,groupNode:z4,workflowNode:D4,waitNode:R4,endNode:H4,startNode:B4,ingressNode:I4,egressNode:q4},G4={animatedEdge:U4},F4={type:"animatedEdge"};function Y4(){return y.jsx("svg",{style:{position:"absolute",width:0,height:0},children:y.jsxs("defs",{children:[y.jsx("marker",{id:"arrow-default",viewBox:"0 0 10 10",refX:"8",refY:"5",markerWidth:"8",markerHeight:"8",orient:"auto-start-reverse",children:y.jsx("path",{d:"M 0 0 L 10 5 L 0 10 z",fill:"var(--edge-color)"})}),y.jsx("marker",{id:"arrow-active",viewBox:"0 0 10 10",refX:"8",refY:"5",markerWidth:"8",markerHeight:"8",orient:"auto-start-reverse",children:y.jsx("path",{d:"M 0 0 L 10 5 L 0 10 z",fill:"var(--edge-active)"})}),y.jsx("marker",{id:"arrow-taken",viewBox:"0 0 10 10",refX:"8",refY:"5",markerWidth:"8",markerHeight:"8",orient:"auto-start-reverse",children:y.jsx("path",{d:"M 0 0 L 10 5 L 0 10 z",fill:"var(--edge-taken)"})}),y.jsx("marker",{id:"arrow-failed",viewBox:"0 0 10 10",refX:"8",refY:"5",markerWidth:"8",markerHeight:"8",orient:"auto-start-reverse",children:y.jsx("path",{d:"M 0 0 L 10 5 L 0 10 z",fill:"var(--failed)"})})]})})}function X4(){const e=T5(),t=ue(z=>z.viewContextPath),r=ue(z=>z.selectNode),l=ue(z=>z.selectedNode),a=ue(z=>z.workflowStatus),o=ue(z=>z.wsStatus),s=ue(z=>z.workflowFailedAgent),c=ue(z=>z.navigateIntoSubworkflow),{agents:h,routes:d,parallelGroups:m,forEachGroups:p,nodes:x,groupProgress:b,entryPoint:w,subworkflowContexts:E,parentAgent:S}=e,[_,N,k]=KM([]),[T,M,A]=JM([]),L=U.useRef(!1),R=U.useRef(""),V=JSON.stringify(t);U.useEffect(()=>{if(h.length===0){R.current!==V&&(L.current=!1,R.current=V,N([]),M([]));return}if(R.current!==V&&(L.current=!1,R.current=V),L.current)return;L.current=!0;const{nodes:z,edges:G}=v4(h,d,m,p,x,b,w,S);N(z),M(G)},[h,d,m,p,x,b,w,N,M,V,S]),U.useEffect(()=>{L.current&&N(z=>z.map(G=>{const Q=x[G.id];if(!Q)return G;const K=Q.status||"pending",D=G.data.status;if(K!==D){const q={...G.data,status:K};return G.data.groupName&&b[G.data.groupName]&&(q.progress=b[G.data.groupName]),{...G,data:q}}if(G.data.groupName&&b[G.data.groupName]){const q=G.data.progress,Y=b[G.data.groupName];if(Y&&(!q||q.completed!==Y.completed||q.failed!==Y.failed))return{...G,data:{...G.data,progress:Y}}}return G}))},[x,b,N]);const H=U.useCallback((z,G)=>{G.type==="groupNode"&&G.data.type!=="for_each_group"||r(G.id)},[r]),B=U.useCallback((z,G)=>{E.some(K=>K.parentAgent===G.id)&&c(G.id)},[E,c]),$=U.useCallback(()=>{r(null)},[r]),ee=U.useCallback(z=>{var Q;const G=((Q=z.data)==null?void 0:Q.status)||"pending";return Ie[G]??Ie.pending??"#6b7280"},[]);U.useEffect(()=>{N(z=>z.map(G=>({...G,selected:G.id===l})))},[l,N]),U.useEffect(()=>{a==="failed"&&s&&r(s)},[a,s,r]);const I=a==="pending"&&h.length===0,F=(()=>{switch(o){case"connecting":return"Connecting to workflow…";case"reconnecting":return"Reconnecting…";case"disconnected":return"Connection lost. Retrying…";default:return"Waiting for workflow…"}})();return y.jsxs("div",{className:"w-full h-full relative",children:[y.jsx(Y4,{}),y.jsx($4,{}),y.jsx(V4,{}),I&&y.jsxs("div",{className:"absolute inset-0 z-10 flex flex-col items-center justify-center pointer-events-none",children:[y.jsxs("div",{className:"relative mb-3",children:[y.jsx(CN,{className:"w-8 h-8 text-[var(--accent)] opacity-20"}),y.jsx(fa,{className:"w-8 h-8 text-[var(--text-muted)] animate-spin absolute inset-0 opacity-40"})]}),y.jsx("p",{className:"text-sm text-[var(--text-muted)] animate-pulse",children:F})]}),y.jsxs(XM,{nodes:_,edges:T,onNodesChange:k,onEdgesChange:A,onNodeClick:H,onNodeDoubleClick:B,onPaneClick:$,nodeTypes:P4,edgeTypes:G4,defaultEdgeOptions:F4,fitView:!0,fitViewOptions:{padding:.2},minZoom:.2,maxZoom:2,proOptions:{hideAttribution:!0},nodesDraggable:!0,nodesConnectable:!1,elementsSelectable:!0,children:[y.jsx(r5,{variant:Mr.Dots,gap:20,size:1,color:"var(--border-subtle)"}),y.jsx(S5,{nodeColor:ee,maskColor:"var(--minimap-mask)",style:{background:"var(--minimap-bg)"},pannable:!0,zoomable:!0}),y.jsx(c5,{showInteractive:!1,children:y.jsx(Q4,{})}),y.jsx(Z4,{}),y.jsx(K4,{viewPathKey:V}),y.jsx(J4,{})]})]})}function Q4(){const{fitView:e}=ul(),t=U.useCallback(()=>{e({padding:.2,duration:300})},[e]);return y.jsx("button",{onClick:t,className:"react-flow__controls-button",title:"Fit view (F)",style:{display:"flex",alignItems:"center",justifyContent:"center"},children:y.jsx(vN,{className:"w-3.5 h-3.5"})})}function Z4(){const{fitView:e}=ul();return U.useEffect(()=>{const t=r=>{var a;const l=(a=r.target)==null?void 0:a.tagName;l==="INPUT"||l==="TEXTAREA"||l==="SELECT"||r.key==="f"&&!r.ctrlKey&&!r.metaKey&&!r.altKey&&e({padding:.2,duration:300})};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[e]),null}function K4({viewPathKey:e}){const{fitView:t}=ul(),r=U.useRef(e);return U.useEffect(()=>{r.current!==e&&(r.current=e,setTimeout(()=>t({padding:.2,duration:300}),50))},[e,t]),null}function J4(){const e=D5();return e?y.jsx("div",{className:"absolute top-3 left-1/2 -translate-x-1/2 z-20 animate-[banner-in_200ms_ease-out]",children:y.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 rounded-lg bg-amber-950/90 border border-amber-500/40 shadow-lg shadow-amber-500/10 backdrop-blur-sm max-w-[560px]",children:[y.jsx("span",{className:"text-xs text-amber-300",children:"⚠"}),y.jsx("span",{className:"text-[11px] text-amber-400/80",children:e.message}),y.jsx("a",{href:window.location.pathname,className:"px-2 py-0.5 rounded text-[10px] font-medium text-amber-300 bg-amber-500/20 hover:bg-amber-500/30 transition-colors flex-shrink-0 ml-1",children:"Root"})]})}):null}function wi({items:e}){const t=e.filter(r=>r.value!=null&&r.value!=="");return t.length===0?null:y.jsx("dl",{className:"grid grid-cols-[auto_1fr] gap-x-3 gap-y-1.5 text-xs",children:t.map(({label:r,value:l})=>y.jsxs("div",{className:"contents",children:[y.jsx("dt",{className:"text-[var(--text-muted)] whitespace-nowrap",children:r}),y.jsx("dd",{className:"text-[var(--text)] break-words",children:typeof l=="object"?JSON.stringify(l):String(l)})]},r))})}function OS(e){const t=[];return e.elapsed!=null&&t.push({label:"Elapsed",value:pt(e.elapsed)}),e.model&&t.push({label:"Model",value:e.model}),e.reasoning_effort&&t.push({label:"Reasoning",value:e.reasoning_effort}),e.tokens!=null&&t.push({label:"Tokens",value:Pn(e.tokens)}),e.input_tokens!=null&&e.output_tokens!=null&&t.push({label:"In / Out",value:`${Pn(e.input_tokens)} / ${Pn(e.output_tokens)}`}),e.cost_usd!=null&&t.push({label:"Cost",value:bi(e.cost_usd)}),e.context_window_used!=null&&e.context_window_max!=null&&t.push({label:"Context",value:IN(e.context_window_used,e.context_window_max)}),e.iteration!=null&&t.push({label:"Iteration",value:e.iteration}),e.error_type&&t.push({label:"Error",value:e.error_type}),e.error_message&&t.push({label:"Message",value:e.error_message}),t}function ll({output:e,title:t="Output",defaultExpanded:r=!0,maxHeight:l="300px"}){const[a,o]=U.useState(r),[s,c]=U.useState(!1),h=kw(e);if(!h)return null;const d=typeof e=="object"&&e!==null,m=async()=>{await navigator.clipboard.writeText(h),c(!0),setTimeout(()=>c(!1),2e3)};return y.jsxs("div",{className:"space-y-1.5",children:[y.jsxs("div",{className:"flex items-center justify-between",children:[y.jsxs("button",{onClick:()=>o(!a),className:"flex items-center gap-1 text-[10px] uppercase tracking-wider text-[var(--text-muted)] hover:text-[var(--text)] transition-colors font-semibold",children:[a?y.jsx(ol,{className:"w-3 h-3"}):y.jsx(Rr,{className:"w-3 h-3"}),t]}),a&&y.jsx("button",{onClick:m,className:"flex items-center gap-1 text-[10px] text-[var(--text-muted)] hover:text-[var(--text)] transition-colors",title:"Copy to clipboard",children:s?y.jsx(Zi,{className:"w-3 h-3 text-[var(--completed)]"}):y.jsx(vw,{className:"w-3 h-3"})})]}),a&&y.jsx("pre",{className:"bg-[var(--bg)] border border-[var(--border)] rounded-md p-3 font-mono text-[11px] leading-relaxed text-[var(--text)] overflow-auto whitespace-pre-wrap break-words",style:{maxHeight:l},children:d?y.jsx(W4,{text:h}):h})]})}function W4({text:e}){const t=e.split(/("(?:[^"\\]|\\.)*")/g);return y.jsx(y.Fragment,{children:t.map((r,l)=>{if(l%2===1){const o=t.slice(l+1).join(""),s=/^\s*:/.test(o);return y.jsx("span",{className:s?"text-blue-400":"text-green-400",children:r},l)}const a=r.replace(/\b(true|false|null)\b|(-?\d+\.?\d*(?:e[+-]?\d+)?)/gi,(o,s,c)=>s?`${o}`:c?`${o}`:o);return y.jsx("span",{dangerouslySetInnerHTML:{__html:a}},l)})})}function Vm({activity:e,defaultExpanded:t=!0}){const[r,l]=U.useState(t),a=U.useRef(null);return U.useEffect(()=>{a.current&&r&&(a.current.scrollTop=a.current.scrollHeight)},[e.length,r]),e.length===0?null:y.jsxs("div",{className:"space-y-1.5",children:[y.jsxs("button",{onClick:()=>l(!r),className:"flex items-center gap-1 text-[10px] uppercase tracking-wider text-[var(--text-muted)] hover:text-[var(--text)] transition-colors font-semibold",children:[r?y.jsx(ol,{className:"w-3 h-3"}):y.jsx(Rr,{className:"w-3 h-3"}),"Activity (",e.length,")"]}),r&&y.jsx("div",{ref:a,className:"max-h-[400px] overflow-y-auto space-y-0.5",children:e.map((o,s)=>y.jsx(eD,{entry:o},s))})]})}function eD({entry:e}){const t={reasoning:"text-indigo-400/70","tool-start":"text-blue-400","tool-complete":"text-green-400",turn:"text-amber-400",message:"text-[var(--text)]"};return y.jsxs("div",{className:Me("py-1.5 px-2 rounded text-[11px] leading-relaxed border-b border-[var(--border-subtle)] last:border-b-0"),children:[y.jsxs("div",{className:"flex items-start gap-1.5",children:[y.jsx("span",{className:"w-4 text-center flex-shrink-0",children:e.icon}),y.jsx("span",{className:"text-[var(--text-muted)] uppercase text-[9px] font-semibold tracking-wider w-12 flex-shrink-0 pt-px",children:e.label}),y.jsx("span",{className:Me("break-words",t[e.type]||"text-[var(--text)]"),children:typeof e.text=="object"?JSON.stringify(e.text):e.text})]}),e.detail&&y.jsx("div",{className:"mt-1 ml-[4.25rem] px-2 py-1 bg-[var(--bg)] rounded text-[10px] font-mono text-[var(--text-muted)] whitespace-pre-wrap break-words max-h-24 overflow-y-auto",children:typeof e.detail=="object"?JSON.stringify(e.detail,null,2):e.detail})]})}function b1({node:e}){const t=e.status,r=Ie[t]||Ie.pending,l=e.iterationHistory&&e.iterationHistory.length>0;return y.jsxs("div",{className:"space-y-4",children:[y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx("span",{className:"inline-flex items-center px-2 py-0.5 rounded text-[10px] font-bold uppercase tracking-wider",style:{backgroundColor:`${r}20`,color:r},children:t}),y.jsx("span",{className:"text-xs text-[var(--text-muted)]",children:"Agent"})]}),l?y.jsx(w1,{label:`Iteration ${e.iteration??"?"} (current)`,defaultExpanded:!0,status:t,snapshot:{iteration:e.iteration??0,prompt:e.prompt,output:e.output,elapsed:e.elapsed,model:e.model,reasoning_effort:e.reasoning_effort,tokens:e.tokens,input_tokens:e.input_tokens,output_tokens:e.output_tokens,cost_usd:e.cost_usd,activity:e.activity,error_type:e.error_type,error_message:e.error_message}}):y.jsxs(y.Fragment,{children:[y.jsx(wi,{items:OS(e)}),e.prompt&&y.jsx(ll,{output:e.prompt,title:"Input / Prompt",defaultExpanded:!0}),y.jsx(Vm,{activity:e.activity,defaultExpanded:t!=="completed"}),e.output!=null&&y.jsx(ll,{output:e.output,title:"Output"})]}),l&&[...e.iterationHistory].reverse().map(a=>y.jsx(w1,{label:`Iteration ${a.iteration}`,defaultExpanded:!1,status:t,snapshot:a},a.iteration))]})}function w1({label:e,defaultExpanded:t,snapshot:r,status:l}){const[a,o]=U.useState(t);return y.jsxs("div",{className:"border border-[var(--border)] rounded-lg overflow-hidden",children:[y.jsxs("button",{onClick:()=>o(!a),className:"flex items-center gap-2 w-full px-3 py-2 bg-[var(--bg)] hover:bg-[var(--node-bg)] transition-colors text-left",children:[a?y.jsx(ol,{className:"w-3.5 h-3.5 text-[var(--text-muted)] flex-shrink-0"}):y.jsx(Rr,{className:"w-3.5 h-3.5 text-[var(--text-muted)] flex-shrink-0"}),y.jsx("span",{className:"text-xs font-semibold text-[var(--text)]",children:e}),r.elapsed!=null&&y.jsx("span",{className:"text-[10px] text-[var(--text-muted)] ml-auto",children:tD(r.elapsed)})]}),a&&y.jsxs("div",{className:"px-3 py-3 space-y-3 border-t border-[var(--border)]",children:[y.jsx(wi,{items:OS(r)}),r.prompt&&y.jsx(ll,{output:r.prompt,title:"Input / Prompt",defaultExpanded:!1}),y.jsx(Vm,{activity:r.activity,defaultExpanded:t&&l!=="completed"}),r.output!=null&&y.jsx(ll,{output:r.output,title:"Output",defaultExpanded:!0}),r.error_type&&y.jsxs("div",{className:"text-xs text-red-400",children:[y.jsx("span",{className:"font-semibold",children:r.error_type}),r.error_message&&y.jsxs("span",{className:"ml-1",children:["— ",r.error_message]})]})]})]})}function tD(e){if(e<1)return`${(e*1e3).toFixed(0)}ms`;if(e<60)return`${e.toFixed(1)}s`;const t=Math.floor(e/60),r=(e%60).toFixed(0);return`${t}m ${r}s`}function nD({node:e}){const t=e.status,r=Ie[t]||Ie.pending,l=[];e.elapsed!=null&&l.push({label:"Elapsed",value:pt(e.elapsed)}),e.exit_code!=null&&l.push({label:"Exit Code",value:e.exit_code}),e.error_type&&l.push({label:"Error",value:e.error_type}),e.error_message&&l.push({label:"Message",value:e.error_message});let a="";return e.stdout&&(a+=e.stdout),e.stderr&&(a+=(a?` + +--- stderr --- +`:"")+e.stderr),y.jsxs("div",{className:"space-y-4",children:[y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx("span",{className:"inline-flex items-center px-2 py-0.5 rounded text-[10px] font-bold uppercase tracking-wider",style:{backgroundColor:`${r}20`,color:r},children:t}),y.jsx("span",{className:"text-xs text-[var(--text-muted)]",children:"Script"})]}),y.jsx(wi,{items:l}),a&&y.jsx(ll,{output:a,title:"Output"})]})}function rD(e,t){const r={};return(e[e.length-1]===""?[...e,""]:e).join((r.padRight?" ":"")+","+(r.padLeft===!1?"":" ")).trim()}const iD=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,lD=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,aD={};function _1(e,t){return(aD.jsx?lD:iD).test(e)}const oD=/[ \t\n\f\r]/g;function sD(e){return typeof e=="object"?e.type==="text"?S1(e.value):!1:S1(e)}function S1(e){return e.replace(oD,"")===""}class os{constructor(t,r,l){this.normal=r,this.property=t,l&&(this.space=l)}}os.prototype.normal={};os.prototype.property={};os.prototype.space=void 0;function LS(e,t){const r={},l={};for(const a of e)Object.assign(r,a.property),Object.assign(l,a.normal);return new os(r,l,t)}function om(e){return e.toLowerCase()}class cn{constructor(t,r){this.attribute=r,this.property=t}}cn.prototype.attribute="";cn.prototype.booleanish=!1;cn.prototype.boolean=!1;cn.prototype.commaOrSpaceSeparated=!1;cn.prototype.commaSeparated=!1;cn.prototype.defined=!1;cn.prototype.mustUseProperty=!1;cn.prototype.number=!1;cn.prototype.overloadedBoolean=!1;cn.prototype.property="";cn.prototype.spaceSeparated=!1;cn.prototype.space=void 0;let uD=0;const Oe=cl(),Tt=cl(),sm=cl(),me=cl(),ut=cl(),ca=cl(),vn=cl();function cl(){return 2**++uD}const um=Object.freeze(Object.defineProperty({__proto__:null,boolean:Oe,booleanish:Tt,commaOrSpaceSeparated:vn,commaSeparated:ca,number:me,overloadedBoolean:sm,spaceSeparated:ut},Symbol.toStringTag,{value:"Module"})),kp=Object.keys(um);class Pm extends cn{constructor(t,r,l,a){let o=-1;if(super(t,r),k1(this,"space",a),typeof l=="number")for(;++o4&&r.slice(0,4)==="data"&&pD.test(t)){if(t.charAt(4)==="-"){const o=t.slice(5).replace(E1,xD);l="data"+o.charAt(0).toUpperCase()+o.slice(1)}else{const o=t.slice(4);if(!E1.test(o)){let s=o.replace(hD,gD);s.charAt(0)!=="-"&&(s="-"+s),t="data"+s}}a=Pm}return new a(l,t)}function gD(e){return"-"+e.toLowerCase()}function xD(e){return e.charAt(1).toUpperCase()}const yD=LS([HS,cD,qS,US,$S],"html"),Gm=LS([HS,fD,qS,US,$S],"svg");function vD(e){return e.join(" ").trim()}var Jl={},Ep,N1;function bD(){if(N1)return Ep;N1=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,r=/^\s*/,l=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,a=/^:\s*/,o=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,s=/^[;\s]*/,c=/^\s+|\s+$/g,h=` +`,d="/",m="*",p="",x="comment",b="declaration";function w(S,_){if(typeof S!="string")throw new TypeError("First argument must be a string");if(!S)return[];_=_||{};var N=1,k=1;function T(I){var F=I.match(t);F&&(N+=F.length);var z=I.lastIndexOf(h);k=~z?I.length-z:k+I.length}function M(){var I={line:N,column:k};return function(F){return F.position=new A(I),V(),F}}function A(I){this.start=I,this.end={line:N,column:k},this.source=_.source}A.prototype.content=S;function L(I){var F=new Error(_.source+":"+N+":"+k+": "+I);if(F.reason=I,F.filename=_.source,F.line=N,F.column=k,F.source=S,!_.silent)throw F}function R(I){var F=I.exec(S);if(F){var z=F[0];return T(z),S=S.slice(z.length),F}}function V(){R(r)}function H(I){var F;for(I=I||[];F=B();)F!==!1&&I.push(F);return I}function B(){var I=M();if(!(d!=S.charAt(0)||m!=S.charAt(1))){for(var F=2;p!=S.charAt(F)&&(m!=S.charAt(F)||d!=S.charAt(F+1));)++F;if(F+=2,p===S.charAt(F-1))return L("End of comment missing");var z=S.slice(2,F-2);return k+=2,T(z),S=S.slice(F),k+=2,I({type:x,comment:z})}}function $(){var I=M(),F=R(l);if(F){if(B(),!R(a))return L("property missing ':'");var z=R(o),G=I({type:b,property:E(F[0].replace(e,p)),value:z?E(z[0].replace(e,p)):p});return R(s),G}}function ee(){var I=[];H(I);for(var F;F=$();)F!==!1&&(I.push(F),H(I));return I}return V(),ee()}function E(S){return S?S.replace(c,p):p}return Ep=w,Ep}var C1;function wD(){if(C1)return Jl;C1=1;var e=Jl&&Jl.__importDefault||function(l){return l&&l.__esModule?l:{default:l}};Object.defineProperty(Jl,"__esModule",{value:!0}),Jl.default=r;const t=e(bD());function r(l,a){let o=null;if(!l||typeof l!="string")return o;const s=(0,t.default)(l),c=typeof a=="function";return s.forEach(h=>{if(h.type!=="declaration")return;const{property:d,value:m}=h;c?a(d,m,h):m&&(o=o||{},o[d]=m)}),o}return Jl}var _o={},j1;function _D(){if(j1)return _o;j1=1,Object.defineProperty(_o,"__esModule",{value:!0}),_o.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,t=/-([a-z])/g,r=/^[^-]+$/,l=/^-(webkit|moz|ms|o|khtml)-/,a=/^-(ms)-/,o=function(d){return!d||r.test(d)||e.test(d)},s=function(d,m){return m.toUpperCase()},c=function(d,m){return"".concat(m,"-")},h=function(d,m){return m===void 0&&(m={}),o(d)?d:(d=d.toLowerCase(),m.reactCompat?d=d.replace(a,c):d=d.replace(l,c),d.replace(t,s))};return _o.camelCase=h,_o}var So,T1;function SD(){if(T1)return So;T1=1;var e=So&&So.__importDefault||function(a){return a&&a.__esModule?a:{default:a}},t=e(wD()),r=_D();function l(a,o){var s={};return!a||typeof a!="string"||(0,t.default)(a,function(c,h){c&&h&&(s[(0,r.camelCase)(c,o)]=h)}),s}return l.default=l,So=l,So}var kD=SD();const ED=Zo(kD),VS=PS("end"),Fm=PS("start");function PS(e){return t;function t(r){const l=r&&r.position&&r.position[e]||{};if(typeof l.line=="number"&&l.line>0&&typeof l.column=="number"&&l.column>0)return{line:l.line,column:l.column,offset:typeof l.offset=="number"&&l.offset>-1?l.offset:void 0}}}function ND(e){const t=Fm(e),r=VS(e);if(t&&r)return{start:t,end:r}}function Ro(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?A1(e.position):"start"in e||"end"in e?A1(e):"line"in e||"column"in e?cm(e):""}function cm(e){return z1(e&&e.line)+":"+z1(e&&e.column)}function A1(e){return cm(e&&e.start)+"-"+cm(e&&e.end)}function z1(e){return e&&typeof e=="number"?e:1}class Qt extends Error{constructor(t,r,l){super(),typeof r=="string"&&(l=r,r=void 0);let a="",o={},s=!1;if(r&&("line"in r&&"column"in r?o={place:r}:"start"in r&&"end"in r?o={place:r}:"type"in r?o={ancestors:[r],place:r.position}:o={...r}),typeof t=="string"?a=t:!o.cause&&t&&(s=!0,a=t.message,o.cause=t),!o.ruleId&&!o.source&&typeof l=="string"){const h=l.indexOf(":");h===-1?o.ruleId=l:(o.source=l.slice(0,h),o.ruleId=l.slice(h+1))}if(!o.place&&o.ancestors&&o.ancestors){const h=o.ancestors[o.ancestors.length-1];h&&(o.place=h.position)}const c=o.place&&"start"in o.place?o.place.start:o.place;this.ancestors=o.ancestors||void 0,this.cause=o.cause||void 0,this.column=c?c.column:void 0,this.fatal=void 0,this.file="",this.message=a,this.line=c?c.line:void 0,this.name=Ro(o.place)||"1:1",this.place=o.place||void 0,this.reason=this.message,this.ruleId=o.ruleId||void 0,this.source=o.source||void 0,this.stack=s&&o.cause&&typeof o.cause.stack=="string"?o.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}Qt.prototype.file="";Qt.prototype.name="";Qt.prototype.reason="";Qt.prototype.message="";Qt.prototype.stack="";Qt.prototype.column=void 0;Qt.prototype.line=void 0;Qt.prototype.ancestors=void 0;Qt.prototype.cause=void 0;Qt.prototype.fatal=void 0;Qt.prototype.place=void 0;Qt.prototype.ruleId=void 0;Qt.prototype.source=void 0;const Ym={}.hasOwnProperty,CD=new Map,jD=/[A-Z]/g,TD=new Set(["table","tbody","thead","tfoot","tr"]),AD=new Set(["td","th"]),GS="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function zD(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const r=t.filePath||void 0;let l;if(t.development){if(typeof t.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");l=ID(r,t.jsxDEV)}else{if(typeof t.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof t.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");l=BD(r,t.jsx,t.jsxs)}const a={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:l,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:r,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space==="svg"?Gm:yD,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},o=FS(a,e,void 0);return o&&typeof o!="string"?o:a.create(e,a.Fragment,{children:o||void 0},void 0)}function FS(e,t,r){if(t.type==="element")return MD(e,t,r);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return DD(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return OD(e,t,r);if(t.type==="mdxjsEsm")return RD(e,t);if(t.type==="root")return LD(e,t,r);if(t.type==="text")return HD(e,t)}function MD(e,t,r){const l=e.schema;let a=l;t.tagName.toLowerCase()==="svg"&&l.space==="html"&&(a=Gm,e.schema=a),e.ancestors.push(t);const o=XS(e,t.tagName,!1),s=qD(e,t);let c=Qm(e,t);return TD.has(t.tagName)&&(c=c.filter(function(h){return typeof h=="string"?!sD(h):!0})),YS(e,s,o,t),Xm(s,c),e.ancestors.pop(),e.schema=l,e.create(t,o,s,r)}function DD(e,t){if(t.data&&t.data.estree&&e.evaluater){const l=t.data.estree.body[0];return l.type,e.evaluater.evaluateExpression(l.expression)}Xo(e,t.position)}function RD(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);Xo(e,t.position)}function OD(e,t,r){const l=e.schema;let a=l;t.name==="svg"&&l.space==="html"&&(a=Gm,e.schema=a),e.ancestors.push(t);const o=t.name===null?e.Fragment:XS(e,t.name,!0),s=UD(e,t),c=Qm(e,t);return YS(e,s,o,t),Xm(s,c),e.ancestors.pop(),e.schema=l,e.create(t,o,s,r)}function LD(e,t,r){const l={};return Xm(l,Qm(e,t)),e.create(t,e.Fragment,l,r)}function HD(e,t){return t.value}function YS(e,t,r,l){typeof r!="string"&&r!==e.Fragment&&e.passNode&&(t.node=l)}function Xm(e,t){if(t.length>0){const r=t.length>1?t:t[0];r&&(e.children=r)}}function BD(e,t,r){return l;function l(a,o,s,c){const d=Array.isArray(s.children)?r:t;return c?d(o,s,c):d(o,s)}}function ID(e,t){return r;function r(l,a,o,s){const c=Array.isArray(o.children),h=Fm(l);return t(a,o,s,c,{columnNumber:h?h.column-1:void 0,fileName:e,lineNumber:h?h.line:void 0},void 0)}}function qD(e,t){const r={};let l,a;for(a in t.properties)if(a!=="children"&&Ym.call(t.properties,a)){const o=$D(e,a,t.properties[a]);if(o){const[s,c]=o;e.tableCellAlignToStyle&&s==="align"&&typeof c=="string"&&AD.has(t.tagName)?l=c:r[s]=c}}if(l){const o=r.style||(r.style={});o[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=l}return r}function UD(e,t){const r={};for(const l of t.attributes)if(l.type==="mdxJsxExpressionAttribute")if(l.data&&l.data.estree&&e.evaluater){const o=l.data.estree.body[0];o.type;const s=o.expression;s.type;const c=s.properties[0];c.type,Object.assign(r,e.evaluater.evaluateExpression(c.argument))}else Xo(e,t.position);else{const a=l.name;let o;if(l.value&&typeof l.value=="object")if(l.value.data&&l.value.data.estree&&e.evaluater){const c=l.value.data.estree.body[0];c.type,o=e.evaluater.evaluateExpression(c.expression)}else Xo(e,t.position);else o=l.value===null?!0:l.value;r[a]=o}return r}function Qm(e,t){const r=[];let l=-1;const a=e.passKeys?new Map:CD;for(;++la?0:a+t:t=t>a?a:t,r=r>0?r:0,l.length<1e4)s=Array.from(l),s.unshift(t,r),e.splice(...s);else for(r&&e.splice(t,r);o0?(_n(e,e.length,0,t),e):t}const R1={}.hasOwnProperty;function ZS(e){const t={};let r=-1;for(;++r13&&r<32||r>126&&r<160||r>55295&&r<57344||r>64975&&r<65008||(r&65535)===65535||(r&65535)===65534||r>1114111?"�":String.fromCodePoint(r)}function Fn(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const Jt=_i(/[A-Za-z]/),Xt=_i(/[\dA-Za-z]/),KD=_i(/[#-'*+\--9=?A-Z^-~]/);function bc(e){return e!==null&&(e<32||e===127)}const fm=_i(/\d/),JD=_i(/[\dA-Fa-f]/),WD=_i(/[!-/:-@[-`{-~]/);function Ee(e){return e!==null&&e<-2}function st(e){return e!==null&&(e<0||e===32)}function Ve(e){return e===-2||e===-1||e===32}const Uc=_i(new RegExp("\\p{P}|\\p{S}","u")),al=_i(/\s/);function _i(e){return t;function t(r){return r!==null&&r>-1&&e.test(String.fromCharCode(r))}}function wa(e){const t=[];let r=-1,l=0,a=0;for(;++r55295&&o<57344){const c=e.charCodeAt(r+1);o<56320&&c>56319&&c<57344?(s=String.fromCharCode(o,c),a=1):s="�"}else s=String.fromCharCode(o);s&&(t.push(e.slice(l,r),encodeURIComponent(s)),l=r+a+1,s=""),a&&(r+=a,a=0)}return t.join("")+e.slice(l)}function Qe(e,t,r,l){const a=l?l-1:Number.POSITIVE_INFINITY;let o=0;return s;function s(h){return Ve(h)?(e.enter(r),c(h)):t(h)}function c(h){return Ve(h)&&o++s))return;const L=t.events.length;let R=L,V,H;for(;R--;)if(t.events[R][0]==="exit"&&t.events[R][1].type==="chunkFlow"){if(V){H=t.events[R][1].end;break}V=!0}for(_(l),A=L;Ak;){const M=r[T];t.containerState=M[1],M[0].exit.call(t,e)}r.length=k}function N(){a.write([null]),o=void 0,a=void 0,t.containerState._closeFlow=void 0}}function iR(e,t,r){return Qe(e,e.attempt(this.parser.constructs.document,t,r),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function va(e){if(e===null||st(e)||al(e))return 1;if(Uc(e))return 2}function $c(e,t,r){const l=[];let a=-1;for(;++a1&&e[r][1].end.offset-e[r][1].start.offset>1?2:1;const p={...e[l][1].end},x={...e[r][1].start};L1(p,-h),L1(x,h),s={type:h>1?"strongSequence":"emphasisSequence",start:p,end:{...e[l][1].end}},c={type:h>1?"strongSequence":"emphasisSequence",start:{...e[r][1].start},end:x},o={type:h>1?"strongText":"emphasisText",start:{...e[l][1].end},end:{...e[r][1].start}},a={type:h>1?"strong":"emphasis",start:{...s.start},end:{...c.end}},e[l][1].end={...s.start},e[r][1].start={...c.end},d=[],e[l][1].end.offset-e[l][1].start.offset&&(d=Dn(d,[["enter",e[l][1],t],["exit",e[l][1],t]])),d=Dn(d,[["enter",a,t],["enter",s,t],["exit",s,t],["enter",o,t]]),d=Dn(d,$c(t.parser.constructs.insideSpan.null,e.slice(l+1,r),t)),d=Dn(d,[["exit",o,t],["enter",c,t],["exit",c,t],["exit",a,t]]),e[r][1].end.offset-e[r][1].start.offset?(m=2,d=Dn(d,[["enter",e[r][1],t],["exit",e[r][1],t]])):m=0,_n(e,l-1,r-l+3,d),r=l+d.length-m-2;break}}for(r=-1;++r0&&Ve(A)?Qe(e,N,"linePrefix",o+1)(A):N(A)}function N(A){return A===null||Ee(A)?e.check(H1,E,T)(A):(e.enter("codeFlowValue"),k(A))}function k(A){return A===null||Ee(A)?(e.exit("codeFlowValue"),N(A)):(e.consume(A),k)}function T(A){return e.exit("codeFenced"),t(A)}function M(A,L,R){let V=0;return H;function H(F){return A.enter("lineEnding"),A.consume(F),A.exit("lineEnding"),B}function B(F){return A.enter("codeFencedFence"),Ve(F)?Qe(A,$,"linePrefix",l.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(F):$(F)}function $(F){return F===c?(A.enter("codeFencedFenceSequence"),ee(F)):R(F)}function ee(F){return F===c?(V++,A.consume(F),ee):V>=s?(A.exit("codeFencedFenceSequence"),Ve(F)?Qe(A,I,"whitespace")(F):I(F)):R(F)}function I(F){return F===null||Ee(F)?(A.exit("codeFencedFence"),L(F)):R(F)}}}function gR(e,t,r){const l=this;return a;function a(s){return s===null?r(s):(e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),o)}function o(s){return l.parser.lazy[l.now().line]?r(s):t(s)}}const Cp={name:"codeIndented",tokenize:yR},xR={partial:!0,tokenize:vR};function yR(e,t,r){const l=this;return a;function a(d){return e.enter("codeIndented"),Qe(e,o,"linePrefix",5)(d)}function o(d){const m=l.events[l.events.length-1];return m&&m[1].type==="linePrefix"&&m[2].sliceSerialize(m[1],!0).length>=4?s(d):r(d)}function s(d){return d===null?h(d):Ee(d)?e.attempt(xR,s,h)(d):(e.enter("codeFlowValue"),c(d))}function c(d){return d===null||Ee(d)?(e.exit("codeFlowValue"),s(d)):(e.consume(d),c)}function h(d){return e.exit("codeIndented"),t(d)}}function vR(e,t,r){const l=this;return a;function a(s){return l.parser.lazy[l.now().line]?r(s):Ee(s)?(e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),a):Qe(e,o,"linePrefix",5)(s)}function o(s){const c=l.events[l.events.length-1];return c&&c[1].type==="linePrefix"&&c[2].sliceSerialize(c[1],!0).length>=4?t(s):Ee(s)?a(s):r(s)}}const bR={name:"codeText",previous:_R,resolve:wR,tokenize:SR};function wR(e){let t=e.length-4,r=3,l,a;if((e[r][1].type==="lineEnding"||e[r][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(l=r;++l=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+t+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return tthis.left.length?this.right.slice(this.right.length-l+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-l+this.left.length).reverse())}splice(t,r,l){const a=r||0;this.setCursor(Math.trunc(t));const o=this.right.splice(this.right.length-a,Number.POSITIVE_INFINITY);return l&&ko(this.left,l),o.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),ko(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),ko(this.right,t.reverse())}setCursor(t){if(!(t===this.left.length||t>this.left.length&&this.right.length===0||t<0&&this.left.length===0))if(t=4?t(s):e.interrupt(l.parser.constructs.flow,r,t)(s)}}function nk(e,t,r,l,a,o,s,c,h){const d=h||Number.POSITIVE_INFINITY;let m=0;return p;function p(_){return _===60?(e.enter(l),e.enter(a),e.enter(o),e.consume(_),e.exit(o),x):_===null||_===32||_===41||bc(_)?r(_):(e.enter(l),e.enter(s),e.enter(c),e.enter("chunkString",{contentType:"string"}),E(_))}function x(_){return _===62?(e.enter(o),e.consume(_),e.exit(o),e.exit(a),e.exit(l),t):(e.enter(c),e.enter("chunkString",{contentType:"string"}),b(_))}function b(_){return _===62?(e.exit("chunkString"),e.exit(c),x(_)):_===null||_===60||Ee(_)?r(_):(e.consume(_),_===92?w:b)}function w(_){return _===60||_===62||_===92?(e.consume(_),b):b(_)}function E(_){return!m&&(_===null||_===41||st(_))?(e.exit("chunkString"),e.exit(c),e.exit(s),e.exit(l),t(_)):m999||b===null||b===91||b===93&&!h||b===94&&!c&&"_hiddenFootnoteSupport"in s.parser.constructs?r(b):b===93?(e.exit(o),e.enter(a),e.consume(b),e.exit(a),e.exit(l),t):Ee(b)?(e.enter("lineEnding"),e.consume(b),e.exit("lineEnding"),m):(e.enter("chunkString",{contentType:"string"}),p(b))}function p(b){return b===null||b===91||b===93||Ee(b)||c++>999?(e.exit("chunkString"),m(b)):(e.consume(b),h||(h=!Ve(b)),b===92?x:p)}function x(b){return b===91||b===92||b===93?(e.consume(b),c++,p):p(b)}}function ik(e,t,r,l,a,o){let s;return c;function c(x){return x===34||x===39||x===40?(e.enter(l),e.enter(a),e.consume(x),e.exit(a),s=x===40?41:x,h):r(x)}function h(x){return x===s?(e.enter(a),e.consume(x),e.exit(a),e.exit(l),t):(e.enter(o),d(x))}function d(x){return x===s?(e.exit(o),h(s)):x===null?r(x):Ee(x)?(e.enter("lineEnding"),e.consume(x),e.exit("lineEnding"),Qe(e,d,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),m(x))}function m(x){return x===s||x===null||Ee(x)?(e.exit("chunkString"),d(x)):(e.consume(x),x===92?p:m)}function p(x){return x===s||x===92?(e.consume(x),m):m(x)}}function Oo(e,t){let r;return l;function l(a){return Ee(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),r=!0,l):Ve(a)?Qe(e,l,r?"linePrefix":"lineSuffix")(a):t(a)}}const zR={name:"definition",tokenize:DR},MR={partial:!0,tokenize:RR};function DR(e,t,r){const l=this;let a;return o;function o(b){return e.enter("definition"),s(b)}function s(b){return rk.call(l,e,c,r,"definitionLabel","definitionLabelMarker","definitionLabelString")(b)}function c(b){return a=Fn(l.sliceSerialize(l.events[l.events.length-1][1]).slice(1,-1)),b===58?(e.enter("definitionMarker"),e.consume(b),e.exit("definitionMarker"),h):r(b)}function h(b){return st(b)?Oo(e,d)(b):d(b)}function d(b){return nk(e,m,r,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(b)}function m(b){return e.attempt(MR,p,p)(b)}function p(b){return Ve(b)?Qe(e,x,"whitespace")(b):x(b)}function x(b){return b===null||Ee(b)?(e.exit("definition"),l.parser.defined.push(a),t(b)):r(b)}}function RR(e,t,r){return l;function l(c){return st(c)?Oo(e,a)(c):r(c)}function a(c){return ik(e,o,r,"definitionTitle","definitionTitleMarker","definitionTitleString")(c)}function o(c){return Ve(c)?Qe(e,s,"whitespace")(c):s(c)}function s(c){return c===null||Ee(c)?t(c):r(c)}}const OR={name:"hardBreakEscape",tokenize:LR};function LR(e,t,r){return l;function l(o){return e.enter("hardBreakEscape"),e.consume(o),a}function a(o){return Ee(o)?(e.exit("hardBreakEscape"),t(o)):r(o)}}const HR={name:"headingAtx",resolve:BR,tokenize:IR};function BR(e,t){let r=e.length-2,l=3,a,o;return e[l][1].type==="whitespace"&&(l+=2),r-2>l&&e[r][1].type==="whitespace"&&(r-=2),e[r][1].type==="atxHeadingSequence"&&(l===r-1||r-4>l&&e[r-2][1].type==="whitespace")&&(r-=l+1===r?2:4),r>l&&(a={type:"atxHeadingText",start:e[l][1].start,end:e[r][1].end},o={type:"chunkText",start:e[l][1].start,end:e[r][1].end,contentType:"text"},_n(e,l,r-l+1,[["enter",a,t],["enter",o,t],["exit",o,t],["exit",a,t]])),e}function IR(e,t,r){let l=0;return a;function a(m){return e.enter("atxHeading"),o(m)}function o(m){return e.enter("atxHeadingSequence"),s(m)}function s(m){return m===35&&l++<6?(e.consume(m),s):m===null||st(m)?(e.exit("atxHeadingSequence"),c(m)):r(m)}function c(m){return m===35?(e.enter("atxHeadingSequence"),h(m)):m===null||Ee(m)?(e.exit("atxHeading"),t(m)):Ve(m)?Qe(e,c,"whitespace")(m):(e.enter("atxHeadingText"),d(m))}function h(m){return m===35?(e.consume(m),h):(e.exit("atxHeadingSequence"),c(m))}function d(m){return m===null||m===35||st(m)?(e.exit("atxHeadingText"),c(m)):(e.consume(m),d)}}const qR=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],I1=["pre","script","style","textarea"],UR={concrete:!0,name:"htmlFlow",resolveTo:PR,tokenize:GR},$R={partial:!0,tokenize:YR},VR={partial:!0,tokenize:FR};function PR(e){let t=e.length;for(;t--&&!(e[t][0]==="enter"&&e[t][1].type==="htmlFlow"););return t>1&&e[t-2][1].type==="linePrefix"&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function GR(e,t,r){const l=this;let a,o,s,c,h;return d;function d(C){return m(C)}function m(C){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(C),p}function p(C){return C===33?(e.consume(C),x):C===47?(e.consume(C),o=!0,E):C===63?(e.consume(C),a=3,l.interrupt?t:D):Jt(C)?(e.consume(C),s=String.fromCharCode(C),S):r(C)}function x(C){return C===45?(e.consume(C),a=2,b):C===91?(e.consume(C),a=5,c=0,w):Jt(C)?(e.consume(C),a=4,l.interrupt?t:D):r(C)}function b(C){return C===45?(e.consume(C),l.interrupt?t:D):r(C)}function w(C){const P="CDATA[";return C===P.charCodeAt(c++)?(e.consume(C),c===P.length?l.interrupt?t:$:w):r(C)}function E(C){return Jt(C)?(e.consume(C),s=String.fromCharCode(C),S):r(C)}function S(C){if(C===null||C===47||C===62||st(C)){const P=C===47,X=s.toLowerCase();return!P&&!o&&I1.includes(X)?(a=1,l.interrupt?t(C):$(C)):qR.includes(s.toLowerCase())?(a=6,P?(e.consume(C),_):l.interrupt?t(C):$(C)):(a=7,l.interrupt&&!l.parser.lazy[l.now().line]?r(C):o?N(C):k(C))}return C===45||Xt(C)?(e.consume(C),s+=String.fromCharCode(C),S):r(C)}function _(C){return C===62?(e.consume(C),l.interrupt?t:$):r(C)}function N(C){return Ve(C)?(e.consume(C),N):H(C)}function k(C){return C===47?(e.consume(C),H):C===58||C===95||Jt(C)?(e.consume(C),T):Ve(C)?(e.consume(C),k):H(C)}function T(C){return C===45||C===46||C===58||C===95||Xt(C)?(e.consume(C),T):M(C)}function M(C){return C===61?(e.consume(C),A):Ve(C)?(e.consume(C),M):k(C)}function A(C){return C===null||C===60||C===61||C===62||C===96?r(C):C===34||C===39?(e.consume(C),h=C,L):Ve(C)?(e.consume(C),A):R(C)}function L(C){return C===h?(e.consume(C),h=null,V):C===null||Ee(C)?r(C):(e.consume(C),L)}function R(C){return C===null||C===34||C===39||C===47||C===60||C===61||C===62||C===96||st(C)?M(C):(e.consume(C),R)}function V(C){return C===47||C===62||Ve(C)?k(C):r(C)}function H(C){return C===62?(e.consume(C),B):r(C)}function B(C){return C===null||Ee(C)?$(C):Ve(C)?(e.consume(C),B):r(C)}function $(C){return C===45&&a===2?(e.consume(C),z):C===60&&a===1?(e.consume(C),G):C===62&&a===4?(e.consume(C),q):C===63&&a===3?(e.consume(C),D):C===93&&a===5?(e.consume(C),K):Ee(C)&&(a===6||a===7)?(e.exit("htmlFlowData"),e.check($R,Y,ee)(C)):C===null||Ee(C)?(e.exit("htmlFlowData"),ee(C)):(e.consume(C),$)}function ee(C){return e.check(VR,I,Y)(C)}function I(C){return e.enter("lineEnding"),e.consume(C),e.exit("lineEnding"),F}function F(C){return C===null||Ee(C)?ee(C):(e.enter("htmlFlowData"),$(C))}function z(C){return C===45?(e.consume(C),D):$(C)}function G(C){return C===47?(e.consume(C),s="",Q):$(C)}function Q(C){if(C===62){const P=s.toLowerCase();return I1.includes(P)?(e.consume(C),q):$(C)}return Jt(C)&&s.length<8?(e.consume(C),s+=String.fromCharCode(C),Q):$(C)}function K(C){return C===93?(e.consume(C),D):$(C)}function D(C){return C===62?(e.consume(C),q):C===45&&a===2?(e.consume(C),D):$(C)}function q(C){return C===null||Ee(C)?(e.exit("htmlFlowData"),Y(C)):(e.consume(C),q)}function Y(C){return e.exit("htmlFlow"),t(C)}}function FR(e,t,r){const l=this;return a;function a(s){return Ee(s)?(e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),o):r(s)}function o(s){return l.parser.lazy[l.now().line]?r(s):t(s)}}function YR(e,t,r){return l;function l(a){return e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),e.attempt(ss,t,r)}}const XR={name:"htmlText",tokenize:QR};function QR(e,t,r){const l=this;let a,o,s;return c;function c(D){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(D),h}function h(D){return D===33?(e.consume(D),d):D===47?(e.consume(D),M):D===63?(e.consume(D),k):Jt(D)?(e.consume(D),R):r(D)}function d(D){return D===45?(e.consume(D),m):D===91?(e.consume(D),o=0,w):Jt(D)?(e.consume(D),N):r(D)}function m(D){return D===45?(e.consume(D),b):r(D)}function p(D){return D===null?r(D):D===45?(e.consume(D),x):Ee(D)?(s=p,G(D)):(e.consume(D),p)}function x(D){return D===45?(e.consume(D),b):p(D)}function b(D){return D===62?z(D):D===45?x(D):p(D)}function w(D){const q="CDATA[";return D===q.charCodeAt(o++)?(e.consume(D),o===q.length?E:w):r(D)}function E(D){return D===null?r(D):D===93?(e.consume(D),S):Ee(D)?(s=E,G(D)):(e.consume(D),E)}function S(D){return D===93?(e.consume(D),_):E(D)}function _(D){return D===62?z(D):D===93?(e.consume(D),_):E(D)}function N(D){return D===null||D===62?z(D):Ee(D)?(s=N,G(D)):(e.consume(D),N)}function k(D){return D===null?r(D):D===63?(e.consume(D),T):Ee(D)?(s=k,G(D)):(e.consume(D),k)}function T(D){return D===62?z(D):k(D)}function M(D){return Jt(D)?(e.consume(D),A):r(D)}function A(D){return D===45||Xt(D)?(e.consume(D),A):L(D)}function L(D){return Ee(D)?(s=L,G(D)):Ve(D)?(e.consume(D),L):z(D)}function R(D){return D===45||Xt(D)?(e.consume(D),R):D===47||D===62||st(D)?V(D):r(D)}function V(D){return D===47?(e.consume(D),z):D===58||D===95||Jt(D)?(e.consume(D),H):Ee(D)?(s=V,G(D)):Ve(D)?(e.consume(D),V):z(D)}function H(D){return D===45||D===46||D===58||D===95||Xt(D)?(e.consume(D),H):B(D)}function B(D){return D===61?(e.consume(D),$):Ee(D)?(s=B,G(D)):Ve(D)?(e.consume(D),B):V(D)}function $(D){return D===null||D===60||D===61||D===62||D===96?r(D):D===34||D===39?(e.consume(D),a=D,ee):Ee(D)?(s=$,G(D)):Ve(D)?(e.consume(D),$):(e.consume(D),I)}function ee(D){return D===a?(e.consume(D),a=void 0,F):D===null?r(D):Ee(D)?(s=ee,G(D)):(e.consume(D),ee)}function I(D){return D===null||D===34||D===39||D===60||D===61||D===96?r(D):D===47||D===62||st(D)?V(D):(e.consume(D),I)}function F(D){return D===47||D===62||st(D)?V(D):r(D)}function z(D){return D===62?(e.consume(D),e.exit("htmlTextData"),e.exit("htmlText"),t):r(D)}function G(D){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(D),e.exit("lineEnding"),Q}function Q(D){return Ve(D)?Qe(e,K,"linePrefix",l.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(D):K(D)}function K(D){return e.enter("htmlTextData"),s(D)}}const Jm={name:"labelEnd",resolveAll:WR,resolveTo:eO,tokenize:tO},ZR={tokenize:nO},KR={tokenize:rO},JR={tokenize:iO};function WR(e){let t=-1;const r=[];for(;++t=3&&(d===null||Ee(d))?(e.exit("thematicBreak"),t(d)):r(d)}function h(d){return d===a?(e.consume(d),l++,h):(e.exit("thematicBreakSequence"),Ve(d)?Qe(e,c,"whitespace")(d):c(d))}}const sn={continuation:{tokenize:pO},exit:gO,name:"list",tokenize:hO},fO={partial:!0,tokenize:xO},dO={partial:!0,tokenize:mO};function hO(e,t,r){const l=this,a=l.events[l.events.length-1];let o=a&&a[1].type==="linePrefix"?a[2].sliceSerialize(a[1],!0).length:0,s=0;return c;function c(b){const w=l.containerState.type||(b===42||b===43||b===45?"listUnordered":"listOrdered");if(w==="listUnordered"?!l.containerState.marker||b===l.containerState.marker:fm(b)){if(l.containerState.type||(l.containerState.type=w,e.enter(w,{_container:!0})),w==="listUnordered")return e.enter("listItemPrefix"),b===42||b===45?e.check(rc,r,d)(b):d(b);if(!l.interrupt||b===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),h(b)}return r(b)}function h(b){return fm(b)&&++s<10?(e.consume(b),h):(!l.interrupt||s<2)&&(l.containerState.marker?b===l.containerState.marker:b===41||b===46)?(e.exit("listItemValue"),d(b)):r(b)}function d(b){return e.enter("listItemMarker"),e.consume(b),e.exit("listItemMarker"),l.containerState.marker=l.containerState.marker||b,e.check(ss,l.interrupt?r:m,e.attempt(fO,x,p))}function m(b){return l.containerState.initialBlankLine=!0,o++,x(b)}function p(b){return Ve(b)?(e.enter("listItemPrefixWhitespace"),e.consume(b),e.exit("listItemPrefixWhitespace"),x):r(b)}function x(b){return l.containerState.size=o+l.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(b)}}function pO(e,t,r){const l=this;return l.containerState._closeFlow=void 0,e.check(ss,a,o);function a(c){return l.containerState.furtherBlankLines=l.containerState.furtherBlankLines||l.containerState.initialBlankLine,Qe(e,t,"listItemIndent",l.containerState.size+1)(c)}function o(c){return l.containerState.furtherBlankLines||!Ve(c)?(l.containerState.furtherBlankLines=void 0,l.containerState.initialBlankLine=void 0,s(c)):(l.containerState.furtherBlankLines=void 0,l.containerState.initialBlankLine=void 0,e.attempt(dO,t,s)(c))}function s(c){return l.containerState._closeFlow=!0,l.interrupt=void 0,Qe(e,e.attempt(sn,t,r),"linePrefix",l.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(c)}}function mO(e,t,r){const l=this;return Qe(e,a,"listItemIndent",l.containerState.size+1);function a(o){const s=l.events[l.events.length-1];return s&&s[1].type==="listItemIndent"&&s[2].sliceSerialize(s[1],!0).length===l.containerState.size?t(o):r(o)}}function gO(e){e.exit(this.containerState.type)}function xO(e,t,r){const l=this;return Qe(e,a,"listItemPrefixWhitespace",l.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function a(o){const s=l.events[l.events.length-1];return!Ve(o)&&s&&s[1].type==="listItemPrefixWhitespace"?t(o):r(o)}}const q1={name:"setextUnderline",resolveTo:yO,tokenize:vO};function yO(e,t){let r=e.length,l,a,o;for(;r--;)if(e[r][0]==="enter"){if(e[r][1].type==="content"){l=r;break}e[r][1].type==="paragraph"&&(a=r)}else e[r][1].type==="content"&&e.splice(r,1),!o&&e[r][1].type==="definition"&&(o=r);const s={type:"setextHeading",start:{...e[l][1].start},end:{...e[e.length-1][1].end}};return e[a][1].type="setextHeadingText",o?(e.splice(a,0,["enter",s,t]),e.splice(o+1,0,["exit",e[l][1],t]),e[l][1].end={...e[o][1].end}):e[l][1]=s,e.push(["exit",s,t]),e}function vO(e,t,r){const l=this;let a;return o;function o(d){let m=l.events.length,p;for(;m--;)if(l.events[m][1].type!=="lineEnding"&&l.events[m][1].type!=="linePrefix"&&l.events[m][1].type!=="content"){p=l.events[m][1].type==="paragraph";break}return!l.parser.lazy[l.now().line]&&(l.interrupt||p)?(e.enter("setextHeadingLine"),a=d,s(d)):r(d)}function s(d){return e.enter("setextHeadingLineSequence"),c(d)}function c(d){return d===a?(e.consume(d),c):(e.exit("setextHeadingLineSequence"),Ve(d)?Qe(e,h,"lineSuffix")(d):h(d))}function h(d){return d===null||Ee(d)?(e.exit("setextHeadingLine"),t(d)):r(d)}}const bO={tokenize:wO};function wO(e){const t=this,r=e.attempt(ss,l,e.attempt(this.parser.constructs.flowInitial,a,Qe(e,e.attempt(this.parser.constructs.flow,a,e.attempt(NR,a)),"linePrefix")));return r;function l(o){if(o===null){e.consume(o);return}return e.enter("lineEndingBlank"),e.consume(o),e.exit("lineEndingBlank"),t.currentConstruct=void 0,r}function a(o){if(o===null){e.consume(o);return}return e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),t.currentConstruct=void 0,r}}const _O={resolveAll:ak()},SO=lk("string"),kO=lk("text");function lk(e){return{resolveAll:ak(e==="text"?EO:void 0),tokenize:t};function t(r){const l=this,a=this.parser.constructs[e],o=r.attempt(a,s,c);return s;function s(m){return d(m)?o(m):c(m)}function c(m){if(m===null){r.consume(m);return}return r.enter("data"),r.consume(m),h}function h(m){return d(m)?(r.exit("data"),o(m)):(r.consume(m),h)}function d(m){if(m===null)return!0;const p=a[m];let x=-1;if(p)for(;++x-1){const c=s[0];typeof c=="string"?s[0]=c.slice(l):s.shift()}o>0&&s.push(e[a].slice(0,o))}return s}function BO(e,t){let r=-1;const l=[];let a;for(;++r0){const Zt=Ne.tokenStack[Ne.tokenStack.length-1];(Zt[1]||$1).call(Ne,void 0,Zt[0])}for(ge.position={start:gi(ce.length>0?ce[0][1].start:{line:1,column:1,offset:0}),end:gi(ce.length>0?ce[ce.length-2][1].end:{line:1,column:1,offset:0})},Xe=-1;++Xe0&&(l.className=["language-"+a[0]]);let o={type:"element",tagName:"code",properties:l,children:[{type:"text",value:r}]};return t.meta&&(o.data={meta:t.meta}),e.patch(t,o),o=e.applyData(t,o),o={type:"element",tagName:"pre",properties:{},children:[o]},e.patch(t,o),o}function JO(e,t){const r={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function WO(e,t){const r={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function e6(e,t){const r=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",l=String(t.identifier).toUpperCase(),a=wa(l.toLowerCase()),o=e.footnoteOrder.indexOf(l);let s,c=e.footnoteCounts.get(l);c===void 0?(c=0,e.footnoteOrder.push(l),s=e.footnoteOrder.length):s=o+1,c+=1,e.footnoteCounts.set(l,c);const h={type:"element",tagName:"a",properties:{href:"#"+r+"fn-"+a,id:r+"fnref-"+a+(c>1?"-"+c:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(s)}]};e.patch(t,h);const d={type:"element",tagName:"sup",properties:{},children:[h]};return e.patch(t,d),e.applyData(t,d)}function t6(e,t){const r={type:"element",tagName:"h"+t.depth,properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function n6(e,t){if(e.options.allowDangerousHtml){const r={type:"raw",value:t.value};return e.patch(t,r),e.applyData(t,r)}}function uk(e,t){const r=t.referenceType;let l="]";if(r==="collapsed"?l+="[]":r==="full"&&(l+="["+(t.label||t.identifier)+"]"),t.type==="imageReference")return[{type:"text",value:"!["+t.alt+l}];const a=e.all(t),o=a[0];o&&o.type==="text"?o.value="["+o.value:a.unshift({type:"text",value:"["});const s=a[a.length-1];return s&&s.type==="text"?s.value+=l:a.push({type:"text",value:l}),a}function r6(e,t){const r=String(t.identifier).toUpperCase(),l=e.definitionById.get(r);if(!l)return uk(e,t);const a={src:wa(l.url||""),alt:t.alt};l.title!==null&&l.title!==void 0&&(a.title=l.title);const o={type:"element",tagName:"img",properties:a,children:[]};return e.patch(t,o),e.applyData(t,o)}function i6(e,t){const r={src:wa(t.url)};t.alt!==null&&t.alt!==void 0&&(r.alt=t.alt),t.title!==null&&t.title!==void 0&&(r.title=t.title);const l={type:"element",tagName:"img",properties:r,children:[]};return e.patch(t,l),e.applyData(t,l)}function l6(e,t){const r={type:"text",value:t.value.replace(/\r?\n|\r/g," ")};e.patch(t,r);const l={type:"element",tagName:"code",properties:{},children:[r]};return e.patch(t,l),e.applyData(t,l)}function a6(e,t){const r=String(t.identifier).toUpperCase(),l=e.definitionById.get(r);if(!l)return uk(e,t);const a={href:wa(l.url||"")};l.title!==null&&l.title!==void 0&&(a.title=l.title);const o={type:"element",tagName:"a",properties:a,children:e.all(t)};return e.patch(t,o),e.applyData(t,o)}function o6(e,t){const r={href:wa(t.url)};t.title!==null&&t.title!==void 0&&(r.title=t.title);const l={type:"element",tagName:"a",properties:r,children:e.all(t)};return e.patch(t,l),e.applyData(t,l)}function s6(e,t,r){const l=e.all(t),a=r?u6(r):ck(t),o={},s=[];if(typeof t.checked=="boolean"){const m=l[0];let p;m&&m.type==="element"&&m.tagName==="p"?p=m:(p={type:"element",tagName:"p",properties:{},children:[]},l.unshift(p)),p.children.length>0&&p.children.unshift({type:"text",value:" "}),p.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),o.className=["task-list-item"]}let c=-1;for(;++c1}function c6(e,t){const r={},l=e.all(t);let a=-1;for(typeof t.start=="number"&&t.start!==1&&(r.start=t.start);++a0){const s={type:"element",tagName:"tbody",properties:{},children:e.wrap(r,!0)},c=Fm(t.children[1]),h=VS(t.children[t.children.length-1]);c&&h&&(s.position={start:c,end:h}),a.push(s)}const o={type:"element",tagName:"table",properties:{},children:e.wrap(a,!0)};return e.patch(t,o),e.applyData(t,o)}function m6(e,t,r){const l=r?r.children:void 0,o=(l?l.indexOf(t):1)===0?"th":"td",s=r&&r.type==="table"?r.align:void 0,c=s?s.length:t.children.length;let h=-1;const d=[];for(;++h0,!0),l[0]),a=l.index+l[0].length,l=r.exec(t);return o.push(G1(t.slice(a),a>0,!1)),o.join("")}function G1(e,t,r){let l=0,a=e.length;if(t){let o=e.codePointAt(l);for(;o===V1||o===P1;)l++,o=e.codePointAt(l)}if(r){let o=e.codePointAt(a-1);for(;o===V1||o===P1;)a--,o=e.codePointAt(a-1)}return a>l?e.slice(l,a):""}function y6(e,t){const r={type:"text",value:x6(String(t.value))};return e.patch(t,r),e.applyData(t,r)}function v6(e,t){const r={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,r),e.applyData(t,r)}const b6={blockquote:QO,break:ZO,code:KO,delete:JO,emphasis:WO,footnoteReference:e6,heading:t6,html:n6,imageReference:r6,image:i6,inlineCode:l6,linkReference:a6,link:o6,listItem:s6,list:c6,paragraph:f6,root:d6,strong:h6,table:p6,tableCell:g6,tableRow:m6,text:y6,thematicBreak:v6,toml:Yu,yaml:Yu,definition:Yu,footnoteDefinition:Yu};function Yu(){}const fk=-1,Vc=0,Lo=1,wc=2,Wm=3,eg=4,tg=5,ng=6,dk=7,hk=8,F1=typeof self=="object"?self:globalThis,w6=(e,t)=>{const r=(a,o)=>(e.set(o,a),a),l=a=>{if(e.has(a))return e.get(a);const[o,s]=t[a];switch(o){case Vc:case fk:return r(s,a);case Lo:{const c=r([],a);for(const h of s)c.push(l(h));return c}case wc:{const c=r({},a);for(const[h,d]of s)c[l(h)]=l(d);return c}case Wm:return r(new Date(s),a);case eg:{const{source:c,flags:h}=s;return r(new RegExp(c,h),a)}case tg:{const c=r(new Map,a);for(const[h,d]of s)c.set(l(h),l(d));return c}case ng:{const c=r(new Set,a);for(const h of s)c.add(l(h));return c}case dk:{const{name:c,message:h}=s;return r(new F1[c](h),a)}case hk:return r(BigInt(s),a);case"BigInt":return r(Object(BigInt(s)),a);case"ArrayBuffer":return r(new Uint8Array(s).buffer,s);case"DataView":{const{buffer:c}=new Uint8Array(s);return r(new DataView(c),s)}}return r(new F1[o](s),a)};return l},Y1=e=>w6(new Map,e)(0),Wl="",{toString:_6}={},{keys:S6}=Object,Eo=e=>{const t=typeof e;if(t!=="object"||!e)return[Vc,t];const r=_6.call(e).slice(8,-1);switch(r){case"Array":return[Lo,Wl];case"Object":return[wc,Wl];case"Date":return[Wm,Wl];case"RegExp":return[eg,Wl];case"Map":return[tg,Wl];case"Set":return[ng,Wl];case"DataView":return[Lo,r]}return r.includes("Array")?[Lo,r]:r.includes("Error")?[dk,r]:[wc,r]},Xu=([e,t])=>e===Vc&&(t==="function"||t==="symbol"),k6=(e,t,r,l)=>{const a=(s,c)=>{const h=l.push(s)-1;return r.set(c,h),h},o=s=>{if(r.has(s))return r.get(s);let[c,h]=Eo(s);switch(c){case Vc:{let m=s;switch(h){case"bigint":c=hk,m=s.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+h);m=null;break;case"undefined":return a([fk],s)}return a([c,m],s)}case Lo:{if(h){let x=s;return h==="DataView"?x=new Uint8Array(s.buffer):h==="ArrayBuffer"&&(x=new Uint8Array(s)),a([h,[...x]],s)}const m=[],p=a([c,m],s);for(const x of s)m.push(o(x));return p}case wc:{if(h)switch(h){case"BigInt":return a([h,s.toString()],s);case"Boolean":case"Number":case"String":return a([h,s.valueOf()],s)}if(t&&"toJSON"in s)return o(s.toJSON());const m=[],p=a([c,m],s);for(const x of S6(s))(e||!Xu(Eo(s[x])))&&m.push([o(x),o(s[x])]);return p}case Wm:return a([c,s.toISOString()],s);case eg:{const{source:m,flags:p}=s;return a([c,{source:m,flags:p}],s)}case tg:{const m=[],p=a([c,m],s);for(const[x,b]of s)(e||!(Xu(Eo(x))||Xu(Eo(b))))&&m.push([o(x),o(b)]);return p}case ng:{const m=[],p=a([c,m],s);for(const x of s)(e||!Xu(Eo(x)))&&m.push(o(x));return p}}const{message:d}=s;return a([c,{name:h,message:d}],s)};return o},X1=(e,{json:t,lossy:r}={})=>{const l=[];return k6(!(t||r),!!t,new Map,l)(e),l},_c=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?Y1(X1(e,t)):structuredClone(e):(e,t)=>Y1(X1(e,t));function E6(e,t){const r=[{type:"text",value:"↩"}];return t>1&&r.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(t)}]}),r}function N6(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}function C6(e){const t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",r=e.options.footnoteBackContent||E6,l=e.options.footnoteBackLabel||N6,a=e.options.footnoteLabel||"Footnotes",o=e.options.footnoteLabelTagName||"h2",s=e.options.footnoteLabelProperties||{className:["sr-only"]},c=[];let h=-1;for(;++h0&&w.push({type:"text",value:" "});let N=typeof r=="string"?r:r(h,b);typeof N=="string"&&(N={type:"text",value:N}),w.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+x+(b>1?"-"+b:""),dataFootnoteBackref:"",ariaLabel:typeof l=="string"?l:l(h,b),className:["data-footnote-backref"]},children:Array.isArray(N)?N:[N]})}const S=m[m.length-1];if(S&&S.type==="element"&&S.tagName==="p"){const N=S.children[S.children.length-1];N&&N.type==="text"?N.value+=" ":S.children.push({type:"text",value:" "}),S.children.push(...w)}else m.push(...w);const _={type:"element",tagName:"li",properties:{id:t+"fn-"+x},children:e.wrap(m,!0)};e.patch(d,_),c.push(_)}if(c.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:o,properties:{..._c(s),id:"footnote-label"},children:[{type:"text",value:a}]},{type:"text",value:` +`},{type:"element",tagName:"ol",properties:{},children:e.wrap(c,!0)},{type:"text",value:` +`}]}}const Pc=(function(e){if(e==null)return z6;if(typeof e=="function")return Gc(e);if(typeof e=="object")return Array.isArray(e)?j6(e):T6(e);if(typeof e=="string")return A6(e);throw new Error("Expected function, string, or object as test")});function j6(e){const t=[];let r=-1;for(;++r":""))+")"})}return x;function x(){let b=pk,w,E,S;if((!t||o(h,d,m[m.length-1]||void 0))&&(b=O6(r(h,m)),b[0]===hm))return b;if("children"in h&&h.children){const _=h;if(_.children&&b[0]!==R6)for(E=(l?_.children.length:-1)+s,S=m.concat(_);E>-1&&E<_.children.length;){const N=_.children[E];if(w=c(N,E,S)(),w[0]===hm)return w;E=typeof w[1]=="number"?w[1]:E+s}}return b}}}function O6(e){return Array.isArray(e)?e:typeof e=="number"?[D6,e]:e==null?pk:[e]}function rg(e,t,r,l){let a,o,s;typeof t=="function"&&typeof r!="function"?(o=void 0,s=t,a=r):(o=t,s=r,a=l),mk(e,o,c,a);function c(h,d){const m=d[d.length-1],p=m?m.children.indexOf(h):void 0;return s(h,p,m)}}const pm={}.hasOwnProperty,L6={};function H6(e,t){const r=t||L6,l=new Map,a=new Map,o=new Map,s={...b6,...r.handlers},c={all:d,applyData:I6,definitionById:l,footnoteById:a,footnoteCounts:o,footnoteOrder:[],handlers:s,one:h,options:r,patch:B6,wrap:U6};return rg(e,function(m){if(m.type==="definition"||m.type==="footnoteDefinition"){const p=m.type==="definition"?l:a,x=String(m.identifier).toUpperCase();p.has(x)||p.set(x,m)}}),c;function h(m,p){const x=m.type,b=c.handlers[x];if(pm.call(c.handlers,x)&&b)return b(c,m,p);if(c.options.passThrough&&c.options.passThrough.includes(x)){if("children"in m){const{children:E,...S}=m,_=_c(S);return _.children=c.all(m),_}return _c(m)}return(c.options.unknownHandler||q6)(c,m,p)}function d(m){const p=[];if("children"in m){const x=m.children;let b=-1;for(;++b0&&r.push({type:"text",value:` +`}),r}function Q1(e){let t=0,r=e.charCodeAt(t);for(;r===9||r===32;)t++,r=e.charCodeAt(t);return e.slice(t)}function Z1(e,t){const r=H6(e,t),l=r.one(e,void 0),a=C6(r),o=Array.isArray(l)?{type:"root",children:l}:l||{type:"root",children:[]};return a&&o.children.push({type:"text",value:` +`},a),o}function $6(e,t){return e&&"run"in e?async function(r,l){const a=Z1(r,{file:l,...t});await e.run(a,l)}:function(r,l){return Z1(r,{file:l,...e||t})}}function K1(e){if(e)throw e}var Tp,J1;function V6(){if(J1)return Tp;J1=1;var e=Object.prototype.hasOwnProperty,t=Object.prototype.toString,r=Object.defineProperty,l=Object.getOwnPropertyDescriptor,a=function(d){return typeof Array.isArray=="function"?Array.isArray(d):t.call(d)==="[object Array]"},o=function(d){if(!d||t.call(d)!=="[object Object]")return!1;var m=e.call(d,"constructor"),p=d.constructor&&d.constructor.prototype&&e.call(d.constructor.prototype,"isPrototypeOf");if(d.constructor&&!m&&!p)return!1;var x;for(x in d);return typeof x>"u"||e.call(d,x)},s=function(d,m){r&&m.name==="__proto__"?r(d,m.name,{enumerable:!0,configurable:!0,value:m.newValue,writable:!0}):d[m.name]=m.newValue},c=function(d,m){if(m==="__proto__")if(e.call(d,m)){if(l)return l(d,m).value}else return;return d[m]};return Tp=function h(){var d,m,p,x,b,w,E=arguments[0],S=1,_=arguments.length,N=!1;for(typeof E=="boolean"&&(N=E,E=arguments[1]||{},S=2),(E==null||typeof E!="object"&&typeof E!="function")&&(E={});S<_;++S)if(d=arguments[S],d!=null)for(m in d)p=c(E,m),x=c(d,m),E!==x&&(N&&x&&(o(x)||(b=a(x)))?(b?(b=!1,w=p&&a(p)?p:[]):w=p&&o(p)?p:{},s(E,{name:m,newValue:h(N,w,x)})):typeof x<"u"&&s(E,{name:m,newValue:x}));return E},Tp}var P6=V6();const Ap=Zo(P6);function mm(e){if(typeof e!="object"||e===null)return!1;const t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function G6(){const e=[],t={run:r,use:l};return t;function r(...a){let o=-1;const s=a.pop();if(typeof s!="function")throw new TypeError("Expected function as last argument, not "+s);c(null,...a);function c(h,...d){const m=e[++o];let p=-1;if(h){s(h);return}for(;++ps.length;let h;c&&s.push(a);try{h=e.apply(this,s)}catch(d){const m=d;if(c&&r)throw m;return a(m)}c||(h&&h.then&&typeof h.then=="function"?h.then(o,a):h instanceof Error?a(h):o(h))}function a(s,...c){r||(r=!0,t(s,...c))}function o(s){a(null,s)}}const nr={basename:Y6,dirname:X6,extname:Q6,join:Z6,sep:"/"};function Y6(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');us(e);let r=0,l=-1,a=e.length,o;if(t===void 0||t.length===0||t.length>e.length){for(;a--;)if(e.codePointAt(a)===47){if(o){r=a+1;break}}else l<0&&(o=!0,l=a+1);return l<0?"":e.slice(r,l)}if(t===e)return"";let s=-1,c=t.length-1;for(;a--;)if(e.codePointAt(a)===47){if(o){r=a+1;break}}else s<0&&(o=!0,s=a+1),c>-1&&(e.codePointAt(a)===t.codePointAt(c--)?c<0&&(l=a):(c=-1,l=s));return r===l?l=s:l<0&&(l=e.length),e.slice(r,l)}function X6(e){if(us(e),e.length===0)return".";let t=-1,r=e.length,l;for(;--r;)if(e.codePointAt(r)===47){if(l){t=r;break}}else l||(l=!0);return t<0?e.codePointAt(0)===47?"/":".":t===1&&e.codePointAt(0)===47?"//":e.slice(0,t)}function Q6(e){us(e);let t=e.length,r=-1,l=0,a=-1,o=0,s;for(;t--;){const c=e.codePointAt(t);if(c===47){if(s){l=t+1;break}continue}r<0&&(s=!0,r=t+1),c===46?a<0?a=t:o!==1&&(o=1):a>-1&&(o=-1)}return a<0||r<0||o===0||o===1&&a===r-1&&a===l+1?"":e.slice(a,r)}function Z6(...e){let t=-1,r;for(;++t0&&e.codePointAt(e.length-1)===47&&(r+="/"),t?"/"+r:r}function J6(e,t){let r="",l=0,a=-1,o=0,s=-1,c,h;for(;++s<=e.length;){if(s2){if(h=r.lastIndexOf("/"),h!==r.length-1){h<0?(r="",l=0):(r=r.slice(0,h),l=r.length-1-r.lastIndexOf("/")),a=s,o=0;continue}}else if(r.length>0){r="",l=0,a=s,o=0;continue}}t&&(r=r.length>0?r+"/..":"..",l=2)}else r.length>0?r+="/"+e.slice(a+1,s):r=e.slice(a+1,s),l=s-a-1;a=s,o=0}else c===46&&o>-1?o++:o=-1}return r}function us(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const W6={cwd:eL};function eL(){return"/"}function gm(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function tL(e){if(typeof e=="string")e=new URL(e);else if(!gm(e)){const t=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code="ERR_INVALID_ARG_TYPE",t}if(e.protocol!=="file:"){const t=new TypeError("The URL must be of scheme file");throw t.code="ERR_INVALID_URL_SCHEME",t}return nL(e)}function nL(e){if(e.hostname!==""){const l=new TypeError('File URL host must be "localhost" or empty on darwin');throw l.code="ERR_INVALID_FILE_URL_HOST",l}const t=e.pathname;let r=-1;for(;++r0){let[b,...w]=m;const E=l[x][1];mm(E)&&mm(b)&&(b=Ap(!0,E,b)),l[x]=[d,b,...w]}}}}const aL=new ig().freeze();function Rp(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function Op(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function Lp(e,t){if(t)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function ew(e){if(!mm(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function tw(e,t,r){if(!r)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function Qu(e){return oL(e)?e:new gk(e)}function oL(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function sL(e){return typeof e=="string"||uL(e)}function uL(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const cL="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",nw=[],rw={allowDangerousHtml:!0},fL=/^(https?|ircs?|mailto|xmpp)$/i,dL=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"className",id:"remove-classname"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function Fc(e){const t=hL(e),r=pL(e);return mL(t.runSync(t.parse(r),r),e)}function hL(e){const t=e.rehypePlugins||nw,r=e.remarkPlugins||nw,l=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...rw}:rw;return aL().use(XO).use(r).use($6,l).use(t)}function pL(e){const t=e.children||"",r=new gk;return typeof t=="string"&&(r.value=t),r}function mL(e,t){const r=t.allowedElements,l=t.allowElement,a=t.components,o=t.disallowedElements,s=t.skipHtml,c=t.unwrapDisallowed,h=t.urlTransform||gL;for(const m of dL)Object.hasOwn(t,m.from)&&(""+m.from+(m.to?"use `"+m.to+"` instead":"remove it")+cL+m.id,void 0);return rg(e,d),zD(e,{Fragment:y.Fragment,components:a,ignoreInvalidStyle:!0,jsx:y.jsx,jsxs:y.jsxs,passKeys:!0,passNode:!0});function d(m,p,x){if(m.type==="raw"&&x&&typeof p=="number")return s?x.children.splice(p,1):x.children[p]={type:"text",value:m.value},p;if(m.type==="element"){let b;for(b in Np)if(Object.hasOwn(Np,b)&&Object.hasOwn(m.properties,b)){const w=m.properties[b],E=Np[b];(E===null||E.includes(m.tagName))&&(m.properties[b]=h(String(w||""),b,m))}}if(m.type==="element"){let b=r?!r.includes(m.tagName):o?o.includes(m.tagName):!1;if(!b&&l&&typeof p=="number"&&(b=!l(m,p,x)),b&&x&&typeof p=="number")return c&&m.children?x.children.splice(p,1,...m.children):x.children.splice(p,1),p}}}function gL(e){const t=e.indexOf(":"),r=e.indexOf("?"),l=e.indexOf("#"),a=e.indexOf("/");return t===-1||a!==-1&&t>a||r!==-1&&t>r||l!==-1&&t>l||fL.test(e.slice(0,t))?e:""}function iw(e,t){const r=String(e);if(typeof t!="string")throw new TypeError("Expected character");let l=0,a=r.indexOf(t);for(;a!==-1;)l++,a=r.indexOf(t,a+t.length);return l}function xL(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function yL(e,t,r){const a=Pc((r||{}).ignore||[]),o=vL(t);let s=-1;for(;++s0?{type:"text",value:A}:void 0),A===!1?x.lastIndex=T+1:(w!==T&&N.push({type:"text",value:d.value.slice(w,T)}),Array.isArray(A)?N.push(...A):A&&N.push(A),w=T+k[0].length,_=!0),!x.global)break;k=x.exec(d.value)}return _?(w?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let r=t[0],l=r.indexOf(")");const a=iw(e,"(");let o=iw(e,")");for(;l!==-1&&a>o;)e+=r.slice(0,l+1),r=r.slice(l+1),l=r.indexOf(")"),o++;return[e,r]}function xk(e,t){const r=e.input.charCodeAt(e.index-1);return(e.index===0||al(r)||Uc(r))&&(!t||r!==47)}yk.peek=$L;function RL(){this.buffer()}function OL(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function LL(){this.buffer()}function HL(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function BL(e){const t=this.resume(),r=this.stack[this.stack.length-1];r.type,r.identifier=Fn(this.sliceSerialize(e)).toLowerCase(),r.label=t}function IL(e){this.exit(e)}function qL(e){const t=this.resume(),r=this.stack[this.stack.length-1];r.type,r.identifier=Fn(this.sliceSerialize(e)).toLowerCase(),r.label=t}function UL(e){this.exit(e)}function $L(){return"["}function yk(e,t,r,l){const a=r.createTracker(l);let o=a.move("[^");const s=r.enter("footnoteReference"),c=r.enter("reference");return o+=a.move(r.safe(r.associationId(e),{after:"]",before:o})),c(),s(),o+=a.move("]"),o}function VL(){return{enter:{gfmFootnoteCallString:RL,gfmFootnoteCall:OL,gfmFootnoteDefinitionLabelString:LL,gfmFootnoteDefinition:HL},exit:{gfmFootnoteCallString:BL,gfmFootnoteCall:IL,gfmFootnoteDefinitionLabelString:qL,gfmFootnoteDefinition:UL}}}function PL(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:r,footnoteReference:yk},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function r(l,a,o,s){const c=o.createTracker(s);let h=c.move("[^");const d=o.enter("footnoteDefinition"),m=o.enter("label");return h+=c.move(o.safe(o.associationId(l),{before:h,after:"]"})),m(),h+=c.move("]:"),l.children&&l.children.length>0&&(c.shift(4),h+=c.move((t?` +`:" ")+o.indentLines(o.containerFlow(l,c.current()),t?vk:GL))),d(),h}}function GL(e,t,r){return t===0?e:vk(e,t,r)}function vk(e,t,r){return(r?"":" ")+e}const FL=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];bk.peek=KL;function YL(){return{canContainEols:["delete"],enter:{strikethrough:QL},exit:{strikethrough:ZL}}}function XL(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:FL}],handlers:{delete:bk}}}function QL(e){this.enter({type:"delete",children:[]},e)}function ZL(e){this.exit(e)}function bk(e,t,r,l){const a=r.createTracker(l),o=r.enter("strikethrough");let s=a.move("~~");return s+=r.containerPhrasing(e,{...a.current(),before:s,after:"~"}),s+=a.move("~~"),o(),s}function KL(){return"~"}function JL(e){return e.length}function WL(e,t){const r=t||{},l=(r.align||[]).concat(),a=r.stringLength||JL,o=[],s=[],c=[],h=[];let d=0,m=-1;for(;++md&&(d=e[m].length);++_h[_])&&(h[_]=k)}E.push(N)}s[m]=E,c[m]=S}let p=-1;if(typeof l=="object"&&"length"in l)for(;++ph[p]&&(h[p]=N),b[p]=N),x[p]=k}s.splice(1,0,x),c.splice(1,0,b),m=-1;const w=[];for(;++m "),o.shift(2);const s=r.indentLines(r.containerFlow(e,o.current()),n8);return a(),s}function n8(e,t,r){return">"+(r?"":" ")+e}function r8(e,t){return aw(e,t.inConstruct,!0)&&!aw(e,t.notInConstruct,!1)}function aw(e,t,r){if(typeof t=="string"&&(t=[t]),!t||t.length===0)return r;let l=-1;for(;++ls&&(s=o):o=1,a=l+t.length,l=r.indexOf(t,a);return s}function l8(e,t){return!!(t.options.fences===!1&&e.value&&!e.lang&&/[^ \r\n]/.test(e.value)&&!/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(e.value))}function a8(e){const t=e.options.fence||"`";if(t!=="`"&&t!=="~")throw new Error("Cannot serialize code with `"+t+"` for `options.fence`, expected `` ` `` or `~`");return t}function o8(e,t,r,l){const a=a8(r),o=e.value||"",s=a==="`"?"GraveAccent":"Tilde";if(l8(e,r)){const p=r.enter("codeIndented"),x=r.indentLines(o,s8);return p(),x}const c=r.createTracker(l),h=a.repeat(Math.max(i8(o,a)+1,3)),d=r.enter("codeFenced");let m=c.move(h);if(e.lang){const p=r.enter(`codeFencedLang${s}`);m+=c.move(r.safe(e.lang,{before:m,after:" ",encode:["`"],...c.current()})),p()}if(e.lang&&e.meta){const p=r.enter(`codeFencedMeta${s}`);m+=c.move(" "),m+=c.move(r.safe(e.meta,{before:m,after:` +`,encode:["`"],...c.current()})),p()}return m+=c.move(` +`),o&&(m+=c.move(o+` +`)),m+=c.move(h),d(),m}function s8(e,t,r){return(r?"":" ")+e}function lg(e){const t=e.options.quote||'"';if(t!=='"'&&t!=="'")throw new Error("Cannot serialize title with `"+t+"` for `options.quote`, expected `\"`, or `'`");return t}function u8(e,t,r,l){const a=lg(r),o=a==='"'?"Quote":"Apostrophe",s=r.enter("definition");let c=r.enter("label");const h=r.createTracker(l);let d=h.move("[");return d+=h.move(r.safe(r.associationId(e),{before:d,after:"]",...h.current()})),d+=h.move("]: "),c(),!e.url||/[\0- \u007F]/.test(e.url)?(c=r.enter("destinationLiteral"),d+=h.move("<"),d+=h.move(r.safe(e.url,{before:d,after:">",...h.current()})),d+=h.move(">")):(c=r.enter("destinationRaw"),d+=h.move(r.safe(e.url,{before:d,after:e.title?" ":` +`,...h.current()}))),c(),e.title&&(c=r.enter(`title${o}`),d+=h.move(" "+a),d+=h.move(r.safe(e.title,{before:d,after:a,...h.current()})),d+=h.move(a),c()),s(),d}function c8(e){const t=e.options.emphasis||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize emphasis with `"+t+"` for `options.emphasis`, expected `*`, or `_`");return t}function Qo(e){return"&#x"+e.toString(16).toUpperCase()+";"}function Sc(e,t,r){const l=va(e),a=va(t);return l===void 0?a===void 0?r==="_"?{inside:!0,outside:!0}:{inside:!1,outside:!1}:a===1?{inside:!0,outside:!0}:{inside:!1,outside:!0}:l===1?a===void 0?{inside:!1,outside:!1}:a===1?{inside:!0,outside:!0}:{inside:!1,outside:!1}:a===void 0?{inside:!1,outside:!1}:a===1?{inside:!0,outside:!1}:{inside:!1,outside:!1}}wk.peek=f8;function wk(e,t,r,l){const a=c8(r),o=r.enter("emphasis"),s=r.createTracker(l),c=s.move(a);let h=s.move(r.containerPhrasing(e,{after:a,before:c,...s.current()}));const d=h.charCodeAt(0),m=Sc(l.before.charCodeAt(l.before.length-1),d,a);m.inside&&(h=Qo(d)+h.slice(1));const p=h.charCodeAt(h.length-1),x=Sc(l.after.charCodeAt(0),p,a);x.inside&&(h=h.slice(0,-1)+Qo(p));const b=s.move(a);return o(),r.attentionEncodeSurroundingInfo={after:x.outside,before:m.outside},c+h+b}function f8(e,t,r){return r.options.emphasis||"*"}function d8(e,t){let r=!1;return rg(e,function(l){if("value"in l&&/\r?\n|\r/.test(l.value)||l.type==="break")return r=!0,hm}),!!((!e.depth||e.depth<3)&&Zm(e)&&(t.options.setext||r))}function h8(e,t,r,l){const a=Math.max(Math.min(6,e.depth||1),1),o=r.createTracker(l);if(d8(e,r)){const m=r.enter("headingSetext"),p=r.enter("phrasing"),x=r.containerPhrasing(e,{...o.current(),before:` +`,after:` +`});return p(),m(),x+` +`+(a===1?"=":"-").repeat(x.length-(Math.max(x.lastIndexOf("\r"),x.lastIndexOf(` +`))+1))}const s="#".repeat(a),c=r.enter("headingAtx"),h=r.enter("phrasing");o.move(s+" ");let d=r.containerPhrasing(e,{before:"# ",after:` +`,...o.current()});return/^[\t ]/.test(d)&&(d=Qo(d.charCodeAt(0))+d.slice(1)),d=d?s+" "+d:s,r.options.closeAtx&&(d+=" "+s),h(),c(),d}_k.peek=p8;function _k(e){return e.value||""}function p8(){return"<"}Sk.peek=m8;function Sk(e,t,r,l){const a=lg(r),o=a==='"'?"Quote":"Apostrophe",s=r.enter("image");let c=r.enter("label");const h=r.createTracker(l);let d=h.move("![");return d+=h.move(r.safe(e.alt,{before:d,after:"]",...h.current()})),d+=h.move("]("),c(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(c=r.enter("destinationLiteral"),d+=h.move("<"),d+=h.move(r.safe(e.url,{before:d,after:">",...h.current()})),d+=h.move(">")):(c=r.enter("destinationRaw"),d+=h.move(r.safe(e.url,{before:d,after:e.title?" ":")",...h.current()}))),c(),e.title&&(c=r.enter(`title${o}`),d+=h.move(" "+a),d+=h.move(r.safe(e.title,{before:d,after:a,...h.current()})),d+=h.move(a),c()),d+=h.move(")"),s(),d}function m8(){return"!"}kk.peek=g8;function kk(e,t,r,l){const a=e.referenceType,o=r.enter("imageReference");let s=r.enter("label");const c=r.createTracker(l);let h=c.move("![");const d=r.safe(e.alt,{before:h,after:"]",...c.current()});h+=c.move(d+"]["),s();const m=r.stack;r.stack=[],s=r.enter("reference");const p=r.safe(r.associationId(e),{before:h,after:"]",...c.current()});return s(),r.stack=m,o(),a==="full"||!d||d!==p?h+=c.move(p+"]"):a==="shortcut"?h=h.slice(0,-1):h+=c.move("]"),h}function g8(){return"!"}Ek.peek=x8;function Ek(e,t,r){let l=e.value||"",a="`",o=-1;for(;new RegExp("(^|[^`])"+a+"([^`]|$)").test(l);)a+="`";for(/[^ \r\n]/.test(l)&&(/^[ \r\n]/.test(l)&&/[ \r\n]$/.test(l)||/^`|`$/.test(l))&&(l=" "+l+" ");++o\u007F]/.test(e.url))}Ck.peek=y8;function Ck(e,t,r,l){const a=lg(r),o=a==='"'?"Quote":"Apostrophe",s=r.createTracker(l);let c,h;if(Nk(e,r)){const m=r.stack;r.stack=[],c=r.enter("autolink");let p=s.move("<");return p+=s.move(r.containerPhrasing(e,{before:p,after:">",...s.current()})),p+=s.move(">"),c(),r.stack=m,p}c=r.enter("link"),h=r.enter("label");let d=s.move("[");return d+=s.move(r.containerPhrasing(e,{before:d,after:"](",...s.current()})),d+=s.move("]("),h(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(h=r.enter("destinationLiteral"),d+=s.move("<"),d+=s.move(r.safe(e.url,{before:d,after:">",...s.current()})),d+=s.move(">")):(h=r.enter("destinationRaw"),d+=s.move(r.safe(e.url,{before:d,after:e.title?" ":")",...s.current()}))),h(),e.title&&(h=r.enter(`title${o}`),d+=s.move(" "+a),d+=s.move(r.safe(e.title,{before:d,after:a,...s.current()})),d+=s.move(a),h()),d+=s.move(")"),c(),d}function y8(e,t,r){return Nk(e,r)?"<":"["}jk.peek=v8;function jk(e,t,r,l){const a=e.referenceType,o=r.enter("linkReference");let s=r.enter("label");const c=r.createTracker(l);let h=c.move("[");const d=r.containerPhrasing(e,{before:h,after:"]",...c.current()});h+=c.move(d+"]["),s();const m=r.stack;r.stack=[],s=r.enter("reference");const p=r.safe(r.associationId(e),{before:h,after:"]",...c.current()});return s(),r.stack=m,o(),a==="full"||!d||d!==p?h+=c.move(p+"]"):a==="shortcut"?h=h.slice(0,-1):h+=c.move("]"),h}function v8(){return"["}function ag(e){const t=e.options.bullet||"*";if(t!=="*"&&t!=="+"&&t!=="-")throw new Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function b8(e){const t=ag(e),r=e.options.bulletOther;if(!r)return t==="*"?"-":"*";if(r!=="*"&&r!=="+"&&r!=="-")throw new Error("Cannot serialize items with `"+r+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(r===t)throw new Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+r+"`) to be different");return r}function w8(e){const t=e.options.bulletOrdered||".";if(t!=="."&&t!==")")throw new Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function Tk(e){const t=e.options.rule||"*";if(t!=="*"&&t!=="-"&&t!=="_")throw new Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function _8(e,t,r,l){const a=r.enter("list"),o=r.bulletCurrent;let s=e.ordered?w8(r):ag(r);const c=e.ordered?s==="."?")":".":b8(r);let h=t&&r.bulletLastUsed?s===r.bulletLastUsed:!1;if(!e.ordered){const m=e.children?e.children[0]:void 0;if((s==="*"||s==="-")&&m&&(!m.children||!m.children[0])&&r.stack[r.stack.length-1]==="list"&&r.stack[r.stack.length-2]==="listItem"&&r.stack[r.stack.length-3]==="list"&&r.stack[r.stack.length-4]==="listItem"&&r.indexStack[r.indexStack.length-1]===0&&r.indexStack[r.indexStack.length-2]===0&&r.indexStack[r.indexStack.length-3]===0&&(h=!0),Tk(r)===s&&m){let p=-1;for(;++p-1?t.start:1)+(r.options.incrementListMarker===!1?0:t.children.indexOf(e))+o);let s=o.length+1;(a==="tab"||a==="mixed"&&(t&&t.type==="list"&&t.spread||e.spread))&&(s=Math.ceil(s/4)*4);const c=r.createTracker(l);c.move(o+" ".repeat(s-o.length)),c.shift(s);const h=r.enter("listItem"),d=r.indentLines(r.containerFlow(e,c.current()),m);return h(),d;function m(p,x,b){return x?(b?"":" ".repeat(s))+p:(b?o:o+" ".repeat(s-o.length))+p}}function E8(e,t,r,l){const a=r.enter("paragraph"),o=r.enter("phrasing"),s=r.containerPhrasing(e,l);return o(),a(),s}const N8=Pc(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function C8(e,t,r,l){return(e.children.some(function(s){return N8(s)})?r.containerPhrasing:r.containerFlow).call(r,e,l)}function j8(e){const t=e.options.strong||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}Ak.peek=T8;function Ak(e,t,r,l){const a=j8(r),o=r.enter("strong"),s=r.createTracker(l),c=s.move(a+a);let h=s.move(r.containerPhrasing(e,{after:a,before:c,...s.current()}));const d=h.charCodeAt(0),m=Sc(l.before.charCodeAt(l.before.length-1),d,a);m.inside&&(h=Qo(d)+h.slice(1));const p=h.charCodeAt(h.length-1),x=Sc(l.after.charCodeAt(0),p,a);x.inside&&(h=h.slice(0,-1)+Qo(p));const b=s.move(a+a);return o(),r.attentionEncodeSurroundingInfo={after:x.outside,before:m.outside},c+h+b}function T8(e,t,r){return r.options.strong||"*"}function A8(e,t,r,l){return r.safe(e.value,l)}function z8(e){const t=e.options.ruleRepetition||3;if(t<3)throw new Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}function M8(e,t,r){const l=(Tk(r)+(r.options.ruleSpaces?" ":"")).repeat(z8(r));return r.options.ruleSpaces?l.slice(0,-1):l}const zk={blockquote:t8,break:ow,code:o8,definition:u8,emphasis:wk,hardBreak:ow,heading:h8,html:_k,image:Sk,imageReference:kk,inlineCode:Ek,link:Ck,linkReference:jk,list:_8,listItem:k8,paragraph:E8,root:C8,strong:Ak,text:A8,thematicBreak:M8};function D8(){return{enter:{table:R8,tableData:sw,tableHeader:sw,tableRow:L8},exit:{codeText:H8,table:O8,tableData:qp,tableHeader:qp,tableRow:qp}}}function R8(e){const t=e._align;this.enter({type:"table",align:t.map(function(r){return r==="none"?null:r}),children:[]},e),this.data.inTable=!0}function O8(e){this.exit(e),this.data.inTable=void 0}function L8(e){this.enter({type:"tableRow",children:[]},e)}function qp(e){this.exit(e)}function sw(e){this.enter({type:"tableCell",children:[]},e)}function H8(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,B8));const r=this.stack[this.stack.length-1];r.type,r.value=t,this.exit(e)}function B8(e,t){return t==="|"?t:e}function I8(e){const t=e||{},r=t.tableCellPadding,l=t.tablePipeAlign,a=t.stringLength,o=r?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:` +`,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:x,table:s,tableCell:h,tableRow:c}};function s(b,w,E,S){return d(m(b,E,S),b.align)}function c(b,w,E,S){const _=p(b,E,S),N=d([_]);return N.slice(0,N.indexOf(` +`))}function h(b,w,E,S){const _=E.enter("tableCell"),N=E.enter("phrasing"),k=E.containerPhrasing(b,{...S,before:o,after:o});return N(),_(),k}function d(b,w){return WL(b,{align:w,alignDelimiters:l,padding:r,stringLength:a})}function m(b,w,E){const S=b.children;let _=-1;const N=[],k=w.enter("table");for(;++_0&&!r&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),r}const r9={tokenize:f9,partial:!0};function i9(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:s9,continuation:{tokenize:u9},exit:c9}},text:{91:{name:"gfmFootnoteCall",tokenize:o9},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:l9,resolveTo:a9}}}}function l9(e,t,r){const l=this;let a=l.events.length;const o=l.parser.gfmFootnotes||(l.parser.gfmFootnotes=[]);let s;for(;a--;){const h=l.events[a][1];if(h.type==="labelImage"){s=h;break}if(h.type==="gfmFootnoteCall"||h.type==="labelLink"||h.type==="label"||h.type==="image"||h.type==="link")break}return c;function c(h){if(!s||!s._balanced)return r(h);const d=Fn(l.sliceSerialize({start:s.end,end:l.now()}));return d.codePointAt(0)!==94||!o.includes(d.slice(1))?r(h):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(h),e.exit("gfmFootnoteCallLabelMarker"),t(h))}}function a9(e,t){let r=e.length;for(;r--;)if(e[r][1].type==="labelImage"&&e[r][0]==="enter"){e[r][1];break}e[r+1][1].type="data",e[r+3][1].type="gfmFootnoteCallLabelMarker";const l={type:"gfmFootnoteCall",start:Object.assign({},e[r+3][1].start),end:Object.assign({},e[e.length-1][1].end)},a={type:"gfmFootnoteCallMarker",start:Object.assign({},e[r+3][1].end),end:Object.assign({},e[r+3][1].end)};a.end.column++,a.end.offset++,a.end._bufferIndex++;const o={type:"gfmFootnoteCallString",start:Object.assign({},a.end),end:Object.assign({},e[e.length-1][1].start)},s={type:"chunkString",contentType:"string",start:Object.assign({},o.start),end:Object.assign({},o.end)},c=[e[r+1],e[r+2],["enter",l,t],e[r+3],e[r+4],["enter",a,t],["exit",a,t],["enter",o,t],["enter",s,t],["exit",s,t],["exit",o,t],e[e.length-2],e[e.length-1],["exit",l,t]];return e.splice(r,e.length-r+1,...c),e}function o9(e,t,r){const l=this,a=l.parser.gfmFootnotes||(l.parser.gfmFootnotes=[]);let o=0,s;return c;function c(p){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(p),e.exit("gfmFootnoteCallLabelMarker"),h}function h(p){return p!==94?r(p):(e.enter("gfmFootnoteCallMarker"),e.consume(p),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",d)}function d(p){if(o>999||p===93&&!s||p===null||p===91||st(p))return r(p);if(p===93){e.exit("chunkString");const x=e.exit("gfmFootnoteCallString");return a.includes(Fn(l.sliceSerialize(x)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(p),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):r(p)}return st(p)||(s=!0),o++,e.consume(p),p===92?m:d}function m(p){return p===91||p===92||p===93?(e.consume(p),o++,d):d(p)}}function s9(e,t,r){const l=this,a=l.parser.gfmFootnotes||(l.parser.gfmFootnotes=[]);let o,s=0,c;return h;function h(w){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(w),e.exit("gfmFootnoteDefinitionLabelMarker"),d}function d(w){return w===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(w),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",m):r(w)}function m(w){if(s>999||w===93&&!c||w===null||w===91||st(w))return r(w);if(w===93){e.exit("chunkString");const E=e.exit("gfmFootnoteDefinitionLabelString");return o=Fn(l.sliceSerialize(E)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(w),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),x}return st(w)||(c=!0),s++,e.consume(w),w===92?p:m}function p(w){return w===91||w===92||w===93?(e.consume(w),s++,m):m(w)}function x(w){return w===58?(e.enter("definitionMarker"),e.consume(w),e.exit("definitionMarker"),a.includes(o)||a.push(o),Qe(e,b,"gfmFootnoteDefinitionWhitespace")):r(w)}function b(w){return t(w)}}function u9(e,t,r){return e.check(ss,t,e.attempt(r9,t,r))}function c9(e){e.exit("gfmFootnoteDefinition")}function f9(e,t,r){const l=this;return Qe(e,a,"gfmFootnoteDefinitionIndent",5);function a(o){const s=l.events[l.events.length-1];return s&&s[1].type==="gfmFootnoteDefinitionIndent"&&s[2].sliceSerialize(s[1],!0).length===4?t(o):r(o)}}function d9(e){let r=(e||{}).singleTilde;const l={name:"strikethrough",tokenize:o,resolveAll:a};return r==null&&(r=!0),{text:{126:l},insideSpan:{null:[l]},attentionMarkers:{null:[126]}};function a(s,c){let h=-1;for(;++h1?h(w):(s.consume(w),p++,b);if(p<2&&!r)return h(w);const S=s.exit("strikethroughSequenceTemporary"),_=va(w);return S._open=!_||_===2&&!!E,S._close=!E||E===2&&!!_,c(w)}}}class h9{constructor(){this.map=[]}add(t,r,l){p9(this,t,r,l)}consume(t){if(this.map.sort(function(o,s){return o[0]-s[0]}),this.map.length===0)return;let r=this.map.length;const l=[];for(;r>0;)r-=1,l.push(t.slice(this.map[r][0]+this.map[r][1]),this.map[r][2]),t.length=this.map[r][0];l.push(t.slice()),t.length=0;let a=l.pop();for(;a;){for(const o of a)t.push(o);a=l.pop()}this.map.length=0}}function p9(e,t,r,l){let a=0;if(!(r===0&&l.length===0)){for(;a-1;){const I=l.events[B][1].type;if(I==="lineEnding"||I==="linePrefix")B--;else break}const $=B>-1?l.events[B][1].type:null,ee=$==="tableHead"||$==="tableRow"?A:h;return ee===A&&l.parser.lazy[l.now().line]?r(H):ee(H)}function h(H){return e.enter("tableHead"),e.enter("tableRow"),d(H)}function d(H){return H===124||(s=!0,o+=1),m(H)}function m(H){return H===null?r(H):Ee(H)?o>1?(o=0,l.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(H),e.exit("lineEnding"),b):r(H):Ve(H)?Qe(e,m,"whitespace")(H):(o+=1,s&&(s=!1,a+=1),H===124?(e.enter("tableCellDivider"),e.consume(H),e.exit("tableCellDivider"),s=!0,m):(e.enter("data"),p(H)))}function p(H){return H===null||H===124||st(H)?(e.exit("data"),m(H)):(e.consume(H),H===92?x:p)}function x(H){return H===92||H===124?(e.consume(H),p):p(H)}function b(H){return l.interrupt=!1,l.parser.lazy[l.now().line]?r(H):(e.enter("tableDelimiterRow"),s=!1,Ve(H)?Qe(e,w,"linePrefix",l.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(H):w(H))}function w(H){return H===45||H===58?S(H):H===124?(s=!0,e.enter("tableCellDivider"),e.consume(H),e.exit("tableCellDivider"),E):M(H)}function E(H){return Ve(H)?Qe(e,S,"whitespace")(H):S(H)}function S(H){return H===58?(o+=1,s=!0,e.enter("tableDelimiterMarker"),e.consume(H),e.exit("tableDelimiterMarker"),_):H===45?(o+=1,_(H)):H===null||Ee(H)?T(H):M(H)}function _(H){return H===45?(e.enter("tableDelimiterFiller"),N(H)):M(H)}function N(H){return H===45?(e.consume(H),N):H===58?(s=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(H),e.exit("tableDelimiterMarker"),k):(e.exit("tableDelimiterFiller"),k(H))}function k(H){return Ve(H)?Qe(e,T,"whitespace")(H):T(H)}function T(H){return H===124?w(H):H===null||Ee(H)?!s||a!==o?M(H):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(H)):M(H)}function M(H){return r(H)}function A(H){return e.enter("tableRow"),L(H)}function L(H){return H===124?(e.enter("tableCellDivider"),e.consume(H),e.exit("tableCellDivider"),L):H===null||Ee(H)?(e.exit("tableRow"),t(H)):Ve(H)?Qe(e,L,"whitespace")(H):(e.enter("data"),R(H))}function R(H){return H===null||H===124||st(H)?(e.exit("data"),L(H)):(e.consume(H),H===92?V:R)}function V(H){return H===92||H===124?(e.consume(H),R):R(H)}}function y9(e,t){let r=-1,l=!0,a=0,o=[0,0,0,0],s=[0,0,0,0],c=!1,h=0,d,m,p;const x=new h9;for(;++rr[2]+1){const w=r[2]+1,E=r[3]-r[2]-1;e.add(w,E,[])}}e.add(r[3]+1,0,[["exit",p,t]])}return a!==void 0&&(o.end=Object.assign({},ta(t.events,a)),e.add(a,0,[["exit",o,t]]),o=void 0),o}function cw(e,t,r,l,a){const o=[],s=ta(t.events,r);a&&(a.end=Object.assign({},s),o.push(["exit",a,t])),l.end=Object.assign({},s),o.push(["exit",l,t]),e.add(r+1,0,o)}function ta(e,t){const r=e[t],l=r[0]==="enter"?"start":"end";return r[1][l]}const v9={name:"tasklistCheck",tokenize:w9};function b9(){return{text:{91:v9}}}function w9(e,t,r){const l=this;return a;function a(h){return l.previous!==null||!l._gfmTasklistFirstContentOfListItem?r(h):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(h),e.exit("taskListCheckMarker"),o)}function o(h){return st(h)?(e.enter("taskListCheckValueUnchecked"),e.consume(h),e.exit("taskListCheckValueUnchecked"),s):h===88||h===120?(e.enter("taskListCheckValueChecked"),e.consume(h),e.exit("taskListCheckValueChecked"),s):r(h)}function s(h){return h===93?(e.enter("taskListCheckMarker"),e.consume(h),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),c):r(h)}function c(h){return Ee(h)?t(h):Ve(h)?e.check({tokenize:_9},t,r)(h):r(h)}}function _9(e,t,r){return Qe(e,l,"whitespace");function l(a){return a===null?r(a):t(a)}}function S9(e){return ZS([X8(),i9(),d9(e),g9(),b9()])}const k9={};function Yc(e){const t=this,r=e||k9,l=t.data(),a=l.micromarkExtensions||(l.micromarkExtensions=[]),o=l.fromMarkdownExtensions||(l.fromMarkdownExtensions=[]),s=l.toMarkdownExtensions||(l.toMarkdownExtensions=[]);a.push(S9(r)),o.push(P8()),s.push(G8(r))}const E9=new Set([".md",".markdown",".mdx"]);function N9({filePath:e,onClose:t}){const[r,l]=U.useState(null),[a,o]=U.useState(null),[s,c]=U.useState(!0),h=U.useCallback(async()=>{c(!0),o(null);try{const m=e.split("/").map(b=>encodeURIComponent(b)).join("/"),p=await fetch(`/api/files/${m}`);if(!p.ok){const b=await p.json().catch(()=>({}));o(b.error||`HTTP ${p.status}`);return}const x=await p.json();l(x)}catch(m){o(m instanceof Error?m.message:"Failed to load file")}finally{c(!1)}},[e]);U.useEffect(()=>{h()},[h]),U.useEffect(()=>{const m=p=>{p.key==="Escape"&&t()};return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[t]);const d=r?E9.has(r.extension):!1;return y.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",children:y.jsxs("div",{className:"relative flex flex-col w-[90vw] max-w-3xl max-h-[80vh] rounded-xl border border-[var(--border)] bg-[var(--surface)] shadow-2xl overflow-hidden",children:[y.jsxs("div",{className:"flex items-center gap-2 px-4 py-2.5 border-b border-[var(--border)] bg-[var(--surface-raised)] flex-shrink-0",children:[y.jsx(bw,{className:"w-4 h-4 text-[var(--text-muted)] flex-shrink-0"}),y.jsx("span",{className:"text-xs font-medium text-[var(--text)] truncate flex-1",title:e,children:e}),r&&y.jsx("span",{className:"text-[10px] text-[var(--text-muted)] flex-shrink-0 tabular-nums",children:j9(r.size)}),y.jsx("button",{onClick:t,className:"p-1 rounded-md text-[var(--text-muted)] hover:text-[var(--text)] hover:bg-[var(--surface-hover)] transition-colors flex-shrink-0",title:"Close (Esc)",children:y.jsx(sl,{className:"w-4 h-4"})})]}),y.jsxs("div",{className:"flex-1 overflow-auto px-5 py-4 min-h-0",children:[s&&y.jsx("div",{className:"flex items-center justify-center py-12",children:y.jsx(fa,{className:"w-5 h-5 text-[var(--text-muted)] animate-spin"})}),a&&y.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg bg-red-500/10 border border-red-500/30",children:[y.jsx(lc,{className:"w-4 h-4 text-red-400 flex-shrink-0"}),y.jsx("span",{className:"text-xs text-red-300",children:a})]}),r&&!a&&(d?y.jsx("div",{className:"file-viewer-markdown text-xs leading-relaxed text-[var(--text)]",children:y.jsx(C9,{content:r.content})}):y.jsx("pre",{className:"font-mono text-[11px] leading-[1.6] text-[var(--text)] whitespace-pre-wrap break-words",children:r.content}))]})]})})}function C9({content:e}){return y.jsx(Fc,{remarkPlugins:[Yc],components:{h1:({children:t})=>y.jsx("h1",{className:"text-base font-bold mb-3 mt-2 text-[var(--text)]",children:t}),h2:({children:t})=>y.jsx("h2",{className:"text-sm font-bold mb-2 mt-3 text-[var(--text)]",children:t}),h3:({children:t})=>y.jsx("h3",{className:"text-xs font-bold mb-1.5 mt-2 text-[var(--text)]",children:t}),p:({children:t})=>y.jsx("p",{className:"mb-2 last:mb-0",children:t}),ul:({children:t})=>y.jsx("ul",{className:"list-disc list-inside mb-2 space-y-1 ml-2",children:t}),ol:({children:t})=>y.jsx("ol",{className:"list-decimal list-inside mb-2 space-y-1 ml-2",children:t}),li:({children:t})=>y.jsx("li",{children:t}),code:({children:t,className:r})=>(r==null?void 0:r.includes("language-"))?y.jsx("code",{className:"block bg-[var(--bg)] border border-[var(--border)] rounded px-3 py-2 font-mono text-[11px] my-2 overflow-x-auto whitespace-pre",children:t}):y.jsx("code",{className:"bg-[var(--bg)] border border-[var(--border)] rounded px-1 py-0.5 font-mono text-[11px]",children:t}),pre:({children:t})=>y.jsx("pre",{className:"bg-[var(--bg)] border border-[var(--border)] rounded-md px-3 py-2.5 font-mono text-[11px] my-2 overflow-x-auto",children:t}),strong:({children:t})=>y.jsx("strong",{className:"font-semibold",children:t}),em:({children:t})=>y.jsx("em",{className:"italic",children:t}),a:({href:t,children:r})=>y.jsx("a",{href:t,target:"_blank",rel:"noopener noreferrer",className:"text-blue-400 hover:text-blue-300 underline underline-offset-2",children:r}),blockquote:({children:t})=>y.jsx("blockquote",{className:"border-l-2 border-[var(--border)] pl-3 my-2 opacity-80",children:t}),hr:()=>y.jsx("hr",{className:"border-[var(--border)] my-3"}),table:({children:t})=>y.jsx("div",{className:"overflow-x-auto my-2",children:y.jsx("table",{className:"text-[11px] border-collapse w-full",children:t})}),th:({children:t})=>y.jsx("th",{className:"border border-[var(--border)] px-2 py-1 text-left bg-[var(--bg)] font-semibold",children:t}),td:({children:t})=>y.jsx("td",{className:"border border-[var(--border)] px-2 py-1",children:t})},children:e})}function j9(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function T9({node:e}){const t=ue(M=>M.sendGateResponse),r=ue(M=>M.wsStatus),[l,a]=U.useState(null),[o,s]=U.useState(""),[c,h]=U.useState(null),[d,m]=U.useState(!1),[p,x]=U.useState(null),b=e.status==="waiting",w=e.status==="completed";U.useEffect(()=>{b&&(a(null),s(""),h(null),m(!1))},[b]);const E=b&&r==="connected"&&l===null,S=(M,A)=>{if(E){if(A){a(M),h(A);return}a(M),m(!0),t(e.name,M)}},_=()=>{if(l===null||c===null)return;const M={[c]:o};m(!0),t(e.name,l,M),h(null)},N=e.option_details,k=N==null?void 0:N.find(M=>M.value===e.selected_option),T=(k==null?void 0:k.label)||e.selected_option;return y.jsxs("div",{className:"space-y-3",children:[b&&y.jsxs(y.Fragment,{children:[y.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2 rounded-lg bg-amber-500/10 border border-amber-500/30",children:[y.jsxs("span",{className:"relative flex h-2.5 w-2.5 flex-shrink-0",children:[y.jsx("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full bg-amber-400 opacity-75"}),y.jsx("span",{className:"relative inline-flex rounded-full h-2.5 w-2.5 bg-amber-500"})]}),y.jsx("span",{className:"text-xs font-semibold text-amber-400 tracking-wide",children:"Decision Required"})]}),e.prompt&&y.jsx("div",{className:"border-l-2 border-amber-500/50 pl-3 py-0.5",children:y.jsx(Up,{text:e.prompt,muted:!1,onFileClick:x})}),N&&N.length>0&&y.jsxs("div",{className:"space-y-2",children:[y.jsx("div",{className:"flex flex-col gap-1.5",children:N.map(M=>{const A=l===M.value,L=l!==null&&!A;return y.jsx("button",{disabled:!E&&!A,onClick:()=>S(M.value,M.prompt_for),className:`w-full text-left px-3 py-2.5 rounded-lg border transition-all duration-150 ${A?"border-green-500/60 bg-green-500/10":L?"border-[var(--border)] opacity-40 cursor-default":"border-[var(--border)] bg-[var(--surface)] hover:border-amber-400/60 hover:bg-amber-500/5 cursor-pointer group"}`,children:y.jsxs("div",{className:"flex items-center gap-2.5",children:[y.jsx("div",{className:"flex-shrink-0",children:A?y.jsx("div",{className:"w-4 h-4 rounded-full bg-green-500 flex items-center justify-center",children:y.jsx(Zi,{className:"w-2.5 h-2.5 text-white",strokeWidth:3})}):y.jsx("div",{className:`w-4 h-4 rounded-full border-2 transition-colors ${L?"border-[var(--border)]":"border-[var(--border)] group-hover:border-amber-400"}`})}),y.jsx("div",{className:"flex-1 min-w-0",children:y.jsx("span",{className:`text-xs font-medium ${A?"text-green-400":"text-[var(--text)]"}`,children:M.label})}),M.route&&y.jsxs("span",{className:"text-[10px] text-[var(--text-muted)] flex-shrink-0",children:["→ ",M.route]})]})},M.value)})}),d&&!c&&y.jsxs("div",{className:"flex items-center gap-2 px-1",children:[y.jsx(fa,{className:"w-3 h-3 text-green-400 animate-spin"}),y.jsx("span",{className:"text-[10px] text-green-400",children:"Sending..."})]}),E&&y.jsx("p",{className:"text-[10px] text-[var(--text-muted)] px-1",children:"Select an option to continue the workflow"})]}),!N&&e.options&&e.options.length>0&&y.jsxs("div",{className:"space-y-1.5",children:[y.jsx("h4",{className:"text-[10px] uppercase tracking-wider text-[var(--text-muted)] font-semibold",children:"Options"}),y.jsx("div",{className:"flex flex-wrap gap-1.5",children:e.options.map(M=>y.jsx("span",{className:"text-[11px] px-2 py-0.5 rounded border border-[var(--border)] text-[var(--text-muted)]",children:M},M))})]}),c&&y.jsxs("div",{className:"rounded-lg border border-[var(--border)] bg-[var(--bg)] overflow-hidden",children:[y.jsx("div",{className:"px-3 py-2 border-b border-[var(--border)] bg-[var(--surface)]",children:y.jsx("h4",{className:"text-[10px] uppercase tracking-wider text-[var(--text-muted)] font-semibold",children:c})}),y.jsxs("div",{className:"p-3 space-y-2",children:[y.jsx("input",{type:"text",value:o,onChange:M=>s(M.target.value),onKeyDown:M=>M.key==="Enter"&&_(),placeholder:`Enter ${c}...`,className:"w-full text-xs px-3 py-2 rounded-lg border border-[var(--border)] bg-[var(--bg)] text-[var(--text)] outline-none focus:border-amber-400 transition-colors",autoFocus:!0}),y.jsxs("div",{className:"flex items-center justify-between",children:[y.jsx("span",{className:"text-[10px] text-[var(--text-muted)]",children:"Press Enter or click Submit"}),y.jsxs("button",{onClick:_,className:"flex items-center gap-1.5 text-xs px-3 py-1.5 rounded-lg bg-amber-500 text-white hover:bg-amber-600 transition-colors font-medium",children:[y.jsx(_w,{className:"w-3 h-3"}),"Submit"]})]})]})]})]}),w&&y.jsxs(y.Fragment,{children:[y.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2 rounded-lg bg-green-500/10 border border-green-500/30",children:[y.jsx(Zi,{className:"w-3.5 h-3.5 text-green-400 flex-shrink-0"}),y.jsx("span",{className:"text-xs font-semibold text-green-400 tracking-wide",children:"Decision Completed"})]}),e.prompt&&y.jsx("div",{className:"border-l-2 border-[var(--border)] pl-3 py-0.5",children:y.jsx(Up,{text:e.prompt,muted:!0,onFileClick:x})}),T&&y.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2.5 rounded-lg border border-green-500/30 bg-green-500/5",children:[y.jsx("div",{className:"w-4 h-4 rounded-full bg-green-500 flex items-center justify-center flex-shrink-0",children:y.jsx(Zi,{className:"w-2.5 h-2.5 text-white",strokeWidth:3})}),y.jsx("span",{className:"text-xs font-medium text-[var(--text)]",children:T}),e.route&&y.jsxs("span",{className:"ml-auto text-[10px] text-[var(--text-muted)]",children:["→ ",e.route]})]}),N&&N.length>1&&y.jsx("div",{className:"space-y-1",children:N.filter(M=>M.value!==e.selected_option).map(M=>y.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2 rounded-lg opacity-35",children:[y.jsx("div",{className:"w-4 h-4 rounded-full border-2 border-[var(--border)] flex-shrink-0"}),y.jsx("span",{className:"text-xs text-[var(--text-muted)]",children:M.label}),M.route&&y.jsxs("span",{className:"ml-auto text-[10px] text-[var(--text-muted)]",children:["→ ",M.route]})]},M.value))}),!N&&e.options&&e.options.length>0&&y.jsx("div",{className:"flex flex-wrap gap-1.5",children:e.options.map(M=>y.jsxs("span",{className:`text-[11px] px-2.5 py-1 rounded-lg border ${M===e.selected_option?"border-green-500/30 text-green-400 bg-green-500/5":"border-[var(--border)] text-[var(--text-muted)] opacity-40"}`,children:[M===e.selected_option&&"✓ ",M]},M))}),y.jsx(z9,{node:e})]}),!b&&!w&&y.jsxs(y.Fragment,{children:[y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx("span",{className:"text-xs text-[var(--text-muted)]",children:"Human Gate"}),y.jsxs("span",{className:"text-[10px] text-[var(--text-muted)] capitalize",children:["(",e.status,")"]})]}),e.prompt&&y.jsx("div",{className:"border-l-2 border-[var(--border)] pl-3 py-0.5",children:y.jsx(Up,{text:e.prompt,muted:!0,onFileClick:x})})]}),p&&y.jsx(N9,{filePath:p,onClose:()=>x(null)})]})}function A9(e){return!(!e||/^[a-z][a-z0-9+.-]*:/i.test(e)||e.startsWith("//")||e.startsWith("#")||e.startsWith("/")||e.startsWith("\\"))}function Up({text:e,muted:t,onFileClick:r}){const l=t?"text-[var(--text-muted)]":"text-[var(--text)]";return y.jsx("div",{className:`gate-markdown text-xs leading-relaxed ${l}`,children:y.jsx(Fc,{remarkPlugins:[Yc],components:{h1:({children:a})=>y.jsx("h1",{className:"text-sm font-bold mb-2 mt-1",children:a}),h2:({children:a})=>y.jsx("h2",{className:"text-xs font-bold mb-1.5 mt-1",children:a}),h3:({children:a})=>y.jsx("h3",{className:"text-xs font-semibold mb-1 mt-1",children:a}),p:({children:a})=>y.jsx("p",{className:"mb-1.5 last:mb-0",children:a}),ul:({children:a})=>y.jsx("ul",{className:"list-disc list-inside mb-1.5 space-y-0.5",children:a}),ol:({children:a})=>y.jsx("ol",{className:"list-decimal list-inside mb-1.5 space-y-0.5",children:a}),li:({children:a})=>y.jsx("li",{children:a}),code:({children:a,className:o})=>(o==null?void 0:o.includes("language-"))?y.jsx("code",{className:"block bg-[var(--bg)] border border-[var(--border)] rounded px-2 py-1.5 font-mono text-[11px] my-1 overflow-x-auto whitespace-pre",children:a}):y.jsx("code",{className:"bg-[var(--bg)] border border-[var(--border)] rounded px-1 py-0.5 font-mono text-[11px]",children:a}),pre:({children:a})=>y.jsx("pre",{className:"bg-[var(--bg)] border border-[var(--border)] rounded-md px-2.5 py-2 font-mono text-[11px] my-1.5 overflow-x-auto",children:a}),strong:({children:a})=>y.jsx("strong",{className:"font-semibold",children:a}),em:({children:a})=>y.jsx("em",{className:"italic",children:a}),a:({href:a,children:o})=>r&&A9(a)?y.jsxs("button",{onClick:s=>{s.preventDefault(),r(a)},className:"inline-flex items-center gap-0.5 text-blue-400 hover:text-blue-300 underline underline-offset-2 cursor-pointer",title:`Open ${a}`,children:[y.jsx(bw,{className:"w-3 h-3 inline flex-shrink-0"}),o]}):y.jsx("a",{href:a,target:"_blank",rel:"noopener noreferrer",className:"text-blue-400 hover:text-blue-300 underline underline-offset-2",children:o}),blockquote:({children:a})=>y.jsx("blockquote",{className:"border-l-2 border-[var(--border)] pl-2.5 my-1.5 opacity-80",children:a}),hr:()=>y.jsx("hr",{className:"border-[var(--border)] my-2"}),table:({children:a})=>y.jsx("div",{className:"overflow-x-auto my-2",children:y.jsx("table",{className:"text-[11px] border-collapse w-full",children:a})}),th:({children:a})=>y.jsx("th",{className:"border border-[var(--border)] px-2 py-1 text-left bg-[var(--bg)] font-semibold",children:a}),td:({children:a})=>y.jsx("td",{className:"border border-[var(--border)] px-2 py-1",children:a})},children:e})})}function z9({node:e}){const t=[];if(e.route&&t.push({label:"Route",value:`→ ${e.route}`}),e.additional_input){const r=typeof e.additional_input=="object"?JSON.stringify(e.additional_input):e.additional_input;t.push({label:"Additional Input",value:r})}return t.length===0?null:y.jsx(wi,{items:t})}function M9({node:e}){const t=e.status,r=Ie[t]||Ie.pending,a=C5()[e.name],o=e.type==="for_each_group",[s,c]=U.useState(!0),h=[];e.elapsed!=null&&h.push({label:"Elapsed",value:pt(e.elapsed)}),a&&(h.push({label:"Total",value:a.total}),h.push({label:"Completed",value:a.completed}),a.failed>0&&h.push({label:"Failed",value:a.failed})),e.success_count!=null&&h.push({label:"Success",value:e.success_count}),e.failure_count!=null&&h.push({label:"Failures",value:e.failure_count});const d=e.for_each_items;return y.jsxs("div",{className:"space-y-4",children:[y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx("span",{className:"inline-flex items-center px-2 py-0.5 rounded text-[10px] font-bold uppercase tracking-wider",style:{backgroundColor:`${r}20`,color:r},children:t}),y.jsx("span",{className:"text-xs text-[var(--text-muted)]",children:o?"For-Each Group":"Parallel Group"})]}),a&&a.total>0&&y.jsxs("div",{className:"space-y-1",children:[y.jsxs("div",{className:"flex justify-between text-[10px] text-[var(--text-muted)]",children:[y.jsx("span",{children:"Progress"}),y.jsxs("span",{children:[a.completed+a.failed,"/",a.total]})]}),y.jsx("div",{className:"h-1.5 bg-[var(--bg)] rounded-full overflow-hidden",children:y.jsx("div",{className:"h-full rounded-full transition-all duration-500",style:{width:`${(a.completed+a.failed)/a.total*100}%`,background:a.failed>0?`linear-gradient(90deg, var(--completed) ${a.completed/(a.completed+a.failed)*100}%, var(--failed) 0%)`:"var(--completed)"}})})]}),y.jsx(wi,{items:h}),o&&d&&d.length>0&&y.jsxs("div",{className:"space-y-2",children:[y.jsxs("button",{onClick:()=>c(!s),className:"flex items-center gap-1.5 text-[10px] uppercase tracking-wider text-[var(--text-muted)] font-semibold hover:text-[var(--text)] transition-colors",children:[s?y.jsx(ol,{className:"w-3 h-3"}):y.jsx(Rr,{className:"w-3 h-3"}),"Items (",d.length,")"]}),s&&y.jsx("div",{className:"space-y-1",children:d.map(m=>y.jsx(R9,{groupName:e.name,item:m},`${m.key}-${m.index}`))})]})]})}const D9={running:Ie.running,completed:Ie.completed,failed:Ie.failed};function R9({groupName:e,item:t}){const[r,l]=U.useState(t.status==="running"),a=D9[t.status],o=Um(),s=ue(x=>x.navigateIntoSubworkflow),c=`${e}[${t.key}]`,h=o.find(x=>x.slotKey===c),d=!!h,m=!!(t.prompt||t.output!=null||t.activity&&t.activity.length>0||t.error_type),p=[];return t.elapsed!=null&&p.push({label:"Elapsed",value:pt(t.elapsed)}),t.tokens!=null&&p.push({label:"Tokens",value:Pn(t.tokens)}),t.cost_usd!=null&&p.push({label:"Cost",value:bi(t.cost_usd)}),y.jsxs("div",{className:"rounded-lg border border-[var(--border)] bg-[var(--surface)] overflow-hidden",children:[y.jsxs("button",{onClick:()=>m&&l(!r),className:"flex items-center gap-2 w-full px-3 py-2 text-left hover:bg-[var(--node-bg)] transition-colors",disabled:!m,children:[m?r?y.jsx(ol,{className:"w-3 h-3 text-[var(--text-muted)] flex-shrink-0"}):y.jsx(Rr,{className:"w-3 h-3 text-[var(--text-muted)] flex-shrink-0"}):t.status==="running"?y.jsx(fa,{className:"w-3 h-3 animate-spin flex-shrink-0",style:{color:a}}):y.jsx("span",{className:"w-2 h-2 rounded-full flex-shrink-0 ml-0.5 mr-0.5",style:{backgroundColor:a}}),y.jsx("span",{className:"text-xs font-medium text-[var(--text)] truncate flex-1 min-w-0",children:t.key}),!r&&(t.elapsed!=null||t.tokens!=null||t.cost_usd!=null)&&y.jsxs("span",{className:"flex items-center gap-2 text-[10px] text-[var(--text-muted)] flex-shrink-0",children:[t.elapsed!=null&&y.jsx("span",{children:pt(t.elapsed)}),t.tokens!=null&&y.jsx("span",{children:Pn(t.tokens)}),t.cost_usd!=null&&y.jsx("span",{children:bi(t.cost_usd)})]}),y.jsx("span",{className:"text-[10px] font-bold uppercase tracking-wider flex-shrink-0 px-1.5 py-0.5 rounded",style:{backgroundColor:`${a}20`,color:a},children:t.status}),d&&y.jsx("span",{role:"button",tabIndex:0,onClick:x=>{x.stopPropagation(),s(c)},onKeyDown:x=>{(x.key==="Enter"||x.key===" ")&&(x.stopPropagation(),x.preventDefault(),s(c))},title:`Dive into ${(h==null?void 0:h.workflowName)??c}`,className:"flex-shrink-0 p-1 rounded hover:bg-[var(--accent)]/20 hover:text-[var(--accent)] transition-colors text-[var(--text-muted)] cursor-pointer",children:y.jsx(kc,{className:"w-3 h-3"})})]}),r&&m&&y.jsxs("div",{className:"px-3 py-3 space-y-3 border-t border-[var(--border)]",children:[p.length>0&&y.jsx(wi,{items:p}),t.prompt&&y.jsx(ll,{output:t.prompt,title:"Input / Prompt",defaultExpanded:!1}),t.activity&&t.activity.length>0&&y.jsx(Vm,{activity:t.activity,defaultExpanded:t.status!=="completed"}),t.output!=null&&y.jsx(ll,{output:t.output,title:"Output",defaultExpanded:!0}),t.status==="failed"&&(t.error_type||t.error_message)&&y.jsxs("div",{className:"text-xs text-red-400",children:[t.error_type&&y.jsx("span",{className:"font-semibold",children:t.error_type}),t.error_message&&y.jsxs("span",{className:"ml-1",children:["— ",t.error_message]})]})]})]})}function O9({node:e}){const t=ue(d=>d.engageDialog),r=ue(d=>d.sendDialogDecline),l=ue(d=>d.wsStatus),a=e.dialog_id||"",o=e.dialog_messages||[],s=l==="connected",c=o.find(d=>d.role==="agent"),h=()=>{s&&r(e.name,a)};return y.jsxs("div",{className:"flex flex-col gap-4",children:[y.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2 rounded-lg bg-fuchsia-500/10 border border-fuchsia-500/30",children:[y.jsxs("span",{className:"relative flex h-2.5 w-2.5 flex-shrink-0",children:[y.jsx("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full bg-fuchsia-400 opacity-75"}),y.jsx("span",{className:"relative inline-flex rounded-full h-2.5 w-2.5 bg-fuchsia-500"})]}),y.jsx("span",{className:"text-xs font-semibold text-fuchsia-400 tracking-wide",children:"Dialog Requested"})]}),c&&y.jsxs("div",{className:"rounded-lg px-3 py-2 bg-amber-500/10 border border-amber-500/30",children:[y.jsx("div",{className:"text-[10px] font-semibold mb-1 text-[var(--text-muted)]",children:e.name}),y.jsx("div",{className:"dialog-markdown text-xs leading-relaxed text-[var(--text)]",children:y.jsx(Fc,{remarkPlugins:[Yc],children:c.content})})]}),y.jsxs("div",{className:"space-y-2",children:[y.jsx("div",{className:"text-[10px] uppercase tracking-wider text-[var(--text-muted)] font-semibold",children:"How would you like to proceed?"}),y.jsxs("div",{className:"flex gap-2",children:[y.jsxs("button",{onClick:t,disabled:!s,className:"flex-1 flex items-center justify-center gap-1.5 text-xs px-3 py-2 rounded-lg border border-fuchsia-500/40 bg-fuchsia-500/10 text-fuchsia-300 hover:bg-fuchsia-500/20 transition-colors font-medium disabled:opacity-40 disabled:cursor-not-allowed",children:[y.jsx(ym,{className:"w-3 h-3"}),"💬 Discuss"]}),y.jsxs("button",{onClick:h,disabled:!s,className:"flex-1 flex items-center justify-center gap-1.5 text-xs px-3 py-2 rounded-lg border border-[var(--border)] bg-[var(--surface)] text-[var(--text-muted)] hover:bg-[var(--surface-hover)] transition-colors font-medium disabled:opacity-40 disabled:cursor-not-allowed",children:[y.jsx(sl,{className:"w-3 h-3"}),"✕ Skip & continue"]})]})]})]})}function L9({node:e}){const t=e.status,r=Ie[t]||Ie.pending,l=ue(c=>c.navigateIntoSubworkflow),o=Um().filter(c=>c.parentAgent===e.name),s=[];return e.elapsed!=null&&s.push({label:"Elapsed",value:pt(e.elapsed)}),e.cost_usd!=null&&s.push({label:"Cost",value:bi(e.cost_usd)}),e.tokens!=null&&s.push({label:"Tokens",value:Pn(e.tokens)}),e.iteration!=null&&e.iteration>1&&s.push({label:"Iteration",value:e.iteration}),y.jsxs("div",{className:"space-y-4",children:[y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx("span",{className:"inline-flex items-center px-2 py-0.5 rounded text-[10px] font-bold uppercase tracking-wider",style:{backgroundColor:`${r}20`,color:r},children:t}),y.jsx("span",{className:"text-xs text-[var(--text-muted)]",children:"Subworkflow Agent"})]}),y.jsx(wi,{items:s}),o.length>0&&y.jsxs("div",{className:"space-y-2",children:[y.jsxs("div",{className:"text-[10px] uppercase tracking-wider text-[var(--text-muted)] font-semibold",children:["Subworkflow Runs (",o.length,")"]}),y.jsx("div",{className:"space-y-1",children:o.map((c,h)=>y.jsx(H9,{ctx:c,onClick:()=>l(c.slotKey)},`${c.slotKey}-${c.iteration}-${h}`))})]}),t==="failed"&&(e.error_type||e.error_message)&&y.jsxs("div",{className:"text-xs text-red-400",children:[e.error_type&&y.jsx("span",{className:"font-semibold",children:e.error_type}),e.error_message&&y.jsxs("span",{className:"ml-1",children:["— ",e.error_message]})]}),o.length===0&&t==="pending"&&y.jsx("div",{className:"text-xs text-[var(--text-muted)] italic",children:"Subworkflow has not started yet."})]})}function H9({ctx:e,onClick:t}){const r=Ie[e.status]||Ie.pending;return y.jsxs("button",{onClick:t,className:"flex items-center gap-2 w-full px-3 py-2 rounded-lg border border-[var(--border)] bg-[var(--surface)] hover:bg-[var(--node-bg)] transition-colors text-left",children:[y.jsx(kc,{className:"w-3.5 h-3.5 flex-shrink-0",style:{color:r}}),y.jsxs("div",{className:"flex flex-col min-w-0 flex-1",children:[y.jsx("span",{className:"text-xs font-medium text-[var(--text)] truncate",children:e.workflowName||e.workflowFile||"Subworkflow"}),y.jsxs("div",{className:"flex items-center gap-2 text-[10px] text-[var(--text-muted)]",children:[e.agentsTotal>0&&y.jsxs("span",{className:"flex items-center gap-0.5",children:[y.jsx(ww,{className:"w-2.5 h-2.5"}),e.agentsCompleted,"/",e.agentsTotal," agents"]}),e.totalCost>0&&y.jsxs("span",{className:"flex items-center gap-0.5",children:[y.jsx(yw,{className:"w-2.5 h-2.5"}),bi(e.totalCost)]})]})]}),y.jsx("span",{className:"text-[10px] font-bold uppercase tracking-wider flex-shrink-0 px-1.5 py-0.5 rounded",style:{backgroundColor:`${r}20`,color:r},children:e.status}),y.jsx(Rr,{className:"w-3.5 h-3.5 flex-shrink-0 text-[var(--text-muted)]"})]})}function B9({node:e}){const t=e.status,r=Ie[t]||Ie.pending,l=[],a=e.requested_seconds??e.duration_seconds;return a!=null&&l.push({label:"Requested",value:pt(a)}),e.waited_seconds!=null?l.push({label:"Waited",value:pt(e.waited_seconds)}):e.elapsed!=null&&l.push({label:"Elapsed",value:pt(e.elapsed)}),e.interrupted&&l.push({label:"Interrupted",value:"yes"}),e.reason&&l.push({label:"Reason",value:e.reason}),e.error_type&&l.push({label:"Error",value:e.error_type}),e.error_message&&l.push({label:"Message",value:e.error_message}),y.jsxs("div",{className:"space-y-4",children:[y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx("span",{className:"inline-flex items-center px-2 py-0.5 rounded text-[10px] font-bold uppercase tracking-wider",style:{backgroundColor:`${r}20`,color:r},children:t}),y.jsx("span",{className:"text-xs text-[var(--text-muted)]",children:"Wait"})]}),y.jsx(wi,{items:l})]})}function I9(){const e=ue(h=>h.selectedNode),t=Lr(),r=ue(h=>h.selectNode),l=ue(h=>h.dialogEngaged),[a,o]=U.useState(!1);U.useEffect(()=>(requestAnimationFrame(()=>o(!0)),()=>o(!1)),[e]);const s=e?t[e]:null;if(!e||!s)return y.jsxs("div",{className:"h-full flex flex-col bg-[var(--surface)]",children:[y.jsx("div",{className:"flex items-center justify-between px-4 py-3 border-b border-[var(--border)]",children:y.jsx("h2",{className:"text-sm font-semibold text-[var(--text)]",children:"Detail"})}),y.jsx("div",{className:"flex-1 flex items-center justify-center",children:y.jsx("p",{className:"text-xs text-[var(--text-muted)]",children:"Click a node to view details"})})]});const c=(()=>{if(s.dialog_active&&!l)return O9;if(s.dialog_active&&l)return b1;switch(s.type){case"script":return nD;case"wait":return B9;case"human_gate":return T9;case"parallel_group":case"for_each_group":return M9;case"workflow":return L9;default:return b1}})();return y.jsxs("div",{className:Me("h-full flex flex-col bg-[var(--surface)] transition-all duration-150 ease-out",a?"translate-x-0 opacity-100":"translate-x-4 opacity-0"),children:[y.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-[var(--border)] flex-shrink-0",children:[y.jsx("h2",{className:"text-sm font-semibold text-[var(--text)] truncate",children:e}),y.jsx("button",{onClick:()=>r(null),className:"p-1 rounded hover:bg-[var(--surface-hover)] text-[var(--text-muted)] hover:text-[var(--text)] transition-colors",title:"Close panel",children:y.jsx(sl,{className:"w-4 h-4"})})]}),y.jsx("div",{className:"flex-1 overflow-y-auto px-4 py-3",children:y.jsx(c,{node:s})})]})}function ic(e){if(e==null)return"";if(typeof e=="string")return e;try{return JSON.stringify(e,null,2)}catch{return String(e)}}function q9(){const e=ue(S=>S.eventLog),t=ue(S=>S.activityLog),r=ue(S=>S.workflowOutput),l=ue(S=>S.workflowStatus),[a,o]=U.useState("log"),[s,c]=U.useState(!1),[h,d]=U.useState(0),[m,p]=U.useState(0),x=U.useCallback(S=>{o(S),S==="log"&&d(e.length),S==="activity"&&p(t.length)},[e.length,t.length]);U.useEffect(()=>{a==="log"&&d(e.length)},[a,e.length]),U.useEffect(()=>{a==="activity"&&p(t.length)},[a,t.length]),U.useEffect(()=>{l==="completed"&&r!=null&&o("output")},[l,r]);const b=r!=null,w=a!=="log"?Math.max(0,e.length-h):0,E=a!=="activity"?Math.max(0,t.length-m):0;return s?y.jsx("div",{className:"flex items-center bg-[var(--surface)] border-t border-[var(--border)] px-3 py-1",children:y.jsxs("button",{onClick:()=>c(!1),className:"flex items-center gap-1.5 text-xs text-[var(--text-muted)] hover:text-[var(--text)] transition-colors",children:[y.jsx(fN,{className:"w-3 h-3"}),y.jsx(ev,{className:"w-3 h-3"}),y.jsx("span",{children:"Output"}),t.length>0&&y.jsxs("span",{className:"text-[10px] text-[var(--text-muted)]",children:["(",t.length,")"]})]})}):y.jsxs("div",{className:"flex flex-col h-full bg-[var(--surface)] border-t border-[var(--border)]",children:[y.jsxs("div",{className:"flex items-center justify-between px-2 flex-shrink-0 border-b border-[var(--border)]",children:[y.jsxs("div",{className:"flex items-center gap-0.5",children:[y.jsx($p,{active:a==="log",onClick:()=>x("log"),icon:y.jsx(ev,{className:"w-3 h-3"}),label:"Log",count:e.length,unread:w}),y.jsx($p,{active:a==="activity",onClick:()=>x("activity"),icon:y.jsx(gw,{className:"w-3 h-3"}),label:"Activity",count:t.length,unread:E}),y.jsx($p,{active:a==="output",onClick:()=>x("output"),icon:y.jsx(xN,{className:"w-3 h-3"}),label:"Output",badge:b?l==="failed"?"error":"success":void 0})]}),y.jsx("button",{onClick:()=>c(!0),className:"p-1 rounded text-[var(--text-muted)] hover:text-[var(--text)] hover:bg-[var(--surface-hover)] transition-colors",title:"Collapse panel",children:y.jsx(ol,{className:"w-3.5 h-3.5"})})]}),y.jsx("div",{className:"flex-1 overflow-hidden",children:a==="activity"?y.jsx(U9,{entries:t}):a==="log"?y.jsx($9,{entries:e}):y.jsx(V9,{output:r,status:l})})]})}function $p({active:e,onClick:t,icon:r,label:l,count:a,badge:o,unread:s}){return y.jsxs("button",{onClick:t,className:Me("relative flex items-center gap-1.5 px-3 py-1.5 text-xs transition-colors border-b-2 -mb-px",e?"text-[var(--text)] border-[var(--accent)]":"text-[var(--text-muted)] border-transparent hover:text-[var(--text-secondary)]"),children:[r,y.jsx("span",{children:l}),a!=null&&a>0&&y.jsx("span",{className:"text-[10px] text-[var(--text-muted)] tabular-nums",children:a}),o&&y.jsx("span",{className:Me("w-1.5 h-1.5 rounded-full",o==="success"?"bg-[var(--completed)]":"bg-[var(--failed)]")}),!e&&s!=null&&s>0&&y.jsx("span",{className:"absolute -top-0.5 -right-0.5 flex h-3.5 min-w-[14px] items-center justify-center rounded-full bg-[var(--accent)] px-1",children:y.jsx("span",{className:"text-[8px] font-bold text-white leading-none tabular-nums",children:s>99?"99+":s})})]})}const fw={reasoning:{color:"text-indigo-400/70",label:"THINK",labelColor:"text-indigo-500"},"tool-start":{color:"text-blue-400",label:"TOOL →",labelColor:"text-blue-500"},"tool-complete":{color:"text-green-400",label:"TOOL ←",labelColor:"text-green-600"},turn:{color:"text-amber-400",label:"STEP",labelColor:"text-amber-500"},message:{color:"text-[var(--text)]",label:"MSG",labelColor:"text-[var(--text-muted)]"},prompt:{color:"text-cyan-400/70",label:"PROMPT",labelColor:"text-cyan-600"}};function U9({entries:e}){const t=U.useRef(null),r=U.useRef(!0),l=ue(h=>h.selectNode),[a,o]=U.useState(""),s=U.useCallback(()=>{const h=t.current;if(!h)return;const d=h.scrollHeight-h.scrollTop-h.clientHeight<30;r.current=d},[]),c=U.useMemo(()=>{if(!a)return e;const h=a.toLowerCase();return e.filter(d=>d.source.toLowerCase().includes(h)||ic(d.message).toLowerCase().includes(h))},[e,a]);return U.useEffect(()=>{t.current&&r.current&&(t.current.scrollTop=t.current.scrollHeight)},[c.length]),e.length===0?y.jsx("div",{className:"h-full flex items-center justify-center",children:y.jsx("p",{className:"text-xs text-[var(--text-muted)]",children:"Waiting for agent activity…"})}):y.jsxs("div",{className:"h-full flex flex-col",children:[y.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 border-b border-[var(--border-subtle)] flex-shrink-0",children:[y.jsx(_N,{className:"w-3 h-3 text-[var(--text-muted)] flex-shrink-0"}),y.jsx("input",{type:"text",value:a,onChange:h=>o(h.target.value),placeholder:"Filter by agent or message…",className:"flex-1 bg-transparent text-[11px] text-[var(--text)] placeholder:text-[var(--text-muted)] outline-none min-w-0"}),a&&y.jsxs(y.Fragment,{children:[y.jsxs("span",{className:"text-[10px] text-[var(--text-muted)] tabular-nums flex-shrink-0",children:[c.length," of ",e.length]}),y.jsx("button",{onClick:()=>o(""),className:"text-[var(--text-muted)] hover:text-[var(--text)] transition-colors flex-shrink-0",title:"Clear filter",children:y.jsx(sl,{className:"w-3 h-3"})})]})]}),y.jsxs("div",{ref:t,onScroll:s,className:"flex-1 overflow-y-auto font-mono text-[11px] leading-[1.6] px-3 py-2",children:[c.map((h,d)=>{const m=fw[h.type]||fw.message,p=qk(h.timestamp);return y.jsxs("div",{className:"group",children:[y.jsxs("div",{className:"flex gap-1.5 hover:bg-[var(--surface-hover)] rounded px-1 -mx-1",children:[y.jsx("span",{className:"text-[var(--text-muted)] flex-shrink-0 select-none tabular-nums",children:p}),y.jsx("span",{className:Me("flex-shrink-0 w-[5ch] text-[10px] font-semibold tabular-nums select-none",m.labelColor),children:m.label}),y.jsx("button",{onClick:()=>l(h.source),className:"text-[var(--text-secondary)] flex-shrink-0 min-w-[8ch] max-w-[16ch] truncate hover:text-[var(--accent)] hover:underline transition-colors text-left",title:`Select ${h.source}`,children:h.source}),y.jsx("span",{className:Me("break-words min-w-0",m.color,h.type==="reasoning"&&"italic"),children:ic(h.message)})]}),h.detail&&y.jsx("div",{className:"ml-[calc(7ch+5ch+8ch+1rem)] px-2 py-1 my-0.5 bg-[var(--bg)] rounded text-[10px] text-[var(--text-muted)] whitespace-pre-wrap break-words max-h-24 overflow-y-auto border-l-2 border-[var(--border)]",children:ic(h.detail)})]},d)}),a&&c.length===0&&y.jsx("div",{className:"flex items-center justify-center py-4",children:y.jsxs("p",{className:"text-xs text-[var(--text-muted)]",children:['No matches for "',a,'"']})})]})]})}const dw={info:{color:"text-blue-400",icon:"›"},success:{color:"text-green-400",icon:"✓"},error:{color:"text-red-400",icon:"✗"},warning:{color:"text-amber-400",icon:"⚠"},debug:{color:"text-[var(--text-muted)]",icon:"·"}};function $9({entries:e}){const t=U.useRef(null),r=U.useRef(!0),l=ue(o=>o.selectNode),a=U.useCallback(()=>{const o=t.current;if(!o)return;const s=o.scrollHeight-o.scrollTop-o.clientHeight<30;r.current=s},[]);return U.useEffect(()=>{t.current&&r.current&&(t.current.scrollTop=t.current.scrollHeight)},[e.length]),e.length===0?y.jsx("div",{className:"h-full flex items-center justify-center",children:y.jsx("p",{className:"text-xs text-[var(--text-muted)]",children:"Waiting for events…"})}):y.jsx("div",{ref:t,onScroll:a,className:"h-full overflow-y-auto font-mono text-[11px] leading-[1.6] px-3 py-2",children:e.map((o,s)=>{const c=dw[o.level]||dw.info,h=qk(o.timestamp);return y.jsxs("div",{className:"flex gap-2 hover:bg-[var(--surface-hover)] rounded px-1 -mx-1",children:[y.jsx("span",{className:"text-[var(--text-muted)] flex-shrink-0 select-none tabular-nums",children:h}),y.jsx("span",{className:Me("flex-shrink-0 w-3 text-center select-none",c.color),children:c.icon}),y.jsx("button",{onClick:()=>l(o.source),className:"text-[var(--text-secondary)] flex-shrink-0 min-w-[8ch] max-w-[16ch] truncate hover:text-[var(--accent)] hover:underline transition-colors text-left",title:`Select ${o.source}`,children:o.source}),y.jsx("span",{className:Me("break-words",o.level==="error"?"text-red-400":o.level==="success"?"text-green-400":"text-[var(--text)]"),children:ic(o.message)})]},s)})})}function qk(e){const t=new Date(e*1e3),r=t.getHours().toString().padStart(2,"0"),l=t.getMinutes().toString().padStart(2,"0"),a=t.getSeconds().toString().padStart(2,"0");return`${r}:${l}:${a}`}function V9({output:e,status:t}){const[r,l]=U.useState(!1),a=kw(e),o=async()=>{a&&(await navigator.clipboard.writeText(a),l(!0),setTimeout(()=>l(!1),2e3))};return e==null?y.jsx("div",{className:"h-full flex items-center justify-center",children:y.jsx("p",{className:"text-xs text-[var(--text-muted)]",children:t==="running"?"Workflow running — output will appear when complete…":t==="failed"?"Workflow failed — no output produced":"No output yet"})}):y.jsxs("div",{className:"h-full flex flex-col",children:[y.jsxs("div",{className:"flex items-center justify-between px-3 py-1 border-b border-[var(--border-subtle)] flex-shrink-0",children:[y.jsx("span",{className:"text-[10px] text-[var(--text-muted)] uppercase tracking-wider font-semibold",children:"Workflow Result"}),y.jsx("button",{onClick:o,className:"flex items-center gap-1 text-[10px] text-[var(--text-muted)] hover:text-[var(--text)] transition-colors px-1.5 py-0.5 rounded hover:bg-[var(--surface-hover)]",title:"Copy to clipboard",children:r?y.jsxs(y.Fragment,{children:[y.jsx(Zi,{className:"w-3 h-3 text-[var(--completed)]"}),y.jsx("span",{className:"text-[var(--completed)]",children:"Copied"})]}):y.jsxs(y.Fragment,{children:[y.jsx(vw,{className:"w-3 h-3"}),y.jsx("span",{children:"Copy"})]})})]}),y.jsx("div",{className:"flex-1 overflow-auto px-3 py-2",children:y.jsx("pre",{className:"font-mono text-[11px] leading-relaxed text-[var(--text)] whitespace-pre-wrap break-words",children:typeof e=="object"?y.jsx(P9,{text:a}):a})})]})}function P9({text:e}){const t=e.split(/("(?:[^"\\]|\\.)*")/g);return y.jsx(y.Fragment,{children:t.map((r,l)=>{if(l%2===1){const o=t.slice(l+1).join(""),s=/^\s*:/.test(o);return y.jsx("span",{className:s?"text-blue-400":"text-green-400",children:r},l)}const a=r.replace(/\b(true|false|null)\b|(-?\d+\.?\d*(?:e[+-]?\d+)?)/gi,(o,s,c)=>s?`${o}`:c?`${o}`:o);return y.jsx("span",{dangerouslySetInnerHTML:{__html:a}},l)})})}function G9({text:e}){return y.jsx("div",{className:"dialog-markdown text-xs leading-relaxed text-[var(--text)]",children:y.jsx(Fc,{remarkPlugins:[Yc],components:{h1:({children:t})=>y.jsx("h1",{className:"text-sm font-bold mb-2 mt-1",children:t}),h2:({children:t})=>y.jsx("h2",{className:"text-xs font-bold mb-1.5 mt-1",children:t}),h3:({children:t})=>y.jsx("h3",{className:"text-xs font-semibold mb-1 mt-1",children:t}),p:({children:t})=>y.jsx("p",{className:"mb-1.5 last:mb-0",children:t}),ul:({children:t})=>y.jsx("ul",{className:"list-disc list-inside mb-1.5 space-y-0.5",children:t}),ol:({children:t})=>y.jsx("ol",{className:"list-decimal list-inside mb-1.5 space-y-0.5",children:t}),li:({children:t})=>y.jsx("li",{children:t}),code:({children:t,className:r})=>(r==null?void 0:r.includes("language-"))?y.jsx("code",{className:"block bg-[var(--bg)] border border-[var(--border)] rounded px-2 py-1.5 font-mono text-[11px] my-1 overflow-x-auto whitespace-pre",children:t}):y.jsx("code",{className:"bg-[var(--bg)] border border-[var(--border)] rounded px-1 py-0.5 font-mono text-[11px]",children:t}),pre:({children:t})=>y.jsx("pre",{className:"bg-[var(--bg)] border border-[var(--border)] rounded-md px-2.5 py-2 font-mono text-[11px] my-1.5 overflow-x-auto",children:t}),strong:({children:t})=>y.jsx("strong",{className:"font-semibold",children:t}),em:({children:t})=>y.jsx("em",{className:"italic",children:t}),a:({href:t,children:r})=>y.jsx("a",{href:t,target:"_blank",rel:"noopener noreferrer",className:"text-blue-400 hover:text-blue-300 underline underline-offset-2",children:r}),blockquote:({children:t})=>y.jsx("blockquote",{className:"border-l-2 border-[var(--border)] pl-2.5 my-1.5 opacity-80",children:t}),hr:()=>y.jsx("hr",{className:"border-[var(--border)] my-2"}),table:({children:t})=>y.jsx("div",{className:"overflow-x-auto my-2",children:y.jsx("table",{className:"text-[11px] border-collapse w-full",children:t})}),th:({children:t})=>y.jsx("th",{className:"border border-[var(--border)] px-2 py-1 text-left bg-[var(--bg)] font-semibold",children:t}),td:({children:t})=>y.jsx("td",{className:"border border-[var(--border)] px-2 py-1",children:t})},children:e})})}function F9({node:e}){const t=ue(x=>x.sendDialogMessage),r=ue(x=>x.wsStatus),[l,a]=U.useState(""),o=U.useRef(null),s=e.dialog_active===!0,c=e.dialog_id||"",h=e.dialog_messages||[],d=s&&r==="connected";U.useEffect(()=>{var x;(x=o.current)==null||x.scrollIntoView({behavior:"smooth"})},[h.length,e.dialog_awaiting_response]);const m=()=>{!l.trim()||!d||(t(e.name,c,l.trim()),a(""))},p=x=>{x.key==="Enter"&&!x.shiftKey&&(x.preventDefault(),m())};return y.jsxs("div",{className:"flex flex-col h-full",children:[s?y.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2 rounded-lg bg-fuchsia-500/10 border border-fuchsia-500/30 mb-3 flex-shrink-0",children:[y.jsxs("span",{className:"relative flex h-2.5 w-2.5 flex-shrink-0",children:[y.jsx("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full bg-fuchsia-400 opacity-75"}),y.jsx("span",{className:"relative inline-flex rounded-full h-2.5 w-2.5 bg-fuchsia-500"})]}),y.jsx("span",{className:"text-xs font-semibold text-fuchsia-400 tracking-wide",children:"Dialog Mode"}),y.jsxs("span",{className:"ml-auto text-[10px] text-[var(--text-muted)]",children:[h.length," message",h.length!==1?"s":""]})]}):y.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2 rounded-lg bg-[var(--surface)] border border-[var(--border)] mb-3 flex-shrink-0",children:[y.jsx(ym,{className:"w-3.5 h-3.5 text-[var(--text-muted)]"}),y.jsx("span",{className:"text-xs font-semibold text-[var(--text-muted)] tracking-wide",children:"Dialog Completed"}),y.jsxs("span",{className:"ml-auto text-[10px] text-[var(--text-muted)]",children:[h.length," message",h.length!==1?"s":""]})]}),y.jsxs("div",{className:"flex-1 overflow-y-auto space-y-3 min-h-0 mb-3",children:[h.map((x,b)=>y.jsx("div",{className:`flex ${x.role==="user"?"justify-end":"justify-start"}`,children:y.jsxs("div",{className:`max-w-[85%] rounded-lg px-3 py-2 ${x.role==="agent"?"bg-amber-500/10 border border-amber-500/30":"bg-blue-500/10 border border-blue-500/30"}`,children:[y.jsx("div",{className:"text-[10px] font-semibold mb-1 text-[var(--text-muted)]",children:x.role==="agent"?e.name:"You"}),y.jsx(G9,{text:x.content})]})},b)),e.dialog_awaiting_response&&y.jsx("div",{className:"flex justify-start",children:y.jsxs("div",{className:"max-w-[85%] rounded-lg px-3 py-2 bg-amber-500/10 border border-amber-500/30",children:[y.jsx("div",{className:"text-[10px] font-semibold mb-1 text-[var(--text-muted)]",children:e.name}),y.jsxs("div",{className:"flex gap-1 items-center h-4",children:[y.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-400/60 animate-bounce [animation-delay:0ms]"}),y.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-400/60 animate-bounce [animation-delay:150ms]"}),y.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-400/60 animate-bounce [animation-delay:300ms]"})]})]})}),y.jsx("div",{ref:o})]}),s&&y.jsxs("div",{className:"flex-shrink-0 border-t border-[var(--border)] pt-3",children:[y.jsxs("div",{className:"flex gap-2",children:[y.jsx("input",{type:"text",value:l,onChange:x=>a(x.target.value),onKeyDown:p,placeholder:"Type your message...",className:"flex-1 text-xs px-3 py-2 rounded-lg border border-[var(--border)] bg-[var(--bg)] text-[var(--text)] outline-none focus:border-fuchsia-400 transition-colors",disabled:!d,autoFocus:!0}),y.jsxs("button",{onClick:m,disabled:!d||!l.trim(),className:"flex items-center justify-center gap-1.5 text-xs px-8 py-2 rounded-lg bg-fuchsia-500 text-white hover:bg-fuchsia-600 transition-colors font-medium disabled:opacity-40 disabled:cursor-not-allowed",children:[y.jsx(_w,{className:"w-3 h-3"}),"Send"]})]}),y.jsx("p",{className:"text-[10px] text-[var(--text-muted)] mt-1.5 px-1",children:'Press Enter to send · Type "done" to end dialog'})]})]})}function Y9(){const e=ue(l=>l.activeDialog),t=ue(l=>l.nodes);if(!e)return null;const r=t[e.agentName];return r?y.jsxs("div",{className:"h-full flex flex-col bg-[var(--bg)] overflow-hidden",children:[y.jsxs("div",{className:"flex items-center gap-2.5 px-5 py-3 border-b border-[var(--border)] bg-[var(--surface)] flex-shrink-0",children:[y.jsx(ym,{className:"w-4 h-4 text-fuchsia-400"}),y.jsxs("h2",{className:"text-sm font-semibold text-[var(--text)]",children:["Dialog with ",e.agentName]})]}),y.jsx("div",{className:"flex-1 overflow-hidden px-5 py-4",children:y.jsx(F9,{node:r})})]}):null}function X9(){const e=ue(l=>l.selectedNode),t=ue(l=>l.activeDialog),r=ue(l=>l.dialogEngaged);return y.jsxs(Pp,{direction:"vertical",className:"flex-1 overflow-hidden",children:[y.jsx(No,{defaultSize:70,minSize:30,children:y.jsxs(Pp,{direction:"horizontal",className:"h-full",children:[y.jsx(No,{defaultSize:e?65:100,minSize:40,children:t&&r?y.jsx(Y9,{}):y.jsx(X4,{})}),e&&y.jsxs(y.Fragment,{children:[y.jsx(Gp,{className:"w-[3px] bg-[var(--border)] hover:bg-[var(--text-muted)] transition-colors cursor-col-resize"}),y.jsx(No,{defaultSize:35,minSize:20,maxSize:60,children:y.jsx(I9,{})})]})]})}),y.jsx(Gp,{className:"h-[3px] bg-[var(--border)] hover:bg-[var(--text-muted)] transition-colors cursor-row-resize"}),y.jsx(No,{defaultSize:30,minSize:5,maxSize:70,collapsible:!0,children:y.jsx(q9,{})})]})}const hw=10;function Q9(){const e=ue(E=>E.iterationLimitGate),t=ue(E=>E.wsStatus),r=ue(E=>E.sendIterationLimitResponse),[l,a]=U.useState(String(hw)),[o,s]=U.useState(!1);U.useEffect(()=>{e!=null&&e.gate_id&&(a(String(hw)),s(!1))},[e==null?void 0:e.gate_id]);const c=U.useMemo(()=>{const E=Number(l);return!Number.isFinite(E)||E<0?null:Math.floor(E)},[l]);if(!e||e.skip_gates)return null;const h=e.agent_name??e.group_name??"workflow",d=t==="connected"&&!o,m=!d||c==null||c<=0,p=()=>e.agent_name!==void 0?{agent_name:e.agent_name}:{group_name:e.group_name},x=()=>{m||c==null||(s(!0),r(p(),e.gate_id,c))},b=()=>{d&&(s(!0),r(p(),e.gate_id,0))},w=E=>{E.key==="Enter"&&(E.preventDefault(),x())};return y.jsx("div",{role:"dialog","aria-modal":"true","aria-labelledby":"iteration-limit-title","data-testid":"iteration-limit-modal",className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",children:y.jsxs("div",{className:"relative flex flex-col w-[90vw] max-w-md rounded-xl border border-amber-500/40 bg-[var(--surface)] shadow-2xl overflow-hidden",children:[y.jsxs("div",{className:"flex items-center gap-2.5 px-4 py-3 border-b border-[var(--border)] bg-amber-500/10",children:[y.jsx(lc,{className:"w-4 h-4 text-amber-400 flex-shrink-0"}),y.jsx("h2",{id:"iteration-limit-title",className:"text-sm font-semibold text-[var(--text)]",children:"Max iterations reached"})]}),y.jsxs("div",{className:"px-4 py-4 space-y-3",children:[y.jsxs("p",{className:"text-xs text-[var(--text)]",children:[y.jsx("span",{className:"font-semibold",children:h})," reached"," ",y.jsxs("span",{className:"tabular-nums",children:[e.current_iteration,"/",e.max_iterations]})," ","iterations."]}),e.possible_loop&&y.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg bg-amber-500/5 border border-amber-500/30",children:[y.jsx(lc,{className:"w-3.5 h-3.5 text-amber-400 flex-shrink-0"}),y.jsx("span",{className:"text-[11px] text-amber-300",children:"The same agent has run repeatedly — this may indicate a loop."})]}),e.agent_history.length>0&&y.jsxs("div",{className:"space-y-1",children:[y.jsx("h3",{className:"text-[10px] uppercase tracking-wider text-[var(--text-muted)] font-semibold",children:"Recent agents"}),y.jsx("ol",{className:"text-[11px] text-[var(--text-muted)] list-decimal list-inside space-y-0.5",children:e.agent_history.map((E,S)=>y.jsx("li",{children:E},`${S}-${E}`))})]}),y.jsxs("div",{className:"space-y-1.5",children:[y.jsx("label",{htmlFor:"iteration-limit-additional",className:"block text-[10px] uppercase tracking-wider text-[var(--text-muted)] font-semibold",children:"Additional iterations"}),y.jsx("input",{id:"iteration-limit-additional","data-testid":"iteration-limit-input",type:"number",min:0,step:1,value:l,onChange:E=>a(E.target.value),onKeyDown:w,disabled:!d,autoFocus:!0,className:"w-full text-xs px-3 py-2 rounded-lg border border-[var(--border)] bg-[var(--bg)] text-[var(--text)] outline-none focus:border-amber-400 transition-colors disabled:opacity-50"}),y.jsx("p",{className:"text-[10px] text-[var(--text-muted)]",children:"Enter a positive number to continue, or press Stop to end the workflow."})]}),t!=="connected"&&y.jsx("div",{className:"text-[11px] text-red-300",children:"Disconnected from server — reconnect to resolve this gate."})]}),y.jsxs("div",{className:"flex items-center justify-end gap-2 px-4 py-3 border-t border-[var(--border)] bg-[var(--surface-raised)]",children:[y.jsxs("button",{type:"button","data-testid":"iteration-limit-stop",onClick:b,disabled:!d,className:"flex items-center gap-1.5 text-xs px-3 py-1.5 rounded-lg border border-[var(--border)] text-[var(--text)] hover:bg-[var(--surface-hover)] disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:[y.jsx(hN,{className:"w-3.5 h-3.5"}),"Stop"]}),y.jsxs("button",{type:"button","data-testid":"iteration-limit-continue",onClick:x,disabled:m,className:"flex items-center gap-1.5 text-xs px-3 py-1.5 rounded-lg bg-amber-500 text-white hover:bg-amber-600 disabled:opacity-50 disabled:cursor-not-allowed transition-colors font-medium",children:[y.jsx(Ec,{className:"w-3.5 h-3.5"}),"Continue"]})]})]})})}const Z9=3e4;function K9(){const e=ue(p=>p.processEvent),t=ue(p=>p.replayState),r=ue(p=>p.setWsStatus),l=ue(p=>p.setWsSend),a=U.useRef(null),o=U.useRef(1e3),s=U.useRef(null),c=U.useRef(null),h=U.useRef(()=>{}),d=U.useCallback(()=>{r("reconnecting"),s.current=setTimeout(()=>{o.current=Math.min(o.current*2,Z9),h.current()},o.current)},[r]),m=U.useCallback(()=>{r("connecting"),c.current&&c.current.abort();const p=new AbortController;c.current=p,fetch("/api/state",{signal:p.signal}).then(x=>x.json()).then(x=>{x&&x.length>0&&t(x);const w=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/ws`;try{const E=new WebSocket(w);a.current=E,E.onopen=()=>{o.current=1e3,r("connected"),l(S=>{E.readyState===WebSocket.OPEN&&E.send(JSON.stringify(S))})},E.onmessage=S=>{try{const _=JSON.parse(S.data);e(_)}catch(_){console.error("Failed to parse WebSocket message:",_)}},E.onclose=()=>{r("disconnected"),l(null),a.current=null,d()},E.onerror=()=>{}}catch{d()}}).catch(x=>{p.signal.aborted||(console.error("Failed to fetch state:",x),d())})},[e,t,r,l,d]);h.current=m,U.useEffect(()=>(m(),()=>{c.current&&c.current.abort(),s.current&&clearTimeout(s.current),a.current&&a.current.close(),l(null)}),[m,l])}function J9(){const e=ue(d=>d.setReplayMode),t=ue(d=>d.setWsStatus),r=ue(d=>d.replayPlaying),l=ue(d=>d.replayPosition),a=ue(d=>d.replayTotalEvents),o=ue(d=>d.replaySpeed),s=ue(d=>d.replayEvents),c=ue(d=>d.setReplayPosition);U.useEffect(()=>{t("connecting"),fetch("/api/state").then(d=>d.json()).then(d=>{e(d),t("connected")}).catch(d=>{console.error("Failed to load replay events:",d),t("disconnected")})},[e,t]);const h=U.useRef(null);U.useEffect(()=>{if(!r||l>=a){h.current&&clearTimeout(h.current),r&&l>=a&&ue.getState().setReplayPlaying(!1);return}const d=s[l-1],m=s[l];let p=100;if(d&&m){const x=(m.timestamp-d.timestamp)*1e3;p=Math.max(16,Math.min(x/o,2e3))}return h.current=setTimeout(()=>{c(l+1)},p),()=>{h.current&&clearTimeout(h.current)}},[r,l,a,o,s,c])}function W9(){return K9(),null}function eH(){return J9(),null}function tH(){const[e,t]=U.useState(null),r=ue(o=>o.replayMode),l=ue(o=>o.selectNode),a=ue(o=>o.workflowName);return U.useEffect(()=>{fetch("/api/replay/info").then(o=>{o.ok?t(!0):t(!1)}).catch(()=>t(!1))},[]),U.useEffect(()=>{document.title=a?`Conductor — ${a}`:"Conductor Dashboard"},[a]),U.useEffect(()=>{const o=s=>{s.key==="Escape"&&l(null)};return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[l]),e===null?null:y.jsxs("div",{className:"h-full flex flex-col bg-[var(--bg)]",children:[e?y.jsx(eH,{}):y.jsx(W9,{}),y.jsx(HN,{}),y.jsx(BN,{}),y.jsx(X9,{}),r?y.jsx(VN,{}):y.jsx(qN,{}),!r&&y.jsx(Q9,{})]})}iN.createRoot(document.getElementById("root")).render(y.jsx(U.StrictMode,{children:y.jsx(tH,{})})); diff --git a/src/conductor/web/static/assets/index-vaqTcrlj.js b/src/conductor/web/static/assets/index-vaqTcrlj.js deleted file mode 100644 index d8c24049..00000000 --- a/src/conductor/web/static/assets/index-vaqTcrlj.js +++ /dev/null @@ -1,351 +0,0 @@ -var GE=Object.defineProperty;var FE=(e,t,r)=>t in e?GE(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var Ct=(e,t,r)=>FE(e,typeof t!="symbol"?t+"":t,r);function YE(e,t){for(var r=0;rl[a]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))l(a);new MutationObserver(a=>{for(const o of a)if(o.type==="childList")for(const u of o.addedNodes)u.tagName==="LINK"&&u.rel==="modulepreload"&&l(u)}).observe(document,{childList:!0,subtree:!0});function r(a){const o={};return a.integrity&&(o.integrity=a.integrity),a.referrerPolicy&&(o.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?o.credentials="include":a.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function l(a){if(a.ep)return;a.ep=!0;const o=r(a);fetch(a.href,o)}})();function Qo(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var oh={exports:{}},mo={};/** - * @license React - * react-jsx-runtime.production.js - * - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */var Py;function XE(){if(Py)return mo;Py=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function r(l,a,o){var u=null;if(o!==void 0&&(u=""+o),a.key!==void 0&&(u=""+a.key),"key"in a){o={};for(var c in a)c!=="key"&&(o[c]=a[c])}else o=a;return a=o.ref,{$$typeof:e,type:l,key:u,ref:a!==void 0?a:null,props:o}}return mo.Fragment=t,mo.jsx=r,mo.jsxs=r,mo}var Gy;function QE(){return Gy||(Gy=1,oh.exports=XE()),oh.exports}var y=QE(),sh={exports:{}},Te={};/** - * @license React - * react.production.js - * - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */var Fy;function ZE(){if(Fy)return Te;Fy=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),r=Symbol.for("react.fragment"),l=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),o=Symbol.for("react.consumer"),u=Symbol.for("react.context"),c=Symbol.for("react.forward_ref"),d=Symbol.for("react.suspense"),h=Symbol.for("react.memo"),m=Symbol.for("react.lazy"),p=Symbol.for("react.activity"),x=Symbol.iterator;function b(q){return q===null||typeof q!="object"?null:(q=x&&q[x]||q["@@iterator"],typeof q=="function"?q:null)}var w={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},E=Object.assign,S={};function _(q,Y,C){this.props=q,this.context=Y,this.refs=S,this.updater=C||w}_.prototype.isReactComponent={},_.prototype.setState=function(q,Y){if(typeof q!="object"&&typeof q!="function"&&q!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,q,Y,"setState")},_.prototype.forceUpdate=function(q){this.updater.enqueueForceUpdate(this,q,"forceUpdate")};function N(){}N.prototype=_.prototype;function k(q,Y,C){this.props=q,this.context=Y,this.refs=S,this.updater=C||w}var A=k.prototype=new N;A.constructor=k,E(A,_.prototype),A.isPureReactComponent=!0;var M=Array.isArray;function T(){}var L={H:null,A:null,T:null,S:null},R=Object.prototype.hasOwnProperty;function V(q,Y,C){var P=C.ref;return{$$typeof:e,type:q,key:Y,ref:P!==void 0?P:null,props:C}}function H(q,Y){return V(q.type,Y,q.props)}function B(q){return typeof q=="object"&&q!==null&&q.$$typeof===e}function U(q){var Y={"=":"=0",":":"=2"};return"$"+q.replace(/[=:]/g,function(C){return Y[C]})}var ee=/\/+/g;function I(q,Y){return typeof q=="object"&&q!==null&&q.key!=null?U(""+q.key):Y.toString(36)}function F(q){switch(q.status){case"fulfilled":return q.value;case"rejected":throw q.reason;default:switch(typeof q.status=="string"?q.then(T,T):(q.status="pending",q.then(function(Y){q.status==="pending"&&(q.status="fulfilled",q.value=Y)},function(Y){q.status==="pending"&&(q.status="rejected",q.reason=Y)})),q.status){case"fulfilled":return q.value;case"rejected":throw q.reason}}throw q}function z(q,Y,C,P,X){var J=typeof q;(J==="undefined"||J==="boolean")&&(q=null);var ne=!1;if(q===null)ne=!0;else switch(J){case"bigint":case"string":case"number":ne=!0;break;case"object":switch(q.$$typeof){case e:case t:ne=!0;break;case m:return ne=q._init,z(ne(q._payload),Y,C,P,X)}}if(ne)return X=X(q),ne=P===""?"."+I(q,0):P,M(X)?(C="",ne!=null&&(C=ne.replace(ee,"$&/")+"/"),z(X,Y,C,"",function(xe){return xe})):X!=null&&(B(X)&&(X=H(X,C+(X.key==null||q&&q.key===X.key?"":(""+X.key).replace(ee,"$&/")+"/")+ne)),Y.push(X)),1;ne=0;var re=P===""?".":P+":";if(M(q))for(var se=0;se>>1,D=z[K];if(0>>1;Ka(C,Q))Pa(X,C)?(z[K]=X,z[P]=Q,K=P):(z[K]=C,z[Y]=Q,K=Y);else if(Pa(X,Q))z[K]=X,z[P]=Q,K=P;else break e}}return G}function a(z,G){var Q=z.sortIndex-G.sortIndex;return Q!==0?Q:z.id-G.id}if(e.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var o=performance;e.unstable_now=function(){return o.now()}}else{var u=Date,c=u.now();e.unstable_now=function(){return u.now()-c}}var d=[],h=[],m=1,p=null,x=3,b=!1,w=!1,E=!1,S=!1,_=typeof setTimeout=="function"?setTimeout:null,N=typeof clearTimeout=="function"?clearTimeout:null,k=typeof setImmediate<"u"?setImmediate:null;function A(z){for(var G=r(h);G!==null;){if(G.callback===null)l(h);else if(G.startTime<=z)l(h),G.sortIndex=G.expirationTime,t(d,G);else break;G=r(h)}}function M(z){if(E=!1,A(z),!w)if(r(d)!==null)w=!0,T||(T=!0,U());else{var G=r(h);G!==null&&F(M,G.startTime-z)}}var T=!1,L=-1,R=5,V=-1;function H(){return S?!0:!(e.unstable_now()-Vz&&H());){var K=p.callback;if(typeof K=="function"){p.callback=null,x=p.priorityLevel;var D=K(p.expirationTime<=z);if(z=e.unstable_now(),typeof D=="function"){p.callback=D,A(z),G=!0;break t}p===r(d)&&l(d),A(z)}else l(d);p=r(d)}if(p!==null)G=!0;else{var q=r(h);q!==null&&F(M,q.startTime-z),G=!1}}break e}finally{p=null,x=Q,b=!1}G=void 0}}finally{G?U():T=!1}}}var U;if(typeof k=="function")U=function(){k(B)};else if(typeof MessageChannel<"u"){var ee=new MessageChannel,I=ee.port2;ee.port1.onmessage=B,U=function(){I.postMessage(null)}}else U=function(){_(B,0)};function F(z,G){L=_(function(){z(e.unstable_now())},G)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(z){z.callback=null},e.unstable_forceFrameRate=function(z){0>z||125K?(z.sortIndex=Q,t(h,z),r(d)===null&&z===r(h)&&(E?(N(L),L=-1):E=!0,F(M,Q-K))):(z.sortIndex=D,t(d,z),w||b||(w=!0,T||(T=!0,U()))),z},e.unstable_shouldYield=H,e.unstable_wrapCallback=function(z){var G=x;return function(){var Q=x;x=G;try{return z.apply(this,arguments)}finally{x=Q}}}})(fh)),fh}var Qy;function WE(){return Qy||(Qy=1,ch.exports=JE()),ch.exports}var dh={exports:{}},Ft={};/** - * @license React - * react-dom.production.js - * - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */var Zy;function eN(){if(Zy)return Ft;Zy=1;var e=Zo();function t(d){var h="https://react.dev/errors/"+d;if(1"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),dh.exports=eN(),dh.exports}/** - * @license React - * react-dom-client.production.js - * - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */var Jy;function tN(){if(Jy)return go;Jy=1;var e=WE(),t=Zo(),r=pw();function l(n){var i="https://react.dev/errors/"+n;if(1D||(n.current=K[D],K[D]=null,D--)}function C(n,i){D++,K[D]=n.current,n.current=i}var P=q(null),X=q(null),J=q(null),ne=q(null);function re(n,i){switch(C(J,i),C(X,n),C(P,null),i.nodeType){case 9:case 11:n=(n=i.documentElement)&&(n=n.namespaceURI)?hy(n):0;break;default:if(n=i.tagName,i=i.namespaceURI)i=hy(i),n=py(i,n);else switch(n){case"svg":n=1;break;case"math":n=2;break;default:n=0}}Y(P),C(P,n)}function se(){Y(P),Y(X),Y(J)}function xe(n){n.memoizedState!==null&&C(ne,n);var i=P.current,s=py(i,n.type);i!==s&&(C(X,n),C(P,s))}function be(n){X.current===n&&(Y(P),Y(X)),ne.current===n&&(Y(ne),co._currentValue=Q)}var ye,pe;function Se(n){if(ye===void 0)try{throw Error()}catch(s){var i=s.stack.trim().match(/\n( *(at )?)/);ye=i&&i[1]||"",pe=-1)":-1g||Z[f]!==le[g]){var fe=` -`+Z[f].replace(" at new "," at ");return n.displayName&&fe.includes("")&&(fe=fe.replace("",n.displayName)),fe}while(1<=f&&0<=g);break}}}finally{ze=!1,Error.prepareStackTrace=s}return(s=n?n.displayName||n.name:"")?Se(s):""}function ut(n,i){switch(n.tag){case 26:case 27:case 5:return Se(n.type);case 16:return Se("Lazy");case 13:return n.child!==i&&i!==null?Se("Suspense Fallback"):Se("Suspense");case 19:return Se("SuspenseList");case 0:case 15:return je(n.type,!1);case 11:return je(n.type.render,!1);case 1:return je(n.type,!0);case 31:return Se("Activity");default:return""}}function nt(n){try{var i="",s=null;do i+=ut(n,s),s=n,n=n.return;while(n);return i}catch(f){return` -Error generating stack: `+f.message+` -`+f.stack}}var zt=Object.prototype.hasOwnProperty,Vt=e.unstable_scheduleCallback,Ht=e.unstable_cancelCallback,kn=e.unstable_shouldYield,Rn=e.unstable_requestPaint,Mt=e.unstable_now,Hr=e.unstable_getCurrentPriorityLevel,ce=e.unstable_ImmediatePriority,ge=e.unstable_UserBlockingPriority,Ne=e.unstable_NormalPriority,Le=e.unstable_LowPriority,Xe=e.unstable_IdlePriority,Qt=e.log,On=e.unstable_setDisableYieldValue,Bt=null,vt=null;function Pt(n){if(typeof Qt=="function"&&On(n),vt&&typeof vt.setStrictMode=="function")try{vt.setStrictMode(Bt,n)}catch{}}var We=Math.clz32?Math.clz32:Xc,Qn=Math.log,fn=Math.LN2;function Xc(n){return n>>>=0,n===0?32:31-(Qn(n)/fn|0)|0}var cl=256,fl=262144,dl=4194304;function sr(n){var i=n&42;if(i!==0)return i;switch(n&-n){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return n&261888;case 262144:case 524288:case 1048576:case 2097152:return n&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return n&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return n}}function hl(n,i,s){var f=n.pendingLanes;if(f===0)return 0;var g=0,v=n.suspendedLanes,j=n.pingedLanes;n=n.warmLanes;var O=f&134217727;return O!==0?(f=O&~v,f!==0?g=sr(f):(j&=O,j!==0?g=sr(j):s||(s=O&~n,s!==0&&(g=sr(s))))):(O=f&~v,O!==0?g=sr(O):j!==0?g=sr(j):s||(s=f&~n,s!==0&&(g=sr(s)))),g===0?0:i!==0&&i!==g&&(i&v)===0&&(v=g&-g,s=i&-i,v>=s||v===32&&(s&4194048)!==0)?i:g}function bi(n,i){return(n.pendingLanes&~(n.suspendedLanes&~n.pingedLanes)&i)===0}function Qc(n,i){switch(n){case 1:case 2:case 4:case 8:case 64:return i+250;case 16:case 32: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 i+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function ss(){var n=dl;return dl<<=1,(dl&62914560)===0&&(dl=4194304),n}function wa(n){for(var i=[],s=0;31>s;s++)i.push(n);return i}function wi(n,i){n.pendingLanes|=i,i!==268435456&&(n.suspendedLanes=0,n.pingedLanes=0,n.warmLanes=0)}function Zc(n,i,s,f,g,v){var j=n.pendingLanes;n.pendingLanes=s,n.suspendedLanes=0,n.pingedLanes=0,n.warmLanes=0,n.expiredLanes&=s,n.entangledLanes&=s,n.errorRecoveryDisabledLanes&=s,n.shellSuspendCounter=0;var O=n.entanglements,Z=n.expirationTimes,le=n.hiddenUpdates;for(s=j&~s;0"u")return null;try{return n.activeElement||n.body}catch{return n.body}}var tf=/[\n"\\]/g;function en(n){return n.replace(tf,function(i){return"\\"+i.charCodeAt(0).toString(16)+" "})}function ki(n,i,s,f,g,v,j,O){n.name="",j!=null&&typeof j!="function"&&typeof j!="symbol"&&typeof j!="boolean"?n.type=j:n.removeAttribute("type"),i!=null?j==="number"?(i===0&&n.value===""||n.value!=i)&&(n.value=""+Wt(i)):n.value!==""+Wt(i)&&(n.value=""+Wt(i)):j!=="submit"&&j!=="reset"||n.removeAttribute("value"),i!=null?Na(n,j,Wt(i)):s!=null?Na(n,j,Wt(s)):f!=null&&n.removeAttribute("value"),g==null&&v!=null&&(n.defaultChecked=!!v),g!=null&&(n.checked=g&&typeof g!="function"&&typeof g!="symbol"),O!=null&&typeof O!="function"&&typeof O!="symbol"&&typeof O!="boolean"?n.name=""+Wt(O):n.removeAttribute("name")}function ws(n,i,s,f,g,v,j,O){if(v!=null&&typeof v!="function"&&typeof v!="symbol"&&typeof v!="boolean"&&(n.type=v),i!=null||s!=null){if(!(v!=="submit"&&v!=="reset"||i!=null)){Vr(n);return}s=s!=null?""+Wt(s):"",i=i!=null?""+Wt(i):s,O||i===n.value||(n.value=i),n.defaultValue=i}f=f??g,f=typeof f!="function"&&typeof f!="symbol"&&!!f,n.checked=O?n.checked:!!f,n.defaultChecked=!!f,j!=null&&typeof j!="function"&&typeof j!="symbol"&&typeof j!="boolean"&&(n.name=j),Vr(n)}function Na(n,i,s){i==="number"&&Si(n.ownerDocument)===n||n.defaultValue===""+s||(n.defaultValue=""+s)}function fr(n,i,s,f){if(n=n.options,i){i={};for(var g=0;g"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),of=!1;if(hr)try{var ja={};Object.defineProperty(ja,"passive",{get:function(){of=!0}}),window.addEventListener("test",ja,ja),window.removeEventListener("test",ja,ja)}catch{of=!1}var Pr=null,sf=null,Ss=null;function pg(){if(Ss)return Ss;var n,i=sf,s=i.length,f,g="value"in Pr?Pr.value:Pr.textContent,v=g.length;for(n=0;n=za),bg=" ",wg=!1;function _g(n,i){switch(n){case"keyup":return h2.indexOf(i.keyCode)!==-1;case"keydown":return i.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Sg(n){return n=n.detail,typeof n=="object"&&"data"in n?n.data:null}var bl=!1;function m2(n,i){switch(n){case"compositionend":return Sg(i);case"keypress":return i.which!==32?null:(wg=!0,bg);case"textInput":return n=i.data,n===bg&&wg?null:n;default:return null}}function g2(n,i){if(bl)return n==="compositionend"||!hf&&_g(n,i)?(n=pg(),Ss=sf=Pr=null,bl=!1,n):null;switch(n){case"paste":return null;case"keypress":if(!(i.ctrlKey||i.altKey||i.metaKey)||i.ctrlKey&&i.altKey){if(i.char&&1=i)return{node:s,offset:i-n};n=f}e:{for(;s;){if(s.nextSibling){s=s.nextSibling;break e}s=s.parentNode}s=void 0}s=zg(s)}}function Dg(n,i){return n&&i?n===i?!0:n&&n.nodeType===3?!1:i&&i.nodeType===3?Dg(n,i.parentNode):"contains"in n?n.contains(i):n.compareDocumentPosition?!!(n.compareDocumentPosition(i)&16):!1:!1}function Rg(n){n=n!=null&&n.ownerDocument!=null&&n.ownerDocument.defaultView!=null?n.ownerDocument.defaultView:window;for(var i=Si(n.document);i instanceof n.HTMLIFrameElement;){try{var s=typeof i.contentWindow.location.href=="string"}catch{s=!1}if(s)n=i.contentWindow;else break;i=Si(n.document)}return i}function gf(n){var i=n&&n.nodeName&&n.nodeName.toLowerCase();return i&&(i==="input"&&(n.type==="text"||n.type==="search"||n.type==="tel"||n.type==="url"||n.type==="password")||i==="textarea"||n.contentEditable==="true")}var k2=hr&&"documentMode"in document&&11>=document.documentMode,wl=null,xf=null,Oa=null,yf=!1;function Og(n,i,s){var f=s.window===s?s.document:s.nodeType===9?s:s.ownerDocument;yf||wl==null||wl!==Si(f)||(f=wl,"selectionStart"in f&&gf(f)?f={start:f.selectionStart,end:f.selectionEnd}:(f=(f.ownerDocument&&f.ownerDocument.defaultView||window).getSelection(),f={anchorNode:f.anchorNode,anchorOffset:f.anchorOffset,focusNode:f.focusNode,focusOffset:f.focusOffset}),Oa&&Ra(Oa,f)||(Oa=f,f=gu(xf,"onSelect"),0>=j,g-=j,Kn=1<<32-We(i)+g|s<Me?(Pe=_e,_e=null):Pe=_e.sibling;var Ke=ae(te,_e,ie[Me],de);if(Ke===null){_e===null&&(_e=Pe);break}n&&_e&&Ke.alternate===null&&i(te,_e),W=v(Ke,W,Me),Ze===null?ke=Ke:Ze.sibling=Ke,Ze=Ke,_e=Pe}if(Me===ie.length)return s(te,_e),Ge&&mr(te,Me),ke;if(_e===null){for(;MeMe?(Pe=_e,_e=null):Pe=_e.sibling;var di=ae(te,_e,Ke.value,de);if(di===null){_e===null&&(_e=Pe);break}n&&_e&&di.alternate===null&&i(te,_e),W=v(di,W,Me),Ze===null?ke=di:Ze.sibling=di,Ze=di,_e=Pe}if(Ke.done)return s(te,_e),Ge&&mr(te,Me),ke;if(_e===null){for(;!Ke.done;Me++,Ke=ie.next())Ke=he(te,Ke.value,de),Ke!==null&&(W=v(Ke,W,Me),Ze===null?ke=Ke:Ze.sibling=Ke,Ze=Ke);return Ge&&mr(te,Me),ke}for(_e=f(_e);!Ke.done;Me++,Ke=ie.next())Ke=oe(_e,te,Me,Ke.value,de),Ke!==null&&(n&&Ke.alternate!==null&&_e.delete(Ke.key===null?Me:Ke.key),W=v(Ke,W,Me),Ze===null?ke=Ke:Ze.sibling=Ke,Ze=Ke);return n&&_e.forEach(function(PE){return i(te,PE)}),Ge&&mr(te,Me),ke}function lt(te,W,ie,de){if(typeof ie=="object"&&ie!==null&&ie.type===E&&ie.key===null&&(ie=ie.props.children),typeof ie=="object"&&ie!==null){switch(ie.$$typeof){case b:e:{for(var ke=ie.key;W!==null;){if(W.key===ke){if(ke=ie.type,ke===E){if(W.tag===7){s(te,W.sibling),de=g(W,ie.props.children),de.return=te,te=de;break e}}else if(W.elementType===ke||typeof ke=="object"&&ke!==null&&ke.$$typeof===R&&Ri(ke)===W.type){s(te,W.sibling),de=g(W,ie.props),Ua(de,ie),de.return=te,te=de;break e}s(te,W);break}else i(te,W);W=W.sibling}ie.type===E?(de=Ti(ie.props.children,te.mode,de,ie.key),de.return=te,te=de):(de=Ds(ie.type,ie.key,ie.props,null,te.mode,de),Ua(de,ie),de.return=te,te=de)}return j(te);case w:e:{for(ke=ie.key;W!==null;){if(W.key===ke)if(W.tag===4&&W.stateNode.containerInfo===ie.containerInfo&&W.stateNode.implementation===ie.implementation){s(te,W.sibling),de=g(W,ie.children||[]),de.return=te,te=de;break e}else{s(te,W);break}else i(te,W);W=W.sibling}de=Ef(ie,te.mode,de),de.return=te,te=de}return j(te);case R:return ie=Ri(ie),lt(te,W,ie,de)}if(F(ie))return we(te,W,ie,de);if(U(ie)){if(ke=U(ie),typeof ke!="function")throw Error(l(150));return ie=ke.call(ie),Ce(te,W,ie,de)}if(typeof ie.then=="function")return lt(te,W,qs(ie),de);if(ie.$$typeof===k)return lt(te,W,Ls(te,ie),de);Us(te,ie)}return typeof ie=="string"&&ie!==""||typeof ie=="number"||typeof ie=="bigint"?(ie=""+ie,W!==null&&W.tag===6?(s(te,W.sibling),de=g(W,ie),de.return=te,te=de):(s(te,W),de=kf(ie,te.mode,de),de.return=te,te=de),j(te)):s(te,W)}return function(te,W,ie,de){try{qa=0;var ke=lt(te,W,ie,de);return Ml=null,ke}catch(_e){if(_e===zl||_e===Bs)throw _e;var Ze=hn(29,_e,null,te.mode);return Ze.lanes=de,Ze.return=te,Ze}finally{}}}var Li=ix(!0),lx=ix(!1),Qr=!1;function Hf(n){n.updateQueue={baseState:n.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Bf(n,i){n=n.updateQueue,i.updateQueue===n&&(i.updateQueue={baseState:n.baseState,firstBaseUpdate:n.firstBaseUpdate,lastBaseUpdate:n.lastBaseUpdate,shared:n.shared,callbacks:null})}function Zr(n){return{lane:n,tag:0,payload:null,callback:null,next:null}}function Kr(n,i,s){var f=n.updateQueue;if(f===null)return null;if(f=f.shared,(Je&2)!==0){var g=f.pending;return g===null?i.next=i:(i.next=g.next,g.next=i),f.pending=i,i=Ms(n),$g(n,null,s),i}return zs(n,f,i,s),Ms(n)}function $a(n,i,s){if(i=i.updateQueue,i!==null&&(i=i.shared,(s&4194048)!==0)){var f=i.lanes;f&=n.pendingLanes,s|=f,i.lanes=s,cs(n,s)}}function If(n,i){var s=n.updateQueue,f=n.alternate;if(f!==null&&(f=f.updateQueue,s===f)){var g=null,v=null;if(s=s.firstBaseUpdate,s!==null){do{var j={lane:s.lane,tag:s.tag,payload:s.payload,callback:null,next:null};v===null?g=v=j:v=v.next=j,s=s.next}while(s!==null);v===null?g=v=i:v=v.next=i}else g=v=i;s={baseState:f.baseState,firstBaseUpdate:g,lastBaseUpdate:v,shared:f.shared,callbacks:f.callbacks},n.updateQueue=s;return}n=s.lastBaseUpdate,n===null?s.firstBaseUpdate=i:n.next=i,s.lastBaseUpdate=i}var qf=!1;function Va(){if(qf){var n=Al;if(n!==null)throw n}}function Pa(n,i,s,f){qf=!1;var g=n.updateQueue;Qr=!1;var v=g.firstBaseUpdate,j=g.lastBaseUpdate,O=g.shared.pending;if(O!==null){g.shared.pending=null;var Z=O,le=Z.next;Z.next=null,j===null?v=le:j.next=le,j=Z;var fe=n.alternate;fe!==null&&(fe=fe.updateQueue,O=fe.lastBaseUpdate,O!==j&&(O===null?fe.firstBaseUpdate=le:O.next=le,fe.lastBaseUpdate=Z))}if(v!==null){var he=g.baseState;j=0,fe=le=Z=null,O=v;do{var ae=O.lane&-536870913,oe=ae!==O.lane;if(oe?(Ve&ae)===ae:(f&ae)===ae){ae!==0&&ae===Tl&&(qf=!0),fe!==null&&(fe=fe.next={lane:0,tag:O.tag,payload:O.payload,callback:null,next:null});e:{var we=n,Ce=O;ae=i;var lt=s;switch(Ce.tag){case 1:if(we=Ce.payload,typeof we=="function"){he=we.call(lt,he,ae);break e}he=we;break e;case 3:we.flags=we.flags&-65537|128;case 0:if(we=Ce.payload,ae=typeof we=="function"?we.call(lt,he,ae):we,ae==null)break e;he=p({},he,ae);break e;case 2:Qr=!0}}ae=O.callback,ae!==null&&(n.flags|=64,oe&&(n.flags|=8192),oe=g.callbacks,oe===null?g.callbacks=[ae]:oe.push(ae))}else oe={lane:ae,tag:O.tag,payload:O.payload,callback:O.callback,next:null},fe===null?(le=fe=oe,Z=he):fe=fe.next=oe,j|=ae;if(O=O.next,O===null){if(O=g.shared.pending,O===null)break;oe=O,O=oe.next,oe.next=null,g.lastBaseUpdate=oe,g.shared.pending=null}}while(!0);fe===null&&(Z=he),g.baseState=Z,g.firstBaseUpdate=le,g.lastBaseUpdate=fe,v===null&&(g.shared.lanes=0),ni|=j,n.lanes=j,n.memoizedState=he}}function ax(n,i){if(typeof n!="function")throw Error(l(191,n));n.call(i)}function ox(n,i){var s=n.callbacks;if(s!==null)for(n.callbacks=null,n=0;nv?v:8;var j=z.T,O={};z.T=O,ld(n,!1,i,s);try{var Z=g(),le=z.S;if(le!==null&&le(O,Z),Z!==null&&typeof Z=="object"&&typeof Z.then=="function"){var fe=D2(Z,f);Ya(n,i,fe,yn(n))}else Ya(n,i,f,yn(n))}catch(he){Ya(n,i,{then:function(){},status:"rejected",reason:he},yn())}finally{G.p=v,j!==null&&O.types!==null&&(j.types=O.types),z.T=j}}function I2(){}function rd(n,i,s,f){if(n.tag!==5)throw Error(l(476));var g=Ix(n).queue;Bx(n,g,i,Q,s===null?I2:function(){return qx(n),s(f)})}function Ix(n){var i=n.memoizedState;if(i!==null)return i;i={memoizedState:Q,baseState:Q,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:vr,lastRenderedState:Q},next:null};var s={};return i.next={memoizedState:s,baseState:s,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:vr,lastRenderedState:s},next:null},n.memoizedState=i,n=n.alternate,n!==null&&(n.memoizedState=i),i}function qx(n){var i=Ix(n);i.next===null&&(i=n.alternate.memoizedState),Ya(n,i.next.queue,{},yn())}function id(){return qt(co)}function Ux(){return wt().memoizedState}function $x(){return wt().memoizedState}function q2(n){for(var i=n.return;i!==null;){switch(i.tag){case 24:case 3:var s=yn();n=Zr(s);var f=Kr(i,n,s);f!==null&&(on(f,i,s),$a(f,i,s)),i={cache:Df()},n.payload=i;return}i=i.return}}function U2(n,i,s){var f=yn();s={lane:f,revertLane:0,gesture:null,action:s,hasEagerState:!1,eagerState:null,next:null},Ks(n)?Px(i,s):(s=_f(n,i,s,f),s!==null&&(on(s,n,f),Gx(s,i,f)))}function Vx(n,i,s){var f=yn();Ya(n,i,s,f)}function Ya(n,i,s,f){var g={lane:f,revertLane:0,gesture:null,action:s,hasEagerState:!1,eagerState:null,next:null};if(Ks(n))Px(i,g);else{var v=n.alternate;if(n.lanes===0&&(v===null||v.lanes===0)&&(v=i.lastRenderedReducer,v!==null))try{var j=i.lastRenderedState,O=v(j,s);if(g.hasEagerState=!0,g.eagerState=O,dn(O,j))return zs(n,i,g,0),at===null&&As(),!1}catch{}finally{}if(s=_f(n,i,g,f),s!==null)return on(s,n,f),Gx(s,i,f),!0}return!1}function ld(n,i,s,f){if(f={lane:2,revertLane:Hd(),gesture:null,action:f,hasEagerState:!1,eagerState:null,next:null},Ks(n)){if(i)throw Error(l(479))}else i=_f(n,s,f,2),i!==null&&on(i,n,2)}function Ks(n){var i=n.alternate;return n===Ae||i!==null&&i===Ae}function Px(n,i){Rl=Ps=!0;var s=n.pending;s===null?i.next=i:(i.next=s.next,s.next=i),n.pending=i}function Gx(n,i,s){if((s&4194048)!==0){var f=i.lanes;f&=n.pendingLanes,s|=f,i.lanes=s,cs(n,s)}}var Xa={readContext:qt,use:Ys,useCallback:gt,useContext:gt,useEffect:gt,useImperativeHandle:gt,useLayoutEffect:gt,useInsertionEffect:gt,useMemo:gt,useReducer:gt,useRef:gt,useState:gt,useDebugValue:gt,useDeferredValue:gt,useTransition:gt,useSyncExternalStore:gt,useId:gt,useHostTransitionStatus:gt,useFormState:gt,useActionState:gt,useOptimistic:gt,useMemoCache:gt,useCacheRefresh:gt};Xa.useEffectEvent=gt;var Fx={readContext:qt,use:Ys,useCallback:function(n,i){return Zt().memoizedState=[n,i===void 0?null:i],n},useContext:qt,useEffect:Tx,useImperativeHandle:function(n,i,s){s=s!=null?s.concat([n]):null,Qs(4194308,4,Dx.bind(null,i,n),s)},useLayoutEffect:function(n,i){return Qs(4194308,4,n,i)},useInsertionEffect:function(n,i){Qs(4,2,n,i)},useMemo:function(n,i){var s=Zt();i=i===void 0?null:i;var f=n();if(Hi){Pt(!0);try{n()}finally{Pt(!1)}}return s.memoizedState=[f,i],f},useReducer:function(n,i,s){var f=Zt();if(s!==void 0){var g=s(i);if(Hi){Pt(!0);try{s(i)}finally{Pt(!1)}}}else g=i;return f.memoizedState=f.baseState=g,n={pending:null,lanes:0,dispatch:null,lastRenderedReducer:n,lastRenderedState:g},f.queue=n,n=n.dispatch=U2.bind(null,Ae,n),[f.memoizedState,n]},useRef:function(n){var i=Zt();return n={current:n},i.memoizedState=n},useState:function(n){n=Jf(n);var i=n.queue,s=Vx.bind(null,Ae,i);return i.dispatch=s,[n.memoizedState,s]},useDebugValue:td,useDeferredValue:function(n,i){var s=Zt();return nd(s,n,i)},useTransition:function(){var n=Jf(!1);return n=Bx.bind(null,Ae,n.queue,!0,!1),Zt().memoizedState=n,[!1,n]},useSyncExternalStore:function(n,i,s){var f=Ae,g=Zt();if(Ge){if(s===void 0)throw Error(l(407));s=s()}else{if(s=i(),at===null)throw Error(l(349));(Ve&127)!==0||hx(f,i,s)}g.memoizedState=s;var v={value:s,getSnapshot:i};return g.queue=v,Tx(mx.bind(null,f,v,n),[n]),f.flags|=2048,Ll(9,{destroy:void 0},px.bind(null,f,v,s,i),null),s},useId:function(){var n=Zt(),i=at.identifierPrefix;if(Ge){var s=Jn,f=Kn;s=(f&~(1<<32-We(f)-1)).toString(32)+s,i="_"+i+"R_"+s,s=Gs++,0<\/script>",v=v.removeChild(v.firstChild);break;case"select":v=typeof f.is=="string"?j.createElement("select",{is:f.is}):j.createElement("select"),f.multiple?v.multiple=!0:f.size&&(v.size=f.size);break;default:v=typeof f.is=="string"?j.createElement(g,{is:f.is}):j.createElement(g)}}v[Dt]=i,v[Gt]=f;e:for(j=i.child;j!==null;){if(j.tag===5||j.tag===6)v.appendChild(j.stateNode);else if(j.tag!==4&&j.tag!==27&&j.child!==null){j.child.return=j,j=j.child;continue}if(j===i)break e;for(;j.sibling===null;){if(j.return===null||j.return===i)break e;j=j.return}j.sibling.return=j.return,j=j.sibling}i.stateNode=v;e:switch($t(v,g,f),g){case"button":case"input":case"select":case"textarea":f=!!f.autoFocus;break e;case"img":f=!0;break e;default:f=!1}f&&wr(i)}}return ft(i),vd(i,i.type,n===null?null:n.memoizedProps,i.pendingProps,s),null;case 6:if(n&&i.stateNode!=null)n.memoizedProps!==f&&wr(i);else{if(typeof f!="string"&&i.stateNode===null)throw Error(l(166));if(n=J.current,Cl(i)){if(n=i.stateNode,s=i.memoizedProps,f=null,g=It,g!==null)switch(g.tag){case 27:case 5:f=g.memoizedProps}n[Dt]=i,n=!!(n.nodeValue===s||f!==null&&f.suppressHydrationWarning===!0||fy(n.nodeValue,s)),n||Yr(i,!0)}else n=xu(n).createTextNode(f),n[Dt]=i,i.stateNode=n}return ft(i),null;case 31:if(s=i.memoizedState,n===null||n.memoizedState!==null){if(f=Cl(i),s!==null){if(n===null){if(!f)throw Error(l(318));if(n=i.memoizedState,n=n!==null?n.dehydrated:null,!n)throw Error(l(557));n[Dt]=i}else Ai(),(i.flags&128)===0&&(i.memoizedState=null),i.flags|=4;ft(i),n=!1}else s=Tf(),n!==null&&n.memoizedState!==null&&(n.memoizedState.hydrationErrors=s),n=!0;if(!n)return i.flags&256?(mn(i),i):(mn(i),null);if((i.flags&128)!==0)throw Error(l(558))}return ft(i),null;case 13:if(f=i.memoizedState,n===null||n.memoizedState!==null&&n.memoizedState.dehydrated!==null){if(g=Cl(i),f!==null&&f.dehydrated!==null){if(n===null){if(!g)throw Error(l(318));if(g=i.memoizedState,g=g!==null?g.dehydrated:null,!g)throw Error(l(317));g[Dt]=i}else Ai(),(i.flags&128)===0&&(i.memoizedState=null),i.flags|=4;ft(i),g=!1}else g=Tf(),n!==null&&n.memoizedState!==null&&(n.memoizedState.hydrationErrors=g),g=!0;if(!g)return i.flags&256?(mn(i),i):(mn(i),null)}return mn(i),(i.flags&128)!==0?(i.lanes=s,i):(s=f!==null,n=n!==null&&n.memoizedState!==null,s&&(f=i.child,g=null,f.alternate!==null&&f.alternate.memoizedState!==null&&f.alternate.memoizedState.cachePool!==null&&(g=f.alternate.memoizedState.cachePool.pool),v=null,f.memoizedState!==null&&f.memoizedState.cachePool!==null&&(v=f.memoizedState.cachePool.pool),v!==g&&(f.flags|=2048)),s!==n&&s&&(i.child.flags|=8192),nu(i,i.updateQueue),ft(i),null);case 4:return se(),n===null&&Ud(i.stateNode.containerInfo),ft(i),null;case 10:return xr(i.type),ft(i),null;case 19:if(Y(bt),f=i.memoizedState,f===null)return ft(i),null;if(g=(i.flags&128)!==0,v=f.rendering,v===null)if(g)Za(f,!1);else{if(xt!==0||n!==null&&(n.flags&128)!==0)for(n=i.child;n!==null;){if(v=Vs(n),v!==null){for(i.flags|=128,Za(f,!1),n=v.updateQueue,i.updateQueue=n,nu(i,n),i.subtreeFlags=0,n=s,s=i.child;s!==null;)Vg(s,n),s=s.sibling;return C(bt,bt.current&1|2),Ge&&mr(i,f.treeForkCount),i.child}n=n.sibling}f.tail!==null&&Mt()>ou&&(i.flags|=128,g=!0,Za(f,!1),i.lanes=4194304)}else{if(!g)if(n=Vs(v),n!==null){if(i.flags|=128,g=!0,n=n.updateQueue,i.updateQueue=n,nu(i,n),Za(f,!0),f.tail===null&&f.tailMode==="hidden"&&!v.alternate&&!Ge)return ft(i),null}else 2*Mt()-f.renderingStartTime>ou&&s!==536870912&&(i.flags|=128,g=!0,Za(f,!1),i.lanes=4194304);f.isBackwards?(v.sibling=i.child,i.child=v):(n=f.last,n!==null?n.sibling=v:i.child=v,f.last=v)}return f.tail!==null?(n=f.tail,f.rendering=n,f.tail=n.sibling,f.renderingStartTime=Mt(),n.sibling=null,s=bt.current,C(bt,g?s&1|2:s&1),Ge&&mr(i,f.treeForkCount),n):(ft(i),null);case 22:case 23:return mn(i),$f(),f=i.memoizedState!==null,n!==null?n.memoizedState!==null!==f&&(i.flags|=8192):f&&(i.flags|=8192),f?(s&536870912)!==0&&(i.flags&128)===0&&(ft(i),i.subtreeFlags&6&&(i.flags|=8192)):ft(i),s=i.updateQueue,s!==null&&nu(i,s.retryQueue),s=null,n!==null&&n.memoizedState!==null&&n.memoizedState.cachePool!==null&&(s=n.memoizedState.cachePool.pool),f=null,i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(f=i.memoizedState.cachePool.pool),f!==s&&(i.flags|=2048),n!==null&&Y(Di),null;case 24:return s=null,n!==null&&(s=n.memoizedState.cache),i.memoizedState.cache!==s&&(i.flags|=2048),xr(St),ft(i),null;case 25:return null;case 30:return null}throw Error(l(156,i.tag))}function F2(n,i){switch(Cf(i),i.tag){case 1:return n=i.flags,n&65536?(i.flags=n&-65537|128,i):null;case 3:return xr(St),se(),n=i.flags,(n&65536)!==0&&(n&128)===0?(i.flags=n&-65537|128,i):null;case 26:case 27:case 5:return be(i),null;case 31:if(i.memoizedState!==null){if(mn(i),i.alternate===null)throw Error(l(340));Ai()}return n=i.flags,n&65536?(i.flags=n&-65537|128,i):null;case 13:if(mn(i),n=i.memoizedState,n!==null&&n.dehydrated!==null){if(i.alternate===null)throw Error(l(340));Ai()}return n=i.flags,n&65536?(i.flags=n&-65537|128,i):null;case 19:return Y(bt),null;case 4:return se(),null;case 10:return xr(i.type),null;case 22:case 23:return mn(i),$f(),n!==null&&Y(Di),n=i.flags,n&65536?(i.flags=n&-65537|128,i):null;case 24:return xr(St),null;case 25:return null;default:return null}}function g0(n,i){switch(Cf(i),i.tag){case 3:xr(St),se();break;case 26:case 27:case 5:be(i);break;case 4:se();break;case 31:i.memoizedState!==null&&mn(i);break;case 13:mn(i);break;case 19:Y(bt);break;case 10:xr(i.type);break;case 22:case 23:mn(i),$f(),n!==null&&Y(Di);break;case 24:xr(St)}}function Ka(n,i){try{var s=i.updateQueue,f=s!==null?s.lastEffect:null;if(f!==null){var g=f.next;s=g;do{if((s.tag&n)===n){f=void 0;var v=s.create,j=s.inst;f=v(),j.destroy=f}s=s.next}while(s!==g)}}catch(O){tt(i,i.return,O)}}function ei(n,i,s){try{var f=i.updateQueue,g=f!==null?f.lastEffect:null;if(g!==null){var v=g.next;f=v;do{if((f.tag&n)===n){var j=f.inst,O=j.destroy;if(O!==void 0){j.destroy=void 0,g=i;var Z=s,le=O;try{le()}catch(fe){tt(g,Z,fe)}}}f=f.next}while(f!==v)}}catch(fe){tt(i,i.return,fe)}}function x0(n){var i=n.updateQueue;if(i!==null){var s=n.stateNode;try{ox(i,s)}catch(f){tt(n,n.return,f)}}}function y0(n,i,s){s.props=Bi(n.type,n.memoizedProps),s.state=n.memoizedState;try{s.componentWillUnmount()}catch(f){tt(n,i,f)}}function Ja(n,i){try{var s=n.ref;if(s!==null){switch(n.tag){case 26:case 27:case 5:var f=n.stateNode;break;case 30:f=n.stateNode;break;default:f=n.stateNode}typeof s=="function"?n.refCleanup=s(f):s.current=f}}catch(g){tt(n,i,g)}}function Wn(n,i){var s=n.ref,f=n.refCleanup;if(s!==null)if(typeof f=="function")try{f()}catch(g){tt(n,i,g)}finally{n.refCleanup=null,n=n.alternate,n!=null&&(n.refCleanup=null)}else if(typeof s=="function")try{s(null)}catch(g){tt(n,i,g)}else s.current=null}function v0(n){var i=n.type,s=n.memoizedProps,f=n.stateNode;try{e:switch(i){case"button":case"input":case"select":case"textarea":s.autoFocus&&f.focus();break e;case"img":s.src?f.src=s.src:s.srcSet&&(f.srcset=s.srcSet)}}catch(g){tt(n,n.return,g)}}function bd(n,i,s){try{var f=n.stateNode;pE(f,n.type,s,i),f[Gt]=i}catch(g){tt(n,n.return,g)}}function b0(n){return n.tag===5||n.tag===3||n.tag===26||n.tag===27&&oi(n.type)||n.tag===4}function wd(n){e:for(;;){for(;n.sibling===null;){if(n.return===null||b0(n.return))return null;n=n.return}for(n.sibling.return=n.return,n=n.sibling;n.tag!==5&&n.tag!==6&&n.tag!==18;){if(n.tag===27&&oi(n.type)||n.flags&2||n.child===null||n.tag===4)continue e;n.child.return=n,n=n.child}if(!(n.flags&2))return n.stateNode}}function _d(n,i,s){var f=n.tag;if(f===5||f===6)n=n.stateNode,i?(s.nodeType===9?s.body:s.nodeName==="HTML"?s.ownerDocument.body:s).insertBefore(n,i):(i=s.nodeType===9?s.body:s.nodeName==="HTML"?s.ownerDocument.body:s,i.appendChild(n),s=s._reactRootContainer,s!=null||i.onclick!==null||(i.onclick=dr));else if(f!==4&&(f===27&&oi(n.type)&&(s=n.stateNode,i=null),n=n.child,n!==null))for(_d(n,i,s),n=n.sibling;n!==null;)_d(n,i,s),n=n.sibling}function ru(n,i,s){var f=n.tag;if(f===5||f===6)n=n.stateNode,i?s.insertBefore(n,i):s.appendChild(n);else if(f!==4&&(f===27&&oi(n.type)&&(s=n.stateNode),n=n.child,n!==null))for(ru(n,i,s),n=n.sibling;n!==null;)ru(n,i,s),n=n.sibling}function w0(n){var i=n.stateNode,s=n.memoizedProps;try{for(var f=n.type,g=i.attributes;g.length;)i.removeAttributeNode(g[0]);$t(i,f,s),i[Dt]=n,i[Gt]=s}catch(v){tt(n,n.return,v)}}var _r=!1,Nt=!1,Sd=!1,_0=typeof WeakSet=="function"?WeakSet:Set,Ot=null;function Y2(n,i){if(n=n.containerInfo,Pd=ku,n=Rg(n),gf(n)){if("selectionStart"in n)var s={start:n.selectionStart,end:n.selectionEnd};else e:{s=(s=n.ownerDocument)&&s.defaultView||window;var f=s.getSelection&&s.getSelection();if(f&&f.rangeCount!==0){s=f.anchorNode;var g=f.anchorOffset,v=f.focusNode;f=f.focusOffset;try{s.nodeType,v.nodeType}catch{s=null;break e}var j=0,O=-1,Z=-1,le=0,fe=0,he=n,ae=null;t:for(;;){for(var oe;he!==s||g!==0&&he.nodeType!==3||(O=j+g),he!==v||f!==0&&he.nodeType!==3||(Z=j+f),he.nodeType===3&&(j+=he.nodeValue.length),(oe=he.firstChild)!==null;)ae=he,he=oe;for(;;){if(he===n)break t;if(ae===s&&++le===g&&(O=j),ae===v&&++fe===f&&(Z=j),(oe=he.nextSibling)!==null)break;he=ae,ae=he.parentNode}he=oe}s=O===-1||Z===-1?null:{start:O,end:Z}}else s=null}s=s||{start:0,end:0}}else s=null;for(Gd={focusedElem:n,selectionRange:s},ku=!1,Ot=i;Ot!==null;)if(i=Ot,n=i.child,(i.subtreeFlags&1028)!==0&&n!==null)n.return=i,Ot=n;else for(;Ot!==null;){switch(i=Ot,v=i.alternate,n=i.flags,i.tag){case 0:if((n&4)!==0&&(n=i.updateQueue,n=n!==null?n.events:null,n!==null))for(s=0;s title"))),$t(v,f,s),v[Dt]=n,_t(v),f=v;break e;case"link":var j=jy("link","href",g).get(f+(s.href||""));if(j){for(var O=0;Olt&&(j=lt,lt=Ce,Ce=j);var te=Mg(O,Ce),W=Mg(O,lt);if(te&&W&&(oe.rangeCount!==1||oe.anchorNode!==te.node||oe.anchorOffset!==te.offset||oe.focusNode!==W.node||oe.focusOffset!==W.offset)){var ie=he.createRange();ie.setStart(te.node,te.offset),oe.removeAllRanges(),Ce>lt?(oe.addRange(ie),oe.extend(W.node,W.offset)):(ie.setEnd(W.node,W.offset),oe.addRange(ie))}}}}for(he=[],oe=O;oe=oe.parentNode;)oe.nodeType===1&&he.push({element:oe,left:oe.scrollLeft,top:oe.scrollTop});for(typeof O.focus=="function"&&O.focus(),O=0;Os?32:s,z.T=null,s=Ad,Ad=null;var v=ii,j=Cr;if(Rt=0,Ul=ii=null,Cr=0,(Je&6)!==0)throw Error(l(331));var O=Je;if(Je|=4,D0(v.current),A0(v,v.current,j,s),Je=O,io(0,!1),vt&&typeof vt.onPostCommitFiberRoot=="function")try{vt.onPostCommitFiberRoot(Bt,v)}catch{}return!0}finally{G.p=g,z.T=f,K0(n,i)}}function W0(n,i,s){i=Nn(s,i),i=ud(n.stateNode,i,2),n=Kr(n,i,2),n!==null&&(wi(n,2),er(n))}function tt(n,i,s){if(n.tag===3)W0(n,n,s);else for(;i!==null;){if(i.tag===3){W0(i,n,s);break}else if(i.tag===1){var f=i.stateNode;if(typeof i.type.getDerivedStateFromError=="function"||typeof f.componentDidCatch=="function"&&(ri===null||!ri.has(f))){n=Nn(s,n),s=e0(2),f=Kr(i,s,2),f!==null&&(t0(s,f,i,n),wi(f,2),er(f));break}}i=i.return}}function Rd(n,i,s){var f=n.pingCache;if(f===null){f=n.pingCache=new Z2;var g=new Set;f.set(i,g)}else g=f.get(i),g===void 0&&(g=new Set,f.set(i,g));g.has(s)||(Nd=!0,g.add(s),n=tE.bind(null,n,i,s),i.then(n,n))}function tE(n,i,s){var f=n.pingCache;f!==null&&f.delete(i),n.pingedLanes|=n.suspendedLanes&s,n.warmLanes&=~s,at===n&&(Ve&s)===s&&(xt===4||xt===3&&(Ve&62914560)===Ve&&300>Mt()-au?(Je&2)===0&&$l(n,0):Cd|=s,ql===Ve&&(ql=0)),er(n)}function ey(n,i){i===0&&(i=ss()),n=ji(n,i),n!==null&&(wi(n,i),er(n))}function nE(n){var i=n.memoizedState,s=0;i!==null&&(s=i.retryLane),ey(n,s)}function rE(n,i){var s=0;switch(n.tag){case 31:case 13:var f=n.stateNode,g=n.memoizedState;g!==null&&(s=g.retryLane);break;case 19:f=n.stateNode;break;case 22:f=n.stateNode._retryCache;break;default:throw Error(l(314))}f!==null&&f.delete(i),ey(n,s)}function iE(n,i){return Vt(n,i)}var hu=null,Pl=null,Od=!1,pu=!1,Ld=!1,ai=0;function er(n){n!==Pl&&n.next===null&&(Pl===null?hu=Pl=n:Pl=Pl.next=n),pu=!0,Od||(Od=!0,aE())}function io(n,i){if(!Ld&&pu){Ld=!0;do for(var s=!1,f=hu;f!==null;){if(n!==0){var g=f.pendingLanes;if(g===0)var v=0;else{var j=f.suspendedLanes,O=f.pingedLanes;v=(1<<31-We(42|n)+1)-1,v&=g&~(j&~O),v=v&201326741?v&201326741|1:v?v|2:0}v!==0&&(s=!0,iy(f,v))}else v=Ve,v=hl(f,f===at?v:0,f.cancelPendingCommit!==null||f.timeoutHandle!==-1),(v&3)===0||bi(f,v)||(s=!0,iy(f,v));f=f.next}while(s);Ld=!1}}function lE(){ty()}function ty(){pu=Od=!1;var n=0;ai!==0&&gE()&&(n=ai);for(var i=Mt(),s=null,f=hu;f!==null;){var g=f.next,v=ny(f,i);v===0?(f.next=null,s===null?hu=g:s.next=g,g===null&&(Pl=s)):(s=f,(n!==0||(v&3)!==0)&&(pu=!0)),f=g}Rt!==0&&Rt!==5||io(n),ai!==0&&(ai=0)}function ny(n,i){for(var s=n.suspendedLanes,f=n.pingedLanes,g=n.expirationTimes,v=n.pendingLanes&-62914561;0O)break;var fe=Z.transferSize,he=Z.initiatorType;fe&&dy(he)&&(Z=Z.responseEnd,j+=fe*(Z"u"?null:document;function ky(n,i,s){var f=Gl;if(f&&typeof i=="string"&&i){var g=en(i);g='link[rel="'+n+'"][href="'+g+'"]',typeof s=="string"&&(g+='[crossorigin="'+s+'"]'),Sy.has(g)||(Sy.add(g),n={rel:n,crossOrigin:s,href:i},f.querySelector(g)===null&&(i=f.createElement("link"),$t(i,"link",n),_t(i),f.head.appendChild(i)))}}function EE(n){jr.D(n),ky("dns-prefetch",n,null)}function NE(n,i){jr.C(n,i),ky("preconnect",n,i)}function CE(n,i,s){jr.L(n,i,s);var f=Gl;if(f&&n&&i){var g='link[rel="preload"][as="'+en(i)+'"]';i==="image"&&s&&s.imageSrcSet?(g+='[imagesrcset="'+en(s.imageSrcSet)+'"]',typeof s.imageSizes=="string"&&(g+='[imagesizes="'+en(s.imageSizes)+'"]')):g+='[href="'+en(n)+'"]';var v=g;switch(i){case"style":v=Fl(n);break;case"script":v=Yl(n)}Mn.has(v)||(n=p({rel:"preload",href:i==="image"&&s&&s.imageSrcSet?void 0:n,as:i},s),Mn.set(v,n),f.querySelector(g)!==null||i==="style"&&f.querySelector(so(v))||i==="script"&&f.querySelector(uo(v))||(i=f.createElement("link"),$t(i,"link",n),_t(i),f.head.appendChild(i)))}}function jE(n,i){jr.m(n,i);var s=Gl;if(s&&n){var f=i&&typeof i.as=="string"?i.as:"script",g='link[rel="modulepreload"][as="'+en(f)+'"][href="'+en(n)+'"]',v=g;switch(f){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":v=Yl(n)}if(!Mn.has(v)&&(n=p({rel:"modulepreload",href:n},i),Mn.set(v,n),s.querySelector(g)===null)){switch(f){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(s.querySelector(uo(v)))return}f=s.createElement("link"),$t(f,"link",n),_t(f),s.head.appendChild(f)}}}function TE(n,i,s){jr.S(n,i,s);var f=Gl;if(f&&n){var g=Ur(f).hoistableStyles,v=Fl(n);i=i||"default";var j=g.get(v);if(!j){var O={loading:0,preload:null};if(j=f.querySelector(so(v)))O.loading=5;else{n=p({rel:"stylesheet",href:n,"data-precedence":i},s),(s=Mn.get(v))&&Jd(n,s);var Z=j=f.createElement("link");_t(Z),$t(Z,"link",n),Z._p=new Promise(function(le,fe){Z.onload=le,Z.onerror=fe}),Z.addEventListener("load",function(){O.loading|=1}),Z.addEventListener("error",function(){O.loading|=2}),O.loading|=4,vu(j,i,f)}j={type:"stylesheet",instance:j,count:1,state:O},g.set(v,j)}}}function AE(n,i){jr.X(n,i);var s=Gl;if(s&&n){var f=Ur(s).hoistableScripts,g=Yl(n),v=f.get(g);v||(v=s.querySelector(uo(g)),v||(n=p({src:n,async:!0},i),(i=Mn.get(g))&&Wd(n,i),v=s.createElement("script"),_t(v),$t(v,"link",n),s.head.appendChild(v)),v={type:"script",instance:v,count:1,state:null},f.set(g,v))}}function zE(n,i){jr.M(n,i);var s=Gl;if(s&&n){var f=Ur(s).hoistableScripts,g=Yl(n),v=f.get(g);v||(v=s.querySelector(uo(g)),v||(n=p({src:n,async:!0,type:"module"},i),(i=Mn.get(g))&&Wd(n,i),v=s.createElement("script"),_t(v),$t(v,"link",n),s.head.appendChild(v)),v={type:"script",instance:v,count:1,state:null},f.set(g,v))}}function Ey(n,i,s,f){var g=(g=J.current)?yu(g):null;if(!g)throw Error(l(446));switch(n){case"meta":case"title":return null;case"style":return typeof s.precedence=="string"&&typeof s.href=="string"?(i=Fl(s.href),s=Ur(g).hoistableStyles,f=s.get(i),f||(f={type:"style",instance:null,count:0,state:null},s.set(i,f)),f):{type:"void",instance:null,count:0,state:null};case"link":if(s.rel==="stylesheet"&&typeof s.href=="string"&&typeof s.precedence=="string"){n=Fl(s.href);var v=Ur(g).hoistableStyles,j=v.get(n);if(j||(g=g.ownerDocument||g,j={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},v.set(n,j),(v=g.querySelector(so(n)))&&!v._p&&(j.instance=v,j.state.loading=5),Mn.has(n)||(s={rel:"preload",as:"style",href:s.href,crossOrigin:s.crossOrigin,integrity:s.integrity,media:s.media,hrefLang:s.hrefLang,referrerPolicy:s.referrerPolicy},Mn.set(n,s),v||ME(g,n,s,j.state))),i&&f===null)throw Error(l(528,""));return j}if(i&&f!==null)throw Error(l(529,""));return null;case"script":return i=s.async,s=s.src,typeof s=="string"&&i&&typeof i!="function"&&typeof i!="symbol"?(i=Yl(s),s=Ur(g).hoistableScripts,f=s.get(i),f||(f={type:"script",instance:null,count:0,state:null},s.set(i,f)),f):{type:"void",instance:null,count:0,state:null};default:throw Error(l(444,n))}}function Fl(n){return'href="'+en(n)+'"'}function so(n){return'link[rel="stylesheet"]['+n+"]"}function Ny(n){return p({},n,{"data-precedence":n.precedence,precedence:null})}function ME(n,i,s,f){n.querySelector('link[rel="preload"][as="style"]['+i+"]")?f.loading=1:(i=n.createElement("link"),f.preload=i,i.addEventListener("load",function(){return f.loading|=1}),i.addEventListener("error",function(){return f.loading|=2}),$t(i,"link",s),_t(i),n.head.appendChild(i))}function Yl(n){return'[src="'+en(n)+'"]'}function uo(n){return"script[async]"+n}function Cy(n,i,s){if(i.count++,i.instance===null)switch(i.type){case"style":var f=n.querySelector('style[data-href~="'+en(s.href)+'"]');if(f)return i.instance=f,_t(f),f;var g=p({},s,{"data-href":s.href,"data-precedence":s.precedence,href:null,precedence:null});return f=(n.ownerDocument||n).createElement("style"),_t(f),$t(f,"style",g),vu(f,s.precedence,n),i.instance=f;case"stylesheet":g=Fl(s.href);var v=n.querySelector(so(g));if(v)return i.state.loading|=4,i.instance=v,_t(v),v;f=Ny(s),(g=Mn.get(g))&&Jd(f,g),v=(n.ownerDocument||n).createElement("link"),_t(v);var j=v;return j._p=new Promise(function(O,Z){j.onload=O,j.onerror=Z}),$t(v,"link",f),i.state.loading|=4,vu(v,s.precedence,n),i.instance=v;case"script":return v=Yl(s.src),(g=n.querySelector(uo(v)))?(i.instance=g,_t(g),g):(f=s,(g=Mn.get(v))&&(f=p({},s),Wd(f,g)),n=n.ownerDocument||n,g=n.createElement("script"),_t(g),$t(g,"link",f),n.head.appendChild(g),i.instance=g);case"void":return null;default:throw Error(l(443,i.type))}else i.type==="stylesheet"&&(i.state.loading&4)===0&&(f=i.instance,i.state.loading|=4,vu(f,s.precedence,n));return i.instance}function vu(n,i,s){for(var f=s.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),g=f.length?f[f.length-1]:null,v=g,j=0;j title"):null)}function DE(n,i,s){if(s===1||i.itemProp!=null)return!1;switch(n){case"meta":case"title":return!0;case"style":if(typeof i.precedence!="string"||typeof i.href!="string"||i.href==="")break;return!0;case"link":if(typeof i.rel!="string"||typeof i.href!="string"||i.href===""||i.onLoad||i.onError)break;switch(i.rel){case"stylesheet":return n=i.disabled,typeof i.precedence=="string"&&n==null;default:return!0}case"script":if(i.async&&typeof i.async!="function"&&typeof i.async!="symbol"&&!i.onLoad&&!i.onError&&i.src&&typeof i.src=="string")return!0}return!1}function Ay(n){return!(n.type==="stylesheet"&&(n.state.loading&3)===0)}function RE(n,i,s,f){if(s.type==="stylesheet"&&(typeof f.media!="string"||matchMedia(f.media).matches!==!1)&&(s.state.loading&4)===0){if(s.instance===null){var g=Fl(f.href),v=i.querySelector(so(g));if(v){i=v._p,i!==null&&typeof i=="object"&&typeof i.then=="function"&&(n.count++,n=wu.bind(n),i.then(n,n)),s.state.loading|=4,s.instance=v,_t(v);return}v=i.ownerDocument||i,f=Ny(f),(g=Mn.get(g))&&Jd(f,g),v=v.createElement("link"),_t(v);var j=v;j._p=new Promise(function(O,Z){j.onload=O,j.onerror=Z}),$t(v,"link",f),s.instance=v}n.stylesheets===null&&(n.stylesheets=new Map),n.stylesheets.set(s,i),(i=s.state.preload)&&(s.state.loading&3)===0&&(n.count++,s=wu.bind(n),i.addEventListener("load",s),i.addEventListener("error",s))}}var eh=0;function OE(n,i){return n.stylesheets&&n.count===0&&Su(n,n.stylesheets),0eh?50:800)+i);return n.unsuspend=s,function(){n.unsuspend=null,clearTimeout(f),clearTimeout(g)}}:null}function wu(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Su(this,this.stylesheets);else if(this.unsuspend){var n=this.unsuspend;this.unsuspend=null,n()}}}var _u=null;function Su(n,i){n.stylesheets=null,n.unsuspend!==null&&(n.count++,_u=new Map,i.forEach(LE,n),_u=null,wu.call(n))}function LE(n,i){if(!(i.state.loading&4)){var s=_u.get(n);if(s)var f=s.get(null);else{s=new Map,_u.set(n,s);for(var g=n.querySelectorAll("link[data-precedence],style[data-precedence]"),v=0;v"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),uh.exports=tN(),uh.exports}var rN=nN();/** - * @license lucide-react v0.469.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const iN=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),mw=(...e)=>e.filter((t,r,l)=>!!t&&t.trim()!==""&&l.indexOf(t)===r).join(" ").trim();/** - * @license lucide-react v0.469.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */var lN={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/** - * @license lucide-react v0.469.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const aN=$.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:r=2,absoluteStrokeWidth:l,className:a="",children:o,iconNode:u,...c},d)=>$.createElement("svg",{ref:d,...lN,width:t,height:t,stroke:e,strokeWidth:l?Number(r)*24/Number(t):r,className:mw("lucide",a),...c},[...u.map(([h,m])=>$.createElement(h,m)),...Array.isArray(o)?o:[o]]));/** - * @license lucide-react v0.469.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const Be=(e,t)=>{const r=$.forwardRef(({className:l,...a},o)=>$.createElement(aN,{ref:o,iconNode:t,className:mw(`lucide-${iN(e)}`,l),...a}));return r.displayName=`${e}`,r};/** - * @license lucide-react v0.469.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const gw=Be("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"}]]);/** - * @license lucide-react v0.469.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const oN=Be("ArrowDownToLine",[["path",{d:"M12 17V3",key:"1cwfxf"}],["path",{d:"m6 11 6 6 6-6",key:"12ii2o"}],["path",{d:"M19 21H5",key:"150jfl"}]]);/** - * @license lucide-react v0.469.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const sN=Be("ArrowUpFromLine",[["path",{d:"m18 9-6-6-6 6",key:"kcunyi"}],["path",{d:"M12 3v14",key:"7cf3v8"}],["path",{d:"M5 21h14",key:"11awu3"}]]);/** - * @license lucide-react v0.469.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const uN=Be("Bot",[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]]);/** - * @license lucide-react v0.469.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const Yi=Be("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);/** - * @license lucide-react v0.469.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const il=Be("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);/** - * @license lucide-react v0.469.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const Rr=Be("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);/** - * @license lucide-react v0.469.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const cN=Be("ChevronUp",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]);/** - * @license lucide-react v0.469.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const fN=Be("CircleCheck",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);/** - * @license lucide-react v0.469.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const dN=Be("CircleStop",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["rect",{x:"9",y:"9",width:"6",height:"6",rx:"1",key:"1ssd4o"}]]);/** - * @license lucide-react v0.469.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const hN=Be("Clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]]);/** - * @license lucide-react v0.469.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const xw=Be("Coins",[["circle",{cx:"8",cy:"8",r:"6",key:"3yglwk"}],["path",{d:"M18.09 10.37A6 6 0 1 1 10.34 18",key:"t5s6rm"}],["path",{d:"M7 6h1v4",key:"1obek4"}],["path",{d:"m16.71 13.88.7.71-2.82 2.82",key:"1rbuyh"}]]);/** - * @license lucide-react v0.469.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const yw=Be("Copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);/** - * @license lucide-react v0.469.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const pN=Be("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"}]]);/** - * @license lucide-react v0.469.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const mN=Be("Eye",[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);/** - * @license lucide-react v0.469.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const gN=Be("FileCode",[["path",{d:"M10 12.5 8 15l2 2.5",key:"1tg20x"}],["path",{d:"m14 12.5 2 2.5-2 2.5",key:"yinavb"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7z",key:"1mlx9k"}]]);/** - * @license lucide-react v0.469.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const xN=Be("FileOutput",[["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M4 7V4a2 2 0 0 1 2-2 2 2 0 0 0-2 2",key:"1vk7w2"}],["path",{d:"M4.063 20.999a2 2 0 0 0 2 1L18 22a2 2 0 0 0 2-2V7l-5-5H6",key:"1jink5"}],["path",{d:"m5 11-3 3",key:"1dgrs4"}],["path",{d:"m5 17-3-3h10",key:"1mvvaf"}]]);/** - * @license lucide-react v0.469.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const vw=Be("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"}]]);/** - * @license lucide-react v0.469.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const yN=Be("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"}]]);/** - * @license lucide-react v0.469.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const bw=Be("Hash",[["line",{x1:"4",x2:"20",y1:"9",y2:"9",key:"4lhtct"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15",key:"vyu0kd"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21",key:"1ggp8o"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21",key:"weycgp"}]]);/** - * @license lucide-react v0.469.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const Sc=Be("Layers",[["path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z",key:"zw3jo"}],["path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12",key:"1wduqc"}],["path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",key:"kqbvx6"}]]);/** - * @license lucide-react v0.469.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const ca=Be("LoaderCircle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);/** - * @license lucide-react v0.469.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const vN=Be("Maximize",[["path",{d:"M8 3H5a2 2 0 0 0-2 2v3",key:"1dcmit"}],["path",{d:"M21 8V5a2 2 0 0 0-2-2h-3",key:"1e4gt3"}],["path",{d:"M3 16v3a2 2 0 0 0 2 2h3",key:"wsl5sc"}],["path",{d:"M16 21h3a2 2 0 0 0 2-2v-3",key:"18trek"}]]);/** - * @license lucide-react v0.469.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const ym=Be("MessageCircle",[["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z",key:"vv11sd"}]]);/** - * @license lucide-react v0.469.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const bN=Be("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"}]]);/** - * @license lucide-react v0.469.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const kc=Be("Play",[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]]);/** - * @license lucide-react v0.469.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const wN=Be("Repeat",[["path",{d:"m17 2 4 4-4 4",key:"nntrym"}],["path",{d:"M3 11v-1a4 4 0 0 1 4-4h14",key:"84bu3i"}],["path",{d:"m7 22-4-4 4-4",key:"1wqhfi"}],["path",{d:"M21 13v1a4 4 0 0 1-4 4H3",key:"1rx37r"}]]);/** - * @license lucide-react v0.469.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const _N=Be("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]);/** - * @license lucide-react v0.469.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const ww=Be("Send",[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]]);/** - * @license lucide-react v0.469.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const SN=Be("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"}]]);/** - * @license lucide-react v0.469.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const ev=Be("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"}]]);/** - * @license lucide-react v0.469.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const _w=Be("Square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);/** - * @license lucide-react v0.469.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const kN=Be("Terminal",[["polyline",{points:"4 17 10 11 4 5",key:"akl6gq"}],["line",{x1:"12",x2:"20",y1:"19",y2:"19",key:"q2wloq"}]]);/** - * @license lucide-react v0.469.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const ic=Be("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"}]]);/** - * @license lucide-react v0.469.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const EN=Be("WifiOff",[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}],["path",{d:"M5 12.859a10 10 0 0 1 5.17-2.69",key:"1dl1wf"}],["path",{d:"M19 12.859a10 10 0 0 0-2.007-1.523",key:"4k23kn"}],["path",{d:"M2 8.82a15 15 0 0 1 4.177-2.643",key:"1grhjp"}],["path",{d:"M22 8.82a15 15 0 0 0-11.288-3.764",key:"z3jwby"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/** - * @license lucide-react v0.469.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const NN=Be("Wifi",[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M2 8.82a15 15 0 0 1 20 0",key:"dnpr2z"}],["path",{d:"M5 12.859a10 10 0 0 1 14 0",key:"1x1e6c"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}]]);/** - * @license lucide-react v0.469.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const ll=Be("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);/** - * @license lucide-react v0.469.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const CN=Be("Zap",[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]]),tv=e=>{let t;const r=new Set,l=(h,m)=>{const p=typeof h=="function"?h(t):h;if(!Object.is(p,t)){const x=t;t=m??(typeof p!="object"||p===null)?p:Object.assign({},t,p),r.forEach(b=>b(t,x))}},a=()=>t,c={setState:l,getState:a,getInitialState:()=>d,subscribe:h=>(r.add(h),()=>r.delete(h))},d=t=e(l,a,c);return c},jN=(e=>e?tv(e):tv),TN=e=>e;function AN(e,t=TN){const r=ta.useSyncExternalStore(e.subscribe,ta.useCallback(()=>t(e.getState()),[e,t]),ta.useCallback(()=>t(e.getInitialState()),[e,t]));return ta.useDebugValue(r),r}const nv=e=>{const t=jN(e),r=l=>AN(t,l);return Object.assign(r,t),r},zN=(e=>e?nv(e):nv);function Ue(e,t,r="agent"){return e[t]||(e[t]={name:t,status:"pending",type:r,activity:[]}),e[t].activity||(e[t].activity=[]),e[t]}function zu(e,t,r){Ue(e,t).activity.push(r)}function De(e,t){e[t]&&(e[t]={...e[t]})}function xo(e,t,r,l){const a=e[t];if(!(a!=null&&a.for_each_items))return;const o=a.for_each_items.find(u=>u.key===r);o&&o.activity.push(l)}function MN(e,t,r,l){return{parentAgent:e,iteration:t,slotKey:l??e,workflowFile:r,workflowName:"",status:"pending",agents:[],routes:[],parallelGroups:[],forEachGroups:[],nodes:{},groupProgress:{},highlightedEdges:[],entryPoint:null,children:[],agentsCompleted:0,agentsTotal:0,totalCost:0,totalTokens:0,eventLog:[],activityLog:[],workflowOutput:null,workflowFailure:null}}function tr(e,t){if(t.length===0)return null;let r=e[t[0]];for(let l=1;l=0;c--)if(l[c].slotKey===o){u=c;break}if(u===-1)return null;r.push(u),a=l[u],l=a.children}return{indexPath:r,ctx:a}}function DN(e,t){for(let r=e.length-1;r>=0;r--){const l=e[r];if(l.slotKey===t)return{ctx:l,index:r}}return null}const ue=zN((e,t)=>({workflowName:"",workflowStatus:"pending",workflowStartTime:null,workflowFailure:null,workflowFailedAgent:null,workflowYaml:null,conductorVersion:null,entryPoint:null,agents:[],routes:[],parallelGroups:[],forEachGroups:[],nodes:{},groupProgress:{},highlightedEdges:[],agentsCompleted:0,agentsTotal:0,totalCost:0,totalTokens:0,selectedNode:null,wsStatus:"connecting",eventLog:[],activityLog:[],workflowOutput:null,lastEventTime:null,isPaused:!1,iterationLimitGate:null,wfDepth:0,subworkflowContexts:[],activeContextPath:[],viewContextPath:[],replayMode:!1,replayEvents:[],replayPosition:0,replayTotalEvents:0,replayPlaying:!1,replaySpeed:1,_wsSend:null,setWsSend:r=>{e({_wsSend:r})},sendGateResponse:(r,l,a)=>{const o=ue.getState()._wsSend;o&&o({type:"gate_response",agent_name:r,selected_value:l,additional_input:a||{}})},activeDialog:null,dialogEngaged:!1,engageDialog:()=>{e({dialogEngaged:!0})},sendDialogMessage:(r,l,a)=>{const o=ue.getState()._wsSend;o&&o({type:"dialog_message",agent_name:r,dialog_id:l,content:a})},sendDialogDecline:(r,l)=>{const a=ue.getState()._wsSend;a&&a({type:"dialog_decline",agent_name:r,dialog_id:l})},sendIterationLimitResponse:(r,l,a)=>{const o=ue.getState()._wsSend;if(!o)return;const u=Math.max(0,Math.floor(Number(a)||0)),c="agent_name"in r?{agent_name:r.agent_name}:{group_name:r.group_name};o({type:"iteration_limit_response",gate_id:l,...c,additional_iterations:u})},processEvent:r=>{const l=Mu[r.type];e(a=>{const o={...a,nodes:{...a.nodes},groupProgress:{...a.groupProgress},eventLog:[...a.eventLog],activityLog:[...a.activityLog],lastEventTime:r.timestamp};l&&l(o,r.data,r.timestamp);const u=Du(r);u&&o.eventLog.push(u);const c=Ru(r);return c&&o.activityLog.push(c),o})},replayState:r=>{e(l=>{const a={...l,agentsCompleted:0,totalCost:0,totalTokens:0,nodes:{},groupProgress:{},highlightedEdges:[],eventLog:[],activityLog:[],workflowOutput:null,workflowFailedAgent:null,activeDialog:null,dialogEngaged:!1,wfDepth:0,subworkflowContexts:[],activeContextPath:[]};for(const o of r){const u=Mu[o.type];u&&u(a,o.data,o.timestamp);const c=Du(o);c&&a.eventLog.push(c);const d=Ru(o);d&&a.activityLog.push(d),a.lastEventTime=o.timestamp}return a})},selectNode:r=>{e({selectedNode:r})},setReplayMode:r=>{e(l=>{const a={...l,replayMode:!0,replayEvents:r,replayTotalEvents:r.length,replayPosition:r.length,replayPlaying:!1,replaySpeed:1,agentsCompleted:0,totalCost:0,totalTokens:0,nodes:{},groupProgress:{},highlightedEdges:[],eventLog:[],activityLog:[],workflowOutput:null,workflowFailedAgent:null,activeDialog:null,dialogEngaged:!1,wfDepth:0,subworkflowContexts:[],activeContextPath:[],viewContextPath:[]};for(const o of r){const u=Mu[o.type];u&&u(a,o.data,o.timestamp);const c=Du(o);c&&a.eventLog.push(c);const d=Ru(o);d&&a.activityLog.push(d),a.lastEventTime=o.timestamp}return a})},setReplayPosition:r=>{e(l=>{const a=l.replayEvents.slice(0,r),o={...l,replayPosition:r,agentsCompleted:0,totalCost:0,totalTokens:0,nodes:{},groupProgress:{},highlightedEdges:[],eventLog:[],activityLog:[],workflowOutput:null,workflowFailedAgent:null,workflowStatus:"pending",workflowStartTime:null,workflowName:"",workflowFailure:null,entryPoint:null,agents:[],routes:[],parallelGroups:[],forEachGroups:[],isPaused:!1,iterationLimitGate:null,lastEventTime:null,activeDialog:null,dialogEngaged:!1,wfDepth:0,subworkflowContexts:[],activeContextPath:[],viewContextPath:[]};for(const u of a){const c=Mu[u.type];c&&c(o,u.data,u.timestamp);const d=Du(u);d&&o.eventLog.push(d);const h=Ru(u);h&&o.activityLog.push(h),o.lastEventTime=u.timestamp}return o})},setReplayPlaying:r=>{e({replayPlaying:r})},setReplaySpeed:r=>{e({replaySpeed:r})},setWsStatus:r=>{e({wsStatus:r})},setEdgeHighlight:(r,l,a)=>{e(o=>({highlightedEdges:[...o.highlightedEdges.filter(u=>!(u.from===r&&u.to===l)),{from:r,to:l,state:a}]}))},clearEdgeHighlight:(r,l)=>{e(a=>({highlightedEdges:a.highlightedEdges.filter(o=>!(o.from===r&&o.to===l))}))},navigateToContext:r=>{e({viewContextPath:r,selectedNode:null})},navigateUp:()=>{e(r=>({viewContextPath:r.viewContextPath.slice(0,-1),selectedNode:null}))},navigateIntoSubworkflow:r=>{const l=t(),a=l.viewContextPath;let o;if(a.length===0)o=l.subworkflowContexts;else{const c=tr(l.subworkflowContexts,a);if(!c)return;o=c.children}const u=DN(o,r);u&&e({viewContextPath:[...a,u.index],selectedNode:null})},getViewedContext:()=>{const r=t();if(r.viewContextPath.length===0)return{workflowName:r.workflowName,agents:r.agents,routes:r.routes,parallelGroups:r.parallelGroups,forEachGroups:r.forEachGroups,nodes:r.nodes,groupProgress:r.groupProgress,highlightedEdges:r.highlightedEdges,entryPoint:r.entryPoint,subworkflowContexts:r.subworkflowContexts};const l=tr(r.subworkflowContexts,r.viewContextPath);return l?{workflowName:l.workflowName,agents:l.agents,routes:l.routes,parallelGroups:l.parallelGroups,forEachGroups:l.forEachGroups,nodes:l.nodes,groupProgress:l.groupProgress,highlightedEdges:l.highlightedEdges,entryPoint:l.entryPoint,subworkflowContexts:l.children}:{workflowName:r.workflowName,agents:r.agents,routes:r.routes,parallelGroups:r.parallelGroups,forEachGroups:r.forEachGroups,nodes:r.nodes,groupProgress:r.groupProgress,highlightedEdges:r.highlightedEdges,entryPoint:r.entryPoint,subworkflowContexts:r.subworkflowContexts}},getBreadcrumbs:()=>{const r=t(),l=[{label:r.workflowName||"Root",path:[]}];let a=r.subworkflowContexts;for(let o=0;o0&&(r=((a=Vi(e.subworkflowContexts,l))==null?void 0:a.ctx)??null),r){const o=r;return{nodes:o.nodes,groupProgress:o.groupProgress,routes:o.routes,highlightedEdges:o.highlightedEdges,addCost:u=>{o.totalCost+=u,e.totalCost+=u},addTokens:u=>{o.totalTokens+=u,e.totalTokens+=u},incrCompleted:()=>{o.agentsCompleted++,e.agentsCompleted++}}}return{nodes:e.nodes,groupProgress:e.groupProgress,routes:e.routes,highlightedEdges:e.highlightedEdges,addCost:o=>{e.totalCost+=o},addTokens:o=>{e.totalTokens+=o},incrCompleted:()=>{e.agentsCompleted++}}}const Mu={workflow_started:(e,t,r)=>{var a;const l=t;if(e.wfDepth===0){e.workflowStatus="running",e.workflowStartTime=r??Date.now()/1e3,e.workflowName=l.name||"",e.workflowYaml=t.yaml_source??null,e.conductorVersion=t.version??null,e.entryPoint=l.entry_point||null,e.agents=l.agents||[],e.routes=l.routes||[],e.parallelGroups=l.parallel_groups||[],e.forEachGroups=l.for_each_groups||[],Ue(e.nodes,"$start","start"),e.nodes.$start.status="running",De(e.nodes,"$start");const o=new Set,u=new Set;for(const c of e.parallelGroups){for(const d of c.agents)o.add(d);u.add(c.name),Ue(e.nodes,c.name,"parallel_group"),e.groupProgress[c.name]={total:c.agents.length,completed:0,failed:0};for(const d of c.agents)Ue(e.nodes,d,"agent")}for(const c of e.forEachGroups)u.add(c.name),Ue(e.nodes,c.name,"for_each_group"),e.groupProgress[c.name]={total:0,completed:0,failed:0};for(const c of e.agents)if(!u.has(c.name)&&!o.has(c.name)){const d=c.type||"agent";Ue(e.nodes,c.name,d),c.model&&(e.nodes[c.name].model=c.model),c.reasoning_effort&&(e.nodes[c.name].reasoning_effort=c.reasoning_effort),u.add(c.name)}e.agentsTotal=u.size}else{const o=t.subworkflow_path,u=Array.isArray(o)&&o.length>0?((a=Vi(e.subworkflowContexts,o))==null?void 0:a.ctx)??null:tr(e.subworkflowContexts,e.activeContextPath);if(u){u.workflowName=l.name||"",u.status="running",u.entryPoint=l.entry_point||null,u.agents=l.agents||[],u.routes=l.routes||[],u.parallelGroups=l.parallel_groups||[],u.forEachGroups=l.for_each_groups||[],Ue(u.nodes,"$start","start"),u.nodes.$start.status="running";const c=new Set,d=new Set;for(const h of u.parallelGroups){for(const m of h.agents)c.add(m);d.add(h.name),Ue(u.nodes,h.name,"parallel_group"),u.groupProgress[h.name]={total:h.agents.length,completed:0,failed:0};for(const m of h.agents)Ue(u.nodes,m,"agent")}for(const h of u.forEachGroups)d.add(h.name),Ue(u.nodes,h.name,"for_each_group"),u.groupProgress[h.name]={total:0,completed:0,failed:0};for(const h of u.agents)if(!d.has(h.name)&&!c.has(h.name)){const m=h.type||"agent";Ue(u.nodes,h.name,m),h.model&&(u.nodes[h.name].model=h.model),h.reasoning_effort&&(u.nodes[h.name].reasoning_effort=h.reasoning_effort),d.add(h.name)}u.agentsTotal=d.size}}e.wfDepth++},agent_started:(e,t,r)=>{const l=t,a=ht(e,t),o=Ue(a.nodes,l.agent_name);o.iteration!=null&&(o.output!=null||o.error_type!=null)&&(o.iterationHistory||(o.iterationHistory=[]),o.iterationHistory.push({iteration:o.iteration,prompt:o.prompt,output:o.output,elapsed:o.elapsed,model:o.model,reasoning_effort:o.reasoning_effort,tokens:o.tokens,input_tokens:o.input_tokens,output_tokens:o.output_tokens,cost_usd:o.cost_usd,activity:o.activity,error_type:o.error_type,error_message:o.error_message})),o.status="running",o.iteration=l.iteration,o.startedAt=r??Date.now()/1e3,o.activity=[],l.context_window_max!=null&&(o.context_window_max=l.context_window_max),o.prompt=void 0,o.output=void 0,o.error_type=void 0,o.error_message=void 0,De(a.nodes,l.agent_name)},agent_completed:(e,t)=>{const r=t,l=ht(e,t),a=Ue(l.nodes,r.agent_name);a.status="completed",l.incrCompleted(),a.elapsed=r.elapsed,a.model=r.model,a.tokens=r.tokens,a.input_tokens=r.input_tokens,a.output_tokens=r.output_tokens,a.cost_usd=r.cost_usd,a.output=r.output,a.output_keys=r.output_keys,a.context_window_used=r.context_window_used,a.context_window_max=r.context_window_max,r.context_window_used!=null&&r.context_window_max!=null&&r.context_window_max>0&&(a.context_pct=Math.round(r.context_window_used/r.context_window_max*100)),r.cost_usd&&l.addCost(r.cost_usd),r.tokens&&l.addTokens(r.tokens),De(l.nodes,r.agent_name)},agent_failed:(e,t)=>{const r=t,l=ht(e,t),a=Ue(l.nodes,r.agent_name);a.status="failed",a.elapsed=r.elapsed,a.error_type=r.error_type,a.error_message=r.message;for(const o of l.routes)o.to===r.agent_name&&l.highlightedEdges.push({from:o.from,to:o.to,state:"failed"});De(l.nodes,r.agent_name)},agent_prompt_rendered:(e,t)=>{var u;const r=t,l=t.item_key,a=ht(e,t),o=Ue(a.nodes,r.agent_name);if(o.prompt=r.rendered_prompt,o.context_keys=r.context_keys,l){xo(a.nodes,r.agent_name,l,{type:"prompt",icon:"📝",label:"prompt",text:"Prompt rendered",detail:((u=r.rendered_prompt)==null?void 0:u.slice(0,500))||null});const c=a.nodes[r.agent_name];if(c!=null&&c.for_each_items){const d=c.for_each_items.find(h=>h.key===l);d&&(d.prompt=r.rendered_prompt)}}De(a.nodes,r.agent_name)},agent_reasoning:(e,t)=>{const r=t,l=t.item_key,a=ht(e,t),o={type:"reasoning",icon:"💭",label:"thinking",text:r.content};zu(a.nodes,r.agent_name,o),l&&xo(a.nodes,r.agent_name,l,o),De(a.nodes,r.agent_name)},agent_tool_start:(e,t)=>{const r=t,l=t.item_key,a=ht(e,t),o={type:"tool-start",icon:"🔧",label:"tool",text:r.tool_name,detail:r.arguments||null};zu(a.nodes,r.agent_name,o),l&&xo(a.nodes,r.agent_name,l,o),De(a.nodes,r.agent_name)},agent_tool_complete:(e,t)=>{const r=t,l=t.item_key,a=ht(e,t),o={type:"tool-complete",icon:"✓",label:"result",text:r.tool_name||"done",detail:r.result||null};zu(a.nodes,r.agent_name,o),l&&xo(a.nodes,r.agent_name,l,o),De(a.nodes,r.agent_name)},agent_turn_start:(e,t)=>{const r=t,l=t.item_key,a=ht(e,t),o={type:"turn",icon:"⏳",label:"turn",text:`Turn ${r.turn??"?"}`};zu(a.nodes,r.agent_name,o),l&&xo(a.nodes,r.agent_name,l,o),De(a.nodes,r.agent_name)},agent_message:(e,t)=>{const r=t,l=ht(e,t),a=Ue(l.nodes,r.agent_name);a.latest_message=r.content,De(l.nodes,r.agent_name)},script_started:(e,t,r)=>{const l=t,a=ht(e,t),o=Ue(a.nodes,l.agent_name);o.status="running",o.startedAt=r??Date.now()/1e3,De(a.nodes,l.agent_name)},script_completed:(e,t)=>{const r=t,l=ht(e,t),a=Ue(l.nodes,r.agent_name);a.status="completed",l.incrCompleted(),a.elapsed=r.elapsed,a.stdout=r.stdout,a.stderr=r.stderr,a.exit_code=r.exit_code,De(l.nodes,r.agent_name)},script_failed:(e,t)=>{const r=t,l=ht(e,t),a=Ue(l.nodes,r.agent_name);a.status="failed",a.elapsed=r.elapsed,a.error_type=r.error_type,a.error_message=r.message,De(l.nodes,r.agent_name)},gate_presented:(e,t)=>{const r=t,l=ht(e,t),a=Ue(l.nodes,r.agent_name);a.status="waiting",a.options=r.options,a.option_details=r.option_details,a.prompt=r.prompt,De(l.nodes,r.agent_name)},gate_resolved:(e,t)=>{const r=t,l=ht(e,t),a=Ue(l.nodes,r.agent_name);a.status="completed",l.incrCompleted(),a.selected_option=r.selected_option,a.route=r.route,a.additional_input=r.additional_input,De(l.nodes,r.agent_name)},route_taken:(e,t)=>{const r=t;ht(e,t).highlightedEdges.push({from:r.from_agent,to:r.to_agent,state:"taken"})},parallel_started:(e,t)=>{const r=t,l=ht(e,t),a=Ue(l.nodes,r.group_name,"parallel_group");a.status="running",l.groupProgress[r.group_name]&&(l.groupProgress[r.group_name].total=r.agents.length,l.groupProgress[r.group_name].completed=0,l.groupProgress[r.group_name].failed=0),De(l.nodes,r.group_name)},parallel_agent_completed:(e,t)=>{const r=t,l=ht(e,t);l.groupProgress[r.group_name]&&l.groupProgress[r.group_name].completed++;const a=Ue(l.nodes,r.agent_name);a.status="completed",a.elapsed=r.elapsed,a.model=r.model,a.tokens=r.tokens,a.cost_usd=r.cost_usd,a.context_window_used=r.context_window_used,a.context_window_max=r.context_window_max,r.context_window_used!=null&&r.context_window_max!=null&&r.context_window_max>0&&(a.context_pct=Math.round(r.context_window_used/r.context_window_max*100)),r.cost_usd&&l.addCost(r.cost_usd),r.tokens&&l.addTokens(r.tokens),De(l.nodes,r.agent_name),De(l.nodes,r.group_name)},parallel_agent_failed:(e,t)=>{const r=t,l=ht(e,t);l.groupProgress[r.group_name]&&l.groupProgress[r.group_name].failed++;const a=Ue(l.nodes,r.agent_name);a.status="failed",a.elapsed=r.elapsed,a.error_type=r.error_type,a.error_message=r.message,De(l.nodes,r.agent_name),De(l.nodes,r.group_name)},parallel_completed:(e,t)=>{const r=t,l=ht(e,t);l.incrCompleted();const a=Ue(l.nodes,r.group_name,"parallel_group");a.status=r.failure_count===0?"completed":"failed",De(l.nodes,r.group_name)},for_each_started:(e,t)=>{const r=t,l=ht(e,t),a=Ue(l.nodes,r.group_name,"for_each_group");a.status="running",a.for_each_items=[],l.groupProgress[r.group_name]&&(l.groupProgress[r.group_name].total=r.item_count,l.groupProgress[r.group_name].completed=0,l.groupProgress[r.group_name].failed=0),De(l.nodes,r.group_name)},for_each_item_started:(e,t)=>{const r=t,l=ht(e,t),a=Ue(l.nodes,r.group_name,"for_each_group");a.for_each_items||(a.for_each_items=[]),a.for_each_items.push({key:r.item_key??String(r.index),index:r.index,status:"running",activity:[]}),De(l.nodes,r.group_name)},for_each_item_completed:(e,t)=>{const r=t,l=ht(e,t);l.groupProgress[r.group_name]&&l.groupProgress[r.group_name].completed++;const a=Ue(l.nodes,r.group_name,"for_each_group");if(a.for_each_items){const o=r.item_key??String(r.index),u=a.for_each_items.find(c=>c.key===o);u&&(u.status="completed",u.elapsed=r.elapsed,u.tokens=r.tokens,u.cost_usd=r.cost_usd,u.output=r.output)}De(l.nodes,r.group_name)},for_each_item_failed:(e,t)=>{const r=t,l=ht(e,t);l.groupProgress[r.group_name]&&l.groupProgress[r.group_name].failed++;const a=Ue(l.nodes,r.group_name,"for_each_group");if(a.for_each_items){const o=r.item_key??String(r.index),u=a.for_each_items.find(c=>c.key===o);u&&(u.status="failed",u.elapsed=r.elapsed,u.error_type=r.error_type,u.error_message=r.message)}De(l.nodes,r.group_name)},for_each_completed:(e,t)=>{const r=t,l=ht(e,t);l.incrCompleted();const a=Ue(l.nodes,r.group_name,"for_each_group");a.status=(r.failure_count??0)===0?"completed":"failed",a.elapsed=r.elapsed,a.success_count=r.success_count,a.failure_count=r.failure_count,De(l.nodes,r.group_name)},workflow_completed:(e,t)=>{var r;if(e.wfDepth=Math.max(0,e.wfDepth-1),e.wfDepth===0){const l=t;e.workflowStatus="completed",e.isPaused=!1,e.iterationLimitGate=null,e.workflowOutput=l.output??null,e.nodes.$end&&(e.nodes.$end.status="completed",De(e.nodes,"$end")),e.nodes.$start&&(e.nodes.$start.status="completed",De(e.nodes,"$start")),e.highlightedEdges=[]}else{const l=t,a=l.subworkflow_path?(r=Vi(e.subworkflowContexts,l.subworkflow_path))==null?void 0:r.ctx:tr(e.subworkflowContexts,e.activeContextPath);a&&(a.status="completed",a.workflowOutput=l.output??null,a.nodes.$end&&(a.nodes.$end.status="completed"),a.nodes.$start&&(a.nodes.$start.status="completed"),a.highlightedEdges=[])}},workflow_failed:(e,t)=>{var l;e.wfDepth=Math.max(0,e.wfDepth-1);const r=t;if(e.wfDepth===0){if(e.workflowStatus="failed",e.isPaused=!1,e.iterationLimitGate=null,e.workflowFailedAgent=r.agent_name||null,r.agent_name&&e.nodes[r.agent_name]){e.nodes[r.agent_name].status="failed",De(e.nodes,r.agent_name);for(const a of e.routes)a.to===r.agent_name&&e.highlightedEdges.push({from:a.from,to:a.to,state:"failed"})}e.workflowFailure={error_type:r.error_type,message:r.message,elapsed_seconds:r.elapsed_seconds,timeout_seconds:r.timeout_seconds,current_agent:r.current_agent},e.nodes.$start&&(e.nodes.$start.status="completed",De(e.nodes,"$start"))}else{const a=r.subworkflow_path?(l=Vi(e.subworkflowContexts,r.subworkflow_path))==null?void 0:l.ctx:tr(e.subworkflowContexts,e.activeContextPath);a&&(a.status="failed",a.workflowFailure={error_type:r.error_type,message:r.message})}},subworkflow_started:(e,t)=>{const r=t,l=r.slot_key??(r.item_key!=null?`${r.agent_name}[${r.item_key}]`:r.agent_name),a=MN(r.agent_name,r.iteration??1,r.workflow,l);let o;if(r.parent_path!==void 0){const c=Vi(e.subworkflowContexts,r.parent_path);if(!c)return;o=c.indexPath}else o=e.activeContextPath;let u;if(o.length===0)e.subworkflowContexts.push(a),u=[e.subworkflowContexts.length-1];else{const c=tr(e.subworkflowContexts,o);if(!c)return;c.children.push(a),u=[...o,c.children.length-1]}if(e.activeContextPath=u,o.length===0){const c=e.nodes[r.agent_name];c&&(c.status="running",De(e.nodes,r.agent_name))}else{const c=tr(e.subworkflowContexts,o);if(c){const d=c.nodes[r.agent_name];d&&(d.status="running",De(c.nodes,r.agent_name))}}},subworkflow_completed:(e,t)=>{var o;const r=t;let l;if(r.parent_path!==void 0){const u=Vi(e.subworkflowContexts,r.parent_path);if(!u)return;l=u.indexPath}else l=e.activeContextPath;const a=l.length===0?e.nodes:(o=tr(e.subworkflowContexts,l))==null?void 0:o.nodes;if(a){const u=a[r.agent_name];if(u){if(r.item_key==null)if(u.status="completed",u.elapsed=r.elapsed,l.length===0)e.agentsCompleted++;else{const c=tr(e.subworkflowContexts,l);c&&c.agentsCompleted++}De(a,r.agent_name)}}e.activeContextPath=l},subworkflow_failed:(e,t)=>{var o;const r=t;let l;if(r.parent_path!==void 0){const u=Vi(e.subworkflowContexts,r.parent_path);if(!u)return;l=u.indexPath}else l=e.activeContextPath;const a=l.length===0?e.nodes:(o=tr(e.subworkflowContexts,l))==null?void 0:o.nodes;if(a){const u=a[r.agent_name];u&&r.item_key==null&&(u.status="failed",u.elapsed=r.elapsed,u.error_type=r.error_type,u.error_message=r.message,De(a,r.agent_name))}e.activeContextPath=l},checkpoint_saved:(e,t)=>{const r=t;r.path&&e.workflowFailure&&(e.workflowFailure={...e.workflowFailure,checkpoint_path:r.path})},agent_paused:(e,t)=>{const r=t,l=Ue(e.nodes,r.agent_name);l.status="waiting",l.activity.push({type:"agent_paused",icon:"⏸",label:"Paused",text:"Agent paused — click Resume to re-execute"}),De(e.nodes,r.agent_name),e.isPaused=!0},agent_resumed:(e,t)=>{const r=t,l=Ue(e.nodes,r.agent_name);l.status="running",l.activity.push({type:"agent_resumed",icon:"▶",label:"Resumed",text:"Agent resumed — re-executing"}),De(e.nodes,r.agent_name),e.isPaused=!1},iteration_limit_reached:(e,t)=>{const r=t;e.iterationLimitGate=r;const l=r.agent_name??r.group_name;l?(Ue(e.nodes,l).activity.push({type:"iteration_limit_reached",icon:"⚠",label:"Iteration limit",text:`Reached ${r.current_iteration}/${r.max_iterations} iterations — ${r.skip_gates?"auto-stopping (--skip-gates)":"awaiting decision"}`}),De(e.nodes,l)):typeof console<"u"&&console.warn("[workflow-store] iteration_limit_reached event missing both agent_name and group_name",r)},iteration_limit_resolved:(e,t)=>{const r=t;e.iterationLimitGate=null;const l=r.agent_name??r.group_name;l?(Ue(e.nodes,l).activity.push({type:"iteration_limit_resolved",icon:r.continue_execution?"▶":"■",label:"Iteration limit",text:r.aborted?"Gate aborted unexpectedly — stopping workflow":r.continue_execution?`Continuing with ${r.additional_iterations} more iteration(s)`:"Stopping workflow"}),De(e.nodes,l)):typeof console<"u"&&console.warn("[workflow-store] iteration_limit_resolved event missing both agent_name and group_name",r)},dialog_started:(e,t)=>{const r=t,l=Ue(e.nodes,r.agent_name);l.dialog_id=r.dialog_id,l.dialog_messages=[],l.dialog_active=!0,l.dialog_awaiting_response=!1,e.activeDialog={agentName:r.agent_name,dialogId:r.dialog_id},e.dialogEngaged=!1,De(e.nodes,r.agent_name)},dialog_message:(e,t)=>{const r=t,l=Ue(e.nodes,r.agent_name);l.dialog_messages||(l.dialog_messages=[]),l.dialog_messages.push({role:r.role,content:r.content}),r.role==="user"?l.dialog_awaiting_response=!0:r.role==="agent"&&(l.dialog_awaiting_response=!1),De(e.nodes,r.agent_name)},dialog_completed:(e,t)=>{const r=t,l=Ue(e.nodes,r.agent_name);l.dialog_active=!1,l.dialog_awaiting_response=!1,e.activeDialog=null,e.dialogEngaged=!1,De(e.nodes,r.agent_name)}};function Du(e){var l,a;const t=e.timestamp,r=e.data;switch(e.type){case"workflow_started":return{timestamp:t,level:"info",source:"workflow",message:`Workflow "${r.name||""}" started`};case"agent_started":return{timestamp:t,level:"info",source:String(r.agent_name),message:`Agent started${r.iteration!=null?` (iteration ${r.iteration})`:""}`};case"agent_completed":return{timestamp:t,level:"success",source:String(r.agent_name),message:`Agent completed${r.elapsed!=null?` in ${Qu(r.elapsed)}`:""}${r.tokens!=null?` · ${r.tokens.toLocaleString()} tokens`:""}${r.cost_usd!=null?` · $${r.cost_usd.toFixed(4)}`:""}`};case"agent_failed":return{timestamp:t,level:"error",source:String(r.agent_name),message:`Agent failed: ${r.message||r.error_type||"unknown error"}`};case"script_started":return{timestamp:t,level:"info",source:String(r.agent_name),message:"Script started"};case"script_completed":return{timestamp:t,level:"success",source:String(r.agent_name),message:`Script completed (exit ${r.exit_code??"?"})${r.elapsed!=null?` in ${Qu(r.elapsed)}`:""}`};case"script_failed":return{timestamp:t,level:"error",source:String(r.agent_name),message:`Script failed: ${r.message||r.error_type||"unknown error"}`};case"gate_presented":return{timestamp:t,level:"warning",source:String(r.agent_name),message:"Waiting for human input…"};case"gate_resolved":return{timestamp:t,level:"success",source:String(r.agent_name),message:`Gate resolved → ${r.selected_option||"continue"}`};case"route_taken":return{timestamp:t,level:"debug",source:"router",message:`${r.from_agent} → ${r.to_agent}`};case"parallel_started":return{timestamp:t,level:"info",source:String(r.group_name),message:`Parallel group started (${((l=r.agents)==null?void 0:l.length)||"?"} agents)`};case"parallel_completed":return{timestamp:t,level:r.failure_count===0?"success":"error",source:String(r.group_name),message:`Parallel group completed${r.failure_count>0?` with ${r.failure_count} failure(s)`:""}`};case"for_each_started":return{timestamp:t,level:"info",source:String(r.group_name),message:`For-each started (${r.item_count} items)`};case"for_each_completed":return{timestamp:t,level:(r.failure_count??0)===0?"success":"error",source:String(r.group_name),message:`For-each completed · ${r.success_count} succeeded${r.failure_count>0?` · ${r.failure_count} failed`:""}`};case"workflow_completed":return{timestamp:t,level:"success",source:"workflow",message:`Workflow completed${r.elapsed!=null?` in ${Qu(r.elapsed)}`:""}`};case"workflow_failed":return{timestamp:t,level:"error",source:"workflow",message:`Workflow failed: ${r.message||r.error_type||"unknown error"}`};case"checkpoint_saved":return{timestamp:t,level:"info",source:"workflow",message:`Checkpoint saved: ${((a=r.path)==null?void 0:a.split("/").pop())||"unknown"}`};case"agent_paused":return{timestamp:t,level:"warning",source:String(r.agent_name),message:"Agent paused — waiting for resume"};case"agent_resumed":return{timestamp:t,level:"info",source:String(r.agent_name),message:"Agent resumed — re-executing"};case"iteration_limit_reached":{const o=r.agent_name??r.group_name??"workflow",u=r.skip_gates?" — auto-stopping (--skip-gates)":" — awaiting decision";return{timestamp:t,level:"warning",source:String(o),message:`Iteration limit reached (${r.current_iteration}/${r.max_iterations})${u}`}}case"iteration_limit_resolved":{const o=r.agent_name??r.group_name??"workflow",u=!!r.continue_execution,c=r.additional_iterations??0;return{timestamp:t,level:u?"info":"warning",source:String(o),message:u?`Iteration limit resolved — continuing with ${c} more`:"Iteration limit resolved — stopping workflow"}}case"dialog_started":return{timestamp:t,level:"warning",source:String(r.agent_name),message:"Dialog started — waiting for user…"};case"dialog_completed":return{timestamp:t,level:"success",source:String(r.agent_name),message:`Dialog completed (${r.turn_count||0} messages)`};default:return null}}function Qu(e){if(e<1)return`${(e*1e3).toFixed(0)}ms`;if(e<60)return`${e.toFixed(1)}s`;const t=Math.floor(e/60),r=(e%60).toFixed(0);return`${t}m ${r}s`}function Ru(e){const t=e.timestamp,r=e.data;switch(e.type){case"agent_started":return{timestamp:t,source:String(r.agent_name),type:"turn",message:`Agent started${r.iteration!=null?` (iteration ${r.iteration})`:""}`};case"agent_prompt_rendered":return{timestamp:t,source:String(r.agent_name),type:"prompt",message:"Prompt rendered",detail:yo(String(r.rendered_prompt||""),500)};case"agent_reasoning":return{timestamp:t,source:String(r.agent_name),type:"reasoning",message:String(r.content||"")};case"agent_tool_start":return{timestamp:t,source:String(r.agent_name),type:"tool-start",message:`→ ${r.tool_name}`,detail:r.arguments?yo(String(r.arguments),300):null};case"agent_tool_complete":return{timestamp:t,source:String(r.agent_name),type:"tool-complete",message:`← ${r.tool_name||"done"}`,detail:r.result?yo(String(r.result),300):null};case"agent_turn_start":return{timestamp:t,source:String(r.agent_name),type:"turn",message:`Turn ${r.turn??"?"}`};case"agent_message":return{timestamp:t,source:String(r.agent_name),type:"message",message:yo(String(r.content||""),500)};case"agent_completed":return{timestamp:t,source:String(r.agent_name),type:"turn",message:`Completed${r.elapsed!=null?` in ${Qu(r.elapsed)}`:""}${r.tokens!=null?` · ${r.tokens.toLocaleString()} tokens`:""}`};case"agent_failed":return{timestamp:t,source:String(r.agent_name),type:"turn",message:`Failed: ${r.message||r.error_type||"unknown"}`};case"script_started":return{timestamp:t,source:String(r.agent_name),type:"turn",message:"Script started"};case"script_completed":return{timestamp:t,source:String(r.agent_name),type:"tool-complete",message:`Script completed (exit ${r.exit_code??"?"})`,detail:r.stdout?yo(String(r.stdout),300):null};case"script_failed":return{timestamp:t,source:String(r.agent_name),type:"turn",message:`Script failed: ${r.message||r.error_type||"unknown"}`};default:return null}}function yo(e,t){return e.length<=t?e:e.slice(0,t)+"…"}function rv(e){const t=e.match(/^(\s*)/);return t?t[1].length:0}function RN(e){const t=new Map;for(let r=0;ra)o=u;else break}o>r&&t.set(r,o)}return t}function ON(e){if(/^\s*#/.test(e))return y.jsx("span",{className:"text-emerald-500/70",children:e});const t=e.match(/^(\s*)(- )?([a-zA-Z_][\w.-]*)(:\s*)(.*)/);if(t){const[,l,a,o,u,c]=t;return y.jsxs("span",{children:[l,a??"",y.jsx("span",{className:"text-sky-400",children:o}),y.jsx("span",{className:"text-[var(--text-muted)]",children:u}),iv(c??"")]})}const r=e.match(/^(\s*)(- )(.*)/);if(r){const[,l,a,o]=r;return y.jsxs("span",{children:[l,y.jsx("span",{className:"text-[var(--text-muted)]",children:a}),iv(o??"")]})}return y.jsx("span",{children:e})}function iv(e){if(!e)return"";const t=e.indexOf(" #"),r=t>=0?e.slice(0,t):e,l=t>=0?e.slice(t):"";let a=r;return/^(true|false|null|yes|no)$/i.test(r.trim())?a=y.jsx("span",{className:"text-amber-400",children:r}):/^\d+(\.\d+)?$/.test(r.trim())?a=y.jsx("span",{className:"text-amber-400",children:r}):/^["'].*["']$/.test(r.trim())?a=y.jsx("span",{className:"text-green-400",children:r}):(r.includes("|")||r.includes(">"))&&(a=y.jsx("span",{className:"text-[var(--text-secondary)]",children:r})),y.jsxs(y.Fragment,{children:[a,l&&y.jsx("span",{className:"text-emerald-500/70",children:l})]})}function LN({yaml:e,onClose:t}){const[r,l]=$.useState(new Set);$.useEffect(()=>{const d=h=>{h.key==="Escape"&&t()};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[t]);const a=$.useMemo(()=>e.split(` -`),[e]),o=$.useMemo(()=>RN(a),[a]),u=$.useCallback(d=>{l(h=>{const m=new Set(h);return m.has(d)?m.delete(d):m.add(d),m})},[]),c=$.useMemo(()=>{const d=[];let h=-1;for(let m=0;my.jsxs("div",{className:"flex",children:[y.jsx("span",{className:"inline-flex items-center justify-center flex-shrink-0",style:{width:"1.25rem"},children:m?y.jsx("button",{onClick:()=>u(d),className:"text-[var(--text-muted)] hover:text-[var(--text)] p-0 leading-none",style:{background:"none",border:"none",cursor:"pointer"},children:p?y.jsx(Rr,{className:"w-3 h-3"}):y.jsx(il,{className:"w-3 h-3"})}):null}),y.jsxs("span",{className:"flex-1",children:[ON(h),p&&y.jsx("span",{className:"text-[var(--text-muted)] text-[11px] ml-2 px-1.5 py-0.5 rounded bg-[var(--surface-hover)] cursor-pointer",onClick:()=>u(d),children:"···"})]})]},d))})})]})]})}function HN(){const e=ue(_=>_.workflowName),t=ue(_=>_.workflowStatus),r=ue(_=>_.isPaused),l=ue(_=>_.workflowYaml),a=ue(_=>_.conductorVersion),[o,u]=$.useState(!1),[c,d]=$.useState(!1),[h,m]=$.useState(!1),[p,x]=$.useState(!1),b=t==="running"||t==="pending";$.useEffect(()=>{r||(u(!1),d(!1),m(!1))},[r]);const w=async()=>{u(!0);try{await fetch("/api/stop",{method:"POST"})}catch(_){console.error("Failed to stop agent:",_),u(!1)}},E=async()=>{d(!0);try{await fetch("/api/resume",{method:"POST"})}catch(_){console.error("Failed to resume agent:",_),d(!1)}},S=async()=>{m(!0);try{await fetch("/api/kill",{method:"POST"})}catch(_){console.error("Failed to kill workflow:",_),m(!1)}};return y.jsxs("header",{className:"flex items-center justify-between px-4 py-2 bg-[var(--surface)] border-b border-[var(--border)] flex-shrink-0",children:[y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx(gw,{className:"w-4 h-4 text-[var(--running)]"}),y.jsx("h1",{className:"text-sm font-semibold text-[var(--text)]",children:"Conductor"}),e&&y.jsxs("span",{className:"text-sm text-[var(--text-muted)] font-normal",children:["— ",e]})]}),y.jsxs("div",{className:"flex items-center gap-3",children:[r?y.jsxs(y.Fragment,{children:[y.jsxs("button",{onClick:E,disabled:c,className:`flex items-center gap-1.5 px-2.5 py-1 text-xs font-medium rounded - bg-emerald-500/10 text-emerald-400 border border-emerald-500/20 - hover:bg-emerald-500/20 hover:border-emerald-500/30 - disabled:opacity-50 disabled:cursor-not-allowed - transition-colors`,title:"Re-execute the paused agent",children:[y.jsx(kc,{className:"w-3 h-3"}),c?"Resuming...":"Resume"]}),y.jsxs("button",{onClick:S,disabled:h,className:`flex items-center gap-1.5 px-2.5 py-1 text-xs font-medium rounded - bg-red-500/10 text-red-400 border border-red-500/20 - hover:bg-red-500/20 hover:border-red-500/30 - disabled:opacity-50 disabled:cursor-not-allowed - transition-colors`,title:"Stop workflow entirely (checkpoint saved for CLI resume)",children:[y.jsx(ll,{className:"w-3 h-3"}),h?"Killing...":"Kill"]})]}):b?y.jsxs("button",{onClick:w,disabled:o,className:`flex items-center gap-1.5 px-2.5 py-1 text-xs font-medium rounded - bg-red-500/10 text-red-400 border border-red-500/20 - hover:bg-red-500/20 hover:border-red-500/30 - disabled:opacity-50 disabled:cursor-not-allowed - transition-colors`,children:[y.jsx(_w,{className:"w-3 h-3"}),o?"Stopping...":"Stop"]}):null,l&&y.jsxs("button",{onClick:()=>x(!0),className:`flex items-center gap-1.5 px-2.5 py-1 text-xs font-medium rounded - bg-[var(--surface-hover)] text-[var(--text-secondary)] border border-[var(--border)] - hover:text-[var(--text)] hover:bg-[var(--surface)] - transition-colors`,title:"View workflow YAML configuration",children:[y.jsx(gN,{className:"w-3 h-3"}),"YAML"]}),y.jsxs("a",{href:"/api/logs",download:"conductor-logs.json",className:`flex items-center gap-1.5 px-2.5 py-1 text-xs font-medium rounded - bg-[var(--surface-hover)] text-[var(--text-secondary)] border border-[var(--border)] - hover:text-[var(--text)] hover:bg-[var(--surface)] - transition-colors`,title:"Download full event log as JSON",children:[y.jsx(pN,{className:"w-3 h-3"}),"Logs"]}),y.jsxs("span",{className:"text-xs text-[var(--text-muted)]",children:["v",a??"—"]})]}),p&&l&&y.jsx(LN,{yaml:l,onClose:()=>x(!1)})]})}function BN(){const e=ue(o=>o.getBreadcrumbs),t=ue(o=>o.navigateToContext),r=ue(o=>o.viewContextPath);if(ue(o=>o.subworkflowContexts).length===0&&r.length===0)return null;const a=e();return y.jsxs("div",{className:"flex items-center gap-1 px-4 py-1.5 bg-[var(--surface)] border-b border-[var(--border)] text-xs flex-shrink-0",children:[y.jsx(Sc,{className:"w-3 h-3 text-[var(--text-muted)] mr-1"}),a.map((o,u)=>{const c=u===a.length-1,d=JSON.stringify(o.path)===JSON.stringify(r);return y.jsxs("span",{className:"flex items-center gap-1",children:[u>0&&y.jsx(Rr,{className:"w-3 h-3 text-[var(--text-muted)]"}),c?y.jsx("span",{className:"font-semibold text-[var(--text)]",children:o.label}):y.jsx("button",{onClick:()=>t(o.path),className:`hover:text-[var(--running)] transition-colors ${d?"text-[var(--text)] font-medium":"text-[var(--text-muted)]"}`,children:o.label})]},u)})]})}function He(...e){return e.filter(Boolean).join(" ")}function Jt(e){if(e==null)return"";if(e<60)return`${e.toFixed(1)}s`;const t=Math.floor(e/60),r=(e%60).toFixed(0);return`${t}m ${r}s`}function Pn(e){return e==null?"":e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:`${e}`}function yi(e){return e==null?"":`$${e.toFixed(4)}`}function Sw(e){return e==null?"":typeof e=="string"?e:JSON.stringify(e,null,2)}function IN(e,t){if(t<=0)return`${e.toLocaleString()} tokens (limit unknown)`;const r=a=>a.toLocaleString(),l=(e/t*100).toFixed(1);return`${r(e)} / ${r(t)} (${l}%)`}function kw(){const e=ue(c=>c.workflowStatus),t=ue(c=>c.workflowStartTime),r=ue(c=>c.replayMode),l=ue(c=>c.lastEventTime),[a,o]=$.useState("—"),u=$.useRef(null);return $.useEffect(()=>{if(t!=null){if(r){u.current&&(clearInterval(u.current),u.current=null),o(Jt((l??t)-t));return}if(e==="running"){const c=()=>{const d=Date.now()/1e3-t;o(Jt(d))};return c(),u.current=setInterval(c,500),()=>{u.current&&clearInterval(u.current)}}else(e==="completed"||e==="failed")&&u.current&&(clearInterval(u.current),u.current=null)}},[e,t,r,l]),a}function qN(){const e=ue(_=>_.workflowStatus),t=ue(_=>_.agentsCompleted),r=ue(_=>_.agentsTotal),l=ue(_=>_.totalCost),a=ue(_=>_.totalTokens),o=ue(_=>_.wsStatus),u=ue(_=>_.workflowFailure),c=ue(_=>_.lastEventTime),d=ue(_=>_.iterationLimitGate),h=kw(),[m,p]=$.useState(null);$.useEffect(()=>{if(e!=="running"||c==null){p(null);return}const _=()=>{p(Math.floor(Date.now()/1e3-c))};_();const N=setInterval(_,1e3);return()=>clearInterval(N)},[e,c]);const x=e==="failed",b=(()=>{if(d&&e==="running"){const _=d.agent_name??d.group_name??"workflow",N=d.skip_gates?" — auto-stopping":" — awaiting decision";return`Iteration limit reached: ${_} ${d.current_iteration}/${d.max_iterations}${N}`}switch(e){case"pending":return"Waiting for workflow…";case"running":return"Running";case"completed":return"Completed";case"failed":{if(!u)return"Failed";const _=u.error_type||"";return _==="MaxIterationsError"?"Failed: exceeded maximum iterations":_==="TimeoutError"?"Failed: workflow timed out":u.message?`Failed: ${u.message.length>60?u.message.slice(0,57)+"...":u.message}`:`Failed: ${_}`}}})(),w=d!=null&&e==="running",E=w?"bg-[var(--waiting)] animate-pulse":{pending:"bg-[var(--pending)]",running:"bg-[var(--running)] animate-pulse",completed:"bg-[var(--completed)]",failed:"bg-[var(--failed)]"}[e],S=(()=>{switch(o){case"connected":return y.jsxs("span",{className:"flex items-center gap-1 text-[var(--completed)]",children:[y.jsx(NN,{className:"w-3 h-3"}),y.jsx("span",{children:"Connected"})]});case"disconnected":return y.jsxs("span",{className:"flex items-center gap-1 text-[var(--failed)]",children:[y.jsx(EN,{className:"w-3 h-3"}),y.jsx("span",{children:"Disconnected"})]});case"reconnecting":return y.jsxs("span",{className:"flex items-center gap-1 text-[var(--waiting)]",children:[y.jsx(ca,{className:"w-3 h-3 animate-spin"}),y.jsx("span",{children:"Reconnecting\\u2026"})]});case"connecting":return y.jsxs("span",{className:"flex items-center gap-1 text-[var(--text-muted)]",children:[y.jsx(ca,{className:"w-3 h-3 animate-spin"}),y.jsx("span",{children:"Connecting\\u2026"})]})}})();return y.jsxs("footer",{className:He("flex items-center gap-4 px-4 py-1.5 border-t text-xs flex-shrink-0 transition-colors duration-300",x?"bg-red-950/50 border-red-500/30":w?"bg-amber-950/30 border-amber-500/30":"bg-[var(--surface)] border-[var(--border)]"),children:[y.jsx("span",{className:He("w-2 h-2 rounded-full flex-shrink-0",E)}),y.jsx("span",{className:He(x?"text-red-300":w?"text-amber-200":"text-[var(--text)]"),children:b}),r>0&&y.jsxs("span",{className:He(x?"text-red-400/60":"text-[var(--text-muted)]"),children:[t,"/",r," agents"]}),e!=="pending"&&y.jsx("span",{className:He("font-mono",x?"text-red-400/60":"text-[var(--text-muted)]"),children:h}),a>0&&y.jsxs("span",{className:He("flex items-center gap-1",x?"text-red-400/60":"text-[var(--text-muted)]"),title:"Total tokens used",children:[y.jsx(bw,{className:"w-3 h-3"}),y.jsx("span",{className:"font-mono",children:a.toLocaleString()})]}),l>0&&y.jsxs("span",{className:He("flex items-center gap-1",x?"text-red-400/60":"text-[var(--text-muted)]"),title:"Total cost",children:[y.jsx(xw,{className:"w-3 h-3"}),y.jsxs("span",{className:"font-mono",children:["$",l.toFixed(4)]})]}),m!=null&&m>=5&&y.jsxs("span",{className:He("flex items-center gap-1 font-mono",m>=60?"text-amber-400":"text-[var(--text-muted)]"),title:"Time since last event from the provider",children:[y.jsx(hN,{className:"w-3 h-3"}),y.jsx("span",{children:m>=60?`${Math.floor(m/60)}m ${m%60}s idle`:`${m}s idle`})]}),y.jsx("span",{className:"flex-1"}),S]})}const UN=[1,5,10,20,50];function $N(e,t){if(t===0||e.length===0)return"+0.0s";const r=e[0].timestamp,a=e[Math.min(t,e.length)-1].timestamp-r;if(a<60)return`+${a.toFixed(1)}s`;const o=Math.floor(a/60),u=a%60;return`+${o}m${u.toFixed(0)}s`}function VN(){const e=ue(p=>p.replayPosition),t=ue(p=>p.replayTotalEvents),r=ue(p=>p.replayPlaying),l=ue(p=>p.replaySpeed),a=ue(p=>p.replayEvents),o=ue(p=>p.setReplayPosition),u=ue(p=>p.setReplayPlaying),c=ue(p=>p.setReplaySpeed),d=p=>{const x=parseInt(p.target.value,10);o(x),r&&u(!1)},h=()=>{!r&&e>=t&&o(0),u(!r)},m=t>0?e/t*100:0;return y.jsxs("footer",{className:"flex items-center gap-3 px-4 py-1.5 border-t bg-[var(--surface)] border-[var(--border)] text-xs flex-shrink-0",children:[y.jsx("button",{onClick:h,className:"flex items-center justify-center w-6 h-6 rounded hover:bg-[var(--surface-hover)] text-[var(--text-secondary)] hover:text-[var(--text)] transition-colors",title:r?"Pause":"Play",children:r?y.jsx(bN,{className:"w-3.5 h-3.5"}):y.jsx(kc,{className:"w-3.5 h-3.5"})}),y.jsxs("div",{className:"flex-1 relative flex items-center",children:[y.jsx("input",{type:"range",min:0,max:t,value:e,onChange:d,className:"w-full h-1 appearance-none rounded-full cursor-pointer",style:{background:`linear-gradient(to right, var(--accent) 0%, var(--accent) ${m}%, var(--border) ${m}%, var(--border) 100%)`,WebkitAppearance:"none"}}),y.jsx("style",{children:` - footer input[type="range"]::-webkit-slider-thumb { - -webkit-appearance: none; - width: 12px; - height: 12px; - border-radius: 50%; - background: var(--accent); - border: 2px solid var(--surface); - cursor: pointer; - box-shadow: 0 0 4px rgba(99, 102, 241, 0.4); - } - footer input[type="range"]::-moz-range-thumb { - width: 12px; - height: 12px; - border-radius: 50%; - background: var(--accent); - border: 2px solid var(--surface); - cursor: pointer; - box-shadow: 0 0 4px rgba(99, 102, 241, 0.4); - } - `})]}),y.jsx("span",{className:"text-[var(--text-muted)] font-mono whitespace-nowrap",children:$N(a,e)}),y.jsxs("span",{className:"text-[var(--text-muted)] font-mono whitespace-nowrap",children:["Event ",e,"/",t]}),y.jsx("div",{className:"flex items-center gap-0.5",children:UN.map(p=>y.jsxs("button",{onClick:()=>c(p),className:He("px-1.5 py-0.5 rounded text-xs font-mono transition-colors",l===p?"bg-[var(--accent)] text-white":"text-[var(--text-muted)] hover:text-[var(--text-secondary)] hover:bg-[var(--surface-hover)]"),children:[p,"×"]},p))})]})}const Ec=$.createContext(null);Ec.displayName="PanelGroupContext";const yt={group:"data-panel-group",groupDirection:"data-panel-group-direction",groupId:"data-panel-group-id",panel:"data-panel",panelCollapsible:"data-panel-collapsible",panelId:"data-panel-id",panelSize:"data-panel-size",resizeHandle:"data-resize-handle",resizeHandleActive:"data-resize-handle-active",resizeHandleEnabled:"data-panel-resize-handle-enabled",resizeHandleId:"data-panel-resize-handle-id",resizeHandleState:"data-resize-handle-state"},vm=10,Xi=$.useLayoutEffect,lv=KE.useId,PN=typeof lv=="function"?lv:()=>null;let GN=0;function bm(e=null){const t=PN(),r=$.useRef(e||t||null);return r.current===null&&(r.current=""+GN++),e??r.current}function Ew({children:e,className:t="",collapsedSize:r,collapsible:l,defaultSize:a,forwardedRef:o,id:u,maxSize:c,minSize:d,onCollapse:h,onExpand:m,onResize:p,order:x,style:b,tagName:w="div",...E}){const S=$.useContext(Ec);if(S===null)throw Error("Panel components must be rendered within a PanelGroup container");const{collapsePanel:_,expandPanel:N,getPanelSize:k,getPanelStyle:A,groupId:M,isPanelCollapsed:T,reevaluatePanelConstraints:L,registerPanel:R,resizePanel:V,unregisterPanel:H}=S,B=bm(u),U=$.useRef({callbacks:{onCollapse:h,onExpand:m,onResize:p},constraints:{collapsedSize:r,collapsible:l,defaultSize:a,maxSize:c,minSize:d},id:B,idIsFromProps:u!==void 0,order:x});$.useRef({didLogMissingDefaultSizeWarning:!1}),Xi(()=>{const{callbacks:I,constraints:F}=U.current,z={...F};U.current.id=B,U.current.idIsFromProps=u!==void 0,U.current.order=x,I.onCollapse=h,I.onExpand=m,I.onResize=p,F.collapsedSize=r,F.collapsible=l,F.defaultSize=a,F.maxSize=c,F.minSize=d,(z.collapsedSize!==F.collapsedSize||z.collapsible!==F.collapsible||z.maxSize!==F.maxSize||z.minSize!==F.minSize)&&L(U.current,z)}),Xi(()=>{const I=U.current;return R(I),()=>{H(I)}},[x,B,R,H]),$.useImperativeHandle(o,()=>({collapse:()=>{_(U.current)},expand:I=>{N(U.current,I)},getId(){return B},getSize(){return k(U.current)},isCollapsed(){return T(U.current)},isExpanded(){return!T(U.current)},resize:I=>{V(U.current,I)}}),[_,N,k,T,B,V]);const ee=A(U.current,a);return $.createElement(w,{...E,children:e,className:t,id:B,style:{...ee,...b},[yt.groupId]:M,[yt.panel]:"",[yt.panelCollapsible]:l||void 0,[yt.panelId]:B,[yt.panelSize]:parseFloat(""+ee.flexGrow).toFixed(1)})}const Eo=$.forwardRef((e,t)=>$.createElement(Ew,{...e,forwardedRef:t}));Ew.displayName="Panel";Eo.displayName="forwardRef(Panel)";let Vp=null,Zu=-1,gi=null;function FN(e,t){if(t){const r=(t&Aw)!==0,l=(t&zw)!==0,a=(t&Mw)!==0,o=(t&Dw)!==0;if(r)return a?"se-resize":o?"ne-resize":"e-resize";if(l)return a?"sw-resize":o?"nw-resize":"w-resize";if(a)return"s-resize";if(o)return"n-resize"}switch(e){case"horizontal":return"ew-resize";case"intersection":return"move";case"vertical":return"ns-resize"}}function YN(){gi!==null&&(document.head.removeChild(gi),Vp=null,gi=null,Zu=-1)}function hh(e,t){var r,l;const a=FN(e,t);if(Vp!==a){if(Vp=a,gi===null&&(gi=document.createElement("style"),document.head.appendChild(gi)),Zu>=0){var o;(o=gi.sheet)===null||o===void 0||o.removeRule(Zu)}Zu=(r=(l=gi.sheet)===null||l===void 0?void 0:l.insertRule(`*{cursor: ${a} !important;}`))!==null&&r!==void 0?r:-1}}function Nw(e){return e.type==="keydown"}function Cw(e){return e.type.startsWith("pointer")}function jw(e){return e.type.startsWith("mouse")}function Nc(e){if(Cw(e)){if(e.isPrimary)return{x:e.clientX,y:e.clientY}}else if(jw(e))return{x:e.clientX,y:e.clientY};return{x:1/0,y:1/0}}function XN(){if(typeof matchMedia=="function")return matchMedia("(pointer:coarse)").matches?"coarse":"fine"}function QN(e,t,r){return e.xt.x&&e.yt.y}function ZN(e,t){if(e===t)throw new Error("Cannot compare node with itself");const r={a:sv(e),b:sv(t)};let l;for(;r.a.at(-1)===r.b.at(-1);)e=r.a.pop(),t=r.b.pop(),l=e;Oe(l,"Stacking order can only be calculated for elements with a common ancestor");const a={a:ov(av(r.a)),b:ov(av(r.b))};if(a.a===a.b){const o=l.childNodes,u={a:r.a.at(-1),b:r.b.at(-1)};let c=o.length;for(;c--;){const d=o[c];if(d===u.a)return 1;if(d===u.b)return-1}}return Math.sign(a.a-a.b)}const KN=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function JN(e){var t;const r=getComputedStyle((t=Tw(e))!==null&&t!==void 0?t:e).display;return r==="flex"||r==="inline-flex"}function WN(e){const t=getComputedStyle(e);return!!(t.position==="fixed"||t.zIndex!=="auto"&&(t.position!=="static"||JN(e))||+t.opacity<1||"transform"in t&&t.transform!=="none"||"webkitTransform"in t&&t.webkitTransform!=="none"||"mixBlendMode"in t&&t.mixBlendMode!=="normal"||"filter"in t&&t.filter!=="none"||"webkitFilter"in t&&t.webkitFilter!=="none"||"isolation"in t&&t.isolation==="isolate"||KN.test(t.willChange)||t.webkitOverflowScrolling==="touch")}function av(e){let t=e.length;for(;t--;){const r=e[t];if(Oe(r,"Missing node"),WN(r))return r}return null}function ov(e){return e&&Number(getComputedStyle(e).zIndex)||0}function sv(e){const t=[];for(;e;)t.push(e),e=Tw(e);return t}function Tw(e){const{parentNode:t}=e;return t&&t instanceof ShadowRoot?t.host:t}const Aw=1,zw=2,Mw=4,Dw=8,eC=XN()==="coarse";let Gn=[],aa=!1,Gi=new Map,Cc=new Map;const Lo=new Set;function tC(e,t,r,l,a){var o;const{ownerDocument:u}=t,c={direction:r,element:t,hitAreaMargins:l,setResizeHandlerState:a},d=(o=Gi.get(u))!==null&&o!==void 0?o:0;return Gi.set(u,d+1),Lo.add(c),lc(),function(){var m;Cc.delete(e),Lo.delete(c);const p=(m=Gi.get(u))!==null&&m!==void 0?m:1;if(Gi.set(u,p-1),lc(),p===1&&Gi.delete(u),Gn.includes(c)){const x=Gn.indexOf(c);x>=0&&Gn.splice(x,1),_m(),a("up",!0,null)}}}function nC(e){const{target:t}=e,{x:r,y:l}=Nc(e);aa=!0,wm({target:t,x:r,y:l}),lc(),Gn.length>0&&(ac("down",e),e.preventDefault(),Rw(t)||e.stopImmediatePropagation())}function ph(e){const{x:t,y:r}=Nc(e);if(aa&&e.buttons===0&&(aa=!1,ac("up",e)),!aa){const{target:l}=e;wm({target:l,x:t,y:r})}ac("move",e),_m(),Gn.length>0&&e.preventDefault()}function mh(e){const{target:t}=e,{x:r,y:l}=Nc(e);Cc.clear(),aa=!1,Gn.length>0&&(e.preventDefault(),Rw(t)||e.stopImmediatePropagation()),ac("up",e),wm({target:t,x:r,y:l}),_m(),lc()}function Rw(e){let t=e;for(;t;){if(t.hasAttribute(yt.resizeHandle))return!0;t=t.parentElement}return!1}function wm({target:e,x:t,y:r}){Gn.splice(0);let l=null;(e instanceof HTMLElement||e instanceof SVGElement)&&(l=e),Lo.forEach(a=>{const{element:o,hitAreaMargins:u}=a,c=o.getBoundingClientRect(),{bottom:d,left:h,right:m,top:p}=c,x=eC?u.coarse:u.fine;if(t>=h-x&&t<=m+x&&r>=p-x&&r<=d+x){if(l!==null&&document.contains(l)&&o!==l&&!o.contains(l)&&!l.contains(o)&&ZN(l,o)>0){let w=l,E=!1;for(;w&&!w.contains(o);){if(QN(w.getBoundingClientRect(),c)){E=!0;break}w=w.parentElement}if(E)return}Gn.push(a)}})}function gh(e,t){Cc.set(e,t)}function _m(){let e=!1,t=!1;Gn.forEach(l=>{const{direction:a}=l;a==="horizontal"?e=!0:t=!0});let r=0;Cc.forEach(l=>{r|=l}),e&&t?hh("intersection",r):e?hh("horizontal",r):t?hh("vertical",r):YN()}let xh=new AbortController;function lc(){xh.abort(),xh=new AbortController;const e={capture:!0,signal:xh.signal};Lo.size&&(aa?(Gn.length>0&&Gi.forEach((t,r)=>{const{body:l}=r;t>0&&(l.addEventListener("contextmenu",mh,e),l.addEventListener("pointerleave",ph,e),l.addEventListener("pointermove",ph,e))}),window.addEventListener("pointerup",mh,e),window.addEventListener("pointercancel",mh,e)):Gi.forEach((t,r)=>{const{body:l}=r;t>0&&(l.addEventListener("pointerdown",nC,e),l.addEventListener("pointermove",ph,e))}))}function ac(e,t){Lo.forEach(r=>{const{setResizeHandlerState:l}=r,a=Gn.includes(r);l(e,a,t)})}function rC(){const[e,t]=$.useState(0);return $.useCallback(()=>t(r=>r+1),[])}function Oe(e,t){if(!e)throw console.error(t),Error(t)}function Ki(e,t,r=vm){return e.toFixed(r)===t.toFixed(r)?0:e>t?1:-1}function Ar(e,t,r=vm){return Ki(e,t,r)===0}function bn(e,t,r){return Ki(e,t,r)===0}function iC(e,t,r){if(e.length!==t.length)return!1;for(let l=0;l0&&(e=e<0?0-_:_)}}}{const p=e<0?c:d,x=r[p];Oe(x,`No panel constraints found for index ${p}`);const{collapsedSize:b=0,collapsible:w,minSize:E=0}=x;if(w){const S=t[p];if(Oe(S!=null,`Previous layout not found for panel index ${p}`),bn(S,E)){const _=S-b;Ki(_,Math.abs(e))>0&&(e=e<0?0-_:_)}}}}{const p=e<0?1:-1;let x=e<0?d:c,b=0;for(;;){const E=t[x];Oe(E!=null,`Previous layout not found for panel index ${x}`);const _=na({panelConstraints:r,panelIndex:x,size:100})-E;if(b+=_,x+=p,x<0||x>=r.length)break}const w=Math.min(Math.abs(e),Math.abs(b));e=e<0?0-w:w}{let x=e<0?c:d;for(;x>=0&&x=0))break;e<0?x--:x++}}if(iC(a,u))return a;{const p=e<0?d:c,x=t[p];Oe(x!=null,`Previous layout not found for panel index ${p}`);const b=x+h,w=na({panelConstraints:r,panelIndex:p,size:b});if(u[p]=w,!bn(w,b)){let E=b-w,_=e<0?d:c;for(;_>=0&&_0?_--:_++}}}const m=u.reduce((p,x)=>x+p,0);return bn(m,100)?u:a}function lC({layout:e,panelsArray:t,pivotIndices:r}){let l=0,a=100,o=0,u=0;const c=r[0];Oe(c!=null,"No pivot index found"),t.forEach((p,x)=>{const{constraints:b}=p,{maxSize:w=100,minSize:E=0}=b;x===c?(l=E,a=w):(o+=E,u+=w)});const d=Math.min(a,100-o),h=Math.max(l,100-u),m=e[c];return{valueMax:d,valueMin:h,valueNow:m}}function Ho(e,t=document){return Array.from(t.querySelectorAll(`[${yt.resizeHandleId}][data-panel-group-id="${e}"]`))}function Ow(e,t,r=document){const a=Ho(e,r).findIndex(o=>o.getAttribute(yt.resizeHandleId)===t);return a??null}function Lw(e,t,r){const l=Ow(e,t,r);return l!=null?[l,l+1]:[-1,-1]}function Hw(e,t=document){var r;if(t instanceof HTMLElement&&(t==null||(r=t.dataset)===null||r===void 0?void 0:r.panelGroupId)==e)return t;const l=t.querySelector(`[data-panel-group][data-panel-group-id="${e}"]`);return l||null}function jc(e,t=document){const r=t.querySelector(`[${yt.resizeHandleId}="${e}"]`);return r||null}function aC(e,t,r,l=document){var a,o,u,c;const d=jc(t,l),h=Ho(e,l),m=d?h.indexOf(d):-1,p=(a=(o=r[m])===null||o===void 0?void 0:o.id)!==null&&a!==void 0?a:null,x=(u=(c=r[m+1])===null||c===void 0?void 0:c.id)!==null&&u!==void 0?u:null;return[p,x]}function oC({committedValuesRef:e,eagerValuesRef:t,groupId:r,layout:l,panelDataArray:a,panelGroupElement:o,setLayout:u}){$.useRef({didWarnAboutMissingResizeHandle:!1}),Xi(()=>{if(!o)return;const c=Ho(r,o);for(let d=0;d{c.forEach((d,h)=>{d.removeAttribute("aria-controls"),d.removeAttribute("aria-valuemax"),d.removeAttribute("aria-valuemin"),d.removeAttribute("aria-valuenow")})}},[r,l,a,o]),$.useEffect(()=>{if(!o)return;const c=t.current;Oe(c,"Eager values not found");const{panelDataArray:d}=c,h=Hw(r,o);Oe(h!=null,`No group found for id "${r}"`);const m=Ho(r,o);Oe(m,`No resize handles found for group id "${r}"`);const p=m.map(x=>{const b=x.getAttribute(yt.resizeHandleId);Oe(b,"Resize handle element has no handle id attribute");const[w,E]=aC(r,b,d,o);if(w==null||E==null)return()=>{};const S=_=>{if(!_.defaultPrevented)switch(_.key){case"Enter":{_.preventDefault();const N=d.findIndex(k=>k.id===w);if(N>=0){const k=d[N];Oe(k,`No panel data found for index ${N}`);const A=l[N],{collapsedSize:M=0,collapsible:T,minSize:L=0}=k.constraints;if(A!=null&&T){const R=No({delta:bn(A,M)?L-M:M-A,initialLayout:l,panelConstraints:d.map(V=>V.constraints),pivotIndices:Lw(r,b,o),prevLayout:l,trigger:"keyboard"});l!==R&&u(R)}}break}}};return x.addEventListener("keydown",S),()=>{x.removeEventListener("keydown",S)}});return()=>{p.forEach(x=>x())}},[o,e,t,r,l,a,u])}function uv(e,t){if(e.length!==t.length)return!1;for(let r=0;ro.constraints);let l=0,a=100;for(let o=0;o{const o=e[a];Oe(o,`Panel data not found for index ${a}`);const{callbacks:u,constraints:c,id:d}=o,{collapsedSize:h=0,collapsible:m}=c,p=r[d];if(p==null||l!==p){r[d]=l;const{onCollapse:x,onExpand:b,onResize:w}=u;w&&w(l,p),m&&(x||b)&&(b&&(p==null||Ar(p,h))&&!Ar(l,h)&&b(),x&&(p==null||!Ar(p,h))&&Ar(l,h)&&x())}})}function Ou(e,t){if(e.length!==t.length)return!1;for(let r=0;r{r!==null&&clearTimeout(r),r=setTimeout(()=>{e(...a)},t)}}function cv(e){try{if(typeof localStorage<"u")e.getItem=t=>localStorage.getItem(t),e.setItem=(t,r)=>{localStorage.setItem(t,r)};else throw new Error("localStorage not supported in this environment")}catch(t){console.error(t),e.getItem=()=>null,e.setItem=()=>{}}}function Iw(e){return`react-resizable-panels:${e}`}function qw(e){return e.map(t=>{const{constraints:r,id:l,idIsFromProps:a,order:o}=t;return a?l:o?`${o}:${JSON.stringify(r)}`:JSON.stringify(r)}).sort((t,r)=>t.localeCompare(r)).join(",")}function Uw(e,t){try{const r=Iw(e),l=t.getItem(r);if(l){const a=JSON.parse(l);if(typeof a=="object"&&a!=null)return a}}catch{}return null}function hC(e,t,r){var l,a;const o=(l=Uw(e,r))!==null&&l!==void 0?l:{},u=qw(t);return(a=o[u])!==null&&a!==void 0?a:null}function pC(e,t,r,l,a){var o;const u=Iw(e),c=qw(t),d=(o=Uw(e,a))!==null&&o!==void 0?o:{};d[c]={expandToSizes:Object.fromEntries(r.entries()),layout:l};try{a.setItem(u,JSON.stringify(d))}catch(h){console.error(h)}}function fv({layout:e,panelConstraints:t}){const r=[...e],l=r.reduce((o,u)=>o+u,0);if(r.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${r.map(o=>`${o}%`).join(", ")}`);if(!bn(l,100)&&r.length>0)for(let o=0;o(cv(Co),Co.getItem(e)),setItem:(e,t)=>{cv(Co),Co.setItem(e,t)}},dv={};function $w({autoSaveId:e=null,children:t,className:r="",direction:l,forwardedRef:a,id:o=null,onLayout:u=null,keyboardResizeBy:c=null,storage:d=Co,style:h,tagName:m="div",...p}){const x=bm(o),b=$.useRef(null),[w,E]=$.useState(null),[S,_]=$.useState([]),N=rC(),k=$.useRef({}),A=$.useRef(new Map),M=$.useRef(0),T=$.useRef({autoSaveId:e,direction:l,dragState:w,id:x,keyboardResizeBy:c,onLayout:u,storage:d}),L=$.useRef({layout:S,panelDataArray:[],panelDataArrayChanged:!1});$.useRef({didLogIdAndOrderWarning:!1,didLogPanelConstraintsWarning:!1,prevPanelIds:[]}),$.useImperativeHandle(a,()=>({getId:()=>T.current.id,getLayout:()=>{const{layout:C}=L.current;return C},setLayout:C=>{const{onLayout:P}=T.current,{layout:X,panelDataArray:J}=L.current,ne=fv({layout:C,panelConstraints:J.map(re=>re.constraints)});uv(X,ne)||(_(ne),L.current.layout=ne,P&&P(ne),Ql(J,ne,k.current))}}),[]),Xi(()=>{T.current.autoSaveId=e,T.current.direction=l,T.current.dragState=w,T.current.id=x,T.current.onLayout=u,T.current.storage=d}),oC({committedValuesRef:T,eagerValuesRef:L,groupId:x,layout:S,panelDataArray:L.current.panelDataArray,setLayout:_,panelGroupElement:b.current}),$.useEffect(()=>{const{panelDataArray:C}=L.current;if(e){if(S.length===0||S.length!==C.length)return;let P=dv[e];P==null&&(P=dC(pC,mC),dv[e]=P);const X=[...C],J=new Map(A.current);P(e,X,J,S,d)}},[e,S,d]),$.useEffect(()=>{});const R=$.useCallback(C=>{const{onLayout:P}=T.current,{layout:X,panelDataArray:J}=L.current;if(C.constraints.collapsible){const ne=J.map(be=>be.constraints),{collapsedSize:re=0,panelSize:se,pivotIndices:xe}=Ui(J,C,X);if(Oe(se!=null,`Panel size not found for panel "${C.id}"`),!Ar(se,re)){A.current.set(C.id,se);const ye=Wl(J,C)===J.length-1?se-re:re-se,pe=No({delta:ye,initialLayout:X,panelConstraints:ne,pivotIndices:xe,prevLayout:X,trigger:"imperative-api"});Ou(X,pe)||(_(pe),L.current.layout=pe,P&&P(pe),Ql(J,pe,k.current))}}},[]),V=$.useCallback((C,P)=>{const{onLayout:X}=T.current,{layout:J,panelDataArray:ne}=L.current;if(C.constraints.collapsible){const re=ne.map(Se=>Se.constraints),{collapsedSize:se=0,panelSize:xe=0,minSize:be=0,pivotIndices:ye}=Ui(ne,C,J),pe=P??be;if(Ar(xe,se)){const Se=A.current.get(C.id),ze=Se!=null&&Se>=pe?Se:pe,ut=Wl(ne,C)===ne.length-1?xe-ze:ze-xe,nt=No({delta:ut,initialLayout:J,panelConstraints:re,pivotIndices:ye,prevLayout:J,trigger:"imperative-api"});Ou(J,nt)||(_(nt),L.current.layout=nt,X&&X(nt),Ql(ne,nt,k.current))}}},[]),H=$.useCallback(C=>{const{layout:P,panelDataArray:X}=L.current,{panelSize:J}=Ui(X,C,P);return Oe(J!=null,`Panel size not found for panel "${C.id}"`),J},[]),B=$.useCallback((C,P)=>{const{panelDataArray:X}=L.current,J=Wl(X,C);return fC({defaultSize:P,dragState:w,layout:S,panelData:X,panelIndex:J})},[w,S]),U=$.useCallback(C=>{const{layout:P,panelDataArray:X}=L.current,{collapsedSize:J=0,collapsible:ne,panelSize:re}=Ui(X,C,P);return Oe(re!=null,`Panel size not found for panel "${C.id}"`),ne===!0&&Ar(re,J)},[]),ee=$.useCallback(C=>{const{layout:P,panelDataArray:X}=L.current,{collapsedSize:J=0,collapsible:ne,panelSize:re}=Ui(X,C,P);return Oe(re!=null,`Panel size not found for panel "${C.id}"`),!ne||Ki(re,J)>0},[]),I=$.useCallback(C=>{const{panelDataArray:P}=L.current;P.push(C),P.sort((X,J)=>{const ne=X.order,re=J.order;return ne==null&&re==null?0:ne==null?-1:re==null?1:ne-re}),L.current.panelDataArrayChanged=!0,N()},[N]);Xi(()=>{if(L.current.panelDataArrayChanged){L.current.panelDataArrayChanged=!1;const{autoSaveId:C,onLayout:P,storage:X}=T.current,{layout:J,panelDataArray:ne}=L.current;let re=null;if(C){const xe=hC(C,ne,X);xe&&(A.current=new Map(Object.entries(xe.expandToSizes)),re=xe.layout)}re==null&&(re=cC({panelDataArray:ne}));const se=fv({layout:re,panelConstraints:ne.map(xe=>xe.constraints)});uv(J,se)||(_(se),L.current.layout=se,P&&P(se),Ql(ne,se,k.current))}}),Xi(()=>{const C=L.current;return()=>{C.layout=[]}},[]);const F=$.useCallback(C=>{let P=!1;const X=b.current;return X&&window.getComputedStyle(X,null).getPropertyValue("direction")==="rtl"&&(P=!0),function(ne){ne.preventDefault();const re=b.current;if(!re)return()=>null;const{direction:se,dragState:xe,id:be,keyboardResizeBy:ye,onLayout:pe}=T.current,{layout:Se,panelDataArray:ze}=L.current,{initialLayout:je}=xe??{},ut=Lw(be,C,re);let nt=uC(ne,C,se,xe,ye,re);const zt=se==="horizontal";zt&&P&&(nt=-nt);const Vt=ze.map(Rn=>Rn.constraints),Ht=No({delta:nt,initialLayout:je??Se,panelConstraints:Vt,pivotIndices:ut,prevLayout:Se,trigger:Nw(ne)?"keyboard":"mouse-or-touch"}),kn=!Ou(Se,Ht);(Cw(ne)||jw(ne))&&M.current!=nt&&(M.current=nt,!kn&&nt!==0?zt?gh(C,nt<0?Aw:zw):gh(C,nt<0?Mw:Dw):gh(C,0)),kn&&(_(Ht),L.current.layout=Ht,pe&&pe(Ht),Ql(ze,Ht,k.current))}},[]),z=$.useCallback((C,P)=>{const{onLayout:X}=T.current,{layout:J,panelDataArray:ne}=L.current,re=ne.map(Se=>Se.constraints),{panelSize:se,pivotIndices:xe}=Ui(ne,C,J);Oe(se!=null,`Panel size not found for panel "${C.id}"`);const ye=Wl(ne,C)===ne.length-1?se-P:P-se,pe=No({delta:ye,initialLayout:J,panelConstraints:re,pivotIndices:xe,prevLayout:J,trigger:"imperative-api"});Ou(J,pe)||(_(pe),L.current.layout=pe,X&&X(pe),Ql(ne,pe,k.current))},[]),G=$.useCallback((C,P)=>{const{layout:X,panelDataArray:J}=L.current,{collapsedSize:ne=0,collapsible:re}=P,{collapsedSize:se=0,collapsible:xe,maxSize:be=100,minSize:ye=0}=C.constraints,{panelSize:pe}=Ui(J,C,X);pe!=null&&(re&&xe&&Ar(pe,ne)?Ar(ne,se)||z(C,se):pebe&&z(C,be))},[z]),Q=$.useCallback((C,P)=>{const{direction:X}=T.current,{layout:J}=L.current;if(!b.current)return;const ne=jc(C,b.current);Oe(ne,`Drag handle element not found for id "${C}"`);const re=Bw(X,P);E({dragHandleId:C,dragHandleRect:ne.getBoundingClientRect(),initialCursorPosition:re,initialLayout:J})},[]),K=$.useCallback(()=>{E(null)},[]),D=$.useCallback(C=>{const{panelDataArray:P}=L.current,X=Wl(P,C);X>=0&&(P.splice(X,1),delete k.current[C.id],L.current.panelDataArrayChanged=!0,N())},[N]),q=$.useMemo(()=>({collapsePanel:R,direction:l,dragState:w,expandPanel:V,getPanelSize:H,getPanelStyle:B,groupId:x,isPanelCollapsed:U,isPanelExpanded:ee,reevaluatePanelConstraints:G,registerPanel:I,registerResizeHandle:F,resizePanel:z,startDragging:Q,stopDragging:K,unregisterPanel:D,panelGroupElement:b.current}),[R,w,l,V,H,B,x,U,ee,G,I,F,z,Q,K,D]),Y={display:"flex",flexDirection:l==="horizontal"?"row":"column",height:"100%",overflow:"hidden",width:"100%"};return $.createElement(Ec.Provider,{value:q},$.createElement(m,{...p,children:t,className:r,id:o,ref:b,style:{...Y,...h},[yt.group]:"",[yt.groupDirection]:l,[yt.groupId]:x}))}const Pp=$.forwardRef((e,t)=>$.createElement($w,{...e,forwardedRef:t}));$w.displayName="PanelGroup";Pp.displayName="forwardRef(PanelGroup)";function Wl(e,t){return e.findIndex(r=>r===t||r.id===t.id)}function Ui(e,t,r){const l=Wl(e,t),o=l===e.length-1?[l-1,l]:[l,l+1],u=r[l];return{...t.constraints,panelSize:u,pivotIndices:o}}function gC({disabled:e,handleId:t,resizeHandler:r,panelGroupElement:l}){$.useEffect(()=>{if(e||r==null||l==null)return;const a=jc(t,l);if(a==null)return;const o=u=>{if(!u.defaultPrevented)switch(u.key){case"ArrowDown":case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"End":case"Home":{u.preventDefault(),r(u);break}case"F6":{u.preventDefault();const c=a.getAttribute(yt.groupId);Oe(c,`No group element found for id "${c}"`);const d=Ho(c,l),h=Ow(c,t,l);Oe(h!==null,`No resize element found for id "${t}"`);const m=u.shiftKey?h>0?h-1:d.length-1:h+1{a.removeEventListener("keydown",o)}},[l,e,t,r])}function Gp({children:e=null,className:t="",disabled:r=!1,hitAreaMargins:l,id:a,onBlur:o,onClick:u,onDragging:c,onFocus:d,onPointerDown:h,onPointerUp:m,style:p={},tabIndex:x=0,tagName:b="div",...w}){var E,S;const _=$.useRef(null),N=$.useRef({onClick:u,onDragging:c,onPointerDown:h,onPointerUp:m});$.useEffect(()=>{N.current.onClick=u,N.current.onDragging=c,N.current.onPointerDown=h,N.current.onPointerUp=m});const k=$.useContext(Ec);if(k===null)throw Error("PanelResizeHandle components must be rendered within a PanelGroup container");const{direction:A,groupId:M,registerResizeHandle:T,startDragging:L,stopDragging:R,panelGroupElement:V}=k,H=bm(a),[B,U]=$.useState("inactive"),[ee,I]=$.useState(!1),[F,z]=$.useState(null),G=$.useRef({state:B});Xi(()=>{G.current.state=B}),$.useEffect(()=>{if(r)z(null);else{const q=T(H);z(()=>q)}},[r,H,T]);const Q=(E=l==null?void 0:l.coarse)!==null&&E!==void 0?E:15,K=(S=l==null?void 0:l.fine)!==null&&S!==void 0?S:5;$.useEffect(()=>{if(r||F==null)return;const q=_.current;Oe(q,"Element ref not attached");let Y=!1;return tC(H,q,A,{coarse:Q,fine:K},(P,X,J)=>{if(!X){U("inactive");return}switch(P){case"down":{U("drag"),Y=!1,Oe(J,'Expected event to be defined for "down" action'),L(H,J);const{onDragging:ne,onPointerDown:re}=N.current;ne==null||ne(!0),re==null||re();break}case"move":{const{state:ne}=G.current;Y=!0,ne!=="drag"&&U("hover"),Oe(J,'Expected event to be defined for "move" action'),F(J);break}case"up":{U("hover"),R();const{onClick:ne,onDragging:re,onPointerUp:se}=N.current;re==null||re(!1),se==null||se(),Y||ne==null||ne();break}}})},[Q,A,r,K,T,H,F,L,R]),gC({disabled:r,handleId:H,resizeHandler:F,panelGroupElement:V});const D={touchAction:"none",userSelect:"none"};return $.createElement(b,{...w,children:e,className:t,id:a,onBlur:()=>{I(!1),o==null||o()},onFocus:()=>{I(!0),d==null||d()},ref:_,role:"separator",style:{...D,...p},tabIndex:x,[yt.groupDirection]:A,[yt.groupId]:M,[yt.resizeHandle]:"",[yt.resizeHandleActive]:B==="drag"?"pointer":ee?"keyboard":void 0,[yt.resizeHandleEnabled]:!r,[yt.resizeHandleId]:H,[yt.resizeHandleState]:B})}Gp.displayName="PanelResizeHandle";function At(e){if(typeof e=="string"||typeof e=="number")return""+e;let t="";if(Array.isArray(e))for(let r=0,l;r{}};function Tc(){for(var e=0,t=arguments.length,r={},l;e=0&&(l=r.slice(a+1),r=r.slice(0,a)),r&&!t.hasOwnProperty(r))throw new Error("unknown type: "+r);return{type:r,name:l}})}Ku.prototype=Tc.prototype={constructor:Ku,on:function(e,t){var r=this._,l=yC(e+"",r),a,o=-1,u=l.length;if(arguments.length<2){for(;++o0)for(var r=new Array(a),l=0,a,o;l=0&&(t=e.slice(0,r))!=="xmlns"&&(e=e.slice(r+1)),pv.hasOwnProperty(t)?{space:pv[t],local:e}:e}function bC(e){return function(){var t=this.ownerDocument,r=this.namespaceURI;return r===Fp&&t.documentElement.namespaceURI===Fp?t.createElement(e):t.createElementNS(r,e)}}function wC(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Vw(e){var t=Ac(e);return(t.local?wC:bC)(t)}function _C(){}function Sm(e){return e==null?_C:function(){return this.querySelector(e)}}function SC(e){typeof e!="function"&&(e=Sm(e));for(var t=this._groups,r=t.length,l=new Array(r),a=0;a=k&&(k=N+1);!(M=S[k])&&++k=0;)(u=l[a])&&(o&&u.compareDocumentPosition(o)^4&&o.parentNode.insertBefore(u,o),o=u);return this}function XC(e){e||(e=QC);function t(p,x){return p&&x?e(p.__data__,x.__data__):!p-!x}for(var r=this._groups,l=r.length,a=new Array(l),o=0;ot?1:e>=t?0:NaN}function ZC(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function KC(){return Array.from(this)}function JC(){for(var e=this._groups,t=0,r=e.length;t1?this.each((t==null?u3:typeof t=="function"?f3:c3)(e,t,r??"")):fa(this.node(),e)}function fa(e,t){return e.style.getPropertyValue(t)||Xw(e).getComputedStyle(e,null).getPropertyValue(t)}function h3(e){return function(){delete this[e]}}function p3(e,t){return function(){this[e]=t}}function m3(e,t){return function(){var r=t.apply(this,arguments);r==null?delete this[e]:this[e]=r}}function g3(e,t){return arguments.length>1?this.each((t==null?h3:typeof t=="function"?m3:p3)(e,t)):this.node()[e]}function Qw(e){return e.trim().split(/^|\s+/)}function km(e){return e.classList||new Zw(e)}function Zw(e){this._node=e,this._names=Qw(e.getAttribute("class")||"")}Zw.prototype={add:function(e){var t=this._names.indexOf(e);t<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 Kw(e,t){for(var r=km(e),l=-1,a=t.length;++l=0&&(r=t.slice(l+1),t=t.slice(0,l)),{type:t,name:r}})}function P3(e){return function(){var t=this.__on;if(t){for(var r=0,l=-1,a=t.length,o;r()=>e;function Yp(e,{sourceEvent:t,subject:r,target:l,identifier:a,active:o,x:u,y:c,dx:d,dy:h,dispatch:m}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:r,enumerable:!0,configurable:!0},target:{value:l,enumerable:!0,configurable:!0},identifier:{value:a,enumerable:!0,configurable:!0},active:{value:o,enumerable:!0,configurable:!0},x:{value:u,enumerable:!0,configurable:!0},y:{value:c,enumerable:!0,configurable:!0},dx:{value:d,enumerable:!0,configurable:!0},dy:{value:h,enumerable:!0,configurable:!0},_:{value:m}})}Yp.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function ej(e){return!e.ctrlKey&&!e.button}function tj(){return this.parentNode}function nj(e,t){return t??{x:e.x,y:e.y}}function rj(){return navigator.maxTouchPoints||"ontouchstart"in this}function r_(){var e=ej,t=tj,r=nj,l=rj,a={},o=Tc("start","drag","end"),u=0,c,d,h,m,p=0;function x(A){A.on("mousedown.drag",b).filter(l).on("touchstart.drag",S).on("touchmove.drag",_,W3).on("touchend.drag touchcancel.drag",N).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function b(A,M){if(!(m||!e.call(this,A,M))){var T=k(this,t.call(this,A,M),A,M,"mouse");T&&(wn(A.view).on("mousemove.drag",w,Bo).on("mouseup.drag",E,Bo),t_(A.view),yh(A),h=!1,c=A.clientX,d=A.clientY,T("start",A))}}function w(A){if(oa(A),!h){var M=A.clientX-c,T=A.clientY-d;h=M*M+T*T>p}a.mouse("drag",A)}function E(A){wn(A.view).on("mousemove.drag mouseup.drag",null),n_(A.view,h),oa(A),a.mouse("end",A)}function S(A,M){if(e.call(this,A,M)){var T=A.changedTouches,L=t.call(this,A,M),R=T.length,V,H;for(V=0;V>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):r===8?Hu(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):r===4?Hu(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=lj.exec(e))?new un(t[1],t[2],t[3],1):(t=aj.exec(e))?new un(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=oj.exec(e))?Hu(t[1],t[2],t[3],t[4]):(t=sj.exec(e))?Hu(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=uj.exec(e))?wv(t[1],t[2]/100,t[3]/100,1):(t=cj.exec(e))?wv(t[1],t[2]/100,t[3]/100,t[4]):mv.hasOwnProperty(e)?yv(mv[e]):e==="transparent"?new un(NaN,NaN,NaN,0):null}function yv(e){return new un(e>>16&255,e>>8&255,e&255,1)}function Hu(e,t,r,l){return l<=0&&(e=t=r=NaN),new un(e,t,r,l)}function hj(e){return e instanceof Jo||(e=Ji(e)),e?(e=e.rgb(),new un(e.r,e.g,e.b,e.opacity)):new un}function Xp(e,t,r,l){return arguments.length===1?hj(e):new un(e,t,r,l??1)}function un(e,t,r,l){this.r=+e,this.g=+t,this.b=+r,this.opacity=+l}Em(un,Xp,i_(Jo,{brighter(e){return e=e==null?sc:Math.pow(sc,e),new un(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Io:Math.pow(Io,e),new un(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new un(Qi(this.r),Qi(this.g),Qi(this.b),uc(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:vv,formatHex:vv,formatHex8:pj,formatRgb:bv,toString:bv}));function vv(){return`#${Fi(this.r)}${Fi(this.g)}${Fi(this.b)}`}function pj(){return`#${Fi(this.r)}${Fi(this.g)}${Fi(this.b)}${Fi((isNaN(this.opacity)?1:this.opacity)*255)}`}function bv(){const e=uc(this.opacity);return`${e===1?"rgb(":"rgba("}${Qi(this.r)}, ${Qi(this.g)}, ${Qi(this.b)}${e===1?")":`, ${e})`}`}function uc(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Qi(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Fi(e){return e=Qi(e),(e<16?"0":"")+e.toString(16)}function wv(e,t,r,l){return l<=0?e=t=r=NaN:r<=0||r>=1?e=t=NaN:t<=0&&(e=NaN),new Un(e,t,r,l)}function l_(e){if(e instanceof Un)return new Un(e.h,e.s,e.l,e.opacity);if(e instanceof Jo||(e=Ji(e)),!e)return new Un;if(e instanceof Un)return e;e=e.rgb();var t=e.r/255,r=e.g/255,l=e.b/255,a=Math.min(t,r,l),o=Math.max(t,r,l),u=NaN,c=o-a,d=(o+a)/2;return c?(t===o?u=(r-l)/c+(r0&&d<1?0:u,new Un(u,c,d,e.opacity)}function mj(e,t,r,l){return arguments.length===1?l_(e):new Un(e,t,r,l??1)}function Un(e,t,r,l){this.h=+e,this.s=+t,this.l=+r,this.opacity=+l}Em(Un,mj,i_(Jo,{brighter(e){return e=e==null?sc:Math.pow(sc,e),new Un(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Io:Math.pow(Io,e),new Un(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,r=this.l,l=r+(r<.5?r:1-r)*t,a=2*r-l;return new un(vh(e>=240?e-240:e+120,a,l),vh(e,a,l),vh(e<120?e+240:e-120,a,l),this.opacity)},clamp(){return new Un(_v(this.h),Bu(this.s),Bu(this.l),uc(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=uc(this.opacity);return`${e===1?"hsl(":"hsla("}${_v(this.h)}, ${Bu(this.s)*100}%, ${Bu(this.l)*100}%${e===1?")":`, ${e})`}`}}));function _v(e){return e=(e||0)%360,e<0?e+360:e}function Bu(e){return Math.max(0,Math.min(1,e||0))}function vh(e,t,r){return(e<60?t+(r-t)*e/60:e<180?r:e<240?t+(r-t)*(240-e)/60:t)*255}const Nm=e=>()=>e;function gj(e,t){return function(r){return e+r*t}}function xj(e,t,r){return e=Math.pow(e,r),t=Math.pow(t,r)-e,r=1/r,function(l){return Math.pow(e+l*t,r)}}function yj(e){return(e=+e)==1?a_:function(t,r){return r-t?xj(t,r,e):Nm(isNaN(t)?r:t)}}function a_(e,t){var r=t-e;return r?gj(e,r):Nm(isNaN(e)?t:e)}const cc=(function e(t){var r=yj(t);function l(a,o){var u=r((a=Xp(a)).r,(o=Xp(o)).r),c=r(a.g,o.g),d=r(a.b,o.b),h=a_(a.opacity,o.opacity);return function(m){return a.r=u(m),a.g=c(m),a.b=d(m),a.opacity=h(m),a+""}}return l.gamma=e,l})(1);function vj(e,t){t||(t=[]);var r=e?Math.min(t.length,e.length):0,l=t.slice(),a;return function(o){for(a=0;ar&&(o=t.slice(r,o),c[u]?c[u]+=o:c[++u]=o),(l=l[0])===(a=a[0])?c[u]?c[u]+=a:c[++u]=a:(c[++u]=null,d.push({i:u,x:rr(l,a)})),r=bh.lastIndex;return r180?m+=360:m-h>180&&(h+=360),x.push({i:p.push(a(p)+"rotate(",null,l)-2,x:rr(h,m)})):m&&p.push(a(p)+"rotate("+m+l)}function c(h,m,p,x){h!==m?x.push({i:p.push(a(p)+"skewX(",null,l)-2,x:rr(h,m)}):m&&p.push(a(p)+"skewX("+m+l)}function d(h,m,p,x,b,w){if(h!==p||m!==x){var E=b.push(a(b)+"scale(",null,",",null,")");w.push({i:E-4,x:rr(h,p)},{i:E-2,x:rr(m,x)})}else(p!==1||x!==1)&&b.push(a(b)+"scale("+p+","+x+")")}return function(h,m){var p=[],x=[];return h=e(h),m=e(m),o(h.translateX,h.translateY,m.translateX,m.translateY,p,x),u(h.rotate,m.rotate,p,x),c(h.skewX,m.skewX,p,x),d(h.scaleX,h.scaleY,m.scaleX,m.scaleY,p,x),h=m=null,function(b){for(var w=-1,E=x.length,S;++w=0&&e._call.call(void 0,t),e=e._next;--da}function Ev(){Wi=(dc=Uo.now())+zc,da=jo=0;try{Rj()}finally{da=0,Lj(),Wi=0}}function Oj(){var e=Uo.now(),t=e-dc;t>c_&&(zc-=t,dc=e)}function Lj(){for(var e,t=fc,r,l=1/0;t;)t._call?(l>t._time&&(l=t._time),e=t,t=t._next):(r=t._next,t._next=null,t=e?e._next=r:fc=r);To=e,Kp(l)}function Kp(e){if(!da){jo&&(jo=clearTimeout(jo));var t=e-Wi;t>24?(e<1/0&&(jo=setTimeout(Ev,e-Uo.now()-zc)),vo&&(vo=clearInterval(vo))):(vo||(dc=Uo.now(),vo=setInterval(Oj,c_)),da=1,f_(Ev))}}function Nv(e,t,r){var l=new hc;return t=t==null?0:+t,l.restart(a=>{l.stop(),e(a+t)},t,r),l}var Hj=Tc("start","end","cancel","interrupt"),Bj=[],h_=0,Cv=1,Jp=2,Wu=3,jv=4,Wp=5,ec=6;function Mc(e,t,r,l,a,o){var u=e.__transition;if(!u)e.__transition={};else if(r in u)return;Ij(e,r,{name:t,index:l,group:a,on:Hj,tween:Bj,time:o.time,delay:o.delay,duration:o.duration,ease:o.ease,timer:null,state:h_})}function jm(e,t){var r=Xn(e,t);if(r.state>h_)throw new Error("too late; already scheduled");return r}function ar(e,t){var r=Xn(e,t);if(r.state>Wu)throw new Error("too late; already running");return r}function Xn(e,t){var r=e.__transition;if(!r||!(r=r[t]))throw new Error("transition not found");return r}function Ij(e,t,r){var l=e.__transition,a;l[t]=r,r.timer=d_(o,0,r.time);function o(h){r.state=Cv,r.timer.restart(u,r.delay,r.time),r.delay<=h&&u(h-r.delay)}function u(h){var m,p,x,b;if(r.state!==Cv)return d();for(m in l)if(b=l[m],b.name===r.name){if(b.state===Wu)return Nv(u);b.state===jv?(b.state=ec,b.timer.stop(),b.on.call("interrupt",e,e.__data__,b.index,b.group),delete l[m]):+mJp&&l.state=0&&(t=t.slice(0,r)),!t||t==="start"})}function mT(e,t,r){var l,a,o=pT(t)?jm:ar;return function(){var u=o(this,e),c=u.on;c!==l&&(a=(l=c).copy()).on(t,r),u.on=a}}function gT(e,t){var r=this._id;return arguments.length<2?Xn(this.node(),r).on.on(e):this.each(mT(r,e,t))}function xT(e){return function(){var t=this.parentNode;for(var r in this.__transition)if(+r!==e)return;t&&t.removeChild(this)}}function yT(){return this.on("end.remove",xT(this._id))}function vT(e){var t=this._name,r=this._id;typeof e!="function"&&(e=Sm(e));for(var l=this._groups,a=l.length,o=new Array(a),u=0;u()=>e;function PT(e,{sourceEvent:t,target:r,transform:l,dispatch:a}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},transform:{value:l,enumerable:!0,configurable:!0},_:{value:a}})}function zr(e,t,r){this.k=e,this.x=t,this.y=r}zr.prototype={constructor:zr,scale:function(e){return e===1?this:new zr(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new zr(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 Dc=new zr(1,0,0);x_.prototype=zr.prototype;function x_(e){for(;!e.__zoom;)if(!(e=e.parentNode))return Dc;return e.__zoom}function wh(e){e.stopImmediatePropagation()}function bo(e){e.preventDefault(),e.stopImmediatePropagation()}function GT(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function FT(){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 Tv(){return this.__zoom||Dc}function YT(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function XT(){return navigator.maxTouchPoints||"ontouchstart"in this}function QT(e,t,r){var l=e.invertX(t[0][0])-r[0][0],a=e.invertX(t[1][0])-r[1][0],o=e.invertY(t[0][1])-r[0][1],u=e.invertY(t[1][1])-r[1][1];return e.translate(a>l?(l+a)/2:Math.min(0,l)||Math.max(0,a),u>o?(o+u)/2:Math.min(0,o)||Math.max(0,u))}function y_(){var e=GT,t=FT,r=QT,l=YT,a=XT,o=[0,1/0],u=[[-1/0,-1/0],[1/0,1/0]],c=250,d=Ju,h=Tc("start","zoom","end"),m,p,x,b=500,w=150,E=0,S=10;function _(I){I.property("__zoom",Tv).on("wheel.zoom",R,{passive:!1}).on("mousedown.zoom",V).on("dblclick.zoom",H).filter(a).on("touchstart.zoom",B).on("touchmove.zoom",U).on("touchend.zoom touchcancel.zoom",ee).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}_.transform=function(I,F,z,G){var Q=I.selection?I.selection():I;Q.property("__zoom",Tv),I!==Q?M(I,F,z,G):Q.interrupt().each(function(){T(this,arguments).event(G).start().zoom(null,typeof F=="function"?F.apply(this,arguments):F).end()})},_.scaleBy=function(I,F,z,G){_.scaleTo(I,function(){var Q=this.__zoom.k,K=typeof F=="function"?F.apply(this,arguments):F;return Q*K},z,G)},_.scaleTo=function(I,F,z,G){_.transform(I,function(){var Q=t.apply(this,arguments),K=this.__zoom,D=z==null?A(Q):typeof z=="function"?z.apply(this,arguments):z,q=K.invert(D),Y=typeof F=="function"?F.apply(this,arguments):F;return r(k(N(K,Y),D,q),Q,u)},z,G)},_.translateBy=function(I,F,z,G){_.transform(I,function(){return r(this.__zoom.translate(typeof F=="function"?F.apply(this,arguments):F,typeof z=="function"?z.apply(this,arguments):z),t.apply(this,arguments),u)},null,G)},_.translateTo=function(I,F,z,G,Q){_.transform(I,function(){var K=t.apply(this,arguments),D=this.__zoom,q=G==null?A(K):typeof G=="function"?G.apply(this,arguments):G;return r(Dc.translate(q[0],q[1]).scale(D.k).translate(typeof F=="function"?-F.apply(this,arguments):-F,typeof z=="function"?-z.apply(this,arguments):-z),K,u)},G,Q)};function N(I,F){return F=Math.max(o[0],Math.min(o[1],F)),F===I.k?I:new zr(F,I.x,I.y)}function k(I,F,z){var G=F[0]-z[0]*I.k,Q=F[1]-z[1]*I.k;return G===I.x&&Q===I.y?I:new zr(I.k,G,Q)}function A(I){return[(+I[0][0]+ +I[1][0])/2,(+I[0][1]+ +I[1][1])/2]}function M(I,F,z,G){I.on("start.zoom",function(){T(this,arguments).event(G).start()}).on("interrupt.zoom end.zoom",function(){T(this,arguments).event(G).end()}).tween("zoom",function(){var Q=this,K=arguments,D=T(Q,K).event(G),q=t.apply(Q,K),Y=z==null?A(q):typeof z=="function"?z.apply(Q,K):z,C=Math.max(q[1][0]-q[0][0],q[1][1]-q[0][1]),P=Q.__zoom,X=typeof F=="function"?F.apply(Q,K):F,J=d(P.invert(Y).concat(C/P.k),X.invert(Y).concat(C/X.k));return function(ne){if(ne===1)ne=X;else{var re=J(ne),se=C/re[2];ne=new zr(se,Y[0]-re[0]*se,Y[1]-re[1]*se)}D.zoom(null,ne)}})}function T(I,F,z){return!z&&I.__zooming||new L(I,F)}function L(I,F){this.that=I,this.args=F,this.active=0,this.sourceEvent=null,this.extent=t.apply(I,F),this.taps=0}L.prototype={event:function(I){return I&&(this.sourceEvent=I),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(I,F){return this.mouse&&I!=="mouse"&&(this.mouse[1]=F.invert(this.mouse[0])),this.touch0&&I!=="touch"&&(this.touch0[1]=F.invert(this.touch0[0])),this.touch1&&I!=="touch"&&(this.touch1[1]=F.invert(this.touch1[0])),this.that.__zoom=F,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(I){var F=wn(this.that).datum();h.call(I,this.that,new PT(I,{sourceEvent:this.sourceEvent,target:_,transform:this.that.__zoom,dispatch:h}),F)}};function R(I,...F){if(!e.apply(this,arguments))return;var z=T(this,F).event(I),G=this.__zoom,Q=Math.max(o[0],Math.min(o[1],G.k*Math.pow(2,l.apply(this,arguments)))),K=qn(I);if(z.wheel)(z.mouse[0][0]!==K[0]||z.mouse[0][1]!==K[1])&&(z.mouse[1]=G.invert(z.mouse[0]=K)),clearTimeout(z.wheel);else{if(G.k===Q)return;z.mouse=[K,G.invert(K)],tc(this),z.start()}bo(I),z.wheel=setTimeout(D,w),z.zoom("mouse",r(k(N(G,Q),z.mouse[0],z.mouse[1]),z.extent,u));function D(){z.wheel=null,z.end()}}function V(I,...F){if(x||!e.apply(this,arguments))return;var z=I.currentTarget,G=T(this,F,!0).event(I),Q=wn(I.view).on("mousemove.zoom",Y,!0).on("mouseup.zoom",C,!0),K=qn(I,z),D=I.clientX,q=I.clientY;t_(I.view),wh(I),G.mouse=[K,this.__zoom.invert(K)],tc(this),G.start();function Y(P){if(bo(P),!G.moved){var X=P.clientX-D,J=P.clientY-q;G.moved=X*X+J*J>E}G.event(P).zoom("mouse",r(k(G.that.__zoom,G.mouse[0]=qn(P,z),G.mouse[1]),G.extent,u))}function C(P){Q.on("mousemove.zoom mouseup.zoom",null),n_(P.view,G.moved),bo(P),G.event(P).end()}}function H(I,...F){if(e.apply(this,arguments)){var z=this.__zoom,G=qn(I.changedTouches?I.changedTouches[0]:I,this),Q=z.invert(G),K=z.k*(I.shiftKey?.5:2),D=r(k(N(z,K),G,Q),t.apply(this,F),u);bo(I),c>0?wn(this).transition().duration(c).call(M,D,G,I):wn(this).call(_.transform,D,G,I)}}function B(I,...F){if(e.apply(this,arguments)){var z=I.touches,G=z.length,Q=T(this,F,I.changedTouches.length===G).event(I),K,D,q,Y;for(wh(I),D=0;D"[React Flow]: Seems like you have not used zustand provider as an ancestor. Help: https://reactflow.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 React Flow 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:r,targetHandle:l})=>`Couldn't create edge for ${e} handle id: "${e==="source"?r:l}", 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."},$o=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],v_=["Enter"," ","Escape"],b_={"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:r})=>`Moved selected node ${e}. New position, x: ${t}, y: ${r}`,"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"};var ha;(function(e){e.Strict="strict",e.Loose="loose"})(ha||(ha={}));var Zi;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Zi||(Zi={}));var Vo;(function(e){e.Partial="partial",e.Full="full"})(Vo||(Vo={}));const w_={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var xi;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(xi||(xi={}));var pc;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(pc||(pc={}));var ve;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(ve||(ve={}));const Av={[ve.Left]:ve.Right,[ve.Right]:ve.Left,[ve.Top]:ve.Bottom,[ve.Bottom]:ve.Top};function __(e){return e===null?null:e?"valid":"invalid"}const S_=e=>"id"in e&&"source"in e&&"target"in e,ZT=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),Am=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),Wo=(e,t=[0,0])=>{const{width:r,height:l}=Or(e),a=e.origin??t,o=r*a[0],u=l*a[1];return{x:e.position.x-o,y:e.position.y-u}},KT=(e,t={nodeOrigin:[0,0]})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};const r=e.reduce((l,a)=>{const o=typeof a=="string";let u=!t.nodeLookup&&!o?a:void 0;t.nodeLookup&&(u=o?t.nodeLookup.get(a):Am(a)?a:t.nodeLookup.get(a.id));const c=u?mc(u,t.nodeOrigin):{x:0,y:0,x2:0,y2:0};return Rc(l,c)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return Oc(r)},es=(e,t={})=>{let r={x:1/0,y:1/0,x2:-1/0,y2:-1/0},l=!1;return e.forEach(a=>{(t.filter===void 0||t.filter(a))&&(r=Rc(r,mc(a)),l=!0)}),l?Oc(r):{x:0,y:0,width:0,height:0}},zm=(e,t,[r,l,a]=[0,0,1],o=!1,u=!1)=>{const c={...ns(t,[r,l,a]),width:t.width/a,height:t.height/a},d=[];for(const h of e.values()){const{measured:m,selectable:p=!0,hidden:x=!1}=h;if(u&&!p||x)continue;const b=m.width??h.width??h.initialWidth??null,w=m.height??h.height??h.initialHeight??null,E=Po(c,ma(h)),S=(b??0)*(w??0),_=o&&E>0;(!h.internals.handleBounds||_||E>=S||h.dragging)&&d.push(h)}return d},JT=(e,t)=>{const r=new Set;return e.forEach(l=>{r.add(l.id)}),t.filter(l=>r.has(l.source)||r.has(l.target))};function WT(e,t){const r=new Map,l=t!=null&&t.nodes?new Set(t.nodes.map(a=>a.id)):null;return e.forEach(a=>{a.measured.width&&a.measured.height&&((t==null?void 0:t.includeHiddenNodes)||!a.hidden)&&(!l||l.has(a.id))&&r.set(a.id,a)}),r}async function eA({nodes:e,width:t,height:r,panZoom:l,minZoom:a,maxZoom:o},u){if(e.size===0)return Promise.resolve(!0);const c=WT(e,u),d=es(c),h=Mm(d,t,r,(u==null?void 0:u.minZoom)??a,(u==null?void 0:u.maxZoom)??o,(u==null?void 0:u.padding)??.1);return await l.setViewport(h,{duration:u==null?void 0:u.duration,ease:u==null?void 0:u.ease,interpolate:u==null?void 0:u.interpolate}),Promise.resolve(!0)}function k_({nodeId:e,nextPosition:t,nodeLookup:r,nodeOrigin:l=[0,0],nodeExtent:a,onError:o}){const u=r.get(e),c=u.parentId?r.get(u.parentId):void 0,{x:d,y:h}=c?c.internals.positionAbsolute:{x:0,y:0},m=u.origin??l;let p=u.extent||a;if(u.extent==="parent"&&!u.expandParent)if(!c)o==null||o("005",lr.error005());else{const b=c.measured.width,w=c.measured.height;b&&w&&(p=[[d,h],[d+b,h+w]])}else c&&ga(u.extent)&&(p=[[u.extent[0][0]+d,u.extent[0][1]+h],[u.extent[1][0]+d,u.extent[1][1]+h]]);const x=ga(p)?el(t,p,u.measured):t;return(u.measured.width===void 0||u.measured.height===void 0)&&(o==null||o("015",lr.error015())),{position:{x:x.x-d+(u.measured.width??0)*m[0],y:x.y-h+(u.measured.height??0)*m[1]},positionAbsolute:x}}async function tA({nodesToRemove:e=[],edgesToRemove:t=[],nodes:r,edges:l,onBeforeDelete:a}){const o=new Set(e.map(x=>x.id)),u=[];for(const x of r){if(x.deletable===!1)continue;const b=o.has(x.id),w=!b&&x.parentId&&u.find(E=>E.id===x.parentId);(b||w)&&u.push(x)}const c=new Set(t.map(x=>x.id)),d=l.filter(x=>x.deletable!==!1),m=JT(u,d);for(const x of d)c.has(x.id)&&!m.find(w=>w.id===x.id)&&m.push(x);if(!a)return{edges:m,nodes:u};const p=await a({nodes:u,edges:m});return typeof p=="boolean"?p?{edges:m,nodes:u}:{edges:[],nodes:[]}:p}const pa=(e,t=0,r=1)=>Math.min(Math.max(e,t),r),el=(e={x:0,y:0},t,r)=>({x:pa(e.x,t[0][0],t[1][0]-((r==null?void 0:r.width)??0)),y:pa(e.y,t[0][1],t[1][1]-((r==null?void 0:r.height)??0))});function E_(e,t,r){const{width:l,height:a}=Or(r),{x:o,y:u}=r.internals.positionAbsolute;return el(e,[[o,u],[o+l,u+a]],t)}const zv=(e,t,r)=>er?-pa(Math.abs(e-r),1,t)/t:0,N_=(e,t,r=15,l=40)=>{const a=zv(e.x,l,t.width-l)*r,o=zv(e.y,l,t.height-l)*r;return[a,o]},Rc=(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)}),em=({x:e,y:t,width:r,height:l})=>({x:e,y:t,x2:e+r,y2:t+l}),Oc=({x:e,y:t,x2:r,y2:l})=>({x:e,y:t,width:r-e,height:l-t}),ma=(e,t=[0,0])=>{var a,o;const{x:r,y:l}=Am(e)?e.internals.positionAbsolute:Wo(e,t);return{x:r,y:l,width:((a=e.measured)==null?void 0:a.width)??e.width??e.initialWidth??0,height:((o=e.measured)==null?void 0:o.height)??e.height??e.initialHeight??0}},mc=(e,t=[0,0])=>{var a,o;const{x:r,y:l}=Am(e)?e.internals.positionAbsolute:Wo(e,t);return{x:r,y:l,x2:r+(((a=e.measured)==null?void 0:a.width)??e.width??e.initialWidth??0),y2:l+(((o=e.measured)==null?void 0:o.height)??e.height??e.initialHeight??0)}},C_=(e,t)=>Oc(Rc(em(e),em(t))),Po=(e,t)=>{const r=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),l=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return Math.ceil(r*l)},Mv=e=>$n(e.width)&&$n(e.height)&&$n(e.x)&&$n(e.y),$n=e=>!isNaN(e)&&isFinite(e),nA=(e,t)=>{},ts=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),ns=({x:e,y:t},[r,l,a],o=!1,u=[1,1])=>{const c={x:(e-r)/a,y:(t-l)/a};return o?ts(c,u):c},gc=({x:e,y:t},[r,l,a])=>({x:e*a+r,y:t*a+l});function Zl(e,t){if(typeof e=="number")return Math.floor((t-t/(1+e))*.5);if(typeof e=="string"&&e.endsWith("px")){const r=parseFloat(e);if(!Number.isNaN(r))return Math.floor(r)}if(typeof e=="string"&&e.endsWith("%")){const r=parseFloat(e);if(!Number.isNaN(r))return Math.floor(t*r*.01)}return console.error(`[React Flow] The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function rA(e,t,r){if(typeof e=="string"||typeof e=="number"){const l=Zl(e,r),a=Zl(e,t);return{top:l,right:a,bottom:l,left:a,x:a*2,y:l*2}}if(typeof e=="object"){const l=Zl(e.top??e.y??0,r),a=Zl(e.bottom??e.y??0,r),o=Zl(e.left??e.x??0,t),u=Zl(e.right??e.x??0,t);return{top:l,right:u,bottom:a,left:o,x:o+u,y:l+a}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function iA(e,t,r,l,a,o){const{x:u,y:c}=gc(e,[t,r,l]),{x:d,y:h}=gc({x:e.x+e.width,y:e.y+e.height},[t,r,l]),m=a-d,p=o-h;return{left:Math.floor(u),top:Math.floor(c),right:Math.floor(m),bottom:Math.floor(p)}}const Mm=(e,t,r,l,a,o)=>{const u=rA(o,t,r),c=(t-u.x)/e.width,d=(r-u.y)/e.height,h=Math.min(c,d),m=pa(h,l,a),p=e.x+e.width/2,x=e.y+e.height/2,b=t/2-p*m,w=r/2-x*m,E=iA(e,b,w,m,t,r),S={left:Math.min(E.left-u.left,0),top:Math.min(E.top-u.top,0),right:Math.min(E.right-u.right,0),bottom:Math.min(E.bottom-u.bottom,0)};return{x:b-S.left+S.right,y:w-S.top+S.bottom,zoom:m}},Go=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0};function ga(e){return e!=null&&e!=="parent"}function Or(e){var t,r;return{width:((t=e.measured)==null?void 0:t.width)??e.width??e.initialWidth??0,height:((r=e.measured)==null?void 0:r.height)??e.height??e.initialHeight??0}}function j_(e){var t,r;return(((t=e.measured)==null?void 0:t.width)??e.width??e.initialWidth)!==void 0&&(((r=e.measured)==null?void 0:r.height)??e.height??e.initialHeight)!==void 0}function T_(e,t={width:0,height:0},r,l,a){const o={...e},u=l.get(r);if(u){const c=u.origin||a;o.x+=u.internals.positionAbsolute.x-(t.width??0)*c[0],o.y+=u.internals.positionAbsolute.y-(t.height??0)*c[1]}return o}function Dv(e,t){if(e.size!==t.size)return!1;for(const r of e)if(!t.has(r))return!1;return!0}function lA(){let e,t;return{promise:new Promise((l,a)=>{e=l,t=a}),resolve:e,reject:t}}function aA(e){return{...b_,...e||{}}}function Mo(e,{snapGrid:t=[0,0],snapToGrid:r=!1,transform:l,containerBounds:a}){const{x:o,y:u}=Vn(e),c=ns({x:o-((a==null?void 0:a.left)??0),y:u-((a==null?void 0:a.top)??0)},l),{x:d,y:h}=r?ts(c,t):c;return{xSnapped:d,ySnapped:h,...c}}const Dm=e=>({width:e.offsetWidth,height:e.offsetHeight}),A_=e=>{var t;return((t=e==null?void 0:e.getRootNode)==null?void 0:t.call(e))||(window==null?void 0:window.document)},oA=["INPUT","SELECT","TEXTAREA"];function z_(e){var l,a;const t=((a=(l=e.composedPath)==null?void 0:l.call(e))==null?void 0:a[0])||e.target;return(t==null?void 0:t.nodeType)!==1?!1:oA.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const M_=e=>"clientX"in e,Vn=(e,t)=>{var o,u;const r=M_(e),l=r?e.clientX:(o=e.touches)==null?void 0:o[0].clientX,a=r?e.clientY:(u=e.touches)==null?void 0:u[0].clientY;return{x:l-((t==null?void 0:t.left)??0),y:a-((t==null?void 0:t.top)??0)}},Rv=(e,t,r,l,a)=>{const o=t.querySelectorAll(`.${e}`);return!o||!o.length?null:Array.from(o).map(u=>{const c=u.getBoundingClientRect();return{id:u.getAttribute("data-handleid"),type:e,nodeId:a,position:u.getAttribute("data-handlepos"),x:(c.left-r.left)/l,y:(c.top-r.top)/l,...Dm(u)}})};function D_({sourceX:e,sourceY:t,targetX:r,targetY:l,sourceControlX:a,sourceControlY:o,targetControlX:u,targetControlY:c}){const d=e*.125+a*.375+u*.375+r*.125,h=t*.125+o*.375+c*.375+l*.125,m=Math.abs(d-e),p=Math.abs(h-t);return[d,h,m,p]}function Uu(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function Ov({pos:e,x1:t,y1:r,x2:l,y2:a,c:o}){switch(e){case ve.Left:return[t-Uu(t-l,o),r];case ve.Right:return[t+Uu(l-t,o),r];case ve.Top:return[t,r-Uu(r-a,o)];case ve.Bottom:return[t,r+Uu(a-r,o)]}}function Rm({sourceX:e,sourceY:t,sourcePosition:r=ve.Bottom,targetX:l,targetY:a,targetPosition:o=ve.Top,curvature:u=.25}){const[c,d]=Ov({pos:r,x1:e,y1:t,x2:l,y2:a,c:u}),[h,m]=Ov({pos:o,x1:l,y1:a,x2:e,y2:t,c:u}),[p,x,b,w]=D_({sourceX:e,sourceY:t,targetX:l,targetY:a,sourceControlX:c,sourceControlY:d,targetControlX:h,targetControlY:m});return[`M${e},${t} C${c},${d} ${h},${m} ${l},${a}`,p,x,b,w]}function R_({sourceX:e,sourceY:t,targetX:r,targetY:l}){const a=Math.abs(r-e)/2,o=r0}const cA=({source:e,sourceHandle:t,target:r,targetHandle:l})=>`xy-edge__${e}${t||""}-${r}${l||""}`,fA=(e,t)=>t.some(r=>r.source===e.source&&r.target===e.target&&(r.sourceHandle===e.sourceHandle||!r.sourceHandle&&!e.sourceHandle)&&(r.targetHandle===e.targetHandle||!r.targetHandle&&!e.targetHandle)),dA=(e,t,r={})=>{if(!e.source||!e.target)return t;const l=r.getEdgeId||cA;let a;return S_(e)?a={...e}:a={...e,id:l(e)},fA(a,t)?t:(a.sourceHandle===null&&delete a.sourceHandle,a.targetHandle===null&&delete a.targetHandle,t.concat(a))};function O_({sourceX:e,sourceY:t,targetX:r,targetY:l}){const[a,o,u,c]=R_({sourceX:e,sourceY:t,targetX:r,targetY:l});return[`M ${e},${t}L ${r},${l}`,a,o,u,c]}const Lv={[ve.Left]:{x:-1,y:0},[ve.Right]:{x:1,y:0},[ve.Top]:{x:0,y:-1},[ve.Bottom]:{x:0,y:1}},hA=({source:e,sourcePosition:t=ve.Bottom,target:r})=>t===ve.Left||t===ve.Right?e.xMath.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function pA({source:e,sourcePosition:t=ve.Bottom,target:r,targetPosition:l=ve.Top,center:a,offset:o,stepPosition:u}){const c=Lv[t],d=Lv[l],h={x:e.x+c.x*o,y:e.y+c.y*o},m={x:r.x+d.x*o,y:r.y+d.y*o},p=hA({source:h,sourcePosition:t,target:m}),x=p.x!==0?"x":"y",b=p[x];let w=[],E,S;const _={x:0,y:0},N={x:0,y:0},[,,k,A]=R_({sourceX:e.x,sourceY:e.y,targetX:r.x,targetY:r.y});if(c[x]*d[x]===-1){x==="x"?(E=a.x??h.x+(m.x-h.x)*u,S=a.y??(h.y+m.y)/2):(E=a.x??(h.x+m.x)/2,S=a.y??h.y+(m.y-h.y)*u);const T=[{x:E,y:h.y},{x:E,y:m.y}],L=[{x:h.x,y:S},{x:m.x,y:S}];c[x]===b?w=x==="x"?T:L:w=x==="x"?L:T}else{const T=[{x:h.x,y:m.y}],L=[{x:m.x,y:h.y}];if(x==="x"?w=c.x===b?L:T:w=c.y===b?T:L,t===l){const U=Math.abs(e[x]-r[x]);if(U<=o){const ee=Math.min(o-1,o-U);c[x]===b?_[x]=(h[x]>e[x]?-1:1)*ee:N[x]=(m[x]>r[x]?-1:1)*ee}}if(t!==l){const U=x==="x"?"y":"x",ee=c[x]===d[U],I=h[U]>m[U],F=h[U]=B?(E=(R.x+V.x)/2,S=w[0].y):(E=w[0].x,S=(R.y+V.y)/2)}return[[e,{x:h.x+_.x,y:h.y+_.y},...w,{x:m.x+N.x,y:m.y+N.y},r],E,S,k,A]}function mA(e,t,r,l){const a=Math.min(Hv(e,t)/2,Hv(t,r)/2,l),{x:o,y:u}=t;if(e.x===o&&o===r.x||e.y===u&&u===r.y)return`L${o} ${u}`;if(e.y===u){const h=e.x{let A="";return k>0&&kr.id===t):e[0])||null}function nm(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(l=>`${l}=${e[l]}`).join("&")}`:""}function xA(e,{id:t,defaultColor:r,defaultMarkerStart:l,defaultMarkerEnd:a}){const o=new Set;return e.reduce((u,c)=>([c.markerStart||l,c.markerEnd||a].forEach(d=>{if(d&&typeof d=="object"){const h=nm(d,t);o.has(h)||(u.push({id:h,color:d.color||r,...d}),o.add(h))}}),u),[]).sort((u,c)=>u.id.localeCompare(c.id))}const L_=1e3,yA=10,Om={nodeOrigin:[0,0],nodeExtent:$o,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},vA={...Om,checkEquality:!0};function Lm(e,t){const r={...e};for(const l in t)t[l]!==void 0&&(r[l]=t[l]);return r}function bA(e,t,r){const l=Lm(Om,r);for(const a of e.values())if(a.parentId)Bm(a,e,t,l);else{const o=Wo(a,l.nodeOrigin),u=ga(a.extent)?a.extent:l.nodeExtent,c=el(o,u,Or(a));a.internals.positionAbsolute=c}}function wA(e,t){if(!e.handles)return e.measured?t==null?void 0:t.internals.handleBounds:void 0;const r=[],l=[];for(const a of e.handles){const o={id:a.id,width:a.width??1,height:a.height??1,nodeId:e.id,x:a.x,y:a.y,position:a.position,type:a.type};a.type==="source"?r.push(o):a.type==="target"&&l.push(o)}return{source:r,target:l}}function Hm(e){return e==="manual"}function rm(e,t,r,l={}){var h,m;const a=Lm(vA,l),o={i:0},u=new Map(t),c=a!=null&&a.elevateNodesOnSelect&&!Hm(a.zIndexMode)?L_:0;let d=e.length>0;t.clear(),r.clear();for(const p of e){let x=u.get(p.id);if(a.checkEquality&&p===(x==null?void 0:x.internals.userNode))t.set(p.id,x);else{const b=Wo(p,a.nodeOrigin),w=ga(p.extent)?p.extent:a.nodeExtent,E=el(b,w,Or(p));x={...a.defaults,...p,measured:{width:(h=p.measured)==null?void 0:h.width,height:(m=p.measured)==null?void 0:m.height},internals:{positionAbsolute:E,handleBounds:wA(p,x),z:H_(p,c,a.zIndexMode),userNode:p}},t.set(p.id,x)}(x.measured===void 0||x.measured.width===void 0||x.measured.height===void 0)&&!x.hidden&&(d=!1),p.parentId&&Bm(x,t,r,l,o)}return d}function _A(e,t){if(!e.parentId)return;const r=t.get(e.parentId);r?r.set(e.id,e):t.set(e.parentId,new Map([[e.id,e]]))}function Bm(e,t,r,l,a){const{elevateNodesOnSelect:o,nodeOrigin:u,nodeExtent:c,zIndexMode:d}=Lm(Om,l),h=e.parentId,m=t.get(h);if(!m){console.warn(`Parent node ${h} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}_A(e,r),a&&!m.parentId&&m.internals.rootParentIndex===void 0&&d==="auto"&&(m.internals.rootParentIndex=++a.i,m.internals.z=m.internals.z+a.i*yA),a&&m.internals.rootParentIndex!==void 0&&(a.i=m.internals.rootParentIndex);const p=o&&!Hm(d)?L_:0,{x,y:b,z:w}=SA(e,m,u,c,p,d),{positionAbsolute:E}=e.internals,S=x!==E.x||b!==E.y;(S||w!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:S?{x,y:b}:E,z:w}})}function H_(e,t,r){const l=$n(e.zIndex)?e.zIndex:0;return Hm(r)?l:l+(e.selected?t:0)}function SA(e,t,r,l,a,o){const{x:u,y:c}=t.internals.positionAbsolute,d=Or(e),h=Wo(e,r),m=ga(e.extent)?el(h,e.extent,d):h;let p=el({x:u+m.x,y:c+m.y},l,d);e.extent==="parent"&&(p=E_(p,d,t));const x=H_(e,a,o),b=t.internals.z??0;return{x:p.x,y:p.y,z:b>=x?b+1:x}}function Im(e,t,r,l=[0,0]){var u;const a=[],o=new Map;for(const c of e){const d=t.get(c.parentId);if(!d)continue;const h=((u=o.get(c.parentId))==null?void 0:u.expandedRect)??ma(d),m=C_(h,c.rect);o.set(c.parentId,{expandedRect:m,parent:d})}return o.size>0&&o.forEach(({expandedRect:c,parent:d},h)=>{var k;const m=d.internals.positionAbsolute,p=Or(d),x=d.origin??l,b=c.x0||w>0||_||N)&&(a.push({id:h,type:"position",position:{x:d.position.x-b+_,y:d.position.y-w+N}}),(k=r.get(h))==null||k.forEach(A=>{e.some(M=>M.id===A.id)||a.push({id:A.id,type:"position",position:{x:A.position.x+b,y:A.position.y+w}})})),(p.width0){const b=Im(x,t,r,a);h.push(...b)}return{changes:h,updatedInternals:d}}async function EA({delta:e,panZoom:t,transform:r,translateExtent:l,width:a,height:o}){if(!t||!e.x&&!e.y)return Promise.resolve(!1);const u=await t.setViewportConstrained({x:r[0]+e.x,y:r[1]+e.y,zoom:r[2]},[[0,0],[a,o]],l),c=!!u&&(u.x!==r[0]||u.y!==r[1]||u.k!==r[2]);return Promise.resolve(c)}function Uv(e,t,r,l,a,o){let u=a;const c=l.get(u)||new Map;l.set(u,c.set(r,t)),u=`${a}-${e}`;const d=l.get(u)||new Map;if(l.set(u,d.set(r,t)),o){u=`${a}-${e}-${o}`;const h=l.get(u)||new Map;l.set(u,h.set(r,t))}}function B_(e,t,r){e.clear(),t.clear();for(const l of r){const{source:a,target:o,sourceHandle:u=null,targetHandle:c=null}=l,d={edgeId:l.id,source:a,target:o,sourceHandle:u,targetHandle:c},h=`${a}-${u}--${o}-${c}`,m=`${o}-${c}--${a}-${u}`;Uv("source",d,m,e,a,u),Uv("target",d,h,e,o,c),t.set(l.id,l)}}function I_(e,t){if(!e.parentId)return!1;const r=t.get(e.parentId);return r?r.selected?!0:I_(r,t):!1}function $v(e,t,r){var a;let l=e;do{if((a=l==null?void 0:l.matches)!=null&&a.call(l,t))return!0;if(l===r)return!1;l=l==null?void 0:l.parentElement}while(l);return!1}function NA(e,t,r,l){const a=new Map;for(const[o,u]of e)if((u.selected||u.id===l)&&(!u.parentId||!I_(u,e))&&(u.draggable||t&&typeof u.draggable>"u")){const c=e.get(o);c&&a.set(o,{id:o,position:c.position||{x:0,y:0},distance:{x:r.x-c.internals.positionAbsolute.x,y:r.y-c.internals.positionAbsolute.y},extent:c.extent,parentId:c.parentId,origin:c.origin,expandParent:c.expandParent,internals:{positionAbsolute:c.internals.positionAbsolute||{x:0,y:0}},measured:{width:c.measured.width??0,height:c.measured.height??0}})}return a}function _h({nodeId:e,dragItems:t,nodeLookup:r,dragging:l=!0}){var u,c,d;const a=[];for(const[h,m]of t){const p=(u=r.get(h))==null?void 0:u.internals.userNode;p&&a.push({...p,position:m.position,dragging:l})}if(!e)return[a[0],a];const o=(c=r.get(e))==null?void 0:c.internals.userNode;return[o?{...o,position:((d=t.get(e))==null?void 0:d.position)||o.position,dragging:l}:a[0],a]}function CA({dragItems:e,snapGrid:t,x:r,y:l}){const a=e.values().next().value;if(!a)return null;const o={x:r-a.distance.x,y:l-a.distance.y},u=ts(o,t);return{x:u.x-o.x,y:u.y-o.y}}function jA({onNodeMouseDown:e,getStoreItems:t,onDragStart:r,onDrag:l,onDragStop:a}){let o={x:null,y:null},u=0,c=new Map,d=!1,h={x:0,y:0},m=null,p=!1,x=null,b=!1,w=!1,E=null;function S({noDragClassName:N,handleSelector:k,domNode:A,isSelectable:M,nodeId:T,nodeClickDistance:L=0}){x=wn(A);function R({x:U,y:ee}){const{nodeLookup:I,nodeExtent:F,snapGrid:z,snapToGrid:G,nodeOrigin:Q,onNodeDrag:K,onSelectionDrag:D,onError:q,updateNodePositions:Y}=t();o={x:U,y:ee};let C=!1;const P=c.size>1,X=P&&F?em(es(c)):null,J=P&&G?CA({dragItems:c,snapGrid:z,x:U,y:ee}):null;for(const[ne,re]of c){if(!I.has(ne))continue;let se={x:U-re.distance.x,y:ee-re.distance.y};G&&(se=J?{x:Math.round(se.x+J.x),y:Math.round(se.y+J.y)}:ts(se,z));let xe=null;if(P&&F&&!re.extent&&X){const{positionAbsolute:pe}=re.internals,Se=pe.x-X.x+F[0][0],ze=pe.x+re.measured.width-X.x2+F[1][0],je=pe.y-X.y+F[0][1],ut=pe.y+re.measured.height-X.y2+F[1][1];xe=[[Se,je],[ze,ut]]}const{position:be,positionAbsolute:ye}=k_({nodeId:ne,nextPosition:se,nodeLookup:I,nodeExtent:xe||F,nodeOrigin:Q,onError:q});C=C||re.position.x!==be.x||re.position.y!==be.y,re.position=be,re.internals.positionAbsolute=ye}if(w=w||C,!!C&&(Y(c,!0),E&&(l||K||!T&&D))){const[ne,re]=_h({nodeId:T,dragItems:c,nodeLookup:I});l==null||l(E,c,ne,re),K==null||K(E,ne,re),T||D==null||D(E,re)}}async function V(){if(!m)return;const{transform:U,panBy:ee,autoPanSpeed:I,autoPanOnNodeDrag:F}=t();if(!F){d=!1,cancelAnimationFrame(u);return}const[z,G]=N_(h,m,I);(z!==0||G!==0)&&(o.x=(o.x??0)-z/U[2],o.y=(o.y??0)-G/U[2],await ee({x:z,y:G})&&R(o)),u=requestAnimationFrame(V)}function H(U){var P;const{nodeLookup:ee,multiSelectionActive:I,nodesDraggable:F,transform:z,snapGrid:G,snapToGrid:Q,selectNodesOnDrag:K,onNodeDragStart:D,onSelectionDragStart:q,unselectNodesAndEdges:Y}=t();p=!0,(!K||!M)&&!I&&T&&((P=ee.get(T))!=null&&P.selected||Y()),M&&K&&T&&(e==null||e(T));const C=Mo(U.sourceEvent,{transform:z,snapGrid:G,snapToGrid:Q,containerBounds:m});if(o=C,c=NA(ee,F,C,T),c.size>0&&(r||D||!T&&q)){const[X,J]=_h({nodeId:T,dragItems:c,nodeLookup:ee});r==null||r(U.sourceEvent,c,X,J),D==null||D(U.sourceEvent,X,J),T||q==null||q(U.sourceEvent,J)}}const B=r_().clickDistance(L).on("start",U=>{const{domNode:ee,nodeDragThreshold:I,transform:F,snapGrid:z,snapToGrid:G}=t();m=(ee==null?void 0:ee.getBoundingClientRect())||null,b=!1,w=!1,E=U.sourceEvent,I===0&&H(U),o=Mo(U.sourceEvent,{transform:F,snapGrid:z,snapToGrid:G,containerBounds:m}),h=Vn(U.sourceEvent,m)}).on("drag",U=>{const{autoPanOnNodeDrag:ee,transform:I,snapGrid:F,snapToGrid:z,nodeDragThreshold:G,nodeLookup:Q}=t(),K=Mo(U.sourceEvent,{transform:I,snapGrid:F,snapToGrid:z,containerBounds:m});if(E=U.sourceEvent,(U.sourceEvent.type==="touchmove"&&U.sourceEvent.touches.length>1||T&&!Q.has(T))&&(b=!0),!b){if(!d&&ee&&p&&(d=!0,V()),!p){const D=Vn(U.sourceEvent,m),q=D.x-h.x,Y=D.y-h.y;Math.sqrt(q*q+Y*Y)>G&&H(U)}(o.x!==K.xSnapped||o.y!==K.ySnapped)&&c&&p&&(h=Vn(U.sourceEvent,m),R(K))}}).on("end",U=>{if(!(!p||b)&&(d=!1,p=!1,cancelAnimationFrame(u),c.size>0)){const{nodeLookup:ee,updateNodePositions:I,onNodeDragStop:F,onSelectionDragStop:z}=t();if(w&&(I(c,!1),w=!1),a||F||!T&&z){const[G,Q]=_h({nodeId:T,dragItems:c,nodeLookup:ee,dragging:!1});a==null||a(U.sourceEvent,c,G,Q),F==null||F(U.sourceEvent,G,Q),T||z==null||z(U.sourceEvent,Q)}}}).filter(U=>{const ee=U.target;return!U.button&&(!N||!$v(ee,`.${N}`,A))&&(!k||$v(ee,k,A))});x.call(B)}function _(){x==null||x.on(".drag",null)}return{update:S,destroy:_}}function TA(e,t,r){const l=[],a={x:e.x-r,y:e.y-r,width:r*2,height:r*2};for(const o of t.values())Po(a,ma(o))>0&&l.push(o);return l}const AA=250;function zA(e,t,r,l){var c,d;let a=[],o=1/0;const u=TA(e,r,t+AA);for(const h of u){const m=[...((c=h.internals.handleBounds)==null?void 0:c.source)??[],...((d=h.internals.handleBounds)==null?void 0:d.target)??[]];for(const p of m){if(l.nodeId===p.nodeId&&l.type===p.type&&l.id===p.id)continue;const{x,y:b}=tl(h,p,p.position,!0),w=Math.sqrt(Math.pow(x-e.x,2)+Math.pow(b-e.y,2));w>t||(w1){const h=l.type==="source"?"target":"source";return a.find(m=>m.type===h)??a[0]}return a[0]}function q_(e,t,r,l,a,o=!1){var h,m,p;const u=l.get(e);if(!u)return null;const c=a==="strict"?(h=u.internals.handleBounds)==null?void 0:h[t]:[...((m=u.internals.handleBounds)==null?void 0:m.source)??[],...((p=u.internals.handleBounds)==null?void 0:p.target)??[]],d=(r?c==null?void 0:c.find(x=>x.id===r):c==null?void 0:c[0])??null;return d&&o?{...d,...tl(u,d,d.position,!0)}:d}function U_(e,t){return e||(t!=null&&t.classList.contains("target")?"target":t!=null&&t.classList.contains("source")?"source":null)}function MA(e,t){let r=null;return t?r=!0:e&&!t&&(r=!1),r}const $_=()=>!0;function DA(e,{connectionMode:t,connectionRadius:r,handleId:l,nodeId:a,edgeUpdaterType:o,isTarget:u,domNode:c,nodeLookup:d,lib:h,autoPanOnConnect:m,flowId:p,panBy:x,cancelConnection:b,onConnectStart:w,onConnect:E,onConnectEnd:S,isValidConnection:_=$_,onReconnectEnd:N,updateConnection:k,getTransform:A,getFromHandle:M,autoPanSpeed:T,dragThreshold:L=1,handleDomNode:R}){const V=A_(e.target);let H=0,B;const{x:U,y:ee}=Vn(e),I=U_(o,R),F=c==null?void 0:c.getBoundingClientRect();let z=!1;if(!F||!I)return;const G=q_(a,I,l,d,t);if(!G)return;let Q=Vn(e,F),K=!1,D=null,q=!1,Y=null;function C(){if(!m||!F)return;const[be,ye]=N_(Q,F,T);x({x:be,y:ye}),H=requestAnimationFrame(C)}const P={...G,nodeId:a,type:I,position:G.position},X=d.get(a);let ne={inProgress:!0,isValid:null,from:tl(X,P,ve.Left,!0),fromHandle:P,fromPosition:P.position,fromNode:X,to:Q,toHandle:null,toPosition:Av[P.position],toNode:null,pointer:Q};function re(){z=!0,k(ne),w==null||w(e,{nodeId:a,handleId:l,handleType:I})}L===0&&re();function se(be){if(!z){const{x:ut,y:nt}=Vn(be),zt=ut-U,Vt=nt-ee;if(!(zt*zt+Vt*Vt>L*L))return;re()}if(!M()||!P){xe(be);return}const ye=A();Q=Vn(be,F),B=zA(ns(Q,ye,!1,[1,1]),r,d,P),K||(C(),K=!0);const pe=V_(be,{handle:B,connectionMode:t,fromNodeId:a,fromHandleId:l,fromType:u?"target":"source",isValidConnection:_,doc:V,lib:h,flowId:p,nodeLookup:d});Y=pe.handleDomNode,D=pe.connection,q=MA(!!B,pe.isValid);const Se=d.get(a),ze=Se?tl(Se,P,ve.Left,!0):ne.from,je={...ne,from:ze,isValid:q,to:pe.toHandle&&q?gc({x:pe.toHandle.x,y:pe.toHandle.y},ye):Q,toHandle:pe.toHandle,toPosition:q&&pe.toHandle?pe.toHandle.position:Av[P.position],toNode:pe.toHandle?d.get(pe.toHandle.nodeId):null,pointer:Q};k(je),ne=je}function xe(be){if(!("touches"in be&&be.touches.length>0)){if(z){(B||Y)&&D&&q&&(E==null||E(D));const{inProgress:ye,...pe}=ne,Se={...pe,toPosition:ne.toHandle?ne.toPosition:null};S==null||S(be,Se),o&&(N==null||N(be,Se))}b(),cancelAnimationFrame(H),K=!1,q=!1,D=null,Y=null,V.removeEventListener("mousemove",se),V.removeEventListener("mouseup",xe),V.removeEventListener("touchmove",se),V.removeEventListener("touchend",xe)}}V.addEventListener("mousemove",se),V.addEventListener("mouseup",xe),V.addEventListener("touchmove",se),V.addEventListener("touchend",xe)}function V_(e,{handle:t,connectionMode:r,fromNodeId:l,fromHandleId:a,fromType:o,doc:u,lib:c,flowId:d,isValidConnection:h=$_,nodeLookup:m}){const p=o==="target",x=t?u.querySelector(`.${c}-flow__handle[data-id="${d}-${t==null?void 0:t.nodeId}-${t==null?void 0:t.id}-${t==null?void 0:t.type}"]`):null,{x:b,y:w}=Vn(e),E=u.elementFromPoint(b,w),S=E!=null&&E.classList.contains(`${c}-flow__handle`)?E:x,_={handleDomNode:S,isValid:!1,connection:null,toHandle:null};if(S){const N=U_(void 0,S),k=S.getAttribute("data-nodeid"),A=S.getAttribute("data-handleid"),M=S.classList.contains("connectable"),T=S.classList.contains("connectableend");if(!k||!N)return _;const L={source:p?k:l,sourceHandle:p?A:a,target:p?l:k,targetHandle:p?a:A};_.connection=L;const V=M&&T&&(r===ha.Strict?p&&N==="source"||!p&&N==="target":k!==l||A!==a);_.isValid=V&&h(L),_.toHandle=q_(k,N,A,m,r,!0)}return _}const im={onPointerDown:DA,isValid:V_};function RA({domNode:e,panZoom:t,getTransform:r,getViewScale:l}){const a=wn(e);function o({translateExtent:c,width:d,height:h,zoomStep:m=1,pannable:p=!0,zoomable:x=!0,inversePan:b=!1}){const w=k=>{if(k.sourceEvent.type!=="wheel"||!t)return;const A=r(),M=k.sourceEvent.ctrlKey&&Go()?10:1,T=-k.sourceEvent.deltaY*(k.sourceEvent.deltaMode===1?.05:k.sourceEvent.deltaMode?1:.002)*m,L=A[2]*Math.pow(2,T*M);t.scaleTo(L)};let E=[0,0];const S=k=>{(k.sourceEvent.type==="mousedown"||k.sourceEvent.type==="touchstart")&&(E=[k.sourceEvent.clientX??k.sourceEvent.touches[0].clientX,k.sourceEvent.clientY??k.sourceEvent.touches[0].clientY])},_=k=>{const A=r();if(k.sourceEvent.type!=="mousemove"&&k.sourceEvent.type!=="touchmove"||!t)return;const M=[k.sourceEvent.clientX??k.sourceEvent.touches[0].clientX,k.sourceEvent.clientY??k.sourceEvent.touches[0].clientY],T=[M[0]-E[0],M[1]-E[1]];E=M;const L=l()*Math.max(A[2],Math.log(A[2]))*(b?-1:1),R={x:A[0]-T[0]*L,y:A[1]-T[1]*L},V=[[0,0],[d,h]];t.setViewportConstrained({x:R.x,y:R.y,zoom:A[2]},V,c)},N=y_().on("start",S).on("zoom",p?_:null).on("zoom.wheel",x?w:null);a.call(N,{})}function u(){a.on("zoom",null)}return{update:o,destroy:u,pointer:qn}}const Lc=e=>({x:e.x,y:e.y,zoom:e.k}),Sh=({x:e,y:t,zoom:r})=>Dc.translate(e,t).scale(r),ra=(e,t)=>e.target.closest(`.${t}`),P_=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),OA=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,kh=(e,t=0,r=OA,l=()=>{})=>{const a=typeof t=="number"&&t>0;return a||l(),a?e.transition().duration(t).ease(r).on("end",l):e},G_=e=>{const t=e.ctrlKey&&Go()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function LA({zoomPanValues:e,noWheelClassName:t,d3Selection:r,d3Zoom:l,panOnScrollMode:a,panOnScrollSpeed:o,zoomOnPinch:u,onPanZoomStart:c,onPanZoom:d,onPanZoomEnd:h}){return m=>{if(ra(m,t))return m.ctrlKey&&m.preventDefault(),!1;m.preventDefault(),m.stopImmediatePropagation();const p=r.property("__zoom").k||1;if(m.ctrlKey&&u){const S=qn(m),_=G_(m),N=p*Math.pow(2,_);l.scaleTo(r,N,S,m);return}const x=m.deltaMode===1?20:1;let b=a===Zi.Vertical?0:m.deltaX*x,w=a===Zi.Horizontal?0:m.deltaY*x;!Go()&&m.shiftKey&&a!==Zi.Vertical&&(b=m.deltaY*x,w=0),l.translateBy(r,-(b/p)*o,-(w/p)*o,{internal:!0});const E=Lc(r.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?(d==null||d(m,E),e.panScrollTimeout=setTimeout(()=>{h==null||h(m,E),e.isPanScrolling=!1},150)):(e.isPanScrolling=!0,c==null||c(m,E))}}function HA({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:r}){return function(l,a){const o=l.type==="wheel",u=!t&&o&&!l.ctrlKey,c=ra(l,e);if(l.ctrlKey&&o&&c&&l.preventDefault(),u||c)return null;l.preventDefault(),r.call(this,l,a)}}function BA({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:r}){return l=>{var o,u,c;if((o=l.sourceEvent)!=null&&o.internal)return;const a=Lc(l.transform);e.mouseButton=((u=l.sourceEvent)==null?void 0:u.button)||0,e.isZoomingOrPanning=!0,e.prevViewport=a,((c=l.sourceEvent)==null?void 0:c.type)==="mousedown"&&t(!0),r&&(r==null||r(l.sourceEvent,a))}}function IA({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:r,onTransformChange:l,onPanZoom:a}){return o=>{var u,c;e.usedRightMouseButton=!!(r&&P_(t,e.mouseButton??0)),(u=o.sourceEvent)!=null&&u.sync||l([o.transform.x,o.transform.y,o.transform.k]),a&&!((c=o.sourceEvent)!=null&&c.internal)&&(a==null||a(o.sourceEvent,Lc(o.transform)))}}function qA({zoomPanValues:e,panOnDrag:t,panOnScroll:r,onDraggingChange:l,onPanZoomEnd:a,onPaneContextMenu:o}){return u=>{var c;if(!((c=u.sourceEvent)!=null&&c.internal)&&(e.isZoomingOrPanning=!1,o&&P_(t,e.mouseButton??0)&&!e.usedRightMouseButton&&u.sourceEvent&&o(u.sourceEvent),e.usedRightMouseButton=!1,l(!1),a)){const d=Lc(u.transform);e.prevViewport=d,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{a==null||a(u.sourceEvent,d)},r?150:0)}}}function UA({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:r,panOnDrag:l,panOnScroll:a,zoomOnDoubleClick:o,userSelectionActive:u,noWheelClassName:c,noPanClassName:d,lib:h,connectionInProgress:m}){return p=>{var S;const x=e||t,b=r&&p.ctrlKey,w=p.type==="wheel";if(p.button===1&&p.type==="mousedown"&&(ra(p,`${h}-flow__node`)||ra(p,`${h}-flow__edge`)))return!0;if(!l&&!x&&!a&&!o&&!r||u||m&&!w||ra(p,c)&&w||ra(p,d)&&(!w||a&&w&&!e)||!r&&p.ctrlKey&&w)return!1;if(!r&&p.type==="touchstart"&&((S=p.touches)==null?void 0:S.length)>1)return p.preventDefault(),!1;if(!x&&!a&&!b&&w||!l&&(p.type==="mousedown"||p.type==="touchstart")||Array.isArray(l)&&!l.includes(p.button)&&p.type==="mousedown")return!1;const E=Array.isArray(l)&&l.includes(p.button)||!p.button||p.button<=1;return(!p.ctrlKey||w)&&E}}function $A({domNode:e,minZoom:t,maxZoom:r,translateExtent:l,viewport:a,onPanZoom:o,onPanZoomStart:u,onPanZoomEnd:c,onDraggingChange:d}){const h={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},m=e.getBoundingClientRect(),p=y_().scaleExtent([t,r]).translateExtent(l),x=wn(e).call(p);N({x:a.x,y:a.y,zoom:pa(a.zoom,t,r)},[[0,0],[m.width,m.height]],l);const b=x.on("wheel.zoom"),w=x.on("dblclick.zoom");p.wheelDelta(G_);function E(B,U){return x?new Promise(ee=>{p==null||p.interpolate((U==null?void 0:U.interpolate)==="linear"?zo:Ju).transform(kh(x,U==null?void 0:U.duration,U==null?void 0:U.ease,()=>ee(!0)),B)}):Promise.resolve(!1)}function S({noWheelClassName:B,noPanClassName:U,onPaneContextMenu:ee,userSelectionActive:I,panOnScroll:F,panOnDrag:z,panOnScrollMode:G,panOnScrollSpeed:Q,preventScrolling:K,zoomOnPinch:D,zoomOnScroll:q,zoomOnDoubleClick:Y,zoomActivationKeyPressed:C,lib:P,onTransformChange:X,connectionInProgress:J,paneClickDistance:ne,selectionOnDrag:re}){I&&!h.isZoomingOrPanning&&_();const se=F&&!C&&!I;p.clickDistance(re?1/0:!$n(ne)||ne<0?0:ne);const xe=se?LA({zoomPanValues:h,noWheelClassName:B,d3Selection:x,d3Zoom:p,panOnScrollMode:G,panOnScrollSpeed:Q,zoomOnPinch:D,onPanZoomStart:u,onPanZoom:o,onPanZoomEnd:c}):HA({noWheelClassName:B,preventScrolling:K,d3ZoomHandler:b});if(x.on("wheel.zoom",xe,{passive:!1}),!I){const ye=BA({zoomPanValues:h,onDraggingChange:d,onPanZoomStart:u});p.on("start",ye);const pe=IA({zoomPanValues:h,panOnDrag:z,onPaneContextMenu:!!ee,onPanZoom:o,onTransformChange:X});p.on("zoom",pe);const Se=qA({zoomPanValues:h,panOnDrag:z,panOnScroll:F,onPaneContextMenu:ee,onPanZoomEnd:c,onDraggingChange:d});p.on("end",Se)}const be=UA({zoomActivationKeyPressed:C,panOnDrag:z,zoomOnScroll:q,panOnScroll:F,zoomOnDoubleClick:Y,zoomOnPinch:D,userSelectionActive:I,noPanClassName:U,noWheelClassName:B,lib:P,connectionInProgress:J});p.filter(be),Y?x.on("dblclick.zoom",w):x.on("dblclick.zoom",null)}function _(){p.on("zoom",null)}async function N(B,U,ee){const I=Sh(B),F=p==null?void 0:p.constrain()(I,U,ee);return F&&await E(F),new Promise(z=>z(F))}async function k(B,U){const ee=Sh(B);return await E(ee,U),new Promise(I=>I(ee))}function A(B){if(x){const U=Sh(B),ee=x.property("__zoom");(ee.k!==B.zoom||ee.x!==B.x||ee.y!==B.y)&&(p==null||p.transform(x,U,null,{sync:!0}))}}function M(){const B=x?x_(x.node()):{x:0,y:0,k:1};return{x:B.x,y:B.y,zoom:B.k}}function T(B,U){return x?new Promise(ee=>{p==null||p.interpolate((U==null?void 0:U.interpolate)==="linear"?zo:Ju).scaleTo(kh(x,U==null?void 0:U.duration,U==null?void 0:U.ease,()=>ee(!0)),B)}):Promise.resolve(!1)}function L(B,U){return x?new Promise(ee=>{p==null||p.interpolate((U==null?void 0:U.interpolate)==="linear"?zo:Ju).scaleBy(kh(x,U==null?void 0:U.duration,U==null?void 0:U.ease,()=>ee(!0)),B)}):Promise.resolve(!1)}function R(B){p==null||p.scaleExtent(B)}function V(B){p==null||p.translateExtent(B)}function H(B){const U=!$n(B)||B<0?0:B;p==null||p.clickDistance(U)}return{update:S,destroy:_,setViewport:k,setViewportConstrained:N,getViewport:M,scaleTo:T,scaleBy:L,setScaleExtent:R,setTranslateExtent:V,syncViewport:A,setClickDistance:H}}var xa;(function(e){e.Line="line",e.Handle="handle"})(xa||(xa={}));function VA({width:e,prevWidth:t,height:r,prevHeight:l,affectsX:a,affectsY:o}){const u=e-t,c=r-l,d=[u>0?1:u<0?-1:0,c>0?1:c<0?-1:0];return u&&a&&(d[0]=d[0]*-1),c&&o&&(d[1]=d[1]*-1),d}function Vv(e){const t=e.includes("right")||e.includes("left"),r=e.includes("bottom")||e.includes("top"),l=e.includes("left"),a=e.includes("top");return{isHorizontal:t,isVertical:r,affectsX:l,affectsY:a}}function hi(e,t){return Math.max(0,t-e)}function pi(e,t){return Math.max(0,e-t)}function $u(e,t,r){return Math.max(0,t-e,e-r)}function Pv(e,t){return e?!t:t}function PA(e,t,r,l,a,o,u,c){let{affectsX:d,affectsY:h}=t;const{isHorizontal:m,isVertical:p}=t,x=m&&p,{xSnapped:b,ySnapped:w}=r,{minWidth:E,maxWidth:S,minHeight:_,maxHeight:N}=l,{x:k,y:A,width:M,height:T,aspectRatio:L}=e;let R=Math.floor(m?b-e.pointerX:0),V=Math.floor(p?w-e.pointerY:0);const H=M+(d?-R:R),B=T+(h?-V:V),U=-o[0]*M,ee=-o[1]*T;let I=$u(H,E,S),F=$u(B,_,N);if(u){let Q=0,K=0;d&&R<0?Q=hi(k+R+U,u[0][0]):!d&&R>0&&(Q=pi(k+H+U,u[1][0])),h&&V<0?K=hi(A+V+ee,u[0][1]):!h&&V>0&&(K=pi(A+B+ee,u[1][1])),I=Math.max(I,Q),F=Math.max(F,K)}if(c){let Q=0,K=0;d&&R>0?Q=pi(k+R,c[0][0]):!d&&R<0&&(Q=hi(k+H,c[1][0])),h&&V>0?K=pi(A+V,c[0][1]):!h&&V<0&&(K=hi(A+B,c[1][1])),I=Math.max(I,Q),F=Math.max(F,K)}if(a){if(m){const Q=$u(H/L,_,N)*L;if(I=Math.max(I,Q),u){let K=0;!d&&!h||d&&!h&&x?K=pi(A+ee+H/L,u[1][1])*L:K=hi(A+ee+(d?R:-R)/L,u[0][1])*L,I=Math.max(I,K)}if(c){let K=0;!d&&!h||d&&!h&&x?K=hi(A+H/L,c[1][1])*L:K=pi(A+(d?R:-R)/L,c[0][1])*L,I=Math.max(I,K)}}if(p){const Q=$u(B*L,E,S)/L;if(F=Math.max(F,Q),u){let K=0;!d&&!h||h&&!d&&x?K=pi(k+B*L+U,u[1][0])/L:K=hi(k+(h?V:-V)*L+U,u[0][0])/L,F=Math.max(F,K)}if(c){let K=0;!d&&!h||h&&!d&&x?K=hi(k+B*L,c[1][0])/L:K=pi(k+(h?V:-V)*L,c[0][0])/L,F=Math.max(F,K)}}}V=V+(V<0?F:-F),R=R+(R<0?I:-I),a&&(x?H>B*L?V=(Pv(d,h)?-R:R)/L:R=(Pv(d,h)?-V:V)*L:m?(V=R/L,h=d):(R=V*L,d=h));const z=d?k+R:k,G=h?A+V:A;return{width:M+(d?-R:R),height:T+(h?-V:V),x:o[0]*R*(d?-1:1)+z,y:o[1]*V*(h?-1:1)+G}}const F_={width:0,height:0,x:0,y:0},GA={...F_,pointerX:0,pointerY:0,aspectRatio:1};function FA(e){return[[0,0],[e.measured.width,e.measured.height]]}function YA(e,t,r){const l=t.position.x+e.position.x,a=t.position.y+e.position.y,o=e.measured.width??0,u=e.measured.height??0,c=r[0]*o,d=r[1]*u;return[[l-c,a-d],[l+o-c,a+u-d]]}function XA({domNode:e,nodeId:t,getStoreItems:r,onChange:l,onEnd:a}){const o=wn(e);let u={controlDirection:Vv("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function c({controlPosition:h,boundaries:m,keepAspectRatio:p,resizeDirection:x,onResizeStart:b,onResize:w,onResizeEnd:E,shouldResize:S}){let _={...F_},N={...GA};u={boundaries:m,resizeDirection:x,keepAspectRatio:p,controlDirection:Vv(h)};let k,A=null,M=[],T,L,R,V=!1;const H=r_().on("start",B=>{const{nodeLookup:U,transform:ee,snapGrid:I,snapToGrid:F,nodeOrigin:z,paneDomNode:G}=r();if(k=U.get(t),!k)return;A=(G==null?void 0:G.getBoundingClientRect())??null;const{xSnapped:Q,ySnapped:K}=Mo(B.sourceEvent,{transform:ee,snapGrid:I,snapToGrid:F,containerBounds:A});_={width:k.measured.width??0,height:k.measured.height??0,x:k.position.x??0,y:k.position.y??0},N={..._,pointerX:Q,pointerY:K,aspectRatio:_.width/_.height},T=void 0,k.parentId&&(k.extent==="parent"||k.expandParent)&&(T=U.get(k.parentId),L=T&&k.extent==="parent"?FA(T):void 0),M=[],R=void 0;for(const[D,q]of U)if(q.parentId===t&&(M.push({id:D,position:{...q.position},extent:q.extent}),q.extent==="parent"||q.expandParent)){const Y=YA(q,k,q.origin??z);R?R=[[Math.min(Y[0][0],R[0][0]),Math.min(Y[0][1],R[0][1])],[Math.max(Y[1][0],R[1][0]),Math.max(Y[1][1],R[1][1])]]:R=Y}b==null||b(B,{..._})}).on("drag",B=>{const{transform:U,snapGrid:ee,snapToGrid:I,nodeOrigin:F}=r(),z=Mo(B.sourceEvent,{transform:U,snapGrid:ee,snapToGrid:I,containerBounds:A}),G=[];if(!k)return;const{x:Q,y:K,width:D,height:q}=_,Y={},C=k.origin??F,{width:P,height:X,x:J,y:ne}=PA(N,u.controlDirection,z,u.boundaries,u.keepAspectRatio,C,L,R),re=P!==D,se=X!==q,xe=J!==Q&&re,be=ne!==K&&se;if(!xe&&!be&&!re&&!se)return;if((xe||be||C[0]===1||C[1]===1)&&(Y.x=xe?J:_.x,Y.y=be?ne:_.y,_.x=Y.x,_.y=Y.y,M.length>0)){const ze=J-Q,je=ne-K;for(const ut of M)ut.position={x:ut.position.x-ze+C[0]*(P-D),y:ut.position.y-je+C[1]*(X-q)},G.push(ut)}if((re||se)&&(Y.width=re&&(!u.resizeDirection||u.resizeDirection==="horizontal")?P:_.width,Y.height=se&&(!u.resizeDirection||u.resizeDirection==="vertical")?X:_.height,_.width=Y.width,_.height=Y.height),T&&k.expandParent){const ze=C[0]*(Y.width??0);Y.x&&Y.x{V&&(E==null||E(B,{..._}),a==null||a({..._}),V=!1)});o.call(H)}function d(){o.on(".drag",null)}return{update:c,destroy:d}}var Eh={exports:{}},Nh={},Ch={exports:{}},jh={};/** - * @license React - * use-sync-external-store-shim.production.js - * - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */var Gv;function QA(){if(Gv)return jh;Gv=1;var e=Zo();function t(p,x){return p===x&&(p!==0||1/p===1/x)||p!==p&&x!==x}var r=typeof Object.is=="function"?Object.is:t,l=e.useState,a=e.useEffect,o=e.useLayoutEffect,u=e.useDebugValue;function c(p,x){var b=x(),w=l({inst:{value:b,getSnapshot:x}}),E=w[0].inst,S=w[1];return o(function(){E.value=b,E.getSnapshot=x,d(E)&&S({inst:E})},[p,b,x]),a(function(){return d(E)&&S({inst:E}),p(function(){d(E)&&S({inst:E})})},[p]),u(b),b}function d(p){var x=p.getSnapshot;p=p.value;try{var b=x();return!r(p,b)}catch{return!0}}function h(p,x){return x()}var m=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?h:c;return jh.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:m,jh}var Fv;function ZA(){return Fv||(Fv=1,Ch.exports=QA()),Ch.exports}/** - * @license React - * use-sync-external-store-shim/with-selector.production.js - * - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */var Yv;function KA(){if(Yv)return Nh;Yv=1;var e=Zo(),t=ZA();function r(h,m){return h===m&&(h!==0||1/h===1/m)||h!==h&&m!==m}var l=typeof Object.is=="function"?Object.is:r,a=t.useSyncExternalStore,o=e.useRef,u=e.useEffect,c=e.useMemo,d=e.useDebugValue;return Nh.useSyncExternalStoreWithSelector=function(h,m,p,x,b){var w=o(null);if(w.current===null){var E={hasValue:!1,value:null};w.current=E}else E=w.current;w=c(function(){function _(T){if(!N){if(N=!0,k=T,T=x(T),b!==void 0&&E.hasValue){var L=E.value;if(b(L,T))return A=L}return A=T}if(L=A,l(k,T))return L;var R=x(T);return b!==void 0&&b(L,R)?(k=T,L):(k=T,A=R)}var N=!1,k,A,M=p===void 0?null:p;return[function(){return _(m())},M===null?void 0:function(){return _(M())}]},[m,p,x,b]);var S=a(h,w[0],w[1]);return u(function(){E.hasValue=!0,E.value=S},[S]),d(S),S},Nh}var Xv;function JA(){return Xv||(Xv=1,Eh.exports=KA()),Eh.exports}var WA=JA();const ez=Qo(WA),tz={},Qv=e=>{let t;const r=new Set,l=(m,p)=>{const x=typeof m=="function"?m(t):m;if(!Object.is(x,t)){const b=t;t=p??(typeof x!="object"||x===null)?x:Object.assign({},t,x),r.forEach(w=>w(t,b))}},a=()=>t,d={setState:l,getState:a,getInitialState:()=>h,subscribe:m=>(r.add(m),()=>r.delete(m)),destroy:()=>{(tz?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),r.clear()}},h=t=e(l,a,d);return d},nz=e=>e?Qv(e):Qv,{useDebugValue:rz}=ta,{useSyncExternalStoreWithSelector:iz}=ez,lz=e=>e;function Y_(e,t=lz,r){const l=iz(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,r);return rz(l),l}const Zv=(e,t)=>{const r=nz(e),l=(a,o=t)=>Y_(r,a,o);return Object.assign(l,r),l},az=(e,t)=>e?Zv(e,t):Zv;function pt(e,t){if(Object.is(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(const[l,a]of e)if(!Object.is(a,t.get(l)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const l of e)if(!t.has(l))return!1;return!0}const r=Object.keys(e);if(r.length!==Object.keys(t).length)return!1;for(const l of r)if(!Object.prototype.hasOwnProperty.call(t,l)||!Object.is(e[l],t[l]))return!1;return!0}var oz=pw();const Hc=$.createContext(null),sz=Hc.Provider,X_=lr.error001();function Ye(e,t){const r=$.useContext(Hc);if(r===null)throw new Error(X_);return Y_(r,e,t)}function mt(){const e=$.useContext(Hc);if(e===null)throw new Error(X_);return $.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const Kv={display:"none"},uz={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},Q_="react-flow__node-desc",Z_="react-flow__edge-desc",cz="react-flow__aria-live",fz=e=>e.ariaLiveMessage,dz=e=>e.ariaLabelConfig;function hz({rfId:e}){const t=Ye(fz);return y.jsx("div",{id:`${cz}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:uz,children:t})}function pz({rfId:e,disableKeyboardA11y:t}){const r=Ye(dz);return y.jsxs(y.Fragment,{children:[y.jsx("div",{id:`${Q_}-${e}`,style:Kv,children:t?r["node.a11yDescription.default"]:r["node.a11yDescription.keyboardDisabled"]}),y.jsx("div",{id:`${Z_}-${e}`,style:Kv,children:r["edge.a11yDescription.default"]}),!t&&y.jsx(hz,{rfId:e})]})}const Bc=$.forwardRef(({position:e="top-left",children:t,className:r,style:l,...a},o)=>{const u=`${e}`.split("-");return y.jsx("div",{className:At(["react-flow__panel",r,...u]),style:l,ref:o,...a,children:t})});Bc.displayName="Panel";function mz({proOptions:e,position:t="bottom-right"}){return e!=null&&e.hideAttribution?null:y.jsx(Bc,{position:t,className:"react-flow__attribution","data-message":"Please only hide this attribution when you are subscribed to React Flow Pro: https://pro.reactflow.dev",children:y.jsx("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const gz=e=>{const t=[],r=[];for(const[,l]of e.nodeLookup)l.selected&&t.push(l.internals.userNode);for(const[,l]of e.edgeLookup)l.selected&&r.push(l);return{selectedNodes:t,selectedEdges:r}},Vu=e=>e.id;function xz(e,t){return pt(e.selectedNodes.map(Vu),t.selectedNodes.map(Vu))&&pt(e.selectedEdges.map(Vu),t.selectedEdges.map(Vu))}function yz({onSelectionChange:e}){const t=mt(),{selectedNodes:r,selectedEdges:l}=Ye(gz,xz);return $.useEffect(()=>{const a={nodes:r,edges:l};e==null||e(a),t.getState().onSelectionChangeHandlers.forEach(o=>o(a))},[r,l,e]),null}const vz=e=>!!e.onSelectionChangeHandlers;function bz({onSelectionChange:e}){const t=Ye(vz);return e||t?y.jsx(yz,{onSelectionChange:e}):null}const K_=[0,0],wz={x:0,y:0,zoom:1},_z=["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"],Jv=[..._z,"rfId"],Sz=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}),Wv={translateExtent:$o,nodeOrigin:K_,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function kz(e){const{setNodes:t,setEdges:r,setMinZoom:l,setMaxZoom:a,setTranslateExtent:o,setNodeExtent:u,reset:c,setDefaultNodesAndEdges:d}=Ye(Sz,pt),h=mt();$.useEffect(()=>(d(e.defaultNodes,e.defaultEdges),()=>{m.current=Wv,c()}),[]);const m=$.useRef(Wv);return $.useEffect(()=>{for(const p of Jv){const x=e[p],b=m.current[p];x!==b&&(typeof e[p]>"u"||(p==="nodes"?t(x):p==="edges"?r(x):p==="minZoom"?l(x):p==="maxZoom"?a(x):p==="translateExtent"?o(x):p==="nodeExtent"?u(x):p==="ariaLabelConfig"?h.setState({ariaLabelConfig:aA(x)}):p==="fitView"?h.setState({fitViewQueued:x}):p==="fitViewOptions"?h.setState({fitViewOptions:x}):h.setState({[p]:x})))}m.current=e},Jv.map(p=>e[p])),null}function eb(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function Ez(e){var l;const[t,r]=$.useState(e==="system"?null:e);return $.useEffect(()=>{if(e!=="system"){r(e);return}const a=eb(),o=()=>r(a!=null&&a.matches?"dark":"light");return o(),a==null||a.addEventListener("change",o),()=>{a==null||a.removeEventListener("change",o)}},[e]),t!==null?t:(l=eb())!=null&&l.matches?"dark":"light"}const tb=typeof document<"u"?document:null;function Fo(e=null,t={target:tb,actInsideInputWithModifier:!0}){const[r,l]=$.useState(!1),a=$.useRef(!1),o=$.useRef(new Set([])),[u,c]=$.useMemo(()=>{if(e!==null){const h=(Array.isArray(e)?e:[e]).filter(p=>typeof p=="string").map(p=>p.replace("+",` -`).replace(` - -`,` -+`).split(` -`)),m=h.reduce((p,x)=>p.concat(...x),[]);return[h,m]}return[[],[]]},[e]);return $.useEffect(()=>{const d=(t==null?void 0:t.target)??tb,h=(t==null?void 0:t.actInsideInputWithModifier)??!0;if(e!==null){const m=b=>{var S,_;if(a.current=b.ctrlKey||b.metaKey||b.shiftKey||b.altKey,(!a.current||a.current&&!h)&&z_(b))return!1;const E=rb(b.code,c);if(o.current.add(b[E]),nb(u,o.current,!1)){const N=((_=(S=b.composedPath)==null?void 0:S.call(b))==null?void 0:_[0])||b.target,k=(N==null?void 0:N.nodeName)==="BUTTON"||(N==null?void 0:N.nodeName)==="A";t.preventDefault!==!1&&(a.current||!k)&&b.preventDefault(),l(!0)}},p=b=>{const w=rb(b.code,c);nb(u,o.current,!0)?(l(!1),o.current.clear()):o.current.delete(b[w]),b.key==="Meta"&&o.current.clear(),a.current=!1},x=()=>{o.current.clear(),l(!1)};return d==null||d.addEventListener("keydown",m),d==null||d.addEventListener("keyup",p),window.addEventListener("blur",x),window.addEventListener("contextmenu",x),()=>{d==null||d.removeEventListener("keydown",m),d==null||d.removeEventListener("keyup",p),window.removeEventListener("blur",x),window.removeEventListener("contextmenu",x)}}},[e,l]),r}function nb(e,t,r){return e.filter(l=>r||l.length===t.size).some(l=>l.every(a=>t.has(a)))}function rb(e,t){return t.includes(e)?"code":"key"}const Nz=()=>{const e=mt();return $.useMemo(()=>({zoomIn:t=>{const{panZoom:r}=e.getState();return r?r.scaleBy(1.2,{duration:t==null?void 0:t.duration}):Promise.resolve(!1)},zoomOut:t=>{const{panZoom:r}=e.getState();return r?r.scaleBy(1/1.2,{duration:t==null?void 0:t.duration}):Promise.resolve(!1)},zoomTo:(t,r)=>{const{panZoom:l}=e.getState();return l?l.scaleTo(t,{duration:r==null?void 0:r.duration}):Promise.resolve(!1)},getZoom:()=>e.getState().transform[2],setViewport:async(t,r)=>{const{transform:[l,a,o],panZoom:u}=e.getState();return u?(await u.setViewport({x:t.x??l,y:t.y??a,zoom:t.zoom??o},r),Promise.resolve(!0)):Promise.resolve(!1)},getViewport:()=>{const[t,r,l]=e.getState().transform;return{x:t,y:r,zoom:l}},setCenter:async(t,r,l)=>e.getState().setCenter(t,r,l),fitBounds:async(t,r)=>{const{width:l,height:a,minZoom:o,maxZoom:u,panZoom:c}=e.getState(),d=Mm(t,l,a,o,u,(r==null?void 0:r.padding)??.1);return c?(await c.setViewport(d,{duration:r==null?void 0:r.duration,ease:r==null?void 0:r.ease,interpolate:r==null?void 0:r.interpolate}),Promise.resolve(!0)):Promise.resolve(!1)},screenToFlowPosition:(t,r={})=>{const{transform:l,snapGrid:a,snapToGrid:o,domNode:u}=e.getState();if(!u)return t;const{x:c,y:d}=u.getBoundingClientRect(),h={x:t.x-c,y:t.y-d},m=r.snapGrid??a,p=r.snapToGrid??o;return ns(h,l,p,m)},flowToScreenPosition:t=>{const{transform:r,domNode:l}=e.getState();if(!l)return t;const{x:a,y:o}=l.getBoundingClientRect(),u=gc(t,r);return{x:u.x+a,y:u.y+o}}}),[])};function J_(e,t){const r=[],l=new Map,a=[];for(const o of e)if(o.type==="add"){a.push(o);continue}else if(o.type==="remove"||o.type==="replace")l.set(o.id,[o]);else{const u=l.get(o.id);u?u.push(o):l.set(o.id,[o])}for(const o of t){const u=l.get(o.id);if(!u){r.push(o);continue}if(u[0].type==="remove")continue;if(u[0].type==="replace"){r.push({...u[0].item});continue}const c={...o};for(const d of u)Cz(d,c);r.push(c)}return a.length&&a.forEach(o=>{o.index!==void 0?r.splice(o.index,0,{...o.item}):r.push({...o.item})}),r}function Cz(e,t){switch(e.type){case"select":{t.selected=e.selected;break}case"position":{typeof e.position<"u"&&(t.position=e.position),typeof e.dragging<"u"&&(t.dragging=e.dragging);break}case"dimensions":{typeof e.dimensions<"u"&&(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);break}}}function W_(e,t){return J_(e,t)}function eS(e,t){return J_(e,t)}function Pi(e,t){return{id:e,type:"select",selected:t}}function ia(e,t=new Set,r=!1){const l=[];for(const[a,o]of e){const u=t.has(a);!(o.selected===void 0&&!u)&&o.selected!==u&&(r&&(o.selected=u),l.push(Pi(o.id,u)))}return l}function ib({items:e=[],lookup:t}){var a;const r=[],l=new Map(e.map(o=>[o.id,o]));for(const[o,u]of e.entries()){const c=t.get(u.id),d=((a=c==null?void 0:c.internals)==null?void 0:a.userNode)??c;d!==void 0&&d!==u&&r.push({id:u.id,item:u,type:"replace"}),d===void 0&&r.push({item:u,type:"add",index:o})}for(const[o]of t)l.get(o)===void 0&&r.push({id:o,type:"remove"});return r}function lb(e){return{id:e.id,type:"remove"}}const ab=e=>ZT(e),jz=e=>S_(e);function tS(e){return $.forwardRef(e)}const Tz=typeof window<"u"?$.useLayoutEffect:$.useEffect;function ob(e){const[t,r]=$.useState(BigInt(0)),[l]=$.useState(()=>Az(()=>r(a=>a+BigInt(1))));return Tz(()=>{const a=l.get();a.length&&(e(a),l.reset())},[t]),l}function Az(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:r=>{t.push(r),e()}}}const nS=$.createContext(null);function zz({children:e}){const t=mt(),r=$.useCallback(c=>{const{nodes:d=[],setNodes:h,hasDefaultNodes:m,onNodesChange:p,nodeLookup:x,fitViewQueued:b,onNodesChangeMiddlewareMap:w}=t.getState();let E=d;for(const _ of c)E=typeof _=="function"?_(E):_;let S=ib({items:E,lookup:x});for(const _ of w.values())S=_(S);m&&h(E),S.length>0?p==null||p(S):b&&window.requestAnimationFrame(()=>{const{fitViewQueued:_,nodes:N,setNodes:k}=t.getState();_&&k(N)})},[]),l=ob(r),a=$.useCallback(c=>{const{edges:d=[],setEdges:h,hasDefaultEdges:m,onEdgesChange:p,edgeLookup:x}=t.getState();let b=d;for(const w of c)b=typeof w=="function"?w(b):w;m?h(b):p&&p(ib({items:b,lookup:x}))},[]),o=ob(a),u=$.useMemo(()=>({nodeQueue:l,edgeQueue:o}),[]);return y.jsx(nS.Provider,{value:u,children:e})}function Mz(){const e=$.useContext(nS);if(!e)throw new Error("useBatchContext must be used within a BatchProvider");return e}const Dz=e=>!!e.panZoom;function al(){const e=Nz(),t=mt(),r=Mz(),l=Ye(Dz),a=$.useMemo(()=>{const o=p=>t.getState().nodeLookup.get(p),u=p=>{r.nodeQueue.push(p)},c=p=>{r.edgeQueue.push(p)},d=p=>{var _,N;const{nodeLookup:x,nodeOrigin:b}=t.getState(),w=ab(p)?p:x.get(p.id),E=w.parentId?T_(w.position,w.measured,w.parentId,x,b):w.position,S={...w,position:E,width:((_=w.measured)==null?void 0:_.width)??w.width,height:((N=w.measured)==null?void 0:N.height)??w.height};return ma(S)},h=(p,x,b={replace:!1})=>{u(w=>w.map(E=>{if(E.id===p){const S=typeof x=="function"?x(E):x;return b.replace&&ab(S)?S:{...E,...S}}return E}))},m=(p,x,b={replace:!1})=>{c(w=>w.map(E=>{if(E.id===p){const S=typeof x=="function"?x(E):x;return b.replace&&jz(S)?S:{...E,...S}}return E}))};return{getNodes:()=>t.getState().nodes.map(p=>({...p})),getNode:p=>{var x;return(x=o(p))==null?void 0:x.internals.userNode},getInternalNode:o,getEdges:()=>{const{edges:p=[]}=t.getState();return p.map(x=>({...x}))},getEdge:p=>t.getState().edgeLookup.get(p),setNodes:u,setEdges:c,addNodes:p=>{const x=Array.isArray(p)?p:[p];r.nodeQueue.push(b=>[...b,...x])},addEdges:p=>{const x=Array.isArray(p)?p:[p];r.edgeQueue.push(b=>[...b,...x])},toObject:()=>{const{nodes:p=[],edges:x=[],transform:b}=t.getState(),[w,E,S]=b;return{nodes:p.map(_=>({..._})),edges:x.map(_=>({..._})),viewport:{x:w,y:E,zoom:S}}},deleteElements:async({nodes:p=[],edges:x=[]})=>{const{nodes:b,edges:w,onNodesDelete:E,onEdgesDelete:S,triggerNodeChanges:_,triggerEdgeChanges:N,onDelete:k,onBeforeDelete:A}=t.getState(),{nodes:M,edges:T}=await tA({nodesToRemove:p,edgesToRemove:x,nodes:b,edges:w,onBeforeDelete:A}),L=T.length>0,R=M.length>0;if(L){const V=T.map(lb);S==null||S(T),N(V)}if(R){const V=M.map(lb);E==null||E(M),_(V)}return(R||L)&&(k==null||k({nodes:M,edges:T})),{deletedNodes:M,deletedEdges:T}},getIntersectingNodes:(p,x=!0,b)=>{const w=Mv(p),E=w?p:d(p),S=b!==void 0;return E?(b||t.getState().nodes).filter(_=>{const N=t.getState().nodeLookup.get(_.id);if(N&&!w&&(_.id===p.id||!N.internals.positionAbsolute))return!1;const k=ma(S?_:N),A=Po(k,E);return x&&A>0||A>=k.width*k.height||A>=E.width*E.height}):[]},isNodeIntersecting:(p,x,b=!0)=>{const E=Mv(p)?p:d(p);if(!E)return!1;const S=Po(E,x);return b&&S>0||S>=x.width*x.height||S>=E.width*E.height},updateNode:h,updateNodeData:(p,x,b={replace:!1})=>{h(p,w=>{const E=typeof x=="function"?x(w):x;return b.replace?{...w,data:E}:{...w,data:{...w.data,...E}}},b)},updateEdge:m,updateEdgeData:(p,x,b={replace:!1})=>{m(p,w=>{const E=typeof x=="function"?x(w):x;return b.replace?{...w,data:E}:{...w,data:{...w.data,...E}}},b)},getNodesBounds:p=>{const{nodeLookup:x,nodeOrigin:b}=t.getState();return KT(p,{nodeLookup:x,nodeOrigin:b})},getHandleConnections:({type:p,id:x,nodeId:b})=>{var w;return Array.from(((w=t.getState().connectionLookup.get(`${b}-${p}${x?`-${x}`:""}`))==null?void 0:w.values())??[])},getNodeConnections:({type:p,handleId:x,nodeId:b})=>{var w;return Array.from(((w=t.getState().connectionLookup.get(`${b}${p?x?`-${p}-${x}`:`-${p}`:""}`))==null?void 0:w.values())??[])},fitView:async p=>{const x=t.getState().fitViewResolver??lA();return t.setState({fitViewQueued:!0,fitViewOptions:p,fitViewResolver:x}),r.nodeQueue.push(b=>[...b]),x.promise}}},[]);return $.useMemo(()=>({...a,...e,viewportInitialized:l}),[l])}const sb=e=>e.selected,Rz=typeof window<"u"?window:void 0;function Oz({deleteKeyCode:e,multiSelectionKeyCode:t}){const r=mt(),{deleteElements:l}=al(),a=Fo(e,{actInsideInputWithModifier:!1}),o=Fo(t,{target:Rz});$.useEffect(()=>{if(a){const{edges:u,nodes:c}=r.getState();l({nodes:c.filter(sb),edges:u.filter(sb)}),r.setState({nodesSelectionActive:!1})}},[a]),$.useEffect(()=>{r.setState({multiSelectionActive:o})},[o])}function Lz(e){const t=mt();$.useEffect(()=>{const r=()=>{var a,o,u,c;if(!e.current||!(((o=(a=e.current).checkVisibility)==null?void 0:o.call(a))??!0))return!1;const l=Dm(e.current);(l.height===0||l.width===0)&&((c=(u=t.getState()).onError)==null||c.call(u,"004",lr.error004())),t.setState({width:l.width||500,height:l.height||500})};if(e.current){r(),window.addEventListener("resize",r);const l=new ResizeObserver(()=>r());return l.observe(e.current),()=>{window.removeEventListener("resize",r),l&&e.current&&l.unobserve(e.current)}}},[])}const Ic={position:"absolute",width:"100%",height:"100%",top:0,left:0},Hz=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function Bz({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:r=!0,panOnScroll:l=!1,panOnScrollSpeed:a=.5,panOnScrollMode:o=Zi.Free,zoomOnDoubleClick:u=!0,panOnDrag:c=!0,defaultViewport:d,translateExtent:h,minZoom:m,maxZoom:p,zoomActivationKeyCode:x,preventScrolling:b=!0,children:w,noWheelClassName:E,noPanClassName:S,onViewportChange:_,isControlledViewport:N,paneClickDistance:k,selectionOnDrag:A}){const M=mt(),T=$.useRef(null),{userSelectionActive:L,lib:R,connectionInProgress:V}=Ye(Hz,pt),H=Fo(x),B=$.useRef();Lz(T);const U=$.useCallback(ee=>{_==null||_({x:ee[0],y:ee[1],zoom:ee[2]}),N||M.setState({transform:ee})},[_,N]);return $.useEffect(()=>{if(T.current){B.current=$A({domNode:T.current,minZoom:m,maxZoom:p,translateExtent:h,viewport:d,onDraggingChange:z=>M.setState(G=>G.paneDragging===z?G:{paneDragging:z}),onPanZoomStart:(z,G)=>{const{onViewportChangeStart:Q,onMoveStart:K}=M.getState();K==null||K(z,G),Q==null||Q(G)},onPanZoom:(z,G)=>{const{onViewportChange:Q,onMove:K}=M.getState();K==null||K(z,G),Q==null||Q(G)},onPanZoomEnd:(z,G)=>{const{onViewportChangeEnd:Q,onMoveEnd:K}=M.getState();K==null||K(z,G),Q==null||Q(G)}});const{x:ee,y:I,zoom:F}=B.current.getViewport();return M.setState({panZoom:B.current,transform:[ee,I,F],domNode:T.current.closest(".react-flow")}),()=>{var z;(z=B.current)==null||z.destroy()}}},[]),$.useEffect(()=>{var ee;(ee=B.current)==null||ee.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:r,panOnScroll:l,panOnScrollSpeed:a,panOnScrollMode:o,zoomOnDoubleClick:u,panOnDrag:c,zoomActivationKeyPressed:H,preventScrolling:b,noPanClassName:S,userSelectionActive:L,noWheelClassName:E,lib:R,onTransformChange:U,connectionInProgress:V,selectionOnDrag:A,paneClickDistance:k})},[e,t,r,l,a,o,u,c,H,b,S,L,E,R,U,V,A,k]),y.jsx("div",{className:"react-flow__renderer",ref:T,style:Ic,children:w})}const Iz=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function qz(){const{userSelectionActive:e,userSelectionRect:t}=Ye(Iz,pt);return e&&t?y.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}const Th=(e,t)=>r=>{r.target===t.current&&(e==null||e(r))},Uz=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,connectionInProgress:e.connection.inProgress,dragging:e.paneDragging});function $z({isSelecting:e,selectionKeyPressed:t,selectionMode:r=Vo.Full,panOnDrag:l,paneClickDistance:a,selectionOnDrag:o,onSelectionStart:u,onSelectionEnd:c,onPaneClick:d,onPaneContextMenu:h,onPaneScroll:m,onPaneMouseEnter:p,onPaneMouseMove:x,onPaneMouseLeave:b,children:w}){const E=mt(),{userSelectionActive:S,elementsSelectable:_,dragging:N,connectionInProgress:k}=Ye(Uz,pt),A=_&&(e||S),M=$.useRef(null),T=$.useRef(),L=$.useRef(new Set),R=$.useRef(new Set),V=$.useRef(!1),H=Q=>{if(V.current||k){V.current=!1;return}d==null||d(Q),E.getState().resetSelectedElements(),E.setState({nodesSelectionActive:!1})},B=Q=>{if(Array.isArray(l)&&(l!=null&&l.includes(2))){Q.preventDefault();return}h==null||h(Q)},U=m?Q=>m(Q):void 0,ee=Q=>{V.current&&(Q.stopPropagation(),V.current=!1)},I=Q=>{var X,J;const{domNode:K}=E.getState();if(T.current=K==null?void 0:K.getBoundingClientRect(),!T.current)return;const D=Q.target===M.current;if(!D&&!!Q.target.closest(".nokey")||!e||!(o&&D||t)||Q.button!==0||!Q.isPrimary)return;(J=(X=Q.target)==null?void 0:X.setPointerCapture)==null||J.call(X,Q.pointerId),V.current=!1;const{x:C,y:P}=Vn(Q.nativeEvent,T.current);E.setState({userSelectionRect:{width:0,height:0,startX:C,startY:P,x:C,y:P}}),D||(Q.stopPropagation(),Q.preventDefault())},F=Q=>{const{userSelectionRect:K,transform:D,nodeLookup:q,edgeLookup:Y,connectionLookup:C,triggerNodeChanges:P,triggerEdgeChanges:X,defaultEdgeOptions:J,resetSelectedElements:ne}=E.getState();if(!T.current||!K)return;const{x:re,y:se}=Vn(Q.nativeEvent,T.current),{startX:xe,startY:be}=K;if(!V.current){const je=t?0:a;if(Math.hypot(re-xe,se-be)<=je)return;ne(),u==null||u(Q)}V.current=!0;const ye={startX:xe,startY:be,x:reje.id)),R.current=new Set;const ze=(J==null?void 0:J.selectable)??!0;for(const je of L.current){const ut=C.get(je);if(ut)for(const{edgeId:nt}of ut.values()){const zt=Y.get(nt);zt&&(zt.selectable??ze)&&R.current.add(nt)}}if(!Dv(pe,L.current)){const je=ia(q,L.current,!0);P(je)}if(!Dv(Se,R.current)){const je=ia(Y,R.current);X(je)}E.setState({userSelectionRect:ye,userSelectionActive:!0,nodesSelectionActive:!1})},z=Q=>{var K,D;Q.button===0&&((D=(K=Q.target)==null?void 0:K.releasePointerCapture)==null||D.call(K,Q.pointerId),!S&&Q.target===M.current&&E.getState().userSelectionRect&&(H==null||H(Q)),E.setState({userSelectionActive:!1,userSelectionRect:null}),V.current&&(c==null||c(Q),E.setState({nodesSelectionActive:L.current.size>0})))},G=l===!0||Array.isArray(l)&&l.includes(0);return y.jsxs("div",{className:At(["react-flow__pane",{draggable:G,dragging:N,selection:e}]),onClick:A?void 0:Th(H,M),onContextMenu:Th(B,M),onWheel:Th(U,M),onPointerEnter:A?void 0:p,onPointerMove:A?F:x,onPointerUp:A?z:void 0,onPointerDownCapture:A?I:void 0,onClickCapture:A?ee:void 0,onPointerLeave:b,ref:M,style:Ic,children:[w,y.jsx(qz,{})]})}function lm({id:e,store:t,unselect:r=!1,nodeRef:l}){const{addSelectedNodes:a,unselectNodesAndEdges:o,multiSelectionActive:u,nodeLookup:c,onError:d}=t.getState(),h=c.get(e);if(!h){d==null||d("012",lr.error012(e));return}t.setState({nodesSelectionActive:!1}),h.selected?(r||h.selected&&u)&&(o({nodes:[h],edges:[]}),requestAnimationFrame(()=>{var m;return(m=l==null?void 0:l.current)==null?void 0:m.blur()})):a([e])}function rS({nodeRef:e,disabled:t=!1,noDragClassName:r,handleSelector:l,nodeId:a,isSelectable:o,nodeClickDistance:u}){const c=mt(),[d,h]=$.useState(!1),m=$.useRef();return $.useEffect(()=>{m.current=jA({getStoreItems:()=>c.getState(),onNodeMouseDown:p=>{lm({id:p,store:c,nodeRef:e})},onDragStart:()=>{h(!0)},onDragStop:()=>{h(!1)}})},[]),$.useEffect(()=>{if(!(t||!e.current||!m.current))return m.current.update({noDragClassName:r,handleSelector:l,domNode:e.current,isSelectable:o,nodeId:a,nodeClickDistance:u}),()=>{var p;(p=m.current)==null||p.destroy()}},[r,l,t,o,e,a,u]),d}const Vz=e=>t=>t.selected&&(t.draggable||e&&typeof t.draggable>"u");function iS(){const e=mt();return $.useCallback(r=>{const{nodeExtent:l,snapToGrid:a,snapGrid:o,nodesDraggable:u,onError:c,updateNodePositions:d,nodeLookup:h,nodeOrigin:m}=e.getState(),p=new Map,x=Vz(u),b=a?o[0]:5,w=a?o[1]:5,E=r.direction.x*b*r.factor,S=r.direction.y*w*r.factor;for(const[,_]of h){if(!x(_))continue;let N={x:_.internals.positionAbsolute.x+E,y:_.internals.positionAbsolute.y+S};a&&(N=ts(N,o));const{position:k,positionAbsolute:A}=k_({nodeId:_.id,nextPosition:N,nodeLookup:h,nodeExtent:l,nodeOrigin:m,onError:c});_.position=k,_.internals.positionAbsolute=A,p.set(_.id,_)}d(p)},[])}const qm=$.createContext(null),Pz=qm.Provider;qm.Consumer;const lS=()=>$.useContext(qm),Gz=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),Fz=(e,t,r)=>l=>{const{connectionClickStartHandle:a,connectionMode:o,connection:u}=l,{fromHandle:c,toHandle:d,isValid:h}=u,m=(d==null?void 0:d.nodeId)===e&&(d==null?void 0:d.id)===t&&(d==null?void 0:d.type)===r;return{connectingFrom:(c==null?void 0:c.nodeId)===e&&(c==null?void 0:c.id)===t&&(c==null?void 0:c.type)===r,connectingTo:m,clickConnecting:(a==null?void 0:a.nodeId)===e&&(a==null?void 0:a.id)===t&&(a==null?void 0:a.type)===r,isPossibleEndHandle:o===ha.Strict?(c==null?void 0:c.type)!==r:e!==(c==null?void 0:c.nodeId)||t!==(c==null?void 0:c.id),connectionInProcess:!!c,clickConnectionInProcess:!!a,valid:m&&h}};function Yz({type:e="source",position:t=ve.Top,isValidConnection:r,isConnectable:l=!0,isConnectableStart:a=!0,isConnectableEnd:o=!0,id:u,onConnect:c,children:d,className:h,onMouseDown:m,onTouchStart:p,...x},b){var F,z;const w=u||null,E=e==="target",S=mt(),_=lS(),{connectOnClick:N,noPanClassName:k,rfId:A}=Ye(Gz,pt),{connectingFrom:M,connectingTo:T,clickConnecting:L,isPossibleEndHandle:R,connectionInProcess:V,clickConnectionInProcess:H,valid:B}=Ye(Fz(_,w,e),pt);_||(z=(F=S.getState()).onError)==null||z.call(F,"010",lr.error010());const U=G=>{const{defaultEdgeOptions:Q,onConnect:K,hasDefaultEdges:D}=S.getState(),q={...Q,...G};if(D){const{edges:Y,setEdges:C}=S.getState();C(dA(q,Y))}K==null||K(q),c==null||c(q)},ee=G=>{if(!_)return;const Q=M_(G.nativeEvent);if(a&&(Q&&G.button===0||!Q)){const K=S.getState();im.onPointerDown(G.nativeEvent,{handleDomNode:G.currentTarget,autoPanOnConnect:K.autoPanOnConnect,connectionMode:K.connectionMode,connectionRadius:K.connectionRadius,domNode:K.domNode,nodeLookup:K.nodeLookup,lib:K.lib,isTarget:E,handleId:w,nodeId:_,flowId:K.rfId,panBy:K.panBy,cancelConnection:K.cancelConnection,onConnectStart:K.onConnectStart,onConnectEnd:(...D)=>{var q,Y;return(Y=(q=S.getState()).onConnectEnd)==null?void 0:Y.call(q,...D)},updateConnection:K.updateConnection,onConnect:U,isValidConnection:r||((...D)=>{var q,Y;return((Y=(q=S.getState()).isValidConnection)==null?void 0:Y.call(q,...D))??!0}),getTransform:()=>S.getState().transform,getFromHandle:()=>S.getState().connection.fromHandle,autoPanSpeed:K.autoPanSpeed,dragThreshold:K.connectionDragThreshold})}Q?m==null||m(G):p==null||p(G)},I=G=>{const{onClickConnectStart:Q,onClickConnectEnd:K,connectionClickStartHandle:D,connectionMode:q,isValidConnection:Y,lib:C,rfId:P,nodeLookup:X,connection:J}=S.getState();if(!_||!D&&!a)return;if(!D){Q==null||Q(G.nativeEvent,{nodeId:_,handleId:w,handleType:e}),S.setState({connectionClickStartHandle:{nodeId:_,type:e,id:w}});return}const ne=A_(G.target),re=r||Y,{connection:se,isValid:xe}=im.isValid(G.nativeEvent,{handle:{nodeId:_,id:w,type:e},connectionMode:q,fromNodeId:D.nodeId,fromHandleId:D.id||null,fromType:D.type,isValidConnection:re,flowId:P,doc:ne,lib:C,nodeLookup:X});xe&&se&&U(se);const be=structuredClone(J);delete be.inProgress,be.toPosition=be.toHandle?be.toHandle.position:null,K==null||K(G,be),S.setState({connectionClickStartHandle:null})};return y.jsx("div",{"data-handleid":w,"data-nodeid":_,"data-handlepos":t,"data-id":`${A}-${_}-${w}-${e}`,className:At(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",k,h,{source:!E,target:E,connectable:l,connectablestart:a,connectableend:o,clickconnecting:L,connectingfrom:M,connectingto:T,valid:B,connectionindicator:l&&(!V||R)&&(V||H?o:a)}]),onMouseDown:ee,onTouchStart:ee,onClick:N?I:void 0,ref:b,...x,children:d})}const Lt=$.memo(tS(Yz));function Xz({data:e,isConnectable:t,sourcePosition:r=ve.Bottom}){return y.jsxs(y.Fragment,{children:[e==null?void 0:e.label,y.jsx(Lt,{type:"source",position:r,isConnectable:t})]})}function Qz({data:e,isConnectable:t,targetPosition:r=ve.Top,sourcePosition:l=ve.Bottom}){return y.jsxs(y.Fragment,{children:[y.jsx(Lt,{type:"target",position:r,isConnectable:t}),e==null?void 0:e.label,y.jsx(Lt,{type:"source",position:l,isConnectable:t})]})}function Zz(){return null}function Kz({data:e,isConnectable:t,targetPosition:r=ve.Top}){return y.jsxs(y.Fragment,{children:[y.jsx(Lt,{type:"target",position:r,isConnectable:t}),e==null?void 0:e.label]})}const xc={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},ub={input:Xz,default:Qz,output:Kz,group:Zz};function Jz(e){var t,r,l,a;return e.internals.handleBounds===void 0?{width:e.width??e.initialWidth??((t=e.style)==null?void 0:t.width),height:e.height??e.initialHeight??((r=e.style)==null?void 0:r.height)}:{width:e.width??((l=e.style)==null?void 0:l.width),height:e.height??((a=e.style)==null?void 0:a.height)}}const Wz=e=>{const{width:t,height:r,x:l,y:a}=es(e.nodeLookup,{filter:o=>!!o.selected});return{width:$n(t)?t:null,height:$n(r)?r:null,userSelectionActive:e.userSelectionActive,transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]}) translate(${l}px,${a}px)`}};function eM({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:r}){const l=mt(),{width:a,height:o,transformString:u,userSelectionActive:c}=Ye(Wz,pt),d=iS(),h=$.useRef(null);$.useEffect(()=>{var b;r||(b=h.current)==null||b.focus({preventScroll:!0})},[r]);const m=!c&&a!==null&&o!==null;if(rS({nodeRef:h,disabled:!m}),!m)return null;const p=e?b=>{const w=l.getState().nodes.filter(E=>E.selected);e(b,w)}:void 0,x=b=>{Object.prototype.hasOwnProperty.call(xc,b.key)&&(b.preventDefault(),d({direction:xc[b.key],factor:b.shiftKey?4:1}))};return y.jsx("div",{className:At(["react-flow__nodesselection","react-flow__container",t]),style:{transform:u},children:y.jsx("div",{ref:h,className:"react-flow__nodesselection-rect",onContextMenu:p,tabIndex:r?void 0:-1,onKeyDown:r?void 0:x,style:{width:a,height:o}})})}const cb=typeof window<"u"?window:void 0,tM=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function aS({children:e,onPaneClick:t,onPaneMouseEnter:r,onPaneMouseMove:l,onPaneMouseLeave:a,onPaneContextMenu:o,onPaneScroll:u,paneClickDistance:c,deleteKeyCode:d,selectionKeyCode:h,selectionOnDrag:m,selectionMode:p,onSelectionStart:x,onSelectionEnd:b,multiSelectionKeyCode:w,panActivationKeyCode:E,zoomActivationKeyCode:S,elementsSelectable:_,zoomOnScroll:N,zoomOnPinch:k,panOnScroll:A,panOnScrollSpeed:M,panOnScrollMode:T,zoomOnDoubleClick:L,panOnDrag:R,defaultViewport:V,translateExtent:H,minZoom:B,maxZoom:U,preventScrolling:ee,onSelectionContextMenu:I,noWheelClassName:F,noPanClassName:z,disableKeyboardA11y:G,onViewportChange:Q,isControlledViewport:K}){const{nodesSelectionActive:D,userSelectionActive:q}=Ye(tM,pt),Y=Fo(h,{target:cb}),C=Fo(E,{target:cb}),P=C||R,X=C||A,J=m&&P!==!0,ne=Y||q||J;return Oz({deleteKeyCode:d,multiSelectionKeyCode:w}),y.jsx(Bz,{onPaneContextMenu:o,elementsSelectable:_,zoomOnScroll:N,zoomOnPinch:k,panOnScroll:X,panOnScrollSpeed:M,panOnScrollMode:T,zoomOnDoubleClick:L,panOnDrag:!Y&&P,defaultViewport:V,translateExtent:H,minZoom:B,maxZoom:U,zoomActivationKeyCode:S,preventScrolling:ee,noWheelClassName:F,noPanClassName:z,onViewportChange:Q,isControlledViewport:K,paneClickDistance:c,selectionOnDrag:J,children:y.jsxs($z,{onSelectionStart:x,onSelectionEnd:b,onPaneClick:t,onPaneMouseEnter:r,onPaneMouseMove:l,onPaneMouseLeave:a,onPaneContextMenu:o,onPaneScroll:u,panOnDrag:P,isSelecting:!!ne,selectionMode:p,selectionKeyPressed:Y,paneClickDistance:c,selectionOnDrag:J,children:[e,D&&y.jsx(eM,{onSelectionContextMenu:I,noPanClassName:z,disableKeyboardA11y:G})]})})}aS.displayName="FlowRenderer";const nM=$.memo(aS),rM=e=>t=>e?zm(t.nodeLookup,{x:0,y:0,width:t.width,height:t.height},t.transform,!0).map(r=>r.id):Array.from(t.nodeLookup.keys());function iM(e){return Ye($.useCallback(rM(e),[e]),pt)}const lM=e=>e.updateNodeInternals;function aM(){const e=Ye(lM),[t]=$.useState(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(r=>{const l=new Map;r.forEach(a=>{const o=a.target.getAttribute("data-id");l.set(o,{id:o,nodeElement:a.target,force:!0})}),e(l)}));return $.useEffect(()=>()=>{t==null||t.disconnect()},[t]),t}function oM({node:e,nodeType:t,hasDimensions:r,resizeObserver:l}){const a=mt(),o=$.useRef(null),u=$.useRef(null),c=$.useRef(e.sourcePosition),d=$.useRef(e.targetPosition),h=$.useRef(t),m=r&&!!e.internals.handleBounds;return $.useEffect(()=>{o.current&&!e.hidden&&(!m||u.current!==o.current)&&(u.current&&(l==null||l.unobserve(u.current)),l==null||l.observe(o.current),u.current=o.current)},[m,e.hidden]),$.useEffect(()=>()=>{u.current&&(l==null||l.unobserve(u.current),u.current=null)},[]),$.useEffect(()=>{if(o.current){const p=h.current!==t,x=c.current!==e.sourcePosition,b=d.current!==e.targetPosition;(p||x||b)&&(h.current=t,c.current=e.sourcePosition,d.current=e.targetPosition,a.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:o.current,force:!0}]])))}},[e.id,t,e.sourcePosition,e.targetPosition]),o}function sM({id:e,onClick:t,onMouseEnter:r,onMouseMove:l,onMouseLeave:a,onContextMenu:o,onDoubleClick:u,nodesDraggable:c,elementsSelectable:d,nodesConnectable:h,nodesFocusable:m,resizeObserver:p,noDragClassName:x,noPanClassName:b,disableKeyboardA11y:w,rfId:E,nodeTypes:S,nodeClickDistance:_,onError:N}){const{node:k,internals:A,isParent:M}=Ye(re=>{const se=re.nodeLookup.get(e),xe=re.parentLookup.has(e);return{node:se,internals:se.internals,isParent:xe}},pt);let T=k.type||"default",L=(S==null?void 0:S[T])||ub[T];L===void 0&&(N==null||N("003",lr.error003(T)),T="default",L=(S==null?void 0:S.default)||ub.default);const R=!!(k.draggable||c&&typeof k.draggable>"u"),V=!!(k.selectable||d&&typeof k.selectable>"u"),H=!!(k.connectable||h&&typeof k.connectable>"u"),B=!!(k.focusable||m&&typeof k.focusable>"u"),U=mt(),ee=j_(k),I=oM({node:k,nodeType:T,hasDimensions:ee,resizeObserver:p}),F=rS({nodeRef:I,disabled:k.hidden||!R,noDragClassName:x,handleSelector:k.dragHandle,nodeId:e,isSelectable:V,nodeClickDistance:_}),z=iS();if(k.hidden)return null;const G=Or(k),Q=Jz(k),K=V||R||t||r||l||a,D=r?re=>r(re,{...A.userNode}):void 0,q=l?re=>l(re,{...A.userNode}):void 0,Y=a?re=>a(re,{...A.userNode}):void 0,C=o?re=>o(re,{...A.userNode}):void 0,P=u?re=>u(re,{...A.userNode}):void 0,X=re=>{const{selectNodesOnDrag:se,nodeDragThreshold:xe}=U.getState();V&&(!se||!R||xe>0)&&lm({id:e,store:U,nodeRef:I}),t&&t(re,{...A.userNode})},J=re=>{if(!(z_(re.nativeEvent)||w)){if(v_.includes(re.key)&&V){const se=re.key==="Escape";lm({id:e,store:U,unselect:se,nodeRef:I})}else if(R&&k.selected&&Object.prototype.hasOwnProperty.call(xc,re.key)){re.preventDefault();const{ariaLabelConfig:se}=U.getState();U.setState({ariaLiveMessage:se["node.a11yDescription.ariaLiveMessage"]({direction:re.key.replace("Arrow","").toLowerCase(),x:~~A.positionAbsolute.x,y:~~A.positionAbsolute.y})}),z({direction:xc[re.key],factor:re.shiftKey?4:1})}}},ne=()=>{var Se;if(w||!((Se=I.current)!=null&&Se.matches(":focus-visible")))return;const{transform:re,width:se,height:xe,autoPanOnNodeFocus:be,setCenter:ye}=U.getState();if(!be)return;zm(new Map([[e,k]]),{x:0,y:0,width:se,height:xe},re,!0).length>0||ye(k.position.x+G.width/2,k.position.y+G.height/2,{zoom:re[2]})};return y.jsx("div",{className:At(["react-flow__node",`react-flow__node-${T}`,{[b]:R},k.className,{selected:k.selected,selectable:V,parent:M,draggable:R,dragging:F}]),ref:I,style:{zIndex:A.z,transform:`translate(${A.positionAbsolute.x}px,${A.positionAbsolute.y}px)`,pointerEvents:K?"all":"none",visibility:ee?"visible":"hidden",...k.style,...Q},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:D,onMouseMove:q,onMouseLeave:Y,onContextMenu:C,onClick:X,onDoubleClick:P,onKeyDown:B?J:void 0,tabIndex:B?0:void 0,onFocus:B?ne:void 0,role:k.ariaRole??(B?"group":void 0),"aria-roledescription":"node","aria-describedby":w?void 0:`${Q_}-${E}`,"aria-label":k.ariaLabel,...k.domAttributes,children:y.jsx(Pz,{value:e,children:y.jsx(L,{id:e,data:k.data,type:T,positionAbsoluteX:A.positionAbsolute.x,positionAbsoluteY:A.positionAbsolute.y,selected:k.selected??!1,selectable:V,draggable:R,deletable:k.deletable??!0,isConnectable:H,sourcePosition:k.sourcePosition,targetPosition:k.targetPosition,dragging:F,dragHandle:k.dragHandle,zIndex:A.z,parentId:k.parentId,...G})})})}var uM=$.memo(sM);const cM=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function oS(e){const{nodesDraggable:t,nodesConnectable:r,nodesFocusable:l,elementsSelectable:a,onError:o}=Ye(cM,pt),u=iM(e.onlyRenderVisibleElements),c=aM();return y.jsx("div",{className:"react-flow__nodes",style:Ic,children:u.map(d=>y.jsx(uM,{id:d,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:c,nodesDraggable:t,nodesConnectable:r,nodesFocusable:l,elementsSelectable:a,nodeClickDistance:e.nodeClickDistance,onError:o},d))})}oS.displayName="NodeRenderer";const fM=$.memo(oS);function dM(e){return Ye($.useCallback(r=>{if(!e)return r.edges.map(a=>a.id);const l=[];if(r.width&&r.height)for(const a of r.edges){const o=r.nodeLookup.get(a.source),u=r.nodeLookup.get(a.target);o&&u&&uA({sourceNode:o,targetNode:u,width:r.width,height:r.height,transform:r.transform})&&l.push(a.id)}return l},[e]),pt)}const hM=({color:e="none",strokeWidth:t=1})=>{const r={strokeWidth:t,...e&&{stroke:e}};return y.jsx("polyline",{className:"arrow",style:r,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},pM=({color:e="none",strokeWidth:t=1})=>{const r={strokeWidth:t,...e&&{stroke:e,fill:e}};return y.jsx("polyline",{className:"arrowclosed",style:r,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},fb={[pc.Arrow]:hM,[pc.ArrowClosed]:pM};function mM(e){const t=mt();return $.useMemo(()=>{var a,o;return Object.prototype.hasOwnProperty.call(fb,e)?fb[e]:((o=(a=t.getState()).onError)==null||o.call(a,"009",lr.error009(e)),null)},[e])}const gM=({id:e,type:t,color:r,width:l=12.5,height:a=12.5,markerUnits:o="strokeWidth",strokeWidth:u,orient:c="auto-start-reverse"})=>{const d=mM(t);return d?y.jsx("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${l}`,markerHeight:`${a}`,viewBox:"-10 -10 20 20",markerUnits:o,orient:c,refX:"0",refY:"0",children:y.jsx(d,{color:r,strokeWidth:u})}):null},sS=({defaultColor:e,rfId:t})=>{const r=Ye(o=>o.edges),l=Ye(o=>o.defaultEdgeOptions),a=$.useMemo(()=>xA(r,{id:t,defaultColor:e,defaultMarkerStart:l==null?void 0:l.markerStart,defaultMarkerEnd:l==null?void 0:l.markerEnd}),[r,l,t,e]);return a.length?y.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:y.jsx("defs",{children:a.map(o=>y.jsx(gM,{id:o.id,type:o.type,color:o.color,width:o.width,height:o.height,markerUnits:o.markerUnits,strokeWidth:o.strokeWidth,orient:o.orient},o.id))})}):null};sS.displayName="MarkerDefinitions";var xM=$.memo(sS);function uS({x:e,y:t,label:r,labelStyle:l,labelShowBg:a=!0,labelBgStyle:o,labelBgPadding:u=[2,4],labelBgBorderRadius:c=2,children:d,className:h,...m}){const[p,x]=$.useState({x:1,y:0,width:0,height:0}),b=At(["react-flow__edge-textwrapper",h]),w=$.useRef(null);return $.useEffect(()=>{if(w.current){const E=w.current.getBBox();x({x:E.x,y:E.y,width:E.width,height:E.height})}},[r]),r?y.jsxs("g",{transform:`translate(${e-p.width/2} ${t-p.height/2})`,className:b,visibility:p.width?"visible":"hidden",...m,children:[a&&y.jsx("rect",{width:p.width+2*u[0],x:-u[0],y:-u[1],height:p.height+2*u[1],className:"react-flow__edge-textbg",style:o,rx:c,ry:c}),y.jsx("text",{className:"react-flow__edge-text",y:p.height/2,dy:"0.3em",ref:w,style:l,children:r}),d]}):null}uS.displayName="EdgeText";const yM=$.memo(uS);function rs({path:e,labelX:t,labelY:r,label:l,labelStyle:a,labelShowBg:o,labelBgStyle:u,labelBgPadding:c,labelBgBorderRadius:d,interactionWidth:h=20,...m}){return y.jsxs(y.Fragment,{children:[y.jsx("path",{...m,d:e,fill:"none",className:At(["react-flow__edge-path",m.className])}),h?y.jsx("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:h,className:"react-flow__edge-interaction"}):null,l&&$n(t)&&$n(r)?y.jsx(yM,{x:t,y:r,label:l,labelStyle:a,labelShowBg:o,labelBgStyle:u,labelBgPadding:c,labelBgBorderRadius:d}):null]})}function db({pos:e,x1:t,y1:r,x2:l,y2:a}){return e===ve.Left||e===ve.Right?[.5*(t+l),r]:[t,.5*(r+a)]}function cS({sourceX:e,sourceY:t,sourcePosition:r=ve.Bottom,targetX:l,targetY:a,targetPosition:o=ve.Top}){const[u,c]=db({pos:r,x1:e,y1:t,x2:l,y2:a}),[d,h]=db({pos:o,x1:l,y1:a,x2:e,y2:t}),[m,p,x,b]=D_({sourceX:e,sourceY:t,targetX:l,targetY:a,sourceControlX:u,sourceControlY:c,targetControlX:d,targetControlY:h});return[`M${e},${t} C${u},${c} ${d},${h} ${l},${a}`,m,p,x,b]}function fS(e){return $.memo(({id:t,sourceX:r,sourceY:l,targetX:a,targetY:o,sourcePosition:u,targetPosition:c,label:d,labelStyle:h,labelShowBg:m,labelBgStyle:p,labelBgPadding:x,labelBgBorderRadius:b,style:w,markerEnd:E,markerStart:S,interactionWidth:_})=>{const[N,k,A]=cS({sourceX:r,sourceY:l,sourcePosition:u,targetX:a,targetY:o,targetPosition:c}),M=e.isInternal?void 0:t;return y.jsx(rs,{id:M,path:N,labelX:k,labelY:A,label:d,labelStyle:h,labelShowBg:m,labelBgStyle:p,labelBgPadding:x,labelBgBorderRadius:b,style:w,markerEnd:E,markerStart:S,interactionWidth:_})})}const vM=fS({isInternal:!1}),dS=fS({isInternal:!0});vM.displayName="SimpleBezierEdge";dS.displayName="SimpleBezierEdgeInternal";function hS(e){return $.memo(({id:t,sourceX:r,sourceY:l,targetX:a,targetY:o,label:u,labelStyle:c,labelShowBg:d,labelBgStyle:h,labelBgPadding:m,labelBgBorderRadius:p,style:x,sourcePosition:b=ve.Bottom,targetPosition:w=ve.Top,markerEnd:E,markerStart:S,pathOptions:_,interactionWidth:N})=>{const[k,A,M]=tm({sourceX:r,sourceY:l,sourcePosition:b,targetX:a,targetY:o,targetPosition:w,borderRadius:_==null?void 0:_.borderRadius,offset:_==null?void 0:_.offset,stepPosition:_==null?void 0:_.stepPosition}),T=e.isInternal?void 0:t;return y.jsx(rs,{id:T,path:k,labelX:A,labelY:M,label:u,labelStyle:c,labelShowBg:d,labelBgStyle:h,labelBgPadding:m,labelBgBorderRadius:p,style:x,markerEnd:E,markerStart:S,interactionWidth:N})})}const pS=hS({isInternal:!1}),mS=hS({isInternal:!0});pS.displayName="SmoothStepEdge";mS.displayName="SmoothStepEdgeInternal";function gS(e){return $.memo(({id:t,...r})=>{var a;const l=e.isInternal?void 0:t;return y.jsx(pS,{...r,id:l,pathOptions:$.useMemo(()=>{var o;return{borderRadius:0,offset:(o=r.pathOptions)==null?void 0:o.offset}},[(a=r.pathOptions)==null?void 0:a.offset])})})}const bM=gS({isInternal:!1}),xS=gS({isInternal:!0});bM.displayName="StepEdge";xS.displayName="StepEdgeInternal";function yS(e){return $.memo(({id:t,sourceX:r,sourceY:l,targetX:a,targetY:o,label:u,labelStyle:c,labelShowBg:d,labelBgStyle:h,labelBgPadding:m,labelBgBorderRadius:p,style:x,markerEnd:b,markerStart:w,interactionWidth:E})=>{const[S,_,N]=O_({sourceX:r,sourceY:l,targetX:a,targetY:o}),k=e.isInternal?void 0:t;return y.jsx(rs,{id:k,path:S,labelX:_,labelY:N,label:u,labelStyle:c,labelShowBg:d,labelBgStyle:h,labelBgPadding:m,labelBgBorderRadius:p,style:x,markerEnd:b,markerStart:w,interactionWidth:E})})}const wM=yS({isInternal:!1}),vS=yS({isInternal:!0});wM.displayName="StraightEdge";vS.displayName="StraightEdgeInternal";function bS(e){return $.memo(({id:t,sourceX:r,sourceY:l,targetX:a,targetY:o,sourcePosition:u=ve.Bottom,targetPosition:c=ve.Top,label:d,labelStyle:h,labelShowBg:m,labelBgStyle:p,labelBgPadding:x,labelBgBorderRadius:b,style:w,markerEnd:E,markerStart:S,pathOptions:_,interactionWidth:N})=>{const[k,A,M]=Rm({sourceX:r,sourceY:l,sourcePosition:u,targetX:a,targetY:o,targetPosition:c,curvature:_==null?void 0:_.curvature}),T=e.isInternal?void 0:t;return y.jsx(rs,{id:T,path:k,labelX:A,labelY:M,label:d,labelStyle:h,labelShowBg:m,labelBgStyle:p,labelBgPadding:x,labelBgBorderRadius:b,style:w,markerEnd:E,markerStart:S,interactionWidth:N})})}const _M=bS({isInternal:!1}),wS=bS({isInternal:!0});_M.displayName="BezierEdge";wS.displayName="BezierEdgeInternal";const hb={default:wS,straight:vS,step:xS,smoothstep:mS,simplebezier:dS},pb={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null},SM=(e,t,r)=>r===ve.Left?e-t:r===ve.Right?e+t:e,kM=(e,t,r)=>r===ve.Top?e-t:r===ve.Bottom?e+t:e,mb="react-flow__edgeupdater";function gb({position:e,centerX:t,centerY:r,radius:l=10,onMouseDown:a,onMouseEnter:o,onMouseOut:u,type:c}){return y.jsx("circle",{onMouseDown:a,onMouseEnter:o,onMouseOut:u,className:At([mb,`${mb}-${c}`]),cx:SM(t,l,e),cy:kM(r,l,e),r:l,stroke:"transparent",fill:"transparent"})}function EM({isReconnectable:e,reconnectRadius:t,edge:r,sourceX:l,sourceY:a,targetX:o,targetY:u,sourcePosition:c,targetPosition:d,onReconnect:h,onReconnectStart:m,onReconnectEnd:p,setReconnecting:x,setUpdateHover:b}){const w=mt(),E=(A,M)=>{if(A.button!==0)return;const{autoPanOnConnect:T,domNode:L,connectionMode:R,connectionRadius:V,lib:H,onConnectStart:B,cancelConnection:U,nodeLookup:ee,rfId:I,panBy:F,updateConnection:z}=w.getState(),G=M.type==="target",Q=(q,Y)=>{x(!1),p==null||p(q,r,M.type,Y)},K=q=>h==null?void 0:h(r,q),D=(q,Y)=>{x(!0),m==null||m(A,r,M.type),B==null||B(q,Y)};im.onPointerDown(A.nativeEvent,{autoPanOnConnect:T,connectionMode:R,connectionRadius:V,domNode:L,handleId:M.id,nodeId:M.nodeId,nodeLookup:ee,isTarget:G,edgeUpdaterType:M.type,lib:H,flowId:I,cancelConnection:U,panBy:F,isValidConnection:(...q)=>{var Y,C;return((C=(Y=w.getState()).isValidConnection)==null?void 0:C.call(Y,...q))??!0},onConnect:K,onConnectStart:D,onConnectEnd:(...q)=>{var Y,C;return(C=(Y=w.getState()).onConnectEnd)==null?void 0:C.call(Y,...q)},onReconnectEnd:Q,updateConnection:z,getTransform:()=>w.getState().transform,getFromHandle:()=>w.getState().connection.fromHandle,dragThreshold:w.getState().connectionDragThreshold,handleDomNode:A.currentTarget})},S=A=>E(A,{nodeId:r.target,id:r.targetHandle??null,type:"target"}),_=A=>E(A,{nodeId:r.source,id:r.sourceHandle??null,type:"source"}),N=()=>b(!0),k=()=>b(!1);return y.jsxs(y.Fragment,{children:[(e===!0||e==="source")&&y.jsx(gb,{position:c,centerX:l,centerY:a,radius:t,onMouseDown:S,onMouseEnter:N,onMouseOut:k,type:"source"}),(e===!0||e==="target")&&y.jsx(gb,{position:d,centerX:o,centerY:u,radius:t,onMouseDown:_,onMouseEnter:N,onMouseOut:k,type:"target"})]})}function NM({id:e,edgesFocusable:t,edgesReconnectable:r,elementsSelectable:l,onClick:a,onDoubleClick:o,onContextMenu:u,onMouseEnter:c,onMouseMove:d,onMouseLeave:h,reconnectRadius:m,onReconnect:p,onReconnectStart:x,onReconnectEnd:b,rfId:w,edgeTypes:E,noPanClassName:S,onError:_,disableKeyboardA11y:N}){let k=Ye(ye=>ye.edgeLookup.get(e));const A=Ye(ye=>ye.defaultEdgeOptions);k=A?{...A,...k}:k;let M=k.type||"default",T=(E==null?void 0:E[M])||hb[M];T===void 0&&(_==null||_("011",lr.error011(M)),M="default",T=(E==null?void 0:E.default)||hb.default);const L=!!(k.focusable||t&&typeof k.focusable>"u"),R=typeof p<"u"&&(k.reconnectable||r&&typeof k.reconnectable>"u"),V=!!(k.selectable||l&&typeof k.selectable>"u"),H=$.useRef(null),[B,U]=$.useState(!1),[ee,I]=$.useState(!1),F=mt(),{zIndex:z,sourceX:G,sourceY:Q,targetX:K,targetY:D,sourcePosition:q,targetPosition:Y}=Ye($.useCallback(ye=>{const pe=ye.nodeLookup.get(k.source),Se=ye.nodeLookup.get(k.target);if(!pe||!Se)return{zIndex:k.zIndex,...pb};const ze=gA({id:e,sourceNode:pe,targetNode:Se,sourceHandle:k.sourceHandle||null,targetHandle:k.targetHandle||null,connectionMode:ye.connectionMode,onError:_});return{zIndex:sA({selected:k.selected,zIndex:k.zIndex,sourceNode:pe,targetNode:Se,elevateOnSelect:ye.elevateEdgesOnSelect,zIndexMode:ye.zIndexMode}),...ze||pb}},[k.source,k.target,k.sourceHandle,k.targetHandle,k.selected,k.zIndex]),pt),C=$.useMemo(()=>k.markerStart?`url('#${nm(k.markerStart,w)}')`:void 0,[k.markerStart,w]),P=$.useMemo(()=>k.markerEnd?`url('#${nm(k.markerEnd,w)}')`:void 0,[k.markerEnd,w]);if(k.hidden||G===null||Q===null||K===null||D===null)return null;const X=ye=>{var je;const{addSelectedEdges:pe,unselectNodesAndEdges:Se,multiSelectionActive:ze}=F.getState();V&&(F.setState({nodesSelectionActive:!1}),k.selected&&ze?(Se({nodes:[],edges:[k]}),(je=H.current)==null||je.blur()):pe([e])),a&&a(ye,k)},J=o?ye=>{o(ye,{...k})}:void 0,ne=u?ye=>{u(ye,{...k})}:void 0,re=c?ye=>{c(ye,{...k})}:void 0,se=d?ye=>{d(ye,{...k})}:void 0,xe=h?ye=>{h(ye,{...k})}:void 0,be=ye=>{var pe;if(!N&&v_.includes(ye.key)&&V){const{unselectNodesAndEdges:Se,addSelectedEdges:ze}=F.getState();ye.key==="Escape"?((pe=H.current)==null||pe.blur(),Se({edges:[k]})):ze([e])}};return y.jsx("svg",{style:{zIndex:z},children:y.jsxs("g",{className:At(["react-flow__edge",`react-flow__edge-${M}`,k.className,S,{selected:k.selected,animated:k.animated,inactive:!V&&!a,updating:B,selectable:V}]),onClick:X,onDoubleClick:J,onContextMenu:ne,onMouseEnter:re,onMouseMove:se,onMouseLeave:xe,onKeyDown:L?be:void 0,tabIndex:L?0:void 0,role:k.ariaRole??(L?"group":"img"),"aria-roledescription":"edge","data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":k.ariaLabel===null?void 0:k.ariaLabel||`Edge from ${k.source} to ${k.target}`,"aria-describedby":L?`${Z_}-${w}`:void 0,ref:H,...k.domAttributes,children:[!ee&&y.jsx(T,{id:e,source:k.source,target:k.target,type:k.type,selected:k.selected,animated:k.animated,selectable:V,deletable:k.deletable??!0,label:k.label,labelStyle:k.labelStyle,labelShowBg:k.labelShowBg,labelBgStyle:k.labelBgStyle,labelBgPadding:k.labelBgPadding,labelBgBorderRadius:k.labelBgBorderRadius,sourceX:G,sourceY:Q,targetX:K,targetY:D,sourcePosition:q,targetPosition:Y,data:k.data,style:k.style,sourceHandleId:k.sourceHandle,targetHandleId:k.targetHandle,markerStart:C,markerEnd:P,pathOptions:"pathOptions"in k?k.pathOptions:void 0,interactionWidth:k.interactionWidth}),R&&y.jsx(EM,{edge:k,isReconnectable:R,reconnectRadius:m,onReconnect:p,onReconnectStart:x,onReconnectEnd:b,sourceX:G,sourceY:Q,targetX:K,targetY:D,sourcePosition:q,targetPosition:Y,setUpdateHover:U,setReconnecting:I})]})})}var CM=$.memo(NM);const jM=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function _S({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:r,edgeTypes:l,noPanClassName:a,onReconnect:o,onEdgeContextMenu:u,onEdgeMouseEnter:c,onEdgeMouseMove:d,onEdgeMouseLeave:h,onEdgeClick:m,reconnectRadius:p,onEdgeDoubleClick:x,onReconnectStart:b,onReconnectEnd:w,disableKeyboardA11y:E}){const{edgesFocusable:S,edgesReconnectable:_,elementsSelectable:N,onError:k}=Ye(jM,pt),A=dM(t);return y.jsxs("div",{className:"react-flow__edges",children:[y.jsx(xM,{defaultColor:e,rfId:r}),A.map(M=>y.jsx(CM,{id:M,edgesFocusable:S,edgesReconnectable:_,elementsSelectable:N,noPanClassName:a,onReconnect:o,onContextMenu:u,onMouseEnter:c,onMouseMove:d,onMouseLeave:h,onClick:m,reconnectRadius:p,onDoubleClick:x,onReconnectStart:b,onReconnectEnd:w,rfId:r,onError:k,edgeTypes:l,disableKeyboardA11y:E},M))]})}_S.displayName="EdgeRenderer";const TM=$.memo(_S),AM=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function zM({children:e}){const t=Ye(AM);return y.jsx("div",{className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:t},children:e})}function MM(e){const t=al(),r=$.useRef(!1);$.useEffect(()=>{!r.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),r.current=!0)},[e,t.viewportInitialized])}const DM=e=>{var t;return(t=e.panZoom)==null?void 0:t.syncViewport};function RM(e){const t=Ye(DM),r=mt();return $.useEffect(()=>{e&&(t==null||t(e),r.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function OM(e){return e.connection.inProgress?{...e.connection,to:ns(e.connection.to,e.transform)}:{...e.connection}}function LM(e){return OM}function HM(e){const t=LM();return Ye(t,pt)}const BM=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function IM({containerStyle:e,style:t,type:r,component:l}){const{nodesConnectable:a,width:o,height:u,isValid:c,inProgress:d}=Ye(BM,pt);return!(o&&a&&d)?null:y.jsx("svg",{style:e,width:o,height:u,className:"react-flow__connectionline react-flow__container",children:y.jsx("g",{className:At(["react-flow__connection",__(c)]),children:y.jsx(SS,{style:t,type:r,CustomComponent:l,isValid:c})})})}const SS=({style:e,type:t=xi.Bezier,CustomComponent:r,isValid:l})=>{const{inProgress:a,from:o,fromNode:u,fromHandle:c,fromPosition:d,to:h,toNode:m,toHandle:p,toPosition:x,pointer:b}=HM();if(!a)return;if(r)return y.jsx(r,{connectionLineType:t,connectionLineStyle:e,fromNode:u,fromHandle:c,fromX:o.x,fromY:o.y,toX:h.x,toY:h.y,fromPosition:d,toPosition:x,connectionStatus:__(l),toNode:m,toHandle:p,pointer:b});let w="";const E={sourceX:o.x,sourceY:o.y,sourcePosition:d,targetX:h.x,targetY:h.y,targetPosition:x};switch(t){case xi.Bezier:[w]=Rm(E);break;case xi.SimpleBezier:[w]=cS(E);break;case xi.Step:[w]=tm({...E,borderRadius:0});break;case xi.SmoothStep:[w]=tm(E);break;default:[w]=O_(E)}return y.jsx("path",{d:w,fill:"none",className:"react-flow__connection-path",style:e})};SS.displayName="ConnectionLine";const qM={};function xb(e=qM){$.useRef(e),mt(),$.useEffect(()=>{},[e])}function UM(){mt(),$.useRef(!1),$.useEffect(()=>{},[])}function kS({nodeTypes:e,edgeTypes:t,onInit:r,onNodeClick:l,onEdgeClick:a,onNodeDoubleClick:o,onEdgeDoubleClick:u,onNodeMouseEnter:c,onNodeMouseMove:d,onNodeMouseLeave:h,onNodeContextMenu:m,onSelectionContextMenu:p,onSelectionStart:x,onSelectionEnd:b,connectionLineType:w,connectionLineStyle:E,connectionLineComponent:S,connectionLineContainerStyle:_,selectionKeyCode:N,selectionOnDrag:k,selectionMode:A,multiSelectionKeyCode:M,panActivationKeyCode:T,zoomActivationKeyCode:L,deleteKeyCode:R,onlyRenderVisibleElements:V,elementsSelectable:H,defaultViewport:B,translateExtent:U,minZoom:ee,maxZoom:I,preventScrolling:F,defaultMarkerColor:z,zoomOnScroll:G,zoomOnPinch:Q,panOnScroll:K,panOnScrollSpeed:D,panOnScrollMode:q,zoomOnDoubleClick:Y,panOnDrag:C,onPaneClick:P,onPaneMouseEnter:X,onPaneMouseMove:J,onPaneMouseLeave:ne,onPaneScroll:re,onPaneContextMenu:se,paneClickDistance:xe,nodeClickDistance:be,onEdgeContextMenu:ye,onEdgeMouseEnter:pe,onEdgeMouseMove:Se,onEdgeMouseLeave:ze,reconnectRadius:je,onReconnect:ut,onReconnectStart:nt,onReconnectEnd:zt,noDragClassName:Vt,noWheelClassName:Ht,noPanClassName:kn,disableKeyboardA11y:Rn,nodeExtent:Mt,rfId:Hr,viewport:ce,onViewportChange:ge}){return xb(e),xb(t),UM(),MM(r),RM(ce),y.jsx(nM,{onPaneClick:P,onPaneMouseEnter:X,onPaneMouseMove:J,onPaneMouseLeave:ne,onPaneContextMenu:se,onPaneScroll:re,paneClickDistance:xe,deleteKeyCode:R,selectionKeyCode:N,selectionOnDrag:k,selectionMode:A,onSelectionStart:x,onSelectionEnd:b,multiSelectionKeyCode:M,panActivationKeyCode:T,zoomActivationKeyCode:L,elementsSelectable:H,zoomOnScroll:G,zoomOnPinch:Q,zoomOnDoubleClick:Y,panOnScroll:K,panOnScrollSpeed:D,panOnScrollMode:q,panOnDrag:C,defaultViewport:B,translateExtent:U,minZoom:ee,maxZoom:I,onSelectionContextMenu:p,preventScrolling:F,noDragClassName:Vt,noWheelClassName:Ht,noPanClassName:kn,disableKeyboardA11y:Rn,onViewportChange:ge,isControlledViewport:!!ce,children:y.jsxs(zM,{children:[y.jsx(TM,{edgeTypes:t,onEdgeClick:a,onEdgeDoubleClick:u,onReconnect:ut,onReconnectStart:nt,onReconnectEnd:zt,onlyRenderVisibleElements:V,onEdgeContextMenu:ye,onEdgeMouseEnter:pe,onEdgeMouseMove:Se,onEdgeMouseLeave:ze,reconnectRadius:je,defaultMarkerColor:z,noPanClassName:kn,disableKeyboardA11y:Rn,rfId:Hr}),y.jsx(IM,{style:E,type:w,component:S,containerStyle:_}),y.jsx("div",{className:"react-flow__edgelabel-renderer"}),y.jsx(fM,{nodeTypes:e,onNodeClick:l,onNodeDoubleClick:o,onNodeMouseEnter:c,onNodeMouseMove:d,onNodeMouseLeave:h,onNodeContextMenu:m,nodeClickDistance:be,onlyRenderVisibleElements:V,noPanClassName:kn,noDragClassName:Vt,disableKeyboardA11y:Rn,nodeExtent:Mt,rfId:Hr}),y.jsx("div",{className:"react-flow__viewport-portal"})]})})}kS.displayName="GraphView";const $M=$.memo(kS),yb=({nodes:e,edges:t,defaultNodes:r,defaultEdges:l,width:a,height:o,fitView:u,fitViewOptions:c,minZoom:d=.5,maxZoom:h=2,nodeOrigin:m,nodeExtent:p,zIndexMode:x="basic"}={})=>{const b=new Map,w=new Map,E=new Map,S=new Map,_=l??t??[],N=r??e??[],k=m??[0,0],A=p??$o;B_(E,S,_);const M=rm(N,b,w,{nodeOrigin:k,nodeExtent:A,zIndexMode:x});let T=[0,0,1];if(u&&a&&o){const L=es(b,{filter:B=>!!((B.width||B.initialWidth)&&(B.height||B.initialHeight))}),{x:R,y:V,zoom:H}=Mm(L,a,o,d,h,(c==null?void 0:c.padding)??.1);T=[R,V,H]}return{rfId:"1",width:a??0,height:o??0,transform:T,nodes:N,nodesInitialized:M,nodeLookup:b,parentLookup:w,edges:_,edgeLookup:S,connectionLookup:E,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:r!==void 0,hasDefaultEdges:l!==void 0,panZoom:null,minZoom:d,maxZoom:h,translateExtent:$o,nodeExtent:A,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:ha.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:k,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:u??!1,fitViewOptions:c,fitViewResolver:null,connection:{...w_},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:nA,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:b_,zIndexMode:x,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},VM=({nodes:e,edges:t,defaultNodes:r,defaultEdges:l,width:a,height:o,fitView:u,fitViewOptions:c,minZoom:d,maxZoom:h,nodeOrigin:m,nodeExtent:p,zIndexMode:x})=>az((b,w)=>{async function E(){const{nodeLookup:S,panZoom:_,fitViewOptions:N,fitViewResolver:k,width:A,height:M,minZoom:T,maxZoom:L}=w();_&&(await eA({nodes:S,width:A,height:M,panZoom:_,minZoom:T,maxZoom:L},N),k==null||k.resolve(!0),b({fitViewResolver:null}))}return{...yb({nodes:e,edges:t,width:a,height:o,fitView:u,fitViewOptions:c,minZoom:d,maxZoom:h,nodeOrigin:m,nodeExtent:p,defaultNodes:r,defaultEdges:l,zIndexMode:x}),setNodes:S=>{const{nodeLookup:_,parentLookup:N,nodeOrigin:k,elevateNodesOnSelect:A,fitViewQueued:M,zIndexMode:T}=w(),L=rm(S,_,N,{nodeOrigin:k,nodeExtent:p,elevateNodesOnSelect:A,checkEquality:!0,zIndexMode:T});M&&L?(E(),b({nodes:S,nodesInitialized:L,fitViewQueued:!1,fitViewOptions:void 0})):b({nodes:S,nodesInitialized:L})},setEdges:S=>{const{connectionLookup:_,edgeLookup:N}=w();B_(_,N,S),b({edges:S})},setDefaultNodesAndEdges:(S,_)=>{if(S){const{setNodes:N}=w();N(S),b({hasDefaultNodes:!0})}if(_){const{setEdges:N}=w();N(_),b({hasDefaultEdges:!0})}},updateNodeInternals:S=>{const{triggerNodeChanges:_,nodeLookup:N,parentLookup:k,domNode:A,nodeOrigin:M,nodeExtent:T,debug:L,fitViewQueued:R,zIndexMode:V}=w(),{changes:H,updatedInternals:B}=kA(S,N,k,A,M,T,V);B&&(bA(N,k,{nodeOrigin:M,nodeExtent:T,zIndexMode:V}),R?(E(),b({fitViewQueued:!1,fitViewOptions:void 0})):b({}),(H==null?void 0:H.length)>0&&(L&&console.log("React Flow: trigger node changes",H),_==null||_(H)))},updateNodePositions:(S,_=!1)=>{const N=[];let k=[];const{nodeLookup:A,triggerNodeChanges:M,connection:T,updateConnection:L,onNodesChangeMiddlewareMap:R}=w();for(const[V,H]of S){const B=A.get(V),U=!!(B!=null&&B.expandParent&&(B!=null&&B.parentId)&&(H!=null&&H.position)),ee={id:V,type:"position",position:U?{x:Math.max(0,H.position.x),y:Math.max(0,H.position.y)}:H.position,dragging:_};if(B&&T.inProgress&&T.fromNode.id===B.id){const I=tl(B,T.fromHandle,ve.Left,!0);L({...T,from:I})}U&&B.parentId&&N.push({id:V,parentId:B.parentId,rect:{...H.internals.positionAbsolute,width:H.measured.width??0,height:H.measured.height??0}}),k.push(ee)}if(N.length>0){const{parentLookup:V,nodeOrigin:H}=w(),B=Im(N,A,V,H);k.push(...B)}for(const V of R.values())k=V(k);M(k)},triggerNodeChanges:S=>{const{onNodesChange:_,setNodes:N,nodes:k,hasDefaultNodes:A,debug:M}=w();if(S!=null&&S.length){if(A){const T=W_(S,k);N(T)}M&&console.log("React Flow: trigger node changes",S),_==null||_(S)}},triggerEdgeChanges:S=>{const{onEdgesChange:_,setEdges:N,edges:k,hasDefaultEdges:A,debug:M}=w();if(S!=null&&S.length){if(A){const T=eS(S,k);N(T)}M&&console.log("React Flow: trigger edge changes",S),_==null||_(S)}},addSelectedNodes:S=>{const{multiSelectionActive:_,edgeLookup:N,nodeLookup:k,triggerNodeChanges:A,triggerEdgeChanges:M}=w();if(_){const T=S.map(L=>Pi(L,!0));A(T);return}A(ia(k,new Set([...S]),!0)),M(ia(N))},addSelectedEdges:S=>{const{multiSelectionActive:_,edgeLookup:N,nodeLookup:k,triggerNodeChanges:A,triggerEdgeChanges:M}=w();if(_){const T=S.map(L=>Pi(L,!0));M(T);return}M(ia(N,new Set([...S]))),A(ia(k,new Set,!0))},unselectNodesAndEdges:({nodes:S,edges:_}={})=>{const{edges:N,nodes:k,nodeLookup:A,triggerNodeChanges:M,triggerEdgeChanges:T}=w(),L=S||k,R=_||N,V=[];for(const B of L){if(!B.selected)continue;const U=A.get(B.id);U&&(U.selected=!1),V.push(Pi(B.id,!1))}const H=[];for(const B of R)B.selected&&H.push(Pi(B.id,!1));M(V),T(H)},setMinZoom:S=>{const{panZoom:_,maxZoom:N}=w();_==null||_.setScaleExtent([S,N]),b({minZoom:S})},setMaxZoom:S=>{const{panZoom:_,minZoom:N}=w();_==null||_.setScaleExtent([N,S]),b({maxZoom:S})},setTranslateExtent:S=>{var _;(_=w().panZoom)==null||_.setTranslateExtent(S),b({translateExtent:S})},resetSelectedElements:()=>{const{edges:S,nodes:_,triggerNodeChanges:N,triggerEdgeChanges:k,elementsSelectable:A}=w();if(!A)return;const M=_.reduce((L,R)=>R.selected?[...L,Pi(R.id,!1)]:L,[]),T=S.reduce((L,R)=>R.selected?[...L,Pi(R.id,!1)]:L,[]);N(M),k(T)},setNodeExtent:S=>{const{nodes:_,nodeLookup:N,parentLookup:k,nodeOrigin:A,elevateNodesOnSelect:M,nodeExtent:T,zIndexMode:L}=w();S[0][0]===T[0][0]&&S[0][1]===T[0][1]&&S[1][0]===T[1][0]&&S[1][1]===T[1][1]||(rm(_,N,k,{nodeOrigin:A,nodeExtent:S,elevateNodesOnSelect:M,checkEquality:!1,zIndexMode:L}),b({nodeExtent:S}))},panBy:S=>{const{transform:_,width:N,height:k,panZoom:A,translateExtent:M}=w();return EA({delta:S,panZoom:A,transform:_,translateExtent:M,width:N,height:k})},setCenter:async(S,_,N)=>{const{width:k,height:A,maxZoom:M,panZoom:T}=w();if(!T)return Promise.resolve(!1);const L=typeof(N==null?void 0:N.zoom)<"u"?N.zoom:M;return await T.setViewport({x:k/2-S*L,y:A/2-_*L,zoom:L},{duration:N==null?void 0:N.duration,ease:N==null?void 0:N.ease,interpolate:N==null?void 0:N.interpolate}),Promise.resolve(!0)},cancelConnection:()=>{b({connection:{...w_}})},updateConnection:S=>{b({connection:S})},reset:()=>b({...yb()})}},Object.is);function PM({initialNodes:e,initialEdges:t,defaultNodes:r,defaultEdges:l,initialWidth:a,initialHeight:o,initialMinZoom:u,initialMaxZoom:c,initialFitViewOptions:d,fitView:h,nodeOrigin:m,nodeExtent:p,zIndexMode:x,children:b}){const[w]=$.useState(()=>VM({nodes:e,edges:t,defaultNodes:r,defaultEdges:l,width:a,height:o,fitView:h,minZoom:u,maxZoom:c,fitViewOptions:d,nodeOrigin:m,nodeExtent:p,zIndexMode:x}));return y.jsx(sz,{value:w,children:y.jsx(zz,{children:b})})}function GM({children:e,nodes:t,edges:r,defaultNodes:l,defaultEdges:a,width:o,height:u,fitView:c,fitViewOptions:d,minZoom:h,maxZoom:m,nodeOrigin:p,nodeExtent:x,zIndexMode:b}){return $.useContext(Hc)?y.jsx(y.Fragment,{children:e}):y.jsx(PM,{initialNodes:t,initialEdges:r,defaultNodes:l,defaultEdges:a,initialWidth:o,initialHeight:u,fitView:c,initialFitViewOptions:d,initialMinZoom:h,initialMaxZoom:m,nodeOrigin:p,nodeExtent:x,zIndexMode:b,children:e})}const FM={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function YM({nodes:e,edges:t,defaultNodes:r,defaultEdges:l,className:a,nodeTypes:o,edgeTypes:u,onNodeClick:c,onEdgeClick:d,onInit:h,onMove:m,onMoveStart:p,onMoveEnd:x,onConnect:b,onConnectStart:w,onConnectEnd:E,onClickConnectStart:S,onClickConnectEnd:_,onNodeMouseEnter:N,onNodeMouseMove:k,onNodeMouseLeave:A,onNodeContextMenu:M,onNodeDoubleClick:T,onNodeDragStart:L,onNodeDrag:R,onNodeDragStop:V,onNodesDelete:H,onEdgesDelete:B,onDelete:U,onSelectionChange:ee,onSelectionDragStart:I,onSelectionDrag:F,onSelectionDragStop:z,onSelectionContextMenu:G,onSelectionStart:Q,onSelectionEnd:K,onBeforeDelete:D,connectionMode:q,connectionLineType:Y=xi.Bezier,connectionLineStyle:C,connectionLineComponent:P,connectionLineContainerStyle:X,deleteKeyCode:J="Backspace",selectionKeyCode:ne="Shift",selectionOnDrag:re=!1,selectionMode:se=Vo.Full,panActivationKeyCode:xe="Space",multiSelectionKeyCode:be=Go()?"Meta":"Control",zoomActivationKeyCode:ye=Go()?"Meta":"Control",snapToGrid:pe,snapGrid:Se,onlyRenderVisibleElements:ze=!1,selectNodesOnDrag:je,nodesDraggable:ut,autoPanOnNodeFocus:nt,nodesConnectable:zt,nodesFocusable:Vt,nodeOrigin:Ht=K_,edgesFocusable:kn,edgesReconnectable:Rn,elementsSelectable:Mt=!0,defaultViewport:Hr=wz,minZoom:ce=.5,maxZoom:ge=2,translateExtent:Ne=$o,preventScrolling:Le=!0,nodeExtent:Xe,defaultMarkerColor:Qt="#b1b1b7",zoomOnScroll:On=!0,zoomOnPinch:Bt=!0,panOnScroll:vt=!1,panOnScrollSpeed:Pt=.5,panOnScrollMode:We=Zi.Free,zoomOnDoubleClick:Qn=!0,panOnDrag:fn=!0,onPaneClick:Xc,onPaneMouseEnter:cl,onPaneMouseMove:fl,onPaneMouseLeave:dl,onPaneScroll:sr,onPaneContextMenu:hl,paneClickDistance:bi=1,nodeClickDistance:Qc=0,children:ss,onReconnect:wa,onReconnectStart:wi,onReconnectEnd:Zc,onEdgeContextMenu:us,onEdgeDoubleClick:cs,onEdgeMouseEnter:fs,onEdgeMouseMove:_a,onEdgeMouseLeave:Sa,reconnectRadius:ds=10,onNodesChange:hs,onEdgesChange:Zn,noDragClassName:Dt="nodrag",noWheelClassName:Gt="nowheel",noPanClassName:ur="nopan",fitView:pl,fitViewOptions:ps,connectOnClick:Kc,attributionPosition:ms,proOptions:_i,defaultEdgeOptions:ka,elevateNodesOnSelect:Br=!0,elevateEdgesOnSelect:Ir=!1,disableKeyboardA11y:qr=!1,autoPanOnConnect:Ur,autoPanOnNodeDrag:_t,autoPanSpeed:gs,connectionRadius:xs,isValidConnection:cr,onError:$r,style:Jc,id:Ea,nodeDragThreshold:ys,connectionDragThreshold:Wc,viewport:ml,onViewportChange:gl,width:Ln,height:Wt,colorMode:vs="light",debug:ef,onScroll:Vr,ariaLabelConfig:bs,zIndexMode:Si="basic",...tf},en){const ki=Ea||"1",ws=Ez(vs),Na=$.useCallback(fr=>{fr.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),Vr==null||Vr(fr)},[Vr]);return y.jsx("div",{"data-testid":"rf__wrapper",...tf,onScroll:Na,style:{...Jc,...FM},ref:en,className:At(["react-flow",a,ws]),id:Ea,role:"application",children:y.jsxs(GM,{nodes:e,edges:t,width:Ln,height:Wt,fitView:pl,fitViewOptions:ps,minZoom:ce,maxZoom:ge,nodeOrigin:Ht,nodeExtent:Xe,zIndexMode:Si,children:[y.jsx($M,{onInit:h,onNodeClick:c,onEdgeClick:d,onNodeMouseEnter:N,onNodeMouseMove:k,onNodeMouseLeave:A,onNodeContextMenu:M,onNodeDoubleClick:T,nodeTypes:o,edgeTypes:u,connectionLineType:Y,connectionLineStyle:C,connectionLineComponent:P,connectionLineContainerStyle:X,selectionKeyCode:ne,selectionOnDrag:re,selectionMode:se,deleteKeyCode:J,multiSelectionKeyCode:be,panActivationKeyCode:xe,zoomActivationKeyCode:ye,onlyRenderVisibleElements:ze,defaultViewport:Hr,translateExtent:Ne,minZoom:ce,maxZoom:ge,preventScrolling:Le,zoomOnScroll:On,zoomOnPinch:Bt,zoomOnDoubleClick:Qn,panOnScroll:vt,panOnScrollSpeed:Pt,panOnScrollMode:We,panOnDrag:fn,onPaneClick:Xc,onPaneMouseEnter:cl,onPaneMouseMove:fl,onPaneMouseLeave:dl,onPaneScroll:sr,onPaneContextMenu:hl,paneClickDistance:bi,nodeClickDistance:Qc,onSelectionContextMenu:G,onSelectionStart:Q,onSelectionEnd:K,onReconnect:wa,onReconnectStart:wi,onReconnectEnd:Zc,onEdgeContextMenu:us,onEdgeDoubleClick:cs,onEdgeMouseEnter:fs,onEdgeMouseMove:_a,onEdgeMouseLeave:Sa,reconnectRadius:ds,defaultMarkerColor:Qt,noDragClassName:Dt,noWheelClassName:Gt,noPanClassName:ur,rfId:ki,disableKeyboardA11y:qr,nodeExtent:Xe,viewport:ml,onViewportChange:gl}),y.jsx(kz,{nodes:e,edges:t,defaultNodes:r,defaultEdges:l,onConnect:b,onConnectStart:w,onConnectEnd:E,onClickConnectStart:S,onClickConnectEnd:_,nodesDraggable:ut,autoPanOnNodeFocus:nt,nodesConnectable:zt,nodesFocusable:Vt,edgesFocusable:kn,edgesReconnectable:Rn,elementsSelectable:Mt,elevateNodesOnSelect:Br,elevateEdgesOnSelect:Ir,minZoom:ce,maxZoom:ge,nodeExtent:Xe,onNodesChange:hs,onEdgesChange:Zn,snapToGrid:pe,snapGrid:Se,connectionMode:q,translateExtent:Ne,connectOnClick:Kc,defaultEdgeOptions:ka,fitView:pl,fitViewOptions:ps,onNodesDelete:H,onEdgesDelete:B,onDelete:U,onNodeDragStart:L,onNodeDrag:R,onNodeDragStop:V,onSelectionDrag:F,onSelectionDragStart:I,onSelectionDragStop:z,onMove:m,onMoveStart:p,onMoveEnd:x,noPanClassName:ur,nodeOrigin:Ht,rfId:ki,autoPanOnConnect:Ur,autoPanOnNodeDrag:_t,autoPanSpeed:gs,onError:$r,connectionRadius:xs,isValidConnection:cr,selectNodesOnDrag:je,nodeDragThreshold:ys,connectionDragThreshold:Wc,onBeforeDelete:D,debug:ef,ariaLabelConfig:bs,zIndexMode:Si}),y.jsx(bz,{onSelectionChange:ee}),ss,y.jsx(mz,{proOptions:_i,position:ms}),y.jsx(pz,{rfId:ki,disableKeyboardA11y:qr})]})})}var XM=tS(YM);const QM=e=>{var t;return(t=e.domNode)==null?void 0:t.querySelector(".react-flow__edgelabel-renderer")};function ZM({children:e}){const t=Ye(QM);return t?oz.createPortal(e,t):null}function KM(e){const[t,r]=$.useState(e),l=$.useCallback(a=>r(o=>W_(a,o)),[]);return[t,r,l]}function JM(e){const[t,r]=$.useState(e),l=$.useCallback(a=>r(o=>eS(a,o)),[]);return[t,r,l]}function WM({dimensions:e,lineWidth:t,variant:r,className:l}){return y.jsx("path",{strokeWidth:t,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:At(["react-flow__background-pattern",r,l])})}function e5({radius:e,className:t}){return y.jsx("circle",{cx:e,cy:e,r:e,className:At(["react-flow__background-pattern","dots",t])})}var Mr;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(Mr||(Mr={}));const t5={[Mr.Dots]:1,[Mr.Lines]:1,[Mr.Cross]:6},n5=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function ES({id:e,variant:t=Mr.Dots,gap:r=20,size:l,lineWidth:a=1,offset:o=0,color:u,bgColor:c,style:d,className:h,patternClassName:m}){const p=$.useRef(null),{transform:x,patternId:b}=Ye(n5,pt),w=l||t5[t],E=t===Mr.Dots,S=t===Mr.Cross,_=Array.isArray(r)?r:[r,r],N=[_[0]*x[2]||1,_[1]*x[2]||1],k=w*x[2],A=Array.isArray(o)?o:[o,o],M=S?[k,k]:N,T=[A[0]*x[2]||1+M[0]/2,A[1]*x[2]||1+M[1]/2],L=`${b}${e||""}`;return y.jsxs("svg",{className:At(["react-flow__background",h]),style:{...d,...Ic,"--xy-background-color-props":c,"--xy-background-pattern-color-props":u},ref:p,"data-testid":"rf__background",children:[y.jsx("pattern",{id:L,x:x[0]%N[0],y:x[1]%N[1],width:N[0],height:N[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${T[0]},-${T[1]})`,children:E?y.jsx(e5,{radius:k/2,className:m}):y.jsx(WM,{dimensions:M,lineWidth:a,variant:t,className:m})}),y.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${L})`})]})}ES.displayName="Background";const r5=$.memo(ES);function i5(){return y.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:y.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function l5(){return y.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:y.jsx("path",{d:"M0 0h32v4.2H0z"})})}function a5(){return y.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:y.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 o5(){return y.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:y.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 s5(){return y.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:y.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 Pu({children:e,className:t,...r}){return y.jsx("button",{type:"button",className:At(["react-flow__controls-button",t]),...r,children:e})}const u5=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function NS({style:e,showZoom:t=!0,showFitView:r=!0,showInteractive:l=!0,fitViewOptions:a,onZoomIn:o,onZoomOut:u,onFitView:c,onInteractiveChange:d,className:h,children:m,position:p="bottom-left",orientation:x="vertical","aria-label":b}){const w=mt(),{isInteractive:E,minZoomReached:S,maxZoomReached:_,ariaLabelConfig:N}=Ye(u5,pt),{zoomIn:k,zoomOut:A,fitView:M}=al(),T=()=>{k(),o==null||o()},L=()=>{A(),u==null||u()},R=()=>{M(a),c==null||c()},V=()=>{w.setState({nodesDraggable:!E,nodesConnectable:!E,elementsSelectable:!E}),d==null||d(!E)},H=x==="horizontal"?"horizontal":"vertical";return y.jsxs(Bc,{className:At(["react-flow__controls",H,h]),position:p,style:e,"data-testid":"rf__controls","aria-label":b??N["controls.ariaLabel"],children:[t&&y.jsxs(y.Fragment,{children:[y.jsx(Pu,{onClick:T,className:"react-flow__controls-zoomin",title:N["controls.zoomIn.ariaLabel"],"aria-label":N["controls.zoomIn.ariaLabel"],disabled:_,children:y.jsx(i5,{})}),y.jsx(Pu,{onClick:L,className:"react-flow__controls-zoomout",title:N["controls.zoomOut.ariaLabel"],"aria-label":N["controls.zoomOut.ariaLabel"],disabled:S,children:y.jsx(l5,{})})]}),r&&y.jsx(Pu,{className:"react-flow__controls-fitview",onClick:R,title:N["controls.fitView.ariaLabel"],"aria-label":N["controls.fitView.ariaLabel"],children:y.jsx(a5,{})}),l&&y.jsx(Pu,{className:"react-flow__controls-interactive",onClick:V,title:N["controls.interactive.ariaLabel"],"aria-label":N["controls.interactive.ariaLabel"],children:E?y.jsx(s5,{}):y.jsx(o5,{})}),m]})}NS.displayName="Controls";const c5=$.memo(NS);function f5({id:e,x:t,y:r,width:l,height:a,style:o,color:u,strokeColor:c,strokeWidth:d,className:h,borderRadius:m,shapeRendering:p,selected:x,onClick:b}){const{background:w,backgroundColor:E}=o||{},S=u||w||E;return y.jsx("rect",{className:At(["react-flow__minimap-node",{selected:x},h]),x:t,y:r,rx:m,ry:m,width:l,height:a,style:{fill:S,stroke:c,strokeWidth:d},shapeRendering:p,onClick:b?_=>b(_,e):void 0})}const d5=$.memo(f5),h5=e=>e.nodes.map(t=>t.id),Ah=e=>e instanceof Function?e:()=>e;function p5({nodeStrokeColor:e,nodeColor:t,nodeClassName:r="",nodeBorderRadius:l=5,nodeStrokeWidth:a,nodeComponent:o=d5,onClick:u}){const c=Ye(h5,pt),d=Ah(t),h=Ah(e),m=Ah(r),p=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return y.jsx(y.Fragment,{children:c.map(x=>y.jsx(g5,{id:x,nodeColorFunc:d,nodeStrokeColorFunc:h,nodeClassNameFunc:m,nodeBorderRadius:l,nodeStrokeWidth:a,NodeComponent:o,onClick:u,shapeRendering:p},x))})}function m5({id:e,nodeColorFunc:t,nodeStrokeColorFunc:r,nodeClassNameFunc:l,nodeBorderRadius:a,nodeStrokeWidth:o,shapeRendering:u,NodeComponent:c,onClick:d}){const{node:h,x:m,y:p,width:x,height:b}=Ye(w=>{const E=w.nodeLookup.get(e);if(!E)return{node:void 0,x:0,y:0,width:0,height:0};const S=E.internals.userNode,{x:_,y:N}=E.internals.positionAbsolute,{width:k,height:A}=Or(S);return{node:S,x:_,y:N,width:k,height:A}},pt);return!h||h.hidden||!j_(h)?null:y.jsx(c,{x:m,y:p,width:x,height:b,style:h.style,selected:!!h.selected,className:l(h),color:t(h),borderRadius:a,strokeColor:r(h),strokeWidth:o,shapeRendering:u,onClick:d,id:h.id})}const g5=$.memo(m5);var x5=$.memo(p5);const y5=200,v5=150,b5=e=>!e.hidden,w5=e=>{const 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?C_(es(e.nodeLookup,{filter:b5}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},_5="react-flow__minimap-desc";function CS({style:e,className:t,nodeStrokeColor:r,nodeColor:l,nodeClassName:a="",nodeBorderRadius:o=5,nodeStrokeWidth:u,nodeComponent:c,bgColor:d,maskColor:h,maskStrokeColor:m,maskStrokeWidth:p,position:x="bottom-right",onClick:b,onNodeClick:w,pannable:E=!1,zoomable:S=!1,ariaLabel:_,inversePan:N,zoomStep:k=1,offsetScale:A=5}){const M=mt(),T=$.useRef(null),{boundingRect:L,viewBB:R,rfId:V,panZoom:H,translateExtent:B,flowWidth:U,flowHeight:ee,ariaLabelConfig:I}=Ye(w5,pt),F=(e==null?void 0:e.width)??y5,z=(e==null?void 0:e.height)??v5,G=L.width/F,Q=L.height/z,K=Math.max(G,Q),D=K*F,q=K*z,Y=A*K,C=L.x-(D-L.width)/2-Y,P=L.y-(q-L.height)/2-Y,X=D+Y*2,J=q+Y*2,ne=`${_5}-${V}`,re=$.useRef(0),se=$.useRef();re.current=K,$.useEffect(()=>{if(T.current&&H)return se.current=RA({domNode:T.current,panZoom:H,getTransform:()=>M.getState().transform,getViewScale:()=>re.current}),()=>{var pe;(pe=se.current)==null||pe.destroy()}},[H]),$.useEffect(()=>{var pe;(pe=se.current)==null||pe.update({translateExtent:B,width:U,height:ee,inversePan:N,pannable:E,zoomStep:k,zoomable:S})},[E,S,N,k,B,U,ee]);const xe=b?pe=>{var je;const[Se,ze]=((je=se.current)==null?void 0:je.pointer(pe))||[0,0];b(pe,{x:Se,y:ze})}:void 0,be=w?$.useCallback((pe,Se)=>{const ze=M.getState().nodeLookup.get(Se).internals.userNode;w(pe,ze)},[]):void 0,ye=_??I["minimap.ariaLabel"];return y.jsx(Bc,{position:x,style:{...e,"--xy-minimap-background-color-props":typeof d=="string"?d:void 0,"--xy-minimap-mask-background-color-props":typeof h=="string"?h:void 0,"--xy-minimap-mask-stroke-color-props":typeof m=="string"?m:void 0,"--xy-minimap-mask-stroke-width-props":typeof p=="number"?p*K:void 0,"--xy-minimap-node-background-color-props":typeof l=="string"?l:void 0,"--xy-minimap-node-stroke-color-props":typeof r=="string"?r:void 0,"--xy-minimap-node-stroke-width-props":typeof u=="number"?u:void 0},className:At(["react-flow__minimap",t]),"data-testid":"rf__minimap",children:y.jsxs("svg",{width:F,height:z,viewBox:`${C} ${P} ${X} ${J}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":ne,ref:T,onClick:xe,children:[ye&&y.jsx("title",{id:ne,children:ye}),y.jsx(x5,{onClick:be,nodeColor:l,nodeStrokeColor:r,nodeBorderRadius:o,nodeClassName:a,nodeStrokeWidth:u,nodeComponent:c}),y.jsx("path",{className:"react-flow__minimap-mask",d:`M${C-Y},${P-Y}h${X+Y*2}v${J+Y*2}h${-X-Y*2}z - M${R.x},${R.y}h${R.width}v${R.height}h${-R.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}CS.displayName="MiniMap";const S5=$.memo(CS),k5=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,E5={[xa.Line]:"right",[xa.Handle]:"bottom-right"};function N5({nodeId:e,position:t,variant:r=xa.Handle,className:l,style:a=void 0,children:o,color:u,minWidth:c=10,minHeight:d=10,maxWidth:h=Number.MAX_VALUE,maxHeight:m=Number.MAX_VALUE,keepAspectRatio:p=!1,resizeDirection:x,autoScale:b=!0,shouldResize:w,onResizeStart:E,onResize:S,onResizeEnd:_}){const N=lS(),k=typeof e=="string"?e:N,A=mt(),M=$.useRef(null),T=r===xa.Handle,L=Ye($.useCallback(k5(T&&b),[T,b]),pt),R=$.useRef(null),V=t??E5[r];$.useEffect(()=>{if(!(!M.current||!k))return R.current||(R.current=XA({domNode:M.current,nodeId:k,getStoreItems:()=>{const{nodeLookup:B,transform:U,snapGrid:ee,snapToGrid:I,nodeOrigin:F,domNode:z}=A.getState();return{nodeLookup:B,transform:U,snapGrid:ee,snapToGrid:I,nodeOrigin:F,paneDomNode:z}},onChange:(B,U)=>{const{triggerNodeChanges:ee,nodeLookup:I,parentLookup:F,nodeOrigin:z}=A.getState(),G=[],Q={x:B.x,y:B.y},K=I.get(k);if(K&&K.expandParent&&K.parentId){const D=K.origin??z,q=B.width??K.measured.width??0,Y=B.height??K.measured.height??0,C={id:K.id,parentId:K.parentId,rect:{width:q,height:Y,...T_({x:B.x??K.position.x,y:B.y??K.position.y},{width:q,height:Y},K.parentId,I,D)}},P=Im([C],I,F,z);G.push(...P),Q.x=B.x?Math.max(D[0]*q,B.x):void 0,Q.y=B.y?Math.max(D[1]*Y,B.y):void 0}if(Q.x!==void 0&&Q.y!==void 0){const D={id:k,type:"position",position:{...Q}};G.push(D)}if(B.width!==void 0&&B.height!==void 0){const q={id:k,type:"dimensions",resizing:!0,setAttributes:x?x==="horizontal"?"width":"height":!0,dimensions:{width:B.width,height:B.height}};G.push(q)}for(const D of U){const q={...D,type:"position"};G.push(q)}ee(G)},onEnd:({width:B,height:U})=>{const ee={id:k,type:"dimensions",resizing:!1,dimensions:{width:B,height:U}};A.getState().triggerNodeChanges([ee])}})),R.current.update({controlPosition:V,boundaries:{minWidth:c,minHeight:d,maxWidth:h,maxHeight:m},keepAspectRatio:p,resizeDirection:x,onResizeStart:E,onResize:S,onResizeEnd:_,shouldResize:w}),()=>{var B;(B=R.current)==null||B.destroy()}},[V,c,d,h,m,p,E,S,_,w]);const H=V.split("-");return y.jsx("div",{className:At(["react-flow__resize-control","nodrag",...H,r,l]),ref:M,style:{...a,scale:L,...u&&{[T?"backgroundColor":"borderColor"]:u}},children:o})}$.memo(N5);function is(e,t){if(t.length===0)return null;let r=e[t[0]];for(let l=1;ll.viewContextPath),t=ue(l=>l.nodes),r=ue(l=>l.subworkflowContexts);return $.useMemo(()=>{var l;return e.length===0?t:((l=is(r,e))==null?void 0:l.nodes)??t},[e,t,r])}function C5(){const e=ue(l=>l.viewContextPath),t=ue(l=>l.groupProgress),r=ue(l=>l.subworkflowContexts);return $.useMemo(()=>{var l;return e.length===0?t:((l=is(r,e))==null?void 0:l.groupProgress)??t},[e,t,r])}function j5(){const e=ue(l=>l.viewContextPath),t=ue(l=>l.highlightedEdges),r=ue(l=>l.subworkflowContexts);return $.useMemo(()=>{var l;return e.length===0?t:((l=is(r,e))==null?void 0:l.highlightedEdges)??t},[e,t,r])}function Um(){const e=ue(r=>r.viewContextPath),t=ue(r=>r.subworkflowContexts);return $.useMemo(()=>{var r;return e.length===0?t:((r=is(t,e))==null?void 0:r.children)??[]},[e,t])}function T5(){const e=ue(h=>h.viewContextPath),t=ue(h=>h.agents),r=ue(h=>h.routes),l=ue(h=>h.parallelGroups),a=ue(h=>h.forEachGroups),o=ue(h=>h.nodes),u=ue(h=>h.groupProgress),c=ue(h=>h.entryPoint),d=ue(h=>h.subworkflowContexts);return $.useMemo(()=>{if(e.length===0)return{agents:t,routes:r,parallelGroups:l,forEachGroups:a,nodes:o,groupProgress:u,entryPoint:c,subworkflowContexts:d,parentAgent:null};const h=is(d,e);return h?{agents:h.agents,routes:h.routes,parallelGroups:h.parallelGroups,forEachGroups:h.forEachGroups,nodes:h.nodes,groupProgress:h.groupProgress,entryPoint:h.entryPoint,subworkflowContexts:h.children,parentAgent:h.parentAgent}:{agents:t,routes:r,parallelGroups:l,forEachGroups:a,nodes:o,groupProgress:u,entryPoint:c,subworkflowContexts:d,parentAgent:null}},[e,t,r,l,a,o,u,c,d])}function A5(){const e=new URLSearchParams(window.location.search);return{subworkflowPath:e.get("subworkflow"),agent:e.get("agent")}}function vb(e,t){const r=[];let l=e;for(const a of t){let o=-1;for(let u=l.length-1;u>=0;u--)if(l[u].slotKey===a){o=u;break}if(o===-1){for(let u=l.length-1;u>=0;u--)if(l[u].parentAgent===a){o=u;break}}if(o===-1)return{path:r,failedSegment:a};r.push(o),l=l[o].children}return{path:r,failedSegment:null}}function am(e,t,r=[]){const l=[];for(let a=0;ac.name===t)&&l.push({path:u,ctx:o}),o.children.length>0&&l.push(...am(o.children,t,u))}return l}function z5(e){return e.length===0?null:[...e].sort((t,r)=>{const l=t.ctx.status==="running"?1:0,a=r.ctx.status==="running"?1:0;if(l!==a)return a-l;if(t.path.length!==r.path.length)return r.path.length-t.path.length;for(let o=0;o{if(r.current||!u)return;let c=null,d=null,h=null;const m=()=>{if(r.current)return;r.current=!0,c&&clearTimeout(c),d&&clearTimeout(d),h&&h();const b=ue.getState();if(b.agents.length===0){t({message:"Workflow state did not load."});return}let w=[];if(a){const E=a.split("/").filter(Boolean),S=vb(b.subworkflowContexts,E);if(S.failedSegment){const _=E.slice(0,S.path.length).join("/");t({message:`Subworkflow "${S.failedSegment}" not found${_?` (resolved: ${_})`:""}. It may not have started yet.`});return}w=S.path}if(o){if((w.length===0?b.agents:(()=>{let S,_=b.subworkflowContexts;for(const N of w){if(S=_[N],!S)break;_=S.children}return(S==null?void 0:S.agents)??[]})()).some(S=>S.name===o))ue.setState({viewContextPath:w,selectedNode:o});else{const S=am(b.subworkflowContexts,o);if(S.length===0){const N=a||"root workflow";ue.setState({viewContextPath:w,selectedNode:null}),t({message:`Agent "${o}" not found in ${N}.`});return}if(a){const N=S.slice(0,5).map(A=>M5(b.subworkflowContexts,A.path)).join(", "),k=S.length>5?`, and ${S.length-5} more`:"";ue.setState({viewContextPath:w,selectedNode:null}),t({message:`Agent "${o}" not found in ${a}. Found in: ${N}${k}`});return}const _=z5(S);ue.setState({viewContextPath:_.path,selectedNode:o})}setTimeout(()=>{l({nodes:[{id:o}],padding:.5,duration:400})},200)}else a&&ue.setState({viewContextPath:w,selectedNode:null})},p=()=>{const b=ue.getState();if(b.agents.length===0)return!1;if(b.workflowStatus!=="running"&&b.workflowStatus!=="pending")return!0;if(a){const w=a.split("/").filter(Boolean),{failedSegment:E}=vb(b.subworkflowContexts,w);if(E)return!1}return!(o&&!a&&!b.agents.some(E=>E.name===o)&&am(b.subworkflowContexts,o).length===0)},x=()=>{c&&clearTimeout(c),c=setTimeout(()=>{r.current||p()&&m()},200)};return h=ue.subscribe(x),d=setTimeout(()=>{r.current||m()},5e3),x(),()=>{c&&clearTimeout(c),d&&clearTimeout(d),h&&h()}},[u,a,o,l]),e}var zh,bb;function $m(){if(bb)return zh;bb=1;var e="\0",t="\0",r="";class l{constructor(m){Ct(this,"_isDirected",!0);Ct(this,"_isMultigraph",!1);Ct(this,"_isCompound",!1);Ct(this,"_label");Ct(this,"_defaultNodeLabelFn",()=>{});Ct(this,"_defaultEdgeLabelFn",()=>{});Ct(this,"_nodes",{});Ct(this,"_in",{});Ct(this,"_preds",{});Ct(this,"_out",{});Ct(this,"_sucs",{});Ct(this,"_edgeObjs",{});Ct(this,"_edgeLabels",{});Ct(this,"_nodeCount",0);Ct(this,"_edgeCount",0);Ct(this,"_parent");Ct(this,"_children");m&&(this._isDirected=Object.hasOwn(m,"directed")?m.directed:!0,this._isMultigraph=Object.hasOwn(m,"multigraph")?m.multigraph:!1,this._isCompound=Object.hasOwn(m,"compound")?m.compound:!1),this._isCompound&&(this._parent={},this._children={},this._children[t]={})}isDirected(){return this._isDirected}isMultigraph(){return this._isMultigraph}isCompound(){return this._isCompound}setGraph(m){return this._label=m,this}graph(){return this._label}setDefaultNodeLabel(m){return this._defaultNodeLabelFn=m,typeof m!="function"&&(this._defaultNodeLabelFn=()=>m),this}nodeCount(){return this._nodeCount}nodes(){return Object.keys(this._nodes)}sources(){var m=this;return this.nodes().filter(p=>Object.keys(m._in[p]).length===0)}sinks(){var m=this;return this.nodes().filter(p=>Object.keys(m._out[p]).length===0)}setNodes(m,p){var x=arguments,b=this;return m.forEach(function(w){x.length>1?b.setNode(w,p):b.setNode(w)}),this}setNode(m,p){return Object.hasOwn(this._nodes,m)?(arguments.length>1&&(this._nodes[m]=p),this):(this._nodes[m]=arguments.length>1?p:this._defaultNodeLabelFn(m),this._isCompound&&(this._parent[m]=t,this._children[m]={},this._children[t][m]=!0),this._in[m]={},this._preds[m]={},this._out[m]={},this._sucs[m]={},++this._nodeCount,this)}node(m){return this._nodes[m]}hasNode(m){return Object.hasOwn(this._nodes,m)}removeNode(m){var p=this;if(Object.hasOwn(this._nodes,m)){var x=b=>p.removeEdge(p._edgeObjs[b]);delete this._nodes[m],this._isCompound&&(this._removeFromParentsChildList(m),delete this._parent[m],this.children(m).forEach(function(b){p.setParent(b)}),delete this._children[m]),Object.keys(this._in[m]).forEach(x),delete this._in[m],delete this._preds[m],Object.keys(this._out[m]).forEach(x),delete this._out[m],delete this._sucs[m],--this._nodeCount}return this}setParent(m,p){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(p===void 0)p=t;else{p+="";for(var x=p;x!==void 0;x=this.parent(x))if(x===m)throw new Error("Setting "+p+" as parent of "+m+" would create a cycle");this.setNode(p)}return this.setNode(m),this._removeFromParentsChildList(m),this._parent[m]=p,this._children[p][m]=!0,this}_removeFromParentsChildList(m){delete this._children[this._parent[m]][m]}parent(m){if(this._isCompound){var p=this._parent[m];if(p!==t)return p}}children(m=t){if(this._isCompound){var p=this._children[m];if(p)return Object.keys(p)}else{if(m===t)return this.nodes();if(this.hasNode(m))return[]}}predecessors(m){var p=this._preds[m];if(p)return Object.keys(p)}successors(m){var p=this._sucs[m];if(p)return Object.keys(p)}neighbors(m){var p=this.predecessors(m);if(p){const b=new Set(p);for(var x of this.successors(m))b.add(x);return Array.from(b.values())}}isLeaf(m){var p;return this.isDirected()?p=this.successors(m):p=this.neighbors(m),p.length===0}filterNodes(m){var p=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});p.setGraph(this.graph());var x=this;Object.entries(this._nodes).forEach(function([E,S]){m(E)&&p.setNode(E,S)}),Object.values(this._edgeObjs).forEach(function(E){p.hasNode(E.v)&&p.hasNode(E.w)&&p.setEdge(E,x.edge(E))});var b={};function w(E){var S=x.parent(E);return S===void 0||p.hasNode(S)?(b[E]=S,S):S in b?b[S]:w(S)}return this._isCompound&&p.nodes().forEach(E=>p.setParent(E,w(E))),p}setDefaultEdgeLabel(m){return this._defaultEdgeLabelFn=m,typeof m!="function"&&(this._defaultEdgeLabelFn=()=>m),this}edgeCount(){return this._edgeCount}edges(){return Object.values(this._edgeObjs)}setPath(m,p){var x=this,b=arguments;return m.reduce(function(w,E){return b.length>1?x.setEdge(w,E,p):x.setEdge(w,E),E}),this}setEdge(){var m,p,x,b,w=!1,E=arguments[0];typeof E=="object"&&E!==null&&"v"in E?(m=E.v,p=E.w,x=E.name,arguments.length===2&&(b=arguments[1],w=!0)):(m=E,p=arguments[1],x=arguments[3],arguments.length>2&&(b=arguments[2],w=!0)),m=""+m,p=""+p,x!==void 0&&(x=""+x);var S=u(this._isDirected,m,p,x);if(Object.hasOwn(this._edgeLabels,S))return w&&(this._edgeLabels[S]=b),this;if(x!==void 0&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(m),this.setNode(p),this._edgeLabels[S]=w?b:this._defaultEdgeLabelFn(m,p,x);var _=c(this._isDirected,m,p,x);return m=_.v,p=_.w,Object.freeze(_),this._edgeObjs[S]=_,a(this._preds[p],m),a(this._sucs[m],p),this._in[p][S]=_,this._out[m][S]=_,this._edgeCount++,this}edge(m,p,x){var b=arguments.length===1?d(this._isDirected,arguments[0]):u(this._isDirected,m,p,x);return this._edgeLabels[b]}edgeAsObj(){const m=this.edge(...arguments);return typeof m!="object"?{label:m}:m}hasEdge(m,p,x){var b=arguments.length===1?d(this._isDirected,arguments[0]):u(this._isDirected,m,p,x);return Object.hasOwn(this._edgeLabels,b)}removeEdge(m,p,x){var b=arguments.length===1?d(this._isDirected,arguments[0]):u(this._isDirected,m,p,x),w=this._edgeObjs[b];return w&&(m=w.v,p=w.w,delete this._edgeLabels[b],delete this._edgeObjs[b],o(this._preds[p],m),o(this._sucs[m],p),delete this._in[p][b],delete this._out[m][b],this._edgeCount--),this}inEdges(m,p){var x=this._in[m];if(x){var b=Object.values(x);return p?b.filter(w=>w.v===p):b}}outEdges(m,p){var x=this._out[m];if(x){var b=Object.values(x);return p?b.filter(w=>w.w===p):b}}nodeEdges(m,p){var x=this.inEdges(m,p);if(x)return x.concat(this.outEdges(m,p))}}function a(h,m){h[m]?h[m]++:h[m]=1}function o(h,m){--h[m]||delete h[m]}function u(h,m,p,x){var b=""+m,w=""+p;if(!h&&b>w){var E=b;b=w,w=E}return b+r+w+r+(x===void 0?e:x)}function c(h,m,p,x){var b=""+m,w=""+p;if(!h&&b>w){var E=b;b=w,w=E}var S={v:b,w};return x&&(S.name=x),S}function d(h,m){return u(h,m.v,m.w,m.name)}return zh=l,zh}var Mh,wb;function R5(){return wb||(wb=1,Mh="2.2.4"),Mh}var Dh,_b;function O5(){return _b||(_b=1,Dh={Graph:$m(),version:R5()}),Dh}var Rh,Sb;function L5(){if(Sb)return Rh;Sb=1;var e=$m();Rh={write:t,read:a};function t(o){var u={options:{directed:o.isDirected(),multigraph:o.isMultigraph(),compound:o.isCompound()},nodes:r(o),edges:l(o)};return o.graph()!==void 0&&(u.value=structuredClone(o.graph())),u}function r(o){return o.nodes().map(function(u){var c=o.node(u),d=o.parent(u),h={v:u};return c!==void 0&&(h.value=c),d!==void 0&&(h.parent=d),h})}function l(o){return o.edges().map(function(u){var c=o.edge(u),d={v:u.v,w:u.w};return u.name!==void 0&&(d.name=u.name),c!==void 0&&(d.value=c),d})}function a(o){var u=new e(o.options).setGraph(o.value);return o.nodes.forEach(function(c){u.setNode(c.v,c.value),c.parent&&u.setParent(c.v,c.parent)}),o.edges.forEach(function(c){u.setEdge({v:c.v,w:c.w,name:c.name},c.value)}),u}return Rh}var Oh,kb;function H5(){if(kb)return Oh;kb=1,Oh=e;function e(t){var r={},l=[],a;function o(u){Object.hasOwn(r,u)||(r[u]=!0,a.push(u),t.successors(u).forEach(o),t.predecessors(u).forEach(o))}return t.nodes().forEach(function(u){a=[],o(u),a.length&&l.push(a)}),l}return Oh}var Lh,Eb;function jS(){if(Eb)return Lh;Eb=1;class e{constructor(){Ct(this,"_arr",[]);Ct(this,"_keyIndices",{})}size(){return this._arr.length}keys(){return this._arr.map(function(r){return r.key})}has(r){return Object.hasOwn(this._keyIndices,r)}priority(r){var l=this._keyIndices[r];if(l!==void 0)return this._arr[l].priority}min(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key}add(r,l){var a=this._keyIndices;if(r=String(r),!Object.hasOwn(a,r)){var o=this._arr,u=o.length;return a[r]=u,o.push({key:r,priority:l}),this._decrease(u),!0}return!1}removeMin(){this._swap(0,this._arr.length-1);var r=this._arr.pop();return delete this._keyIndices[r.key],this._heapify(0),r.key}decrease(r,l){var a=this._keyIndices[r];if(l>this._arr[a].priority)throw new Error("New priority is greater than current priority. Key: "+r+" Old: "+this._arr[a].priority+" New: "+l);this._arr[a].priority=l,this._decrease(a)}_heapify(r){var l=this._arr,a=2*r,o=a+1,u=r;a>1,!(l[o].priority1;function r(a,o,u,c){return l(a,String(o),u||t,c||function(d){return a.outEdges(d)})}function l(a,o,u,c){var d={},h=new e,m,p,x=function(b){var w=b.v!==m?b.v:b.w,E=d[w],S=u(b),_=p.distance+S;if(S<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+b+" Weight: "+S);_0&&(m=h.removeMin(),p=d[m],p.distance!==Number.POSITIVE_INFINITY);)c(m).forEach(x);return d}return Hh}var Bh,Cb;function B5(){if(Cb)return Bh;Cb=1;var e=TS();Bh=t;function t(r,l,a){return r.nodes().reduce(function(o,u){return o[u]=e(r,u,l,a),o},{})}return Bh}var Ih,jb;function AS(){if(jb)return Ih;jb=1,Ih=e;function e(t){var r=0,l=[],a={},o=[];function u(c){var d=a[c]={onStack:!0,lowlink:r,index:r++};if(l.push(c),t.successors(c).forEach(function(p){Object.hasOwn(a,p)?a[p].onStack&&(d.lowlink=Math.min(d.lowlink,a[p].index)):(u(p),d.lowlink=Math.min(d.lowlink,a[p].lowlink))}),d.lowlink===d.index){var h=[],m;do m=l.pop(),a[m].onStack=!1,h.push(m);while(c!==m);o.push(h)}}return t.nodes().forEach(function(c){Object.hasOwn(a,c)||u(c)}),o}return Ih}var qh,Tb;function I5(){if(Tb)return qh;Tb=1;var e=AS();qh=t;function t(r){return e(r).filter(function(l){return l.length>1||l.length===1&&r.hasEdge(l[0],l[0])})}return qh}var Uh,Ab;function q5(){if(Ab)return Uh;Ab=1,Uh=t;var e=()=>1;function t(l,a,o){return r(l,a||e,o||function(u){return l.outEdges(u)})}function r(l,a,o){var u={},c=l.nodes();return c.forEach(function(d){u[d]={},u[d][d]={distance:0},c.forEach(function(h){d!==h&&(u[d][h]={distance:Number.POSITIVE_INFINITY})}),o(d).forEach(function(h){var m=h.v===d?h.w:h.v,p=a(h);u[d][m]={distance:p,predecessor:d}})}),c.forEach(function(d){var h=u[d];c.forEach(function(m){var p=u[m];c.forEach(function(x){var b=p[d],w=h[x],E=p[x],S=b.distance+w.distance;Sa.successors(p):p=>a.neighbors(p),d=u==="post"?t:r,h=[],m={};return o.forEach(p=>{if(!a.hasNode(p))throw new Error("Graph does not have node: "+p);d(p,c,m,h)}),h}function t(a,o,u,c){for(var d=[[a,!1]];d.length>0;){var h=d.pop();h[1]?c.push(h[0]):Object.hasOwn(u,h[0])||(u[h[0]]=!0,d.push([h[0],!0]),l(o(h[0]),m=>d.push([m,!1])))}}function r(a,o,u,c){for(var d=[a];d.length>0;){var h=d.pop();Object.hasOwn(u,h)||(u[h]=!0,c.push(h),l(o(h),m=>d.push(m)))}}function l(a,o){for(var u=a.length;u--;)o(a[u],u,a);return a}return Ph}var Gh,Rb;function $5(){if(Rb)return Gh;Rb=1;var e=MS();Gh=t;function t(r,l){return e(r,l,"post")}return Gh}var Fh,Ob;function V5(){if(Ob)return Fh;Ob=1;var e=MS();Fh=t;function t(r,l){return e(r,l,"pre")}return Fh}var Yh,Lb;function P5(){if(Lb)return Yh;Lb=1;var e=$m(),t=jS();Yh=r;function r(l,a){var o=new e,u={},c=new t,d;function h(p){var x=p.v===d?p.w:p.v,b=c.priority(x);if(b!==void 0){var w=a(p);w0;){if(d=c.removeMin(),Object.hasOwn(u,d))o.setEdge(d,u[d]);else{if(m)throw new Error("Input graph is not connected: "+l);m=!0}l.nodeEdges(d).forEach(h)}return o}return Yh}var Xh,Hb;function G5(){return Hb||(Hb=1,Xh={components:H5(),dijkstra:TS(),dijkstraAll:B5(),findCycles:I5(),floydWarshall:q5(),isAcyclic:U5(),postorder:$5(),preorder:V5(),prim:P5(),tarjan:AS(),topsort:zS()}),Xh}var Qh,Bb;function Yn(){if(Bb)return Qh;Bb=1;var e=O5();return Qh={Graph:e.Graph,json:L5(),alg:G5(),version:e.version},Qh}var Zh,Ib;function F5(){if(Ib)return Zh;Ib=1;class e{constructor(){let a={};a._next=a._prev=a,this._sentinel=a}dequeue(){let a=this._sentinel,o=a._prev;if(o!==a)return t(o),o}enqueue(a){let o=this._sentinel;a._prev&&a._next&&t(a),a._next=o._next,o._next._prev=a,o._next=a,a._prev=o}toString(){let a=[],o=this._sentinel,u=o._prev;for(;u!==o;)a.push(JSON.stringify(u,r)),u=u._prev;return"["+a.join(", ")+"]"}}function t(l){l._prev._next=l._next,l._next._prev=l._prev,delete l._next,delete l._prev}function r(l,a){if(l!=="_next"&&l!=="_prev")return a}return Zh=e,Zh}var Kh,qb;function Y5(){if(qb)return Kh;qb=1;let e=Yn().Graph,t=F5();Kh=l;let r=()=>1;function l(h,m){if(h.nodeCount()<=1)return[];let p=u(h,m||r);return a(p.graph,p.buckets,p.zeroIdx).flatMap(b=>h.outEdges(b.v,b.w))}function a(h,m,p){let x=[],b=m[m.length-1],w=m[0],E;for(;h.nodeCount();){for(;E=w.dequeue();)o(h,m,p,E);for(;E=b.dequeue();)o(h,m,p,E);if(h.nodeCount()){for(let S=m.length-2;S>0;--S)if(E=m[S].dequeue(),E){x=x.concat(o(h,m,p,E,!0));break}}}return x}function o(h,m,p,x,b){let w=b?[]:void 0;return h.inEdges(x.v).forEach(E=>{let S=h.edge(E),_=h.node(E.v);b&&w.push({v:E.v,w:E.w}),_.out-=S,c(m,p,_)}),h.outEdges(x.v).forEach(E=>{let S=h.edge(E),_=E.w,N=h.node(_);N.in-=S,c(m,p,N)}),h.removeNode(x.v),w}function u(h,m){let p=new e,x=0,b=0;h.nodes().forEach(S=>{p.setNode(S,{v:S,in:0,out:0})}),h.edges().forEach(S=>{let _=p.edge(S.v,S.w)||0,N=m(S),k=_+N;p.setEdge(S.v,S.w,k),b=Math.max(b,p.node(S.v).out+=N),x=Math.max(x,p.node(S.w).in+=N)});let w=d(b+x+3).map(()=>new t),E=x+1;return p.nodes().forEach(S=>{c(w,E,p.node(S))}),{graph:p,buckets:w,zeroIdx:E}}function c(h,m,p){p.out?p.in?h[p.out-p.in+m].enqueue(p):h[h.length-1].enqueue(p):h[0].enqueue(p)}function d(h){const m=[];for(let p=0;pV.setNode(H,R.node(H))),R.edges().forEach(H=>{let B=V.edge(H.v,H.w)||{weight:0,minlen:1},U=R.edge(H);V.setEdge(H.v,H.w,{weight:B.weight+U.weight,minlen:Math.max(B.minlen,U.minlen)})}),V}function l(R){let V=new e({multigraph:R.isMultigraph()}).setGraph(R.graph());return R.nodes().forEach(H=>{R.children(H).length||V.setNode(H,R.node(H))}),R.edges().forEach(H=>{V.setEdge(H,R.edge(H))}),V}function a(R){let V=R.nodes().map(H=>{let B={};return R.outEdges(H).forEach(U=>{B[U.w]=(B[U.w]||0)+R.edge(U).weight}),B});return L(R.nodes(),V)}function o(R){let V=R.nodes().map(H=>{let B={};return R.inEdges(H).forEach(U=>{B[U.v]=(B[U.v]||0)+R.edge(U).weight}),B});return L(R.nodes(),V)}function u(R,V){let H=R.x,B=R.y,U=V.x-H,ee=V.y-B,I=R.width/2,F=R.height/2;if(!U&&!ee)throw new Error("Not possible to find intersection inside of the rectangle");let z,G;return Math.abs(ee)*I>Math.abs(U)*F?(ee<0&&(F=-F),z=F*U/ee,G=F):(U<0&&(I=-I),z=I,G=I*ee/U),{x:H+z,y:B+G}}function c(R){let V=A(w(R)+1).map(()=>[]);return R.nodes().forEach(H=>{let B=R.node(H),U=B.rank;U!==void 0&&(V[U][B.order]=H)}),V}function d(R){let V=R.nodes().map(B=>{let U=R.node(B).rank;return U===void 0?Number.MAX_VALUE:U}),H=b(Math.min,V);R.nodes().forEach(B=>{let U=R.node(B);Object.hasOwn(U,"rank")&&(U.rank-=H)})}function h(R){let V=R.nodes().map(I=>R.node(I).rank),H=b(Math.min,V),B=[];R.nodes().forEach(I=>{let F=R.node(I).rank-H;B[F]||(B[F]=[]),B[F].push(I)});let U=0,ee=R.graph().nodeRankFactor;Array.from(B).forEach((I,F)=>{I===void 0&&F%ee!==0?--U:I!==void 0&&U&&I.forEach(z=>R.node(z).rank+=U)})}function m(R,V,H,B){let U={width:0,height:0};return arguments.length>=4&&(U.rank=H,U.order=B),t(R,"border",U,V)}function p(R,V=x){const H=[];for(let B=0;Bx){const H=p(V);return R.apply(null,H.map(B=>R.apply(null,B)))}else return R.apply(null,V)}function w(R){const H=R.nodes().map(B=>{let U=R.node(B).rank;return U===void 0?Number.MIN_VALUE:U});return b(Math.max,H)}function E(R,V){let H={lhs:[],rhs:[]};return R.forEach(B=>{V(B)?H.lhs.push(B):H.rhs.push(B)}),H}function S(R,V){let H=Date.now();try{return V()}finally{console.log(R+" time: "+(Date.now()-H)+"ms")}}function _(R,V){return V()}let N=0;function k(R){var V=++N;return R+(""+V)}function A(R,V,H=1){V==null&&(V=R,R=0);let B=ee=>eeVB[V]),Object.entries(R).reduce((B,[U,ee])=>(B[U]=H(ee,U),B),{})}function L(R,V){return R.reduce((H,B,U)=>(H[B]=V[U],H),{})}return Jh}var Wh,$b;function X5(){if($b)return Wh;$b=1;let e=Y5(),t=Tt().uniqueId;Wh={run:r,undo:a};function r(o){(o.graph().acyclicer==="greedy"?e(o,c(o)):l(o)).forEach(d=>{let h=o.edge(d);o.removeEdge(d),h.forwardName=d.name,h.reversed=!0,o.setEdge(d.w,d.v,h,t("rev"))});function c(d){return h=>d.edge(h).weight}}function l(o){let u=[],c={},d={};function h(m){Object.hasOwn(d,m)||(d[m]=!0,c[m]=!0,o.outEdges(m).forEach(p=>{Object.hasOwn(c,p.w)?u.push(p):h(p.w)}),delete c[m])}return o.nodes().forEach(h),u}function a(o){o.edges().forEach(u=>{let c=o.edge(u);if(c.reversed){o.removeEdge(u);let d=c.forwardName;delete c.reversed,delete c.forwardName,o.setEdge(u.w,u.v,c,d)}})}return Wh}var ep,Vb;function Q5(){if(Vb)return ep;Vb=1;let e=Tt();ep={run:t,undo:l};function t(a){a.graph().dummyChains=[],a.edges().forEach(o=>r(a,o))}function r(a,o){let u=o.v,c=a.node(u).rank,d=o.w,h=a.node(d).rank,m=o.name,p=a.edge(o),x=p.labelRank;if(h===c+1)return;a.removeEdge(o);let b,w,E;for(E=0,++c;c{let u=a.node(o),c=u.edgeLabel,d;for(a.setEdge(u.edgeObj,c);u.dummy;)d=a.successors(o)[0],a.removeNode(o),c.points.push({x:u.x,y:u.y}),u.dummy==="edge-label"&&(c.x=u.x,c.y=u.y,c.width=u.width,c.height=u.height),o=d,u=a.node(o)})}return ep}var tp,Pb;function yc(){if(Pb)return tp;Pb=1;const{applyWithChunking:e}=Tt();tp={longestPath:t,slack:r};function t(l){var a={};function o(u){var c=l.node(u);if(Object.hasOwn(a,u))return c.rank;a[u]=!0;let d=l.outEdges(u).map(m=>m==null?Number.POSITIVE_INFINITY:o(m.w)-l.edge(m).minlen);var h=e(Math.min,d);return h===Number.POSITIVE_INFINITY&&(h=0),c.rank=h}l.sources().forEach(o)}function r(l,a){return l.node(a.w).rank-l.node(a.v).rank-l.edge(a).minlen}return tp}var np,Gb;function DS(){if(Gb)return np;Gb=1;var e=Yn().Graph,t=yc().slack;np=r;function r(u){var c=new e({directed:!1}),d=u.nodes()[0],h=u.nodeCount();c.setNode(d,{});for(var m,p;l(c,u){var p=m.v,x=h===p?m.w:p;!u.hasNode(x)&&!t(c,m)&&(u.setNode(x,{}),u.setEdge(h,x,{}),d(x))})}return u.nodes().forEach(d),u.nodeCount()}function a(u,c){return c.edges().reduce((h,m)=>{let p=Number.POSITIVE_INFINITY;return u.hasNode(m.v)!==u.hasNode(m.w)&&(p=t(c,m)),pc.node(h).rank+=d)}return np}var rp,Fb;function Z5(){if(Fb)return rp;Fb=1;var e=DS(),t=yc().slack,r=yc().longestPath,l=Yn().alg.preorder,a=Yn().alg.postorder,o=Tt().simplify;rp=u,u.initLowLimValues=m,u.initCutValues=c,u.calcCutValue=h,u.leaveEdge=x,u.enterEdge=b,u.exchangeEdges=w;function u(N){N=o(N),r(N);var k=e(N);m(k),c(k,N);for(var A,M;A=x(k);)M=b(k,N,A),w(k,N,A,M)}function c(N,k){var A=a(N,N.nodes());A=A.slice(0,A.length-1),A.forEach(M=>d(N,k,M))}function d(N,k,A){var M=N.node(A),T=M.parent;N.edge(A,T).cutvalue=h(N,k,A)}function h(N,k,A){var M=N.node(A),T=M.parent,L=!0,R=k.edge(A,T),V=0;return R||(L=!1,R=k.edge(T,A)),V=R.weight,k.nodeEdges(A).forEach(H=>{var B=H.v===A,U=B?H.w:H.v;if(U!==T){var ee=B===L,I=k.edge(H).weight;if(V+=ee?I:-I,S(N,A,U)){var F=N.edge(A,U).cutvalue;V+=ee?-F:F}}}),V}function m(N,k){arguments.length<2&&(k=N.nodes()[0]),p(N,{},1,k)}function p(N,k,A,M,T){var L=A,R=N.node(M);return k[M]=!0,N.neighbors(M).forEach(V=>{Object.hasOwn(k,V)||(A=p(N,k,A,V,M))}),R.low=L,R.lim=A++,T?R.parent=T:delete R.parent,A}function x(N){return N.edges().find(k=>N.edge(k).cutvalue<0)}function b(N,k,A){var M=A.v,T=A.w;k.hasEdge(M,T)||(M=A.w,T=A.v);var L=N.node(M),R=N.node(T),V=L,H=!1;L.lim>R.lim&&(V=R,H=!0);var B=k.edges().filter(U=>H===_(N,N.node(U.v),V)&&H!==_(N,N.node(U.w),V));return B.reduce((U,ee)=>t(k,ee)!k.node(T).parent),M=l(N,A);M=M.slice(1),M.forEach(T=>{var L=N.node(T).parent,R=k.edge(T,L),V=!1;R||(R=k.edge(L,T),V=!0),k.node(T).rank=k.node(L).rank+(V?R.minlen:-R.minlen)})}function S(N,k,A){return N.hasEdge(k,A)}function _(N,k,A){return A.low<=k.lim&&k.lim<=A.lim}return rp}var ip,Yb;function K5(){if(Yb)return ip;Yb=1;var e=yc(),t=e.longestPath,r=DS(),l=Z5();ip=a;function a(d){var h=d.graph().ranker;if(h instanceof Function)return h(d);switch(d.graph().ranker){case"network-simplex":c(d);break;case"tight-tree":u(d);break;case"longest-path":o(d);break;case"none":break;default:c(d)}}var o=t;function u(d){t(d),r(d)}function c(d){l(d)}return ip}var lp,Xb;function J5(){if(Xb)return lp;Xb=1,lp=e;function e(l){let a=r(l);l.graph().dummyChains.forEach(o=>{let u=l.node(o),c=u.edgeObj,d=t(l,a,c.v,c.w),h=d.path,m=d.lca,p=0,x=h[p],b=!0;for(;o!==c.w;){if(u=l.node(o),b){for(;(x=h[p])!==m&&l.node(x).maxRankh||m>a[p].lim));for(x=p,p=u;(p=l.parent(p))!==x;)d.push(p);return{path:c.concat(d.reverse()),lca:x}}function r(l){let a={},o=0;function u(c){let d=o;l.children(c).forEach(u),a[c]={low:d,lim:o++}}return l.children().forEach(u),a}return lp}var ap,Qb;function W5(){if(Qb)return ap;Qb=1;let e=Tt();ap={run:t,cleanup:o};function t(u){let c=e.addDummyNode(u,"root",{},"_root"),d=l(u),h=Object.values(d),m=e.applyWithChunking(Math.max,h)-1,p=2*m+1;u.graph().nestingRoot=c,u.edges().forEach(b=>u.edge(b).minlen*=p);let x=a(u)+1;u.children().forEach(b=>r(u,c,p,x,m,d,b)),u.graph().nodeRankFactor=p}function r(u,c,d,h,m,p,x){let b=u.children(x);if(!b.length){x!==c&&u.setEdge(c,x,{weight:0,minlen:d});return}let w=e.addBorderNode(u,"_bt"),E=e.addBorderNode(u,"_bb"),S=u.node(x);u.setParent(w,x),S.borderTop=w,u.setParent(E,x),S.borderBottom=E,b.forEach(_=>{r(u,c,d,h,m,p,_);let N=u.node(_),k=N.borderTop?N.borderTop:_,A=N.borderBottom?N.borderBottom:_,M=N.borderTop?h:2*h,T=k!==A?1:m-p[x]+1;u.setEdge(w,k,{weight:M,minlen:T,nestingEdge:!0}),u.setEdge(A,E,{weight:M,minlen:T,nestingEdge:!0})}),u.parent(x)||u.setEdge(c,w,{weight:0,minlen:m+p[x]})}function l(u){var c={};function d(h,m){var p=u.children(h);p&&p.length&&p.forEach(x=>d(x,m+1)),c[h]=m}return u.children().forEach(h=>d(h,1)),c}function a(u){return u.edges().reduce((c,d)=>c+u.edge(d).weight,0)}function o(u){var c=u.graph();u.removeNode(c.nestingRoot),delete c.nestingRoot,u.edges().forEach(d=>{var h=u.edge(d);h.nestingEdge&&u.removeEdge(d)})}return ap}var op,Zb;function e4(){if(Zb)return op;Zb=1;let e=Tt();op=t;function t(l){function a(o){let u=l.children(o),c=l.node(o);if(u.length&&u.forEach(a),Object.hasOwn(c,"minRank")){c.borderLeft=[],c.borderRight=[];for(let d=c.minRank,h=c.maxRank+1;dl(d.node(h))),d.edges().forEach(h=>l(d.edge(h)))}function l(d){let h=d.width;d.width=d.height,d.height=h}function a(d){d.nodes().forEach(h=>o(d.node(h))),d.edges().forEach(h=>{let m=d.edge(h);m.points.forEach(o),Object.hasOwn(m,"y")&&o(m)})}function o(d){d.y=-d.y}function u(d){d.nodes().forEach(h=>c(d.node(h))),d.edges().forEach(h=>{let m=d.edge(h);m.points.forEach(c),Object.hasOwn(m,"x")&&c(m)})}function c(d){let h=d.x;d.x=d.y,d.y=h}return sp}var up,Jb;function n4(){if(Jb)return up;Jb=1;let e=Tt();up=t;function t(r){let l={},a=r.nodes().filter(m=>!r.children(m).length),o=a.map(m=>r.node(m).rank),u=e.applyWithChunking(Math.max,o),c=e.range(u+1).map(()=>[]);function d(m){if(l[m])return;l[m]=!0;let p=r.node(m);c[p.rank].push(m),r.successors(m).forEach(d)}return a.sort((m,p)=>r.node(m).rank-r.node(p).rank).forEach(d),c}return up}var cp,Wb;function r4(){if(Wb)return cp;Wb=1;let e=Tt().zipObject;cp=t;function t(l,a){let o=0;for(let u=1;ub)),c=a.flatMap(x=>l.outEdges(x).map(b=>({pos:u[b.w],weight:l.edge(b).weight})).sort((b,w)=>b.pos-w.pos)),d=1;for(;d{let b=x.pos+d;m[b]+=x.weight;let w=0;for(;b>0;)b%2&&(w+=m[b+1]),b=b-1>>1,m[b]+=x.weight;p+=x.weight*w}),p}return cp}var fp,e1;function i4(){if(e1)return fp;e1=1,fp=e;function e(t,r=[]){return r.map(l=>{let a=t.inEdges(l);if(a.length){let o=a.reduce((u,c)=>{let d=t.edge(c),h=t.node(c.v);return{sum:u.sum+d.weight*h.order,weight:u.weight+d.weight}},{sum:0,weight:0});return{v:l,barycenter:o.sum/o.weight,weight:o.weight}}else return{v:l}})}return fp}var dp,t1;function l4(){if(t1)return dp;t1=1;let e=Tt();dp=t;function t(a,o){let u={};a.forEach((d,h)=>{let m=u[d.v]={indegree:0,in:[],out:[],vs:[d.v],i:h};d.barycenter!==void 0&&(m.barycenter=d.barycenter,m.weight=d.weight)}),o.edges().forEach(d=>{let h=u[d.v],m=u[d.w];h!==void 0&&m!==void 0&&(m.indegree++,h.out.push(u[d.w]))});let c=Object.values(u).filter(d=>!d.indegree);return r(c)}function r(a){let o=[];function u(d){return h=>{h.merged||(h.barycenter===void 0||d.barycenter===void 0||h.barycenter>=d.barycenter)&&l(d,h)}}function c(d){return h=>{h.in.push(d),--h.indegree===0&&a.push(h)}}for(;a.length;){let d=a.pop();o.push(d),d.in.reverse().forEach(u(d)),d.out.forEach(c(d))}return o.filter(d=>!d.merged).map(d=>e.pick(d,["vs","i","barycenter","weight"]))}function l(a,o){let u=0,c=0;a.weight&&(u+=a.barycenter*a.weight,c+=a.weight),o.weight&&(u+=o.barycenter*o.weight,c+=o.weight),a.vs=o.vs.concat(a.vs),a.barycenter=u/c,a.weight=c,a.i=Math.min(o.i,a.i),o.merged=!0}return dp}var hp,n1;function a4(){if(n1)return hp;n1=1;let e=Tt();hp=t;function t(a,o){let u=e.partition(a,w=>Object.hasOwn(w,"barycenter")),c=u.lhs,d=u.rhs.sort((w,E)=>E.i-w.i),h=[],m=0,p=0,x=0;c.sort(l(!!o)),x=r(h,d,x),c.forEach(w=>{x+=w.vs.length,h.push(w.vs),m+=w.barycenter*w.weight,p+=w.weight,x=r(h,d,x)});let b={vs:h.flat(!0)};return p&&(b.barycenter=m/p,b.weight=p),b}function r(a,o,u){let c;for(;o.length&&(c=o[o.length-1]).i<=u;)o.pop(),a.push(c.vs),u++;return u}function l(a){return(o,u)=>o.barycenteru.barycenter?1:a?u.i-o.i:o.i-u.i}return hp}var pp,r1;function o4(){if(r1)return pp;r1=1;let e=i4(),t=l4(),r=a4();pp=l;function l(u,c,d,h){let m=u.children(c),p=u.node(c),x=p?p.borderLeft:void 0,b=p?p.borderRight:void 0,w={};x&&(m=m.filter(N=>N!==x&&N!==b));let E=e(u,m);E.forEach(N=>{if(u.children(N.v).length){let k=l(u,N.v,d,h);w[N.v]=k,Object.hasOwn(k,"barycenter")&&o(N,k)}});let S=t(E,d);a(S,w);let _=r(S,h);if(x&&(_.vs=[x,_.vs,b].flat(!0),u.predecessors(x).length)){let N=u.node(u.predecessors(x)[0]),k=u.node(u.predecessors(b)[0]);Object.hasOwn(_,"barycenter")||(_.barycenter=0,_.weight=0),_.barycenter=(_.barycenter*_.weight+N.order+k.order)/(_.weight+2),_.weight+=2}return _}function a(u,c){u.forEach(d=>{d.vs=d.vs.flatMap(h=>c[h]?c[h].vs:h)})}function o(u,c){u.barycenter!==void 0?(u.barycenter=(u.barycenter*u.weight+c.barycenter*c.weight)/(u.weight+c.weight),u.weight+=c.weight):(u.barycenter=c.barycenter,u.weight=c.weight)}return pp}var mp,i1;function s4(){if(i1)return mp;i1=1;let e=Yn().Graph,t=Tt();mp=r;function r(a,o,u,c){c||(c=a.nodes());let d=l(a),h=new e({compound:!0}).setGraph({root:d}).setDefaultNodeLabel(m=>a.node(m));return c.forEach(m=>{let p=a.node(m),x=a.parent(m);(p.rank===o||p.minRank<=o&&o<=p.maxRank)&&(h.setNode(m),h.setParent(m,x||d),a[u](m).forEach(b=>{let w=b.v===m?b.w:b.v,E=h.edge(w,m),S=E!==void 0?E.weight:0;h.setEdge(w,m,{weight:a.edge(b).weight+S})}),Object.hasOwn(p,"minRank")&&h.setNode(m,{borderLeft:p.borderLeft[o],borderRight:p.borderRight[o]}))}),h}function l(a){for(var o;a.hasNode(o=t.uniqueId("_root")););return o}return mp}var gp,l1;function u4(){if(l1)return gp;l1=1,gp=e;function e(t,r,l){let a={},o;l.forEach(u=>{let c=t.parent(u),d,h;for(;c;){if(d=t.parent(c),d?(h=a[d],a[d]=c):(h=o,o=c),h&&h!==c){r.setEdge(h,c);return}c=d}})}return gp}var xp,a1;function c4(){if(a1)return xp;a1=1;let e=n4(),t=r4(),r=o4(),l=s4(),a=u4(),o=Yn().Graph,u=Tt();xp=c;function c(p,x){if(x&&typeof x.customOrder=="function"){x.customOrder(p,c);return}let b=u.maxRank(p),w=d(p,u.range(1,b+1),"inEdges"),E=d(p,u.range(b-1,-1,-1),"outEdges"),S=e(p);if(m(p,S),x&&x.disableOptimalOrderHeuristic)return;let _=Number.POSITIVE_INFINITY,N;for(let k=0,A=0;A<4;++k,++A){h(k%2?w:E,k%4>=2),S=u.buildLayerMatrix(p);let M=t(p,S);M<_&&(A=0,N=Object.assign({},S),_=M)}m(p,N)}function d(p,x,b){const w=new Map,E=(S,_)=>{w.has(S)||w.set(S,[]),w.get(S).push(_)};for(const S of p.nodes()){const _=p.node(S);if(typeof _.rank=="number"&&E(_.rank,S),typeof _.minRank=="number"&&typeof _.maxRank=="number")for(let N=_.minRank;N<=_.maxRank;N++)N!==_.rank&&E(N,S)}return x.map(function(S){return l(p,S,b,w.get(S)||[])})}function h(p,x){let b=new o;p.forEach(function(w){let E=w.graph().root,S=r(w,E,b,x);S.vs.forEach((_,N)=>w.node(_).order=N),a(w,b,S.vs)})}function m(p,x){Object.values(x).forEach(b=>b.forEach((w,E)=>p.node(w).order=E))}return xp}var yp,o1;function f4(){if(o1)return yp;o1=1;let e=Yn().Graph,t=Tt();yp={positionX:b,findType1Conflicts:r,findType2Conflicts:l,addConflict:o,hasConflict:u,verticalAlignment:c,horizontalCompaction:d,alignCoordinates:p,findSmallestWidthAlignment:m,balance:x};function r(S,_){let N={};function k(A,M){let T=0,L=0,R=A.length,V=M[M.length-1];return M.forEach((H,B)=>{let U=a(S,H),ee=U?S.node(U).order:R;(U||H===V)&&(M.slice(L,B+1).forEach(I=>{S.predecessors(I).forEach(F=>{let z=S.node(F),G=z.order;(G{H=M[B],S.node(H).dummy&&S.predecessors(H).forEach(U=>{let ee=S.node(U);ee.dummy&&(ee.orderV)&&o(N,U,H)})})}function A(M,T){let L=-1,R,V=0;return T.forEach((H,B)=>{if(S.node(H).dummy==="border"){let U=S.predecessors(H);U.length&&(R=S.node(U[0]).order,k(T,V,B,L,R),V=B,L=R)}k(T,V,T.length,R,M.length)}),T}return _.length&&_.reduce(A),N}function a(S,_){if(S.node(_).dummy)return S.predecessors(_).find(N=>S.node(N).dummy)}function o(S,_,N){if(_>N){let A=_;_=N,N=A}let k=S[_];k||(S[_]=k={}),k[N]=!0}function u(S,_,N){if(_>N){let k=_;_=N,N=k}return!!S[_]&&Object.hasOwn(S[_],N)}function c(S,_,N,k){let A={},M={},T={};return _.forEach(L=>{L.forEach((R,V)=>{A[R]=R,M[R]=R,T[R]=V})}),_.forEach(L=>{let R=-1;L.forEach(V=>{let H=k(V);if(H.length){H=H.sort((U,ee)=>T[U]-T[ee]);let B=(H.length-1)/2;for(let U=Math.floor(B),ee=Math.ceil(B);U<=ee;++U){let I=H[U];M[V]===V&&RMath.max(U,M[ee.v]+T.edge(ee)),0)}function H(B){let U=T.outEdges(B).reduce((I,F)=>Math.min(I,M[F.w]-T.edge(F)),Number.POSITIVE_INFINITY),ee=S.node(B);U!==Number.POSITIVE_INFINITY&&ee.borderType!==L&&(M[B]=Math.max(M[B],U))}return R(V,T.predecessors.bind(T)),R(H,T.successors.bind(T)),Object.keys(k).forEach(B=>M[B]=M[N[B]]),M}function h(S,_,N,k){let A=new e,M=S.graph(),T=w(M.nodesep,M.edgesep,k);return _.forEach(L=>{let R;L.forEach(V=>{let H=N[V];if(A.setNode(H),R){var B=N[R],U=A.edge(B,H);A.setEdge(B,H,Math.max(T(S,V,R),U||0))}R=V})}),A}function m(S,_){return Object.values(_).reduce((N,k)=>{let A=Number.NEGATIVE_INFINITY,M=Number.POSITIVE_INFINITY;Object.entries(k).forEach(([L,R])=>{let V=E(S,L)/2;A=Math.max(R+V,A),M=Math.min(R-V,M)});const T=A-M;return T{["l","r"].forEach(T=>{let L=M+T,R=S[L];if(R===_)return;let V=Object.values(R),H=k-t.applyWithChunking(Math.min,V);T!=="l"&&(H=A-t.applyWithChunking(Math.max,V)),H&&(S[L]=t.mapValues(R,B=>B+H))})})}function x(S,_){return t.mapValues(S.ul,(N,k)=>{if(_)return S[_.toLowerCase()][k];{let A=Object.values(S).map(M=>M[k]).sort((M,T)=>M-T);return(A[1]+A[2])/2}})}function b(S){let _=t.buildLayerMatrix(S),N=Object.assign(r(S,_),l(S,_)),k={},A;["u","d"].forEach(T=>{A=T==="u"?_:Object.values(_).reverse(),["l","r"].forEach(L=>{L==="r"&&(A=A.map(B=>Object.values(B).reverse()));let R=(T==="u"?S.predecessors:S.successors).bind(S),V=c(S,A,N,R),H=d(S,A,V.root,V.align,L==="r");L==="r"&&(H=t.mapValues(H,B=>-B)),k[T+L]=H})});let M=m(S,k);return p(k,M),x(k,S.graph().align)}function w(S,_,N){return(k,A,M)=>{let T=k.node(A),L=k.node(M),R=0,V;if(R+=T.width/2,Object.hasOwn(T,"labelpos"))switch(T.labelpos.toLowerCase()){case"l":V=-T.width/2;break;case"r":V=T.width/2;break}if(V&&(R+=N?V:-V),V=0,R+=(T.dummy?_:S)/2,R+=(L.dummy?_:S)/2,R+=L.width/2,Object.hasOwn(L,"labelpos"))switch(L.labelpos.toLowerCase()){case"l":V=L.width/2;break;case"r":V=-L.width/2;break}return V&&(R+=N?V:-V),V=0,R}}function E(S,_){return S.node(_).width}return yp}var vp,s1;function d4(){if(s1)return vp;s1=1;let e=Tt(),t=f4().positionX;vp=r;function r(a){a=e.asNonCompoundGraph(a),l(a),Object.entries(t(a)).forEach(([o,u])=>a.node(o).x=u)}function l(a){let o=e.buildLayerMatrix(a),u=a.graph().ranksep,c=0;o.forEach(d=>{const h=d.reduce((m,p)=>{const x=a.node(p).height;return m>x?m:x},0);d.forEach(m=>a.node(m).y=c+h/2),c+=h+u})}return vp}var bp,u1;function h4(){if(u1)return bp;u1=1;let e=X5(),t=Q5(),r=K5(),l=Tt().normalizeRanks,a=J5(),o=Tt().removeEmptyRanks,u=W5(),c=e4(),d=t4(),h=c4(),m=d4(),p=Tt(),x=Yn().Graph;bp=b;function b(C,P){let X=P&&P.debugTiming?p.time:p.notime;X("layout",()=>{let J=X(" buildLayoutGraph",()=>R(C));X(" runLayout",()=>w(J,X,P)),X(" updateInputGraph",()=>E(C,J))})}function w(C,P,X){P(" makeSpaceForEdgeLabels",()=>V(C)),P(" removeSelfEdges",()=>Q(C)),P(" acyclic",()=>e.run(C)),P(" nestingGraph.run",()=>u.run(C)),P(" rank",()=>r(p.asNonCompoundGraph(C))),P(" injectEdgeLabelProxies",()=>H(C)),P(" removeEmptyRanks",()=>o(C)),P(" nestingGraph.cleanup",()=>u.cleanup(C)),P(" normalizeRanks",()=>l(C)),P(" assignRankMinMax",()=>B(C)),P(" removeEdgeLabelProxies",()=>U(C)),P(" normalize.run",()=>t.run(C)),P(" parentDummyChains",()=>a(C)),P(" addBorderSegments",()=>c(C)),P(" order",()=>h(C,X)),P(" insertSelfEdges",()=>K(C)),P(" adjustCoordinateSystem",()=>d.adjust(C)),P(" position",()=>m(C)),P(" positionSelfEdges",()=>D(C)),P(" removeBorderNodes",()=>G(C)),P(" normalize.undo",()=>t.undo(C)),P(" fixupEdgeLabelCoords",()=>F(C)),P(" undoCoordinateSystem",()=>d.undo(C)),P(" translateGraph",()=>ee(C)),P(" assignNodeIntersects",()=>I(C)),P(" reversePoints",()=>z(C)),P(" acyclic.undo",()=>e.undo(C))}function E(C,P){C.nodes().forEach(X=>{let J=C.node(X),ne=P.node(X);J&&(J.x=ne.x,J.y=ne.y,J.rank=ne.rank,P.children(X).length&&(J.width=ne.width,J.height=ne.height))}),C.edges().forEach(X=>{let J=C.edge(X),ne=P.edge(X);J.points=ne.points,Object.hasOwn(ne,"x")&&(J.x=ne.x,J.y=ne.y)}),C.graph().width=P.graph().width,C.graph().height=P.graph().height}let S=["nodesep","edgesep","ranksep","marginx","marginy"],_={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},N=["acyclicer","ranker","rankdir","align"],k=["width","height","rank"],A={width:0,height:0},M=["minlen","weight","width","height","labeloffset"],T={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},L=["labelpos"];function R(C){let P=new x({multigraph:!0,compound:!0}),X=Y(C.graph());return P.setGraph(Object.assign({},_,q(X,S),p.pick(X,N))),C.nodes().forEach(J=>{let ne=Y(C.node(J));const re=q(ne,k);Object.keys(A).forEach(se=>{re[se]===void 0&&(re[se]=A[se])}),P.setNode(J,re),P.setParent(J,C.parent(J))}),C.edges().forEach(J=>{let ne=Y(C.edge(J));P.setEdge(J,Object.assign({},T,q(ne,M),p.pick(ne,L)))}),P}function V(C){let P=C.graph();P.ranksep/=2,C.edges().forEach(X=>{let J=C.edge(X);J.minlen*=2,J.labelpos.toLowerCase()!=="c"&&(P.rankdir==="TB"||P.rankdir==="BT"?J.width+=J.labeloffset:J.height+=J.labeloffset)})}function H(C){C.edges().forEach(P=>{let X=C.edge(P);if(X.width&&X.height){let J=C.node(P.v),re={rank:(C.node(P.w).rank-J.rank)/2+J.rank,e:P};p.addDummyNode(C,"edge-proxy",re,"_ep")}})}function B(C){let P=0;C.nodes().forEach(X=>{let J=C.node(X);J.borderTop&&(J.minRank=C.node(J.borderTop).rank,J.maxRank=C.node(J.borderBottom).rank,P=Math.max(P,J.maxRank))}),C.graph().maxRank=P}function U(C){C.nodes().forEach(P=>{let X=C.node(P);X.dummy==="edge-proxy"&&(C.edge(X.e).labelRank=X.rank,C.removeNode(P))})}function ee(C){let P=Number.POSITIVE_INFINITY,X=0,J=Number.POSITIVE_INFINITY,ne=0,re=C.graph(),se=re.marginx||0,xe=re.marginy||0;function be(ye){let pe=ye.x,Se=ye.y,ze=ye.width,je=ye.height;P=Math.min(P,pe-ze/2),X=Math.max(X,pe+ze/2),J=Math.min(J,Se-je/2),ne=Math.max(ne,Se+je/2)}C.nodes().forEach(ye=>be(C.node(ye))),C.edges().forEach(ye=>{let pe=C.edge(ye);Object.hasOwn(pe,"x")&&be(pe)}),P-=se,J-=xe,C.nodes().forEach(ye=>{let pe=C.node(ye);pe.x-=P,pe.y-=J}),C.edges().forEach(ye=>{let pe=C.edge(ye);pe.points.forEach(Se=>{Se.x-=P,Se.y-=J}),Object.hasOwn(pe,"x")&&(pe.x-=P),Object.hasOwn(pe,"y")&&(pe.y-=J)}),re.width=X-P+se,re.height=ne-J+xe}function I(C){C.edges().forEach(P=>{let X=C.edge(P),J=C.node(P.v),ne=C.node(P.w),re,se;X.points?(re=X.points[0],se=X.points[X.points.length-1]):(X.points=[],re=ne,se=J),X.points.unshift(p.intersectRect(J,re)),X.points.push(p.intersectRect(ne,se))})}function F(C){C.edges().forEach(P=>{let X=C.edge(P);if(Object.hasOwn(X,"x"))switch((X.labelpos==="l"||X.labelpos==="r")&&(X.width-=X.labeloffset),X.labelpos){case"l":X.x-=X.width/2+X.labeloffset;break;case"r":X.x+=X.width/2+X.labeloffset;break}})}function z(C){C.edges().forEach(P=>{let X=C.edge(P);X.reversed&&X.points.reverse()})}function G(C){C.nodes().forEach(P=>{if(C.children(P).length){let X=C.node(P),J=C.node(X.borderTop),ne=C.node(X.borderBottom),re=C.node(X.borderLeft[X.borderLeft.length-1]),se=C.node(X.borderRight[X.borderRight.length-1]);X.width=Math.abs(se.x-re.x),X.height=Math.abs(ne.y-J.y),X.x=re.x+X.width/2,X.y=J.y+X.height/2}}),C.nodes().forEach(P=>{C.node(P).dummy==="border"&&C.removeNode(P)})}function Q(C){C.edges().forEach(P=>{if(P.v===P.w){var X=C.node(P.v);X.selfEdges||(X.selfEdges=[]),X.selfEdges.push({e:P,label:C.edge(P)}),C.removeEdge(P)}})}function K(C){var P=p.buildLayerMatrix(C);P.forEach(X=>{var J=0;X.forEach((ne,re)=>{var se=C.node(ne);se.order=re+J,(se.selfEdges||[]).forEach(xe=>{p.addDummyNode(C,"selfedge",{width:xe.label.width,height:xe.label.height,rank:se.rank,order:re+ ++J,e:xe.e,label:xe.label},"_se")}),delete se.selfEdges})})}function D(C){C.nodes().forEach(P=>{var X=C.node(P);if(X.dummy==="selfedge"){var J=C.node(X.e.v),ne=J.x+J.width/2,re=J.y,se=X.x-ne,xe=J.height/2;C.setEdge(X.e,X.label),C.removeNode(P),X.label.points=[{x:ne+2*se/3,y:re-xe},{x:ne+5*se/6,y:re-xe},{x:ne+se,y:re},{x:ne+5*se/6,y:re+xe},{x:ne+2*se/3,y:re+xe}],X.label.x=X.x,X.label.y=X.y}})}function q(C,P){return p.mapValues(p.pick(C,P),Number)}function Y(C){var P={};return C&&Object.entries(C).forEach(([X,J])=>{typeof X=="string"&&(X=X.toLowerCase()),P[X]=J}),P}return bp}var wp,c1;function p4(){if(c1)return wp;c1=1;let e=Tt(),t=Yn().Graph;wp={debugOrdering:r};function r(l){let a=e.buildLayerMatrix(l),o=new t({compound:!0,multigraph:!0}).setGraph({});return l.nodes().forEach(u=>{o.setNode(u,{label:u}),o.setParent(u,"layer"+l.node(u).rank)}),l.edges().forEach(u=>o.setEdge(u.v,u.w,{},u.name)),a.forEach((u,c)=>{let d="layer"+c;o.setNode(d,{rank:"same"}),u.reduce((h,m)=>(o.setEdge(h,m,{style:"invis"}),m))}),o}return wp}var _p,f1;function m4(){return f1||(f1=1,_p="1.1.8"),_p}var Sp,d1;function g4(){return d1||(d1=1,Sp={graphlib:Yn(),layout:h4(),debug:p4(),util:{time:Tt().time,notime:Tt().notime},version:m4()}),Sp}var x4=g4();const h1=Qo(x4),Ao=200,la=56,p1=20,m1=40,y4=20,g1=12;function v4(e,t,r,l,a,o,u,c){const d=[],h=[],m=new Set,p=new Set,x=new Map;for(const N of r)for(const k of N.agents)p.add(k),x.set(k,N.name);for(const N of r){const k=a[N.name],A=N.agents.length,M=Ao+p1*2,T=m1+A*la+(A-1)*g1+y4;d.push({id:N.name,type:"groupNode",position:{x:0,y:0},data:{label:N.name,type:"parallel_group",status:(k==null?void 0:k.status)||"pending",groupName:N.name,progress:o[N.name]},style:{width:M,height:T}});for(let L=0;L$entryPoint",source:"$start",target:u,type:"animatedEdge",data:{},animated:!1})}const w=new Set(d.map(N=>N.id)),E=new Map;for(const N of d)N.parentId&&E.set(N.id,N.parentId);const S=new Map;for(const N of t){const k=E.get(N.from)??N.from,A=E.get(N.to)??N.to;if(!w.has(k)||!w.has(A)||k===A)continue;const M=`${k}->${A}`,T=S.get(M);if(T){T.when!==N.when&&(h[T.idx].data={when:void 0});continue}const L=h.length;S.set(M,{when:N.when,idx:L});const R=`${M}${N.when?`[${N.when}]`:""}`;h.push({id:R,source:k,target:A,type:"animatedEdge",data:{when:N.when},animated:!1})}const _=b4(d,h,"$start");return w4(d,h,_),{nodes:d,edges:h}}function b4(e,t,r){const l=new Set(e.filter(h=>!h.parentId).map(h=>h.id)),a=new Map;for(const h of t)!l.has(h.source)||!l.has(h.target)||(a.has(h.source)||a.set(h.source,[]),a.get(h.source).push({target:h.target,edgeId:h.id}));for(const h of a.values())h.sort((m,p)=>m.targetp.target?1:0);const o=new Set,u=new Set,c=new Set,d=h=>{c.add(h),u.add(h);for(const{target:m,edgeId:p}of a.get(h)??[])u.has(m)?o.add(p):c.has(m)||d(m);u.delete(h)};l.has(r)&&d(r);for(const h of[...a.keys()].sort())c.has(h)||d(h);return o}function w4(e,t,r){var a,o,u,c;const l=new h1.graphlib.Graph;l.setDefaultEdgeLabel(()=>({})),l.setGraph({rankdir:"TB",nodesep:50,ranksep:70,marginx:30,marginy:30});for(const d of e){if(d.parentId)continue;const h=d.type==="groupNode",m=h&&((a=d.style)==null?void 0:a.width)||Ao,p=h&&((o=d.style)==null?void 0:o.height)||la;l.setNode(d.id,{width:m,height:p})}for(const d of t)!l.hasNode(d.source)||!l.hasNode(d.target)||(r.has(d.id)?l.setEdge(d.target,d.source):l.setEdge(d.source,d.target));h1.layout(l);for(const d of e){if(d.parentId)continue;const h=l.node(d.id);if(!h)continue;const m=d.type==="groupNode",p=m&&((u=d.style)==null?void 0:u.width)||Ao,x=m&&((c=d.style)==null?void 0:c.height)||la;d.position={x:h.x-p/2,y:h.y-x/2}}}const Fe={pending:"#6b7280",running:"#3b82f6",completed:"#22c55e",failed:"#ef4444",paused:"#f59e0b",idle:"#6b7280",waiting:"#a855f7"},_4=70,x1=90;function qc({data:e,children:t}){const[r,l]=$.useState(!1),a=$.useRef(null),o=$.useCallback(()=>{a.current=setTimeout(()=>l(!0),200)},[]),u=$.useCallback(()=>{a.current&&clearTimeout(a.current),l(!1)},[]),c=Fe[e.status]||Fe.pending;return y.jsxs("div",{className:"relative",onMouseEnter:o,onMouseLeave:u,children:[t,r&&y.jsxs("div",{className:He("absolute z-50 bottom-full left-1/2 -translate-x-1/2 mb-2","bg-[var(--surface-raised)] border border-[var(--border)] shadow-lg","rounded-lg px-3 py-2 max-w-[260px] pointer-events-none","animate-[tooltip-in_150ms_ease-out]"),children:[y.jsx("div",{className:"absolute top-full left-1/2 -translate-x-1/2 w-0 h-0 border-x-[6px] border-x-transparent border-t-[6px] border-t-[var(--border)]"}),y.jsxs("div",{className:"flex flex-col gap-1.5 text-[11px]",children:[y.jsxs("div",{className:"flex items-center gap-1.5",children:[y.jsx("span",{className:"w-2 h-2 rounded-full flex-shrink-0",style:{backgroundColor:c}}),y.jsx("span",{className:"font-medium text-[var(--text)] capitalize",children:e.status}),e.iteration!=null&&e.iteration>1&&y.jsxs("span",{className:"text-[var(--text-muted)] ml-auto",children:["iter ",e.iteration]})]}),y.jsx("div",{className:"h-px bg-[var(--border)]"}),y.jsxs("div",{className:"grid grid-cols-[auto_1fr] gap-x-3 gap-y-0.5",children:[e.elapsed!=null&&y.jsxs(y.Fragment,{children:[y.jsx("span",{className:"text-[var(--text-muted)]",children:"Elapsed"}),y.jsx("span",{className:"text-[var(--text)] font-mono",children:Jt(e.elapsed)})]}),e.model&&y.jsxs(y.Fragment,{children:[y.jsx("span",{className:"text-[var(--text-muted)]",children:"Model"}),y.jsx("span",{className:"text-[var(--text)] truncate",children:e.model})]}),e.tokens!=null&&y.jsxs(y.Fragment,{children:[y.jsx("span",{className:"text-[var(--text-muted)]",children:"Tokens"}),y.jsxs("span",{className:"text-[var(--text)] font-mono",children:[Pn(e.tokens),e.inputTokens!=null&&e.outputTokens!=null&&y.jsxs("span",{className:"text-[var(--text-muted)]",children:[" ","(",Pn(e.inputTokens),"↑ ",Pn(e.outputTokens),"↓)"]})]})]}),e.costUsd!=null&&y.jsxs(y.Fragment,{children:[y.jsx("span",{className:"text-[var(--text-muted)]",children:"Cost"}),y.jsx("span",{className:"text-[var(--text)] font-mono",children:yi(e.costUsd)})]}),e.exitCode!=null&&y.jsxs(y.Fragment,{children:[y.jsx("span",{className:"text-[var(--text-muted)]",children:"Exit code"}),y.jsx("span",{className:He("font-mono",e.exitCode===0?"text-[var(--completed)]":"text-[var(--failed)]"),children:e.exitCode})]}),e.selectedOption&&y.jsxs(y.Fragment,{children:[y.jsx("span",{className:"text-[var(--text-muted)]",children:"Selected"}),y.jsx("span",{className:"text-[var(--text)] truncate",children:e.selectedOption})]})]}),e.errorMessage&&y.jsxs(y.Fragment,{children:[y.jsx("div",{className:"h-px bg-[var(--border)]"}),y.jsxs("div",{className:"text-red-400 leading-tight",children:[e.errorType&&y.jsxs("span",{className:"font-medium",children:[e.errorType,": "]}),y.jsxs("span",{className:"break-words",children:[e.errorMessage.slice(0,120),e.errorMessage.length>120?"...":""]})]})]})]})]})]})}const S4=$.memo(function({data:t,id:r,selected:l}){var L;const a=t,o=ol(),c=((L=o[r])==null?void 0:L.status)||a.status||"pending",d=Fe[c]||Fe.pending,h=o[r],m=h==null?void 0:h.elapsed,p=h==null?void 0:h.model,x=h==null?void 0:h.tokens,b=h==null?void 0:h.input_tokens,w=h==null?void 0:h.output_tokens,E=h==null?void 0:h.cost_usd,S=h==null?void 0:h.iteration,_=h==null?void 0:h.error_type,N=h==null?void 0:h.error_message,k=h==null?void 0:h.context_pct,A=k4(r,c),M=E4(c),T=(()=>{if(c==="failed"&&N)return{text:N.length>40?N.slice(0,37)+"...":N,className:"text-red-400"};if(c==="running")return{text:A,className:"text-[var(--text-muted)]"};if(c==="completed"){const R=[];return m!=null&&R.push(Jt(m)),x!=null&&R.push(`${Pn(x)} tok`),E!=null&&R.push(yi(E)),{text:R.join(" · ")||null,className:"text-[var(--text-muted)]"}}return{text:null,className:""}})();return y.jsxs(y.Fragment,{children:[y.jsx(Lt,{type:"target",position:ve.Top,className:"!bg-[var(--border)] !border-none !w-2 !h-2"}),y.jsx(qc,{data:{status:c,elapsed:m,model:p,tokens:x,inputTokens:b,outputTokens:w,costUsd:E,iteration:S,errorType:_,errorMessage:N},children:y.jsxs("div",{className:He("flex items-center gap-2 px-3 py-1.5 rounded-lg border-2 bg-[var(--node-bg)] min-w-[140px] max-w-[220px] transition-all duration-300",l&&"ring-2 ring-[var(--accent)] ring-offset-1 ring-offset-[var(--bg)]",c==="running"&&"shadow-[0_0_12px_var(--running-glow)]",M),style:{borderColor:d},children:[y.jsx("div",{className:He("flex items-center justify-center w-6 h-6 rounded-md flex-shrink-0",c==="running"&&"animate-pulse"),style:{backgroundColor:`${d}20`},children:y.jsx(uN,{className:"w-3.5 h-3.5",style:{color:d}})}),y.jsxs("div",{className:"flex flex-col min-w-0 flex-1",children:[y.jsxs("div",{className:"flex items-center gap-1",children:[y.jsx("span",{className:"text-xs font-medium text-[var(--text)] truncate",children:a.label}),S!=null&&S>1&&y.jsxs("span",{className:"flex-shrink-0 inline-flex items-center justify-center px-1.5 py-0.5 rounded-full text-[9px] font-bold leading-none",style:{backgroundColor:`${d}25`,color:d},children:["x",S]})]}),T.text&&y.jsx("span",{className:He("text-[10px] truncate leading-tight",T.className),children:T.text})]}),k!=null&&y.jsx("div",{className:"absolute bottom-0 left-0 right-0 h-[2px] rounded-b-lg overflow-hidden",style:{backgroundColor:"rgba(255,255,255,0.06)"},children:y.jsx("div",{className:He("h-full transition-all duration-500",k>=x1?"animate-[context-pulse_2s_ease-in-out_infinite]":""),style:{width:`${Math.min(k,100)}%`,backgroundColor:k>=x1?"#ef4444":k>=_4?"#f59e0b":"#22c55e"}})})]})}),y.jsx(Lt,{type:"source",position:ve.Bottom,className:"!bg-[var(--border)] !border-none !w-2 !h-2"})]})});function k4(e,t){var d;const r=(d=ol()[e])==null?void 0:d.startedAt,l=ue(h=>h.replayMode),a=ue(h=>h.lastEventTime),[o,u]=$.useState("0.0s"),c=$.useRef(null);return $.useEffect(()=>{if(t==="running"){if(l){c.current&&clearInterval(c.current);const p=r??a??0;u(Jt((a??p)-p));return}const h=r!=null?r*1e3:Date.now(),m=()=>{const p=(Date.now()-h)/1e3;u(Jt(p))};return m(),c.current=setInterval(m,1e3),()=>{c.current&&clearInterval(c.current)}}else c.current&&clearInterval(c.current)},[t,r,l,a]),o}function E4(e){const t=$.useRef(e),[r,l]=$.useState("");return $.useEffect(()=>{const a=t.current;if(t.current=e,a===e)return;e==="running"?l("node-activate"):a==="running"&&(e==="completed"||e==="failed")&&l(e==="completed"?"node-complete":"node-fail");const o=setTimeout(()=>l(""),400);return()=>clearTimeout(o)},[e]),r}const N4=$.memo(function({data:t,id:r,selected:l}){var _;const a=t,o=ol(),c=((_=o[r])==null?void 0:_.status)||a.status||"pending",d=Fe[c]||Fe.pending,h=o[r],m=h==null?void 0:h.elapsed,p=h==null?void 0:h.exit_code,x=h==null?void 0:h.error_type,b=h==null?void 0:h.error_message,w=C4(r,c),E=j4(c),S=(()=>{if(c==="failed"&&b)return{text:b.length>40?b.slice(0,37)+"...":b,className:"text-red-400"};if(c==="running")return{text:w,className:"text-[var(--text-muted)]"};if(c==="completed"){const N=[];return m!=null&&N.push(Jt(m)),p!=null&&N.push(`exit ${p}`),{text:N.join(" · ")||null,className:"text-[var(--text-muted)]"}}return{text:null,className:""}})();return y.jsxs(y.Fragment,{children:[y.jsx(Lt,{type:"target",position:ve.Top,className:"!bg-[var(--border)] !border-none !w-2 !h-2"}),y.jsx(qc,{data:{status:c,elapsed:m,exitCode:p,errorType:x,errorMessage:b},children:y.jsxs("div",{className:He("flex items-center gap-2 px-3 py-1.5 rounded-lg border-2 bg-[var(--node-bg)] min-w-[140px] max-w-[220px] transition-all duration-300",l&&"ring-2 ring-[var(--accent)] ring-offset-1 ring-offset-[var(--bg)]",c==="running"&&"shadow-[0_0_12px_var(--running-glow)]",E),style:{borderColor:d},children:[y.jsx("div",{className:He("flex items-center justify-center w-6 h-6 rounded-md flex-shrink-0",c==="running"&&"animate-pulse"),style:{backgroundColor:`${d}20`},children:y.jsx(kN,{className:"w-3.5 h-3.5",style:{color:d}})}),y.jsxs("div",{className:"flex flex-col min-w-0 flex-1",children:[y.jsx("span",{className:"text-xs font-medium text-[var(--text)] truncate",children:a.label}),S.text&&y.jsx("span",{className:He("text-[10px] truncate leading-tight",S.className),children:S.text})]})]})}),y.jsx(Lt,{type:"source",position:ve.Bottom,className:"!bg-[var(--border)] !border-none !w-2 !h-2"})]})});function C4(e,t){var d;const r=(d=ol()[e])==null?void 0:d.startedAt,l=ue(h=>h.replayMode),a=ue(h=>h.lastEventTime),[o,u]=$.useState("0.0s"),c=$.useRef(null);return $.useEffect(()=>{if(t==="running"){if(l){c.current&&clearInterval(c.current);const p=r??a??0;u(Jt((a??p)-p));return}const h=r!=null?r*1e3:Date.now(),m=()=>{const p=(Date.now()-h)/1e3;u(Jt(p))};return m(),c.current=setInterval(m,1e3),()=>{c.current&&clearInterval(c.current)}}else c.current&&clearInterval(c.current)},[t,r,l,a]),o}function j4(e){const t=$.useRef(e),[r,l]=$.useState("");return $.useEffect(()=>{const a=t.current;if(t.current=e,a===e)return;e==="running"?l("node-activate"):a==="running"&&(e==="completed"||e==="failed")&&l(e==="completed"?"node-complete":"node-fail");const o=setTimeout(()=>l(""),400);return()=>clearTimeout(o)},[e]),r}const T4=$.memo(function({data:t,id:r,selected:l}){var p,x;const a=t,o=ol(),c=((p=o[r])==null?void 0:p.status)||a.status||"pending",d=Fe[c]||Fe.pending,h=(x=o[r])==null?void 0:x.selected_option,m=A4(c);return y.jsxs(y.Fragment,{children:[y.jsx(Lt,{type:"target",position:ve.Top,className:"!bg-[var(--border)] !border-none !w-2 !h-2"}),y.jsx(qc,{data:{status:c,selectedOption:h},children:y.jsxs("div",{className:He("flex items-center gap-2 px-3 py-1.5 rounded-lg border-2 border-dashed bg-[var(--node-bg)] min-w-[140px] max-w-[220px] transition-all duration-300",l&&"ring-2 ring-[var(--accent)] ring-offset-1 ring-offset-[var(--bg)]",c==="waiting"&&"shadow-[0_0_12px_var(--waiting-muted)]",c==="running"&&"shadow-[0_0_12px_var(--running-glow)]",m),style:{borderColor:d},children:[y.jsx("div",{className:He("flex items-center justify-center w-6 h-6 rounded-md flex-shrink-0",c==="waiting"&&"animate-pulse"),style:{backgroundColor:`${d}20`},children:y.jsx(SN,{className:"w-3.5 h-3.5",style:{color:d}})}),y.jsxs("div",{className:"flex flex-col min-w-0 flex-1",children:[y.jsx("span",{className:"text-xs font-medium text-[var(--text)] truncate",children:a.label}),c==="waiting"&&y.jsx("span",{className:"text-[10px] text-[var(--waiting)] truncate leading-tight",children:"Awaiting input..."}),c==="completed"&&h&&y.jsx("span",{className:"text-[10px] text-[var(--text-muted)] truncate leading-tight",children:h})]})]})}),y.jsx(Lt,{type:"source",position:ve.Bottom,className:"!bg-[var(--border)] !border-none !w-2 !h-2"})]})});function A4(e){const t=$.useRef(e),[r,l]=$.useState("");return $.useEffect(()=>{const a=t.current;if(t.current=e,a===e)return;e==="running"||e==="waiting"?l("node-activate"):(a==="running"||a==="waiting")&&e==="completed"&&l("node-complete");const o=setTimeout(()=>l(""),400);return()=>clearTimeout(o)},[e]),r}const z4=$.memo(function({data:t,id:r,selected:l}){var S;const a=t,u=a.type==="for_each_group"?wN:yN,c=a.progress,m=((S=ol()[r])==null?void 0:S.status)||a.status||"pending",p=Fe[m]||Fe.pending,x=M4(m),b=c?`${c.completed+c.failed}/${c.total}${c.failed>0?` (${c.failed} failed)`:""}`:null,w=c&&c.total>0?(c.completed+c.failed)/c.total*100:0,E=c!=null&&c.failed>0;return y.jsxs(y.Fragment,{children:[y.jsx(Lt,{type:"target",position:ve.Top,className:"!bg-[var(--border)] !border-none !w-2 !h-2"}),y.jsxs("div",{className:He("flex flex-col gap-1 px-4 py-3 rounded-xl border-2 border-dashed bg-[var(--surface)]/80 min-w-[180px] transition-all duration-300",l&&"ring-2 ring-[var(--accent)] ring-offset-1 ring-offset-[var(--bg)]",m==="running"&&"shadow-[0_0_16px_var(--running-glow)]",x),style:{borderColor:p,minHeight:"100%"},children:[y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx(u,{className:"w-3.5 h-3.5",style:{color:p}}),y.jsx("span",{className:"text-xs font-medium text-[var(--text-secondary)]",children:a.label})]}),b&&y.jsx("span",{className:"text-[10px] text-[var(--text-muted)] font-mono",children:b}),c&&c.total>0&&m==="running"&&y.jsx("div",{className:"w-full h-1 rounded-full bg-[var(--border)] overflow-hidden mt-0.5",children:y.jsx("div",{className:"h-full rounded-full transition-all duration-500 ease-out",style:{width:`${w}%`,backgroundColor:E?"var(--failed)":"var(--completed)"}})})]}),y.jsx(Lt,{type:"source",position:ve.Bottom,className:"!bg-[var(--border)] !border-none !w-2 !h-2"})]})});function M4(e){const t=$.useRef(e),[r,l]=$.useState("");return $.useEffect(()=>{const a=t.current;if(t.current=e,a===e)return;e==="running"?l("node-activate"):a==="running"&&(e==="completed"||e==="failed")&&l(e==="completed"?"node-complete":"node-fail");const o=setTimeout(()=>l(""),400);return()=>clearTimeout(o)},[e]),r}const D4=$.memo(function({data:t,id:r,selected:l}){const a=t,u=ue(S=>{var _;return(_=S.nodes[r])==null?void 0:_.status})||a.status||"pending",c=Fe[u]||Fe.pending,d=ue(S=>{var _;return(_=S.nodes[r])==null?void 0:_.elapsed}),h=ue(S=>{var _;return(_=S.nodes[r])==null?void 0:_.error_message}),m=ue(S=>S.navigateIntoSubworkflow),p=Um(),x=p.some(S=>S.parentAgent===r),b=p.find(S=>S.parentAgent===r),w=b==null?void 0:b.workflowName,E=(()=>{if(u==="failed"&&h)return{text:h.length>35?h.slice(0,32)+"...":h,className:"text-red-400"};if(u==="running")return{text:w||"Running subworkflow…",className:"text-[var(--text-muted)]"};if(u==="completed"){const S=[];return w&&S.push(w),d!=null&&S.push(`${d.toFixed(1)}s`),{text:S.join(" · ")||"Done",className:"text-[var(--text-muted)]"}}return{text:w||null,className:"text-[var(--text-muted)]"}})();return y.jsxs(y.Fragment,{children:[y.jsx(Lt,{type:"target",position:ve.Top,className:"!bg-[var(--border)] !border-none !w-2 !h-2"}),y.jsx(qc,{data:{status:u,elapsed:d,errorType:void 0,errorMessage:h,iteration:void 0},children:y.jsxs("div",{className:He("flex items-center gap-2 px-3 py-1.5 rounded-lg border-2 bg-[var(--node-bg)] min-w-[140px] max-w-[240px] transition-all duration-300 cursor-pointer",l&&"ring-2 ring-[var(--accent)] ring-offset-1 ring-offset-[var(--bg)]",u==="running"&&"shadow-[0_0_12px_var(--running-glow)]"),style:{borderColor:c,borderStyle:"dashed"},onDoubleClick:S=>{x&&(S.stopPropagation(),m(r))},children:[y.jsx("div",{className:He("flex items-center justify-center w-6 h-6 rounded-md flex-shrink-0",u==="running"&&"animate-pulse"),style:{backgroundColor:`${c}20`},children:y.jsx(Sc,{className:"w-3.5 h-3.5",style:{color:c}})}),y.jsxs("div",{className:"flex flex-col min-w-0 flex-1",children:[y.jsx("div",{className:"flex items-center gap-1",children:y.jsx("span",{className:"text-xs font-medium text-[var(--text)] truncate",children:a.label})}),E.text&&y.jsx("span",{className:He("text-[10px] truncate leading-tight",E.className),children:E.text})]}),x&&y.jsx(Rr,{className:"w-3.5 h-3.5 flex-shrink-0 text-[var(--text-muted)]"})]})}),y.jsx(Lt,{type:"source",position:ve.Bottom,className:"!bg-[var(--border)] !border-none !w-2 !h-2"})]})}),R4=$.memo(function({data:t,selected:r}){const a=t.status||"pending",o=a==="completed",u=a==="failed",c=!o&&!u,d=o?Fe.completed:u?Fe.failed:Fe.pending;return y.jsxs(y.Fragment,{children:[y.jsx(Lt,{type:"target",position:ve.Top,className:"!bg-[var(--border)] !border-none !w-2 !h-2"}),y.jsx("div",{className:He("flex items-center justify-center w-11 h-11 rounded-full border-2 transition-all duration-300",o?"bg-[var(--completed)] shadow-[0_0_16px_var(--completed-muted)]":u?"bg-[var(--failed)] shadow-[0_0_16px_var(--failed-muted)]":"bg-[var(--node-bg)]",r&&"ring-2 ring-[var(--accent)] ring-offset-1 ring-offset-[var(--bg)]"),style:{borderColor:d},children:o?y.jsx(Yi,{className:"w-5 h-5 text-white",strokeWidth:3}):u?y.jsx(_w,{className:"w-3.5 h-3.5 text-white",fill:"white"}):y.jsx(Yi,{className:"w-5 h-5",strokeWidth:2.5,style:{color:c?Fe.pending:d}})})]})}),O4=$.memo(function({data:t,selected:r}){const a=t.status||"pending",o=Fe[a]||Fe.pending,u=a==="running"||a==="completed";return y.jsxs(y.Fragment,{children:[y.jsx("div",{className:He("flex items-center justify-center w-11 h-11 rounded-full border-2 transition-all duration-300",u?"bg-[var(--completed)]":"bg-[var(--node-bg)]",r&&"ring-2 ring-[var(--accent)] ring-offset-1 ring-offset-[var(--bg)]",u&&"shadow-[0_0_12px_var(--completed-muted)]"),style:{borderColor:o},children:y.jsx(kc,{className:"w-4 h-4 ml-0.5",style:{color:u?"white":o}})}),y.jsx(Lt,{type:"source",position:ve.Bottom,className:"!bg-[var(--border)] !border-none !w-2 !h-2"})]})}),y1="#a78bfa",L4=$.memo(function({data:t,selected:r}){const l=t,a=l.status||"pending",o=a==="running"||a==="completed",u=o?y1:Fe[a]||y1,c=l.parentAgent,d=ue(h=>h.navigateUp);return y.jsxs(y.Fragment,{children:[y.jsxs("div",{className:"flex flex-col items-center gap-1",children:[y.jsx("div",{className:He("flex items-center justify-center w-11 h-11 rounded-full border-2 border-dashed transition-all duration-300 cursor-pointer",o?"bg-[#a78bfa]":"bg-[var(--node-bg)]",r&&"ring-2 ring-[var(--accent)] ring-offset-1 ring-offset-[var(--bg)]",o&&"shadow-[0_0_12px_rgba(167,139,250,0.4)]"),style:{borderColor:u},onDoubleClick:h=>{h.stopPropagation(),d()},children:y.jsx(oN,{className:"w-4 h-4",style:{color:o?"white":u}})}),c&&y.jsxs("span",{className:"text-[10px] text-[var(--text-muted)] whitespace-nowrap",children:["from ",y.jsx("span",{className:"font-medium text-[var(--text)]",children:c})]})]}),y.jsx(Lt,{type:"source",position:ve.Bottom,className:"!bg-[var(--border)] !border-none !w-2 !h-2"})]})}),v1="#a78bfa",H4=$.memo(function({data:t,selected:r}){const l=t,a=l.status||"pending",o=a==="completed",u=a==="failed",c=o?v1:u?Fe.failed:v1,d=l.parentAgent,h=ue(m=>m.navigateUp);return y.jsxs(y.Fragment,{children:[y.jsx(Lt,{type:"target",position:ve.Top,className:"!bg-[var(--border)] !border-none !w-2 !h-2"}),y.jsxs("div",{className:"flex flex-col items-center gap-1",children:[y.jsx("div",{className:He("flex items-center justify-center w-11 h-11 rounded-full border-2 border-dashed transition-all duration-300 cursor-pointer",o?"bg-[#a78bfa] shadow-[0_0_12px_rgba(167,139,250,0.4)]":u?"bg-[var(--failed)] shadow-[0_0_16px_var(--failed-muted)]":"bg-[var(--node-bg)]",r&&"ring-2 ring-[var(--accent)] ring-offset-1 ring-offset-[var(--bg)]"),style:{borderColor:c},onDoubleClick:m=>{m.stopPropagation(),h()},children:y.jsx(sN,{className:"w-4 h-4",style:{color:o||u?"white":c}})}),d&&y.jsxs("span",{className:"text-[10px] text-[var(--text-muted)] whitespace-nowrap",children:["return to ",y.jsx("span",{className:"font-medium text-[var(--text)]",children:d})]})]})]})}),B4=$.memo(function({id:t,sourceX:r,sourceY:l,targetX:a,targetY:o,sourcePosition:u,targetPosition:c,source:d,target:h,data:m}){const p=j5(),x=$.useMemo(()=>p.find(V=>V.from===d&&V.to===h),[p,d,h]),[b,w,E]=Rm({sourceX:r,sourceY:l,targetX:a,targetY:o,sourcePosition:u,targetPosition:c}),S=m==null?void 0:m.when,_=!!S,N=(x==null?void 0:x.state)==="taken",k=(x==null?void 0:x.state)==="highlighted",A=(x==null?void 0:x.state)==="failed";let M="var(--edge-color)",T=2,L;A?(M="var(--failed)",T=3):N?(M="var(--edge-taken)",T=3):k&&(M="var(--edge-active)",T=3),_&&!N&&!k&&!A&&(L="6 3");const R=A?"failed":N?"taken":k?"active":"default";return y.jsxs(y.Fragment,{children:[y.jsx(rs,{id:t,path:b,style:{stroke:M,strokeWidth:T,strokeDasharray:L,transition:"stroke 0.3s ease, stroke-width 0.3s ease"},markerEnd:`url(#arrow-${R})`}),_&&y.jsx(ZM,{children:y.jsx("div",{className:"nodrag nopan",style:{position:"absolute",transform:`translate(-50%, -50%) translate(${w}px,${E}px)`,pointerEvents:"all"},children:y.jsx("span",{className:"inline-block px-1.5 py-0.5 rounded-full text-[9px] font-mono leading-tight max-w-[140px] truncate",style:{backgroundColor:A?"var(--failed)":N?"var(--edge-taken)":"var(--surface)",color:A||N?"var(--bg)":"var(--text-muted)",border:`1px solid ${A?"var(--failed)":N?"var(--edge-taken)":"var(--border)"}`},title:S,children:S})})}),N&&y.jsx("circle",{r:"3",fill:"var(--edge-taken)",children:y.jsx("animateMotion",{dur:"1s",repeatCount:"indefinite",path:b})}),A&&y.jsx("circle",{r:"3",fill:"var(--failed)",opacity:"0.8",children:y.jsx("animateMotion",{dur:"1.5s",repeatCount:"indefinite",path:b})})]})});function I4(){const e=ue(u=>u.workflowStatus),t=ue(u=>u.workflowFailure),r=ue(u=>u.workflowFailedAgent),l=ue(u=>u.selectNode);if(e!=="failed"||!t)return null;const a=t.message||t.error_type||"Unknown error",o=t.error_type==="TimeoutError";return y.jsx("div",{className:"absolute top-3 left-1/2 -translate-x-1/2 z-20 animate-[banner-in_200ms_ease-out]",children:y.jsxs("div",{className:He("flex items-center gap-2 px-4 py-2 rounded-lg","bg-red-950/90 border border-red-500/40 shadow-lg shadow-red-500/10","backdrop-blur-sm max-w-[560px]"),children:[y.jsx(ic,{className:"w-4 h-4 text-red-400 flex-shrink-0"}),y.jsxs("div",{className:"flex flex-col min-w-0",children:[y.jsx("span",{className:"text-xs font-medium text-red-300",children:"Workflow Failed"}),y.jsx("span",{className:"text-[11px] text-red-400/80 truncate",children:a}),o&&t.current_agent&&y.jsxs("span",{className:"text-[10px] text-red-400/60 truncate",children:["Timed out on agent: ",t.current_agent]}),t.checkpoint_path&&y.jsxs("span",{className:"text-[10px] text-red-400/50 truncate",title:t.checkpoint_path,children:["Checkpoint: ",t.checkpoint_path.split("/").pop()]})]}),r&&y.jsxs("button",{onClick:()=>l(r),className:"flex items-center gap-1 px-2 py-1 rounded text-[10px] font-medium text-red-300 bg-red-500/20 hover:bg-red-500/30 transition-colors flex-shrink-0 ml-1",children:[y.jsx(mN,{className:"w-3 h-3"}),"View"]})]})})}function q4(){const[e,t]=$.useState(!1),r=ue(d=>d.workflowStatus),l=ue(d=>d.totalCost),a=ue(d=>d.totalTokens),o=ue(d=>d.agentsCompleted),u=ue(d=>d.agentsTotal),c=kw();return r!=="completed"||e?null:y.jsx("div",{className:"absolute top-3 left-1/2 -translate-x-1/2 z-20 animate-[banner-in_200ms_ease-out]",children:y.jsxs("div",{className:He("flex items-center gap-3 px-4 py-2 rounded-lg","bg-green-950/90 border border-green-500/40 shadow-lg shadow-green-500/10","backdrop-blur-sm"),children:[y.jsx(fN,{className:"w-4 h-4 text-green-400 flex-shrink-0"}),y.jsx("span",{className:"text-xs font-medium text-green-300",children:"Completed"}),y.jsxs("div",{className:"flex items-center gap-3 text-[11px] text-green-400/80 font-mono",children:[y.jsx("span",{children:c}),u>0&&y.jsxs("span",{children:[o,"/",u," agents"]}),a>0&&y.jsxs("span",{children:[Pn(a)," tok"]}),l>0&&y.jsx("span",{children:yi(l)})]}),y.jsx("button",{onClick:()=>t(!0),className:"p-0.5 rounded text-green-500/60 hover:text-green-300 transition-colors flex-shrink-0 ml-1",children:y.jsx(ll,{className:"w-3.5 h-3.5"})})]})})}const U4={agentNode:S4,scriptNode:N4,gateNode:T4,groupNode:z4,workflowNode:D4,endNode:R4,startNode:O4,ingressNode:L4,egressNode:H4},$4={animatedEdge:B4},V4={type:"animatedEdge"};function P4(){return y.jsx("svg",{style:{position:"absolute",width:0,height:0},children:y.jsxs("defs",{children:[y.jsx("marker",{id:"arrow-default",viewBox:"0 0 10 10",refX:"8",refY:"5",markerWidth:"8",markerHeight:"8",orient:"auto-start-reverse",children:y.jsx("path",{d:"M 0 0 L 10 5 L 0 10 z",fill:"var(--edge-color)"})}),y.jsx("marker",{id:"arrow-active",viewBox:"0 0 10 10",refX:"8",refY:"5",markerWidth:"8",markerHeight:"8",orient:"auto-start-reverse",children:y.jsx("path",{d:"M 0 0 L 10 5 L 0 10 z",fill:"var(--edge-active)"})}),y.jsx("marker",{id:"arrow-taken",viewBox:"0 0 10 10",refX:"8",refY:"5",markerWidth:"8",markerHeight:"8",orient:"auto-start-reverse",children:y.jsx("path",{d:"M 0 0 L 10 5 L 0 10 z",fill:"var(--edge-taken)"})}),y.jsx("marker",{id:"arrow-failed",viewBox:"0 0 10 10",refX:"8",refY:"5",markerWidth:"8",markerHeight:"8",orient:"auto-start-reverse",children:y.jsx("path",{d:"M 0 0 L 10 5 L 0 10 z",fill:"var(--failed)"})})]})})}function G4(){const e=T5(),t=ue(z=>z.viewContextPath),r=ue(z=>z.selectNode),l=ue(z=>z.selectedNode),a=ue(z=>z.workflowStatus),o=ue(z=>z.wsStatus),u=ue(z=>z.workflowFailedAgent),c=ue(z=>z.navigateIntoSubworkflow),{agents:d,routes:h,parallelGroups:m,forEachGroups:p,nodes:x,groupProgress:b,entryPoint:w,subworkflowContexts:E,parentAgent:S}=e,[_,N,k]=KM([]),[A,M,T]=JM([]),L=$.useRef(!1),R=$.useRef(""),V=JSON.stringify(t);$.useEffect(()=>{if(d.length===0){R.current!==V&&(L.current=!1,R.current=V,N([]),M([]));return}if(R.current!==V&&(L.current=!1,R.current=V),L.current)return;L.current=!0;const{nodes:z,edges:G}=v4(d,h,m,p,x,b,w,S);N(z),M(G)},[d,h,m,p,x,b,w,N,M,V,S]),$.useEffect(()=>{L.current&&N(z=>z.map(G=>{const Q=x[G.id];if(!Q)return G;const K=Q.status||"pending",D=G.data.status;if(K!==D){const q={...G.data,status:K};return G.data.groupName&&b[G.data.groupName]&&(q.progress=b[G.data.groupName]),{...G,data:q}}if(G.data.groupName&&b[G.data.groupName]){const q=G.data.progress,Y=b[G.data.groupName];if(Y&&(!q||q.completed!==Y.completed||q.failed!==Y.failed))return{...G,data:{...G.data,progress:Y}}}return G}))},[x,b,N]);const H=$.useCallback((z,G)=>{G.type==="groupNode"&&G.data.type!=="for_each_group"||r(G.id)},[r]),B=$.useCallback((z,G)=>{E.some(K=>K.parentAgent===G.id)&&c(G.id)},[E,c]),U=$.useCallback(()=>{r(null)},[r]),ee=$.useCallback(z=>{var Q;const G=((Q=z.data)==null?void 0:Q.status)||"pending";return Fe[G]??Fe.pending??"#6b7280"},[]);$.useEffect(()=>{N(z=>z.map(G=>({...G,selected:G.id===l})))},[l,N]),$.useEffect(()=>{a==="failed"&&u&&r(u)},[a,u,r]);const I=a==="pending"&&d.length===0,F=(()=>{switch(o){case"connecting":return"Connecting to workflow…";case"reconnecting":return"Reconnecting…";case"disconnected":return"Connection lost. Retrying…";default:return"Waiting for workflow…"}})();return y.jsxs("div",{className:"w-full h-full relative",children:[y.jsx(P4,{}),y.jsx(I4,{}),y.jsx(q4,{}),I&&y.jsxs("div",{className:"absolute inset-0 z-10 flex flex-col items-center justify-center pointer-events-none",children:[y.jsxs("div",{className:"relative mb-3",children:[y.jsx(CN,{className:"w-8 h-8 text-[var(--accent)] opacity-20"}),y.jsx(ca,{className:"w-8 h-8 text-[var(--text-muted)] animate-spin absolute inset-0 opacity-40"})]}),y.jsx("p",{className:"text-sm text-[var(--text-muted)] animate-pulse",children:F})]}),y.jsxs(XM,{nodes:_,edges:A,onNodesChange:k,onEdgesChange:T,onNodeClick:H,onNodeDoubleClick:B,onPaneClick:U,nodeTypes:U4,edgeTypes:$4,defaultEdgeOptions:V4,fitView:!0,fitViewOptions:{padding:.2},minZoom:.2,maxZoom:2,proOptions:{hideAttribution:!0},nodesDraggable:!0,nodesConnectable:!1,elementsSelectable:!0,children:[y.jsx(r5,{variant:Mr.Dots,gap:20,size:1,color:"var(--border-subtle)"}),y.jsx(S5,{nodeColor:ee,maskColor:"var(--minimap-mask)",style:{background:"var(--minimap-bg)"},pannable:!0,zoomable:!0}),y.jsx(c5,{showInteractive:!1,children:y.jsx(F4,{})}),y.jsx(Y4,{}),y.jsx(X4,{viewPathKey:V}),y.jsx(Q4,{})]})]})}function F4(){const{fitView:e}=al(),t=$.useCallback(()=>{e({padding:.2,duration:300})},[e]);return y.jsx("button",{onClick:t,className:"react-flow__controls-button",title:"Fit view (F)",style:{display:"flex",alignItems:"center",justifyContent:"center"},children:y.jsx(vN,{className:"w-3.5 h-3.5"})})}function Y4(){const{fitView:e}=al();return $.useEffect(()=>{const t=r=>{var a;const l=(a=r.target)==null?void 0:a.tagName;l==="INPUT"||l==="TEXTAREA"||l==="SELECT"||r.key==="f"&&!r.ctrlKey&&!r.metaKey&&!r.altKey&&e({padding:.2,duration:300})};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[e]),null}function X4({viewPathKey:e}){const{fitView:t}=al(),r=$.useRef(e);return $.useEffect(()=>{r.current!==e&&(r.current=e,setTimeout(()=>t({padding:.2,duration:300}),50))},[e,t]),null}function Q4(){const e=D5();return e?y.jsx("div",{className:"absolute top-3 left-1/2 -translate-x-1/2 z-20 animate-[banner-in_200ms_ease-out]",children:y.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 rounded-lg bg-amber-950/90 border border-amber-500/40 shadow-lg shadow-amber-500/10 backdrop-blur-sm max-w-[560px]",children:[y.jsx("span",{className:"text-xs text-amber-300",children:"⚠"}),y.jsx("span",{className:"text-[11px] text-amber-400/80",children:e.message}),y.jsx("a",{href:window.location.pathname,className:"px-2 py-0.5 rounded text-[10px] font-medium text-amber-300 bg-amber-500/20 hover:bg-amber-500/30 transition-colors flex-shrink-0 ml-1",children:"Root"})]})}):null}function sl({items:e}){const t=e.filter(r=>r.value!=null&&r.value!=="");return t.length===0?null:y.jsx("dl",{className:"grid grid-cols-[auto_1fr] gap-x-3 gap-y-1.5 text-xs",children:t.map(({label:r,value:l})=>y.jsxs("div",{className:"contents",children:[y.jsx("dt",{className:"text-[var(--text-muted)] whitespace-nowrap",children:r}),y.jsx("dd",{className:"text-[var(--text)] break-words",children:typeof l=="object"?JSON.stringify(l):String(l)})]},r))})}function RS(e){const t=[];return e.elapsed!=null&&t.push({label:"Elapsed",value:Jt(e.elapsed)}),e.model&&t.push({label:"Model",value:e.model}),e.reasoning_effort&&t.push({label:"Reasoning",value:e.reasoning_effort}),e.tokens!=null&&t.push({label:"Tokens",value:Pn(e.tokens)}),e.input_tokens!=null&&e.output_tokens!=null&&t.push({label:"In / Out",value:`${Pn(e.input_tokens)} / ${Pn(e.output_tokens)}`}),e.cost_usd!=null&&t.push({label:"Cost",value:yi(e.cost_usd)}),e.context_window_used!=null&&e.context_window_max!=null&&t.push({label:"Context",value:IN(e.context_window_used,e.context_window_max)}),e.iteration!=null&&t.push({label:"Iteration",value:e.iteration}),e.error_type&&t.push({label:"Error",value:e.error_type}),e.error_message&&t.push({label:"Message",value:e.error_message}),t}function nl({output:e,title:t="Output",defaultExpanded:r=!0,maxHeight:l="300px"}){const[a,o]=$.useState(r),[u,c]=$.useState(!1),d=Sw(e);if(!d)return null;const h=typeof e=="object"&&e!==null,m=async()=>{await navigator.clipboard.writeText(d),c(!0),setTimeout(()=>c(!1),2e3)};return y.jsxs("div",{className:"space-y-1.5",children:[y.jsxs("div",{className:"flex items-center justify-between",children:[y.jsxs("button",{onClick:()=>o(!a),className:"flex items-center gap-1 text-[10px] uppercase tracking-wider text-[var(--text-muted)] hover:text-[var(--text)] transition-colors font-semibold",children:[a?y.jsx(il,{className:"w-3 h-3"}):y.jsx(Rr,{className:"w-3 h-3"}),t]}),a&&y.jsx("button",{onClick:m,className:"flex items-center gap-1 text-[10px] text-[var(--text-muted)] hover:text-[var(--text)] transition-colors",title:"Copy to clipboard",children:u?y.jsx(Yi,{className:"w-3 h-3 text-[var(--completed)]"}):y.jsx(yw,{className:"w-3 h-3"})})]}),a&&y.jsx("pre",{className:"bg-[var(--bg)] border border-[var(--border)] rounded-md p-3 font-mono text-[11px] leading-relaxed text-[var(--text)] overflow-auto whitespace-pre-wrap break-words",style:{maxHeight:l},children:h?y.jsx(Z4,{text:d}):d})]})}function Z4({text:e}){const t=e.split(/("(?:[^"\\]|\\.)*")/g);return y.jsx(y.Fragment,{children:t.map((r,l)=>{if(l%2===1){const o=t.slice(l+1).join(""),u=/^\s*:/.test(o);return y.jsx("span",{className:u?"text-blue-400":"text-green-400",children:r},l)}const a=r.replace(/\b(true|false|null)\b|(-?\d+\.?\d*(?:e[+-]?\d+)?)/gi,(o,u,c)=>u?`${o}`:c?`${o}`:o);return y.jsx("span",{dangerouslySetInnerHTML:{__html:a}},l)})})}function Vm({activity:e,defaultExpanded:t=!0}){const[r,l]=$.useState(t),a=$.useRef(null);return $.useEffect(()=>{a.current&&r&&(a.current.scrollTop=a.current.scrollHeight)},[e.length,r]),e.length===0?null:y.jsxs("div",{className:"space-y-1.5",children:[y.jsxs("button",{onClick:()=>l(!r),className:"flex items-center gap-1 text-[10px] uppercase tracking-wider text-[var(--text-muted)] hover:text-[var(--text)] transition-colors font-semibold",children:[r?y.jsx(il,{className:"w-3 h-3"}):y.jsx(Rr,{className:"w-3 h-3"}),"Activity (",e.length,")"]}),r&&y.jsx("div",{ref:a,className:"max-h-[400px] overflow-y-auto space-y-0.5",children:e.map((o,u)=>y.jsx(K4,{entry:o},u))})]})}function K4({entry:e}){const t={reasoning:"text-indigo-400/70","tool-start":"text-blue-400","tool-complete":"text-green-400",turn:"text-amber-400",message:"text-[var(--text)]"};return y.jsxs("div",{className:He("py-1.5 px-2 rounded text-[11px] leading-relaxed border-b border-[var(--border-subtle)] last:border-b-0"),children:[y.jsxs("div",{className:"flex items-start gap-1.5",children:[y.jsx("span",{className:"w-4 text-center flex-shrink-0",children:e.icon}),y.jsx("span",{className:"text-[var(--text-muted)] uppercase text-[9px] font-semibold tracking-wider w-12 flex-shrink-0 pt-px",children:e.label}),y.jsx("span",{className:He("break-words",t[e.type]||"text-[var(--text)]"),children:typeof e.text=="object"?JSON.stringify(e.text):e.text})]}),e.detail&&y.jsx("div",{className:"mt-1 ml-[4.25rem] px-2 py-1 bg-[var(--bg)] rounded text-[10px] font-mono text-[var(--text-muted)] whitespace-pre-wrap break-words max-h-24 overflow-y-auto",children:typeof e.detail=="object"?JSON.stringify(e.detail,null,2):e.detail})]})}function b1({node:e}){const t=e.status,r=Fe[t]||Fe.pending,l=e.iterationHistory&&e.iterationHistory.length>0;return y.jsxs("div",{className:"space-y-4",children:[y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx("span",{className:"inline-flex items-center px-2 py-0.5 rounded text-[10px] font-bold uppercase tracking-wider",style:{backgroundColor:`${r}20`,color:r},children:t}),y.jsx("span",{className:"text-xs text-[var(--text-muted)]",children:"Agent"})]}),l?y.jsx(w1,{label:`Iteration ${e.iteration??"?"} (current)`,defaultExpanded:!0,status:t,snapshot:{iteration:e.iteration??0,prompt:e.prompt,output:e.output,elapsed:e.elapsed,model:e.model,reasoning_effort:e.reasoning_effort,tokens:e.tokens,input_tokens:e.input_tokens,output_tokens:e.output_tokens,cost_usd:e.cost_usd,activity:e.activity,error_type:e.error_type,error_message:e.error_message}}):y.jsxs(y.Fragment,{children:[y.jsx(sl,{items:RS(e)}),e.prompt&&y.jsx(nl,{output:e.prompt,title:"Input / Prompt",defaultExpanded:!0}),y.jsx(Vm,{activity:e.activity,defaultExpanded:t!=="completed"}),e.output!=null&&y.jsx(nl,{output:e.output,title:"Output"})]}),l&&[...e.iterationHistory].reverse().map(a=>y.jsx(w1,{label:`Iteration ${a.iteration}`,defaultExpanded:!1,status:t,snapshot:a},a.iteration))]})}function w1({label:e,defaultExpanded:t,snapshot:r,status:l}){const[a,o]=$.useState(t);return y.jsxs("div",{className:"border border-[var(--border)] rounded-lg overflow-hidden",children:[y.jsxs("button",{onClick:()=>o(!a),className:"flex items-center gap-2 w-full px-3 py-2 bg-[var(--bg)] hover:bg-[var(--node-bg)] transition-colors text-left",children:[a?y.jsx(il,{className:"w-3.5 h-3.5 text-[var(--text-muted)] flex-shrink-0"}):y.jsx(Rr,{className:"w-3.5 h-3.5 text-[var(--text-muted)] flex-shrink-0"}),y.jsx("span",{className:"text-xs font-semibold text-[var(--text)]",children:e}),r.elapsed!=null&&y.jsx("span",{className:"text-[10px] text-[var(--text-muted)] ml-auto",children:J4(r.elapsed)})]}),a&&y.jsxs("div",{className:"px-3 py-3 space-y-3 border-t border-[var(--border)]",children:[y.jsx(sl,{items:RS(r)}),r.prompt&&y.jsx(nl,{output:r.prompt,title:"Input / Prompt",defaultExpanded:!1}),y.jsx(Vm,{activity:r.activity,defaultExpanded:t&&l!=="completed"}),r.output!=null&&y.jsx(nl,{output:r.output,title:"Output",defaultExpanded:!0}),r.error_type&&y.jsxs("div",{className:"text-xs text-red-400",children:[y.jsx("span",{className:"font-semibold",children:r.error_type}),r.error_message&&y.jsxs("span",{className:"ml-1",children:["— ",r.error_message]})]})]})]})}function J4(e){if(e<1)return`${(e*1e3).toFixed(0)}ms`;if(e<60)return`${e.toFixed(1)}s`;const t=Math.floor(e/60),r=(e%60).toFixed(0);return`${t}m ${r}s`}function W4({node:e}){const t=e.status,r=Fe[t]||Fe.pending,l=[];e.elapsed!=null&&l.push({label:"Elapsed",value:Jt(e.elapsed)}),e.exit_code!=null&&l.push({label:"Exit Code",value:e.exit_code}),e.error_type&&l.push({label:"Error",value:e.error_type}),e.error_message&&l.push({label:"Message",value:e.error_message});let a="";return e.stdout&&(a+=e.stdout),e.stderr&&(a+=(a?` - ---- stderr --- -`:"")+e.stderr),y.jsxs("div",{className:"space-y-4",children:[y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx("span",{className:"inline-flex items-center px-2 py-0.5 rounded text-[10px] font-bold uppercase tracking-wider",style:{backgroundColor:`${r}20`,color:r},children:t}),y.jsx("span",{className:"text-xs text-[var(--text-muted)]",children:"Script"})]}),y.jsx(sl,{items:l}),a&&y.jsx(nl,{output:a,title:"Output"})]})}function eD(e,t){const r={};return(e[e.length-1]===""?[...e,""]:e).join((r.padRight?" ":"")+","+(r.padLeft===!1?"":" ")).trim()}const tD=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,nD=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,rD={};function _1(e,t){return(rD.jsx?nD:tD).test(e)}const iD=/[ \t\n\f\r]/g;function lD(e){return typeof e=="object"?e.type==="text"?S1(e.value):!1:S1(e)}function S1(e){return e.replace(iD,"")===""}class ls{constructor(t,r,l){this.normal=r,this.property=t,l&&(this.space=l)}}ls.prototype.normal={};ls.prototype.property={};ls.prototype.space=void 0;function OS(e,t){const r={},l={};for(const a of e)Object.assign(r,a.property),Object.assign(l,a.normal);return new ls(r,l,t)}function om(e){return e.toLowerCase()}class cn{constructor(t,r){this.attribute=r,this.property=t}}cn.prototype.attribute="";cn.prototype.booleanish=!1;cn.prototype.boolean=!1;cn.prototype.commaOrSpaceSeparated=!1;cn.prototype.commaSeparated=!1;cn.prototype.defined=!1;cn.prototype.mustUseProperty=!1;cn.prototype.number=!1;cn.prototype.overloadedBoolean=!1;cn.prototype.property="";cn.prototype.spaceSeparated=!1;cn.prototype.space=void 0;let aD=0;const Re=ul(),jt=ul(),sm=ul(),me=ul(),st=ul(),ua=ul(),vn=ul();function ul(){return 2**++aD}const um=Object.freeze(Object.defineProperty({__proto__:null,boolean:Re,booleanish:jt,commaOrSpaceSeparated:vn,commaSeparated:ua,number:me,overloadedBoolean:sm,spaceSeparated:st},Symbol.toStringTag,{value:"Module"})),kp=Object.keys(um);class Pm extends cn{constructor(t,r,l,a){let o=-1;if(super(t,r),k1(this,"space",a),typeof l=="number")for(;++o4&&r.slice(0,4)==="data"&&fD.test(t)){if(t.charAt(4)==="-"){const o=t.slice(5).replace(E1,pD);l="data"+o.charAt(0).toUpperCase()+o.slice(1)}else{const o=t.slice(4);if(!E1.test(o)){let u=o.replace(cD,hD);u.charAt(0)!=="-"&&(u="-"+u),t="data"+u}}a=Pm}return new a(l,t)}function hD(e){return"-"+e.toLowerCase()}function pD(e){return e.charAt(1).toUpperCase()}const mD=OS([LS,oD,IS,qS,US],"html"),Gm=OS([LS,sD,IS,qS,US],"svg");function gD(e){return e.join(" ").trim()}var Kl={},Ep,N1;function xD(){if(N1)return Ep;N1=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,r=/^\s*/,l=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,a=/^:\s*/,o=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,u=/^[;\s]*/,c=/^\s+|\s+$/g,d=` -`,h="/",m="*",p="",x="comment",b="declaration";function w(S,_){if(typeof S!="string")throw new TypeError("First argument must be a string");if(!S)return[];_=_||{};var N=1,k=1;function A(I){var F=I.match(t);F&&(N+=F.length);var z=I.lastIndexOf(d);k=~z?I.length-z:k+I.length}function M(){var I={line:N,column:k};return function(F){return F.position=new T(I),V(),F}}function T(I){this.start=I,this.end={line:N,column:k},this.source=_.source}T.prototype.content=S;function L(I){var F=new Error(_.source+":"+N+":"+k+": "+I);if(F.reason=I,F.filename=_.source,F.line=N,F.column=k,F.source=S,!_.silent)throw F}function R(I){var F=I.exec(S);if(F){var z=F[0];return A(z),S=S.slice(z.length),F}}function V(){R(r)}function H(I){var F;for(I=I||[];F=B();)F!==!1&&I.push(F);return I}function B(){var I=M();if(!(h!=S.charAt(0)||m!=S.charAt(1))){for(var F=2;p!=S.charAt(F)&&(m!=S.charAt(F)||h!=S.charAt(F+1));)++F;if(F+=2,p===S.charAt(F-1))return L("End of comment missing");var z=S.slice(2,F-2);return k+=2,A(z),S=S.slice(F),k+=2,I({type:x,comment:z})}}function U(){var I=M(),F=R(l);if(F){if(B(),!R(a))return L("property missing ':'");var z=R(o),G=I({type:b,property:E(F[0].replace(e,p)),value:z?E(z[0].replace(e,p)):p});return R(u),G}}function ee(){var I=[];H(I);for(var F;F=U();)F!==!1&&(I.push(F),H(I));return I}return V(),ee()}function E(S){return S?S.replace(c,p):p}return Ep=w,Ep}var C1;function yD(){if(C1)return Kl;C1=1;var e=Kl&&Kl.__importDefault||function(l){return l&&l.__esModule?l:{default:l}};Object.defineProperty(Kl,"__esModule",{value:!0}),Kl.default=r;const t=e(xD());function r(l,a){let o=null;if(!l||typeof l!="string")return o;const u=(0,t.default)(l),c=typeof a=="function";return u.forEach(d=>{if(d.type!=="declaration")return;const{property:h,value:m}=d;c?a(h,m,d):m&&(o=o||{},o[h]=m)}),o}return Kl}var wo={},j1;function vD(){if(j1)return wo;j1=1,Object.defineProperty(wo,"__esModule",{value:!0}),wo.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,t=/-([a-z])/g,r=/^[^-]+$/,l=/^-(webkit|moz|ms|o|khtml)-/,a=/^-(ms)-/,o=function(h){return!h||r.test(h)||e.test(h)},u=function(h,m){return m.toUpperCase()},c=function(h,m){return"".concat(m,"-")},d=function(h,m){return m===void 0&&(m={}),o(h)?h:(h=h.toLowerCase(),m.reactCompat?h=h.replace(a,c):h=h.replace(l,c),h.replace(t,u))};return wo.camelCase=d,wo}var _o,T1;function bD(){if(T1)return _o;T1=1;var e=_o&&_o.__importDefault||function(a){return a&&a.__esModule?a:{default:a}},t=e(yD()),r=vD();function l(a,o){var u={};return!a||typeof a!="string"||(0,t.default)(a,function(c,d){c&&d&&(u[(0,r.camelCase)(c,o)]=d)}),u}return l.default=l,_o=l,_o}var wD=bD();const _D=Qo(wD),$S=VS("end"),Fm=VS("start");function VS(e){return t;function t(r){const l=r&&r.position&&r.position[e]||{};if(typeof l.line=="number"&&l.line>0&&typeof l.column=="number"&&l.column>0)return{line:l.line,column:l.column,offset:typeof l.offset=="number"&&l.offset>-1?l.offset:void 0}}}function SD(e){const t=Fm(e),r=$S(e);if(t&&r)return{start:t,end:r}}function Do(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?A1(e.position):"start"in e||"end"in e?A1(e):"line"in e||"column"in e?cm(e):""}function cm(e){return z1(e&&e.line)+":"+z1(e&&e.column)}function A1(e){return cm(e&&e.start)+"-"+cm(e&&e.end)}function z1(e){return e&&typeof e=="number"?e:1}class Xt extends Error{constructor(t,r,l){super(),typeof r=="string"&&(l=r,r=void 0);let a="",o={},u=!1;if(r&&("line"in r&&"column"in r?o={place:r}:"start"in r&&"end"in r?o={place:r}:"type"in r?o={ancestors:[r],place:r.position}:o={...r}),typeof t=="string"?a=t:!o.cause&&t&&(u=!0,a=t.message,o.cause=t),!o.ruleId&&!o.source&&typeof l=="string"){const d=l.indexOf(":");d===-1?o.ruleId=l:(o.source=l.slice(0,d),o.ruleId=l.slice(d+1))}if(!o.place&&o.ancestors&&o.ancestors){const d=o.ancestors[o.ancestors.length-1];d&&(o.place=d.position)}const c=o.place&&"start"in o.place?o.place.start:o.place;this.ancestors=o.ancestors||void 0,this.cause=o.cause||void 0,this.column=c?c.column:void 0,this.fatal=void 0,this.file="",this.message=a,this.line=c?c.line:void 0,this.name=Do(o.place)||"1:1",this.place=o.place||void 0,this.reason=this.message,this.ruleId=o.ruleId||void 0,this.source=o.source||void 0,this.stack=u&&o.cause&&typeof o.cause.stack=="string"?o.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}Xt.prototype.file="";Xt.prototype.name="";Xt.prototype.reason="";Xt.prototype.message="";Xt.prototype.stack="";Xt.prototype.column=void 0;Xt.prototype.line=void 0;Xt.prototype.ancestors=void 0;Xt.prototype.cause=void 0;Xt.prototype.fatal=void 0;Xt.prototype.place=void 0;Xt.prototype.ruleId=void 0;Xt.prototype.source=void 0;const Ym={}.hasOwnProperty,kD=new Map,ED=/[A-Z]/g,ND=new Set(["table","tbody","thead","tfoot","tr"]),CD=new Set(["td","th"]),PS="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function jD(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const r=t.filePath||void 0;let l;if(t.development){if(typeof t.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");l=LD(r,t.jsxDEV)}else{if(typeof t.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof t.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");l=OD(r,t.jsx,t.jsxs)}const a={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:l,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:r,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space==="svg"?Gm:mD,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},o=GS(a,e,void 0);return o&&typeof o!="string"?o:a.create(e,a.Fragment,{children:o||void 0},void 0)}function GS(e,t,r){if(t.type==="element")return TD(e,t,r);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return AD(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return MD(e,t,r);if(t.type==="mdxjsEsm")return zD(e,t);if(t.type==="root")return DD(e,t,r);if(t.type==="text")return RD(e,t)}function TD(e,t,r){const l=e.schema;let a=l;t.tagName.toLowerCase()==="svg"&&l.space==="html"&&(a=Gm,e.schema=a),e.ancestors.push(t);const o=YS(e,t.tagName,!1),u=HD(e,t);let c=Qm(e,t);return ND.has(t.tagName)&&(c=c.filter(function(d){return typeof d=="string"?!lD(d):!0})),FS(e,u,o,t),Xm(u,c),e.ancestors.pop(),e.schema=l,e.create(t,o,u,r)}function AD(e,t){if(t.data&&t.data.estree&&e.evaluater){const l=t.data.estree.body[0];return l.type,e.evaluater.evaluateExpression(l.expression)}Yo(e,t.position)}function zD(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);Yo(e,t.position)}function MD(e,t,r){const l=e.schema;let a=l;t.name==="svg"&&l.space==="html"&&(a=Gm,e.schema=a),e.ancestors.push(t);const o=t.name===null?e.Fragment:YS(e,t.name,!0),u=BD(e,t),c=Qm(e,t);return FS(e,u,o,t),Xm(u,c),e.ancestors.pop(),e.schema=l,e.create(t,o,u,r)}function DD(e,t,r){const l={};return Xm(l,Qm(e,t)),e.create(t,e.Fragment,l,r)}function RD(e,t){return t.value}function FS(e,t,r,l){typeof r!="string"&&r!==e.Fragment&&e.passNode&&(t.node=l)}function Xm(e,t){if(t.length>0){const r=t.length>1?t:t[0];r&&(e.children=r)}}function OD(e,t,r){return l;function l(a,o,u,c){const h=Array.isArray(u.children)?r:t;return c?h(o,u,c):h(o,u)}}function LD(e,t){return r;function r(l,a,o,u){const c=Array.isArray(o.children),d=Fm(l);return t(a,o,u,c,{columnNumber:d?d.column-1:void 0,fileName:e,lineNumber:d?d.line:void 0},void 0)}}function HD(e,t){const r={};let l,a;for(a in t.properties)if(a!=="children"&&Ym.call(t.properties,a)){const o=ID(e,a,t.properties[a]);if(o){const[u,c]=o;e.tableCellAlignToStyle&&u==="align"&&typeof c=="string"&&CD.has(t.tagName)?l=c:r[u]=c}}if(l){const o=r.style||(r.style={});o[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=l}return r}function BD(e,t){const r={};for(const l of t.attributes)if(l.type==="mdxJsxExpressionAttribute")if(l.data&&l.data.estree&&e.evaluater){const o=l.data.estree.body[0];o.type;const u=o.expression;u.type;const c=u.properties[0];c.type,Object.assign(r,e.evaluater.evaluateExpression(c.argument))}else Yo(e,t.position);else{const a=l.name;let o;if(l.value&&typeof l.value=="object")if(l.value.data&&l.value.data.estree&&e.evaluater){const c=l.value.data.estree.body[0];c.type,o=e.evaluater.evaluateExpression(c.expression)}else Yo(e,t.position);else o=l.value===null?!0:l.value;r[a]=o}return r}function Qm(e,t){const r=[];let l=-1;const a=e.passKeys?new Map:kD;for(;++la?0:a+t:t=t>a?a:t,r=r>0?r:0,l.length<1e4)u=Array.from(l),u.unshift(t,r),e.splice(...u);else for(r&&e.splice(t,r);o0?(_n(e,e.length,0,t),e):t}const R1={}.hasOwnProperty;function QS(e){const t={};let r=-1;for(;++r13&&r<32||r>126&&r<160||r>55295&&r<57344||r>64975&&r<65008||(r&65535)===65535||(r&65535)===65534||r>1114111?"�":String.fromCodePoint(r)}function Fn(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const Kt=vi(/[A-Za-z]/),Yt=vi(/[\dA-Za-z]/),XD=vi(/[#-'*+\--9=?A-Z^-~]/);function vc(e){return e!==null&&(e<32||e===127)}const fm=vi(/\d/),QD=vi(/[\dA-Fa-f]/),ZD=vi(/[!-/:-@[-`{-~]/);function Ee(e){return e!==null&&e<-2}function ot(e){return e!==null&&(e<0||e===32)}function $e(e){return e===-2||e===-1||e===32}const Uc=vi(new RegExp("\\p{P}|\\p{S}","u")),rl=vi(/\s/);function vi(e){return t;function t(r){return r!==null&&r>-1&&e.test(String.fromCharCode(r))}}function ba(e){const t=[];let r=-1,l=0,a=0;for(;++r55295&&o<57344){const c=e.charCodeAt(r+1);o<56320&&c>56319&&c<57344?(u=String.fromCharCode(o,c),a=1):u="�"}else u=String.fromCharCode(o);u&&(t.push(e.slice(l,r),encodeURIComponent(u)),l=r+a+1,u=""),a&&(r+=a,a=0)}return t.join("")+e.slice(l)}function Qe(e,t,r,l){const a=l?l-1:Number.POSITIVE_INFINITY;let o=0;return u;function u(d){return $e(d)?(e.enter(r),c(d)):t(d)}function c(d){return $e(d)&&o++u))return;const L=t.events.length;let R=L,V,H;for(;R--;)if(t.events[R][0]==="exit"&&t.events[R][1].type==="chunkFlow"){if(V){H=t.events[R][1].end;break}V=!0}for(_(l),T=L;Tk;){const M=r[A];t.containerState=M[1],M[0].exit.call(t,e)}r.length=k}function N(){a.write([null]),o=void 0,a=void 0,t.containerState._closeFlow=void 0}}function tR(e,t,r){return Qe(e,e.attempt(this.parser.constructs.document,t,r),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function ya(e){if(e===null||ot(e)||rl(e))return 1;if(Uc(e))return 2}function $c(e,t,r){const l=[];let a=-1;for(;++a1&&e[r][1].end.offset-e[r][1].start.offset>1?2:1;const p={...e[l][1].end},x={...e[r][1].start};L1(p,-d),L1(x,d),u={type:d>1?"strongSequence":"emphasisSequence",start:p,end:{...e[l][1].end}},c={type:d>1?"strongSequence":"emphasisSequence",start:{...e[r][1].start},end:x},o={type:d>1?"strongText":"emphasisText",start:{...e[l][1].end},end:{...e[r][1].start}},a={type:d>1?"strong":"emphasis",start:{...u.start},end:{...c.end}},e[l][1].end={...u.start},e[r][1].start={...c.end},h=[],e[l][1].end.offset-e[l][1].start.offset&&(h=Dn(h,[["enter",e[l][1],t],["exit",e[l][1],t]])),h=Dn(h,[["enter",a,t],["enter",u,t],["exit",u,t],["enter",o,t]]),h=Dn(h,$c(t.parser.constructs.insideSpan.null,e.slice(l+1,r),t)),h=Dn(h,[["exit",o,t],["enter",c,t],["exit",c,t],["exit",a,t]]),e[r][1].end.offset-e[r][1].start.offset?(m=2,h=Dn(h,[["enter",e[r][1],t],["exit",e[r][1],t]])):m=0,_n(e,l-1,r-l+3,h),r=l+h.length-m-2;break}}for(r=-1;++r0&&$e(T)?Qe(e,N,"linePrefix",o+1)(T):N(T)}function N(T){return T===null||Ee(T)?e.check(H1,E,A)(T):(e.enter("codeFlowValue"),k(T))}function k(T){return T===null||Ee(T)?(e.exit("codeFlowValue"),N(T)):(e.consume(T),k)}function A(T){return e.exit("codeFenced"),t(T)}function M(T,L,R){let V=0;return H;function H(F){return T.enter("lineEnding"),T.consume(F),T.exit("lineEnding"),B}function B(F){return T.enter("codeFencedFence"),$e(F)?Qe(T,U,"linePrefix",l.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(F):U(F)}function U(F){return F===c?(T.enter("codeFencedFenceSequence"),ee(F)):R(F)}function ee(F){return F===c?(V++,T.consume(F),ee):V>=u?(T.exit("codeFencedFenceSequence"),$e(F)?Qe(T,I,"whitespace")(F):I(F)):R(F)}function I(F){return F===null||Ee(F)?(T.exit("codeFencedFence"),L(F)):R(F)}}}function hR(e,t,r){const l=this;return a;function a(u){return u===null?r(u):(e.enter("lineEnding"),e.consume(u),e.exit("lineEnding"),o)}function o(u){return l.parser.lazy[l.now().line]?r(u):t(u)}}const Cp={name:"codeIndented",tokenize:mR},pR={partial:!0,tokenize:gR};function mR(e,t,r){const l=this;return a;function a(h){return e.enter("codeIndented"),Qe(e,o,"linePrefix",5)(h)}function o(h){const m=l.events[l.events.length-1];return m&&m[1].type==="linePrefix"&&m[2].sliceSerialize(m[1],!0).length>=4?u(h):r(h)}function u(h){return h===null?d(h):Ee(h)?e.attempt(pR,u,d)(h):(e.enter("codeFlowValue"),c(h))}function c(h){return h===null||Ee(h)?(e.exit("codeFlowValue"),u(h)):(e.consume(h),c)}function d(h){return e.exit("codeIndented"),t(h)}}function gR(e,t,r){const l=this;return a;function a(u){return l.parser.lazy[l.now().line]?r(u):Ee(u)?(e.enter("lineEnding"),e.consume(u),e.exit("lineEnding"),a):Qe(e,o,"linePrefix",5)(u)}function o(u){const c=l.events[l.events.length-1];return c&&c[1].type==="linePrefix"&&c[2].sliceSerialize(c[1],!0).length>=4?t(u):Ee(u)?a(u):r(u)}}const xR={name:"codeText",previous:vR,resolve:yR,tokenize:bR};function yR(e){let t=e.length-4,r=3,l,a;if((e[r][1].type==="lineEnding"||e[r][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(l=r;++l=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+t+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return tthis.left.length?this.right.slice(this.right.length-l+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-l+this.left.length).reverse())}splice(t,r,l){const a=r||0;this.setCursor(Math.trunc(t));const o=this.right.splice(this.right.length-a,Number.POSITIVE_INFINITY);return l&&So(this.left,l),o.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),So(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),So(this.right,t.reverse())}setCursor(t){if(!(t===this.left.length||t>this.left.length&&this.right.length===0||t<0&&this.left.length===0))if(t=4?t(u):e.interrupt(l.parser.constructs.flow,r,t)(u)}}function tk(e,t,r,l,a,o,u,c,d){const h=d||Number.POSITIVE_INFINITY;let m=0;return p;function p(_){return _===60?(e.enter(l),e.enter(a),e.enter(o),e.consume(_),e.exit(o),x):_===null||_===32||_===41||vc(_)?r(_):(e.enter(l),e.enter(u),e.enter(c),e.enter("chunkString",{contentType:"string"}),E(_))}function x(_){return _===62?(e.enter(o),e.consume(_),e.exit(o),e.exit(a),e.exit(l),t):(e.enter(c),e.enter("chunkString",{contentType:"string"}),b(_))}function b(_){return _===62?(e.exit("chunkString"),e.exit(c),x(_)):_===null||_===60||Ee(_)?r(_):(e.consume(_),_===92?w:b)}function w(_){return _===60||_===62||_===92?(e.consume(_),b):b(_)}function E(_){return!m&&(_===null||_===41||ot(_))?(e.exit("chunkString"),e.exit(c),e.exit(u),e.exit(l),t(_)):m999||b===null||b===91||b===93&&!d||b===94&&!c&&"_hiddenFootnoteSupport"in u.parser.constructs?r(b):b===93?(e.exit(o),e.enter(a),e.consume(b),e.exit(a),e.exit(l),t):Ee(b)?(e.enter("lineEnding"),e.consume(b),e.exit("lineEnding"),m):(e.enter("chunkString",{contentType:"string"}),p(b))}function p(b){return b===null||b===91||b===93||Ee(b)||c++>999?(e.exit("chunkString"),m(b)):(e.consume(b),d||(d=!$e(b)),b===92?x:p)}function x(b){return b===91||b===92||b===93?(e.consume(b),c++,p):p(b)}}function rk(e,t,r,l,a,o){let u;return c;function c(x){return x===34||x===39||x===40?(e.enter(l),e.enter(a),e.consume(x),e.exit(a),u=x===40?41:x,d):r(x)}function d(x){return x===u?(e.enter(a),e.consume(x),e.exit(a),e.exit(l),t):(e.enter(o),h(x))}function h(x){return x===u?(e.exit(o),d(u)):x===null?r(x):Ee(x)?(e.enter("lineEnding"),e.consume(x),e.exit("lineEnding"),Qe(e,h,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),m(x))}function m(x){return x===u||x===null||Ee(x)?(e.exit("chunkString"),h(x)):(e.consume(x),x===92?p:m)}function p(x){return x===u||x===92?(e.consume(x),m):m(x)}}function Ro(e,t){let r;return l;function l(a){return Ee(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),r=!0,l):$e(a)?Qe(e,l,r?"linePrefix":"lineSuffix")(a):t(a)}}const jR={name:"definition",tokenize:AR},TR={partial:!0,tokenize:zR};function AR(e,t,r){const l=this;let a;return o;function o(b){return e.enter("definition"),u(b)}function u(b){return nk.call(l,e,c,r,"definitionLabel","definitionLabelMarker","definitionLabelString")(b)}function c(b){return a=Fn(l.sliceSerialize(l.events[l.events.length-1][1]).slice(1,-1)),b===58?(e.enter("definitionMarker"),e.consume(b),e.exit("definitionMarker"),d):r(b)}function d(b){return ot(b)?Ro(e,h)(b):h(b)}function h(b){return tk(e,m,r,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(b)}function m(b){return e.attempt(TR,p,p)(b)}function p(b){return $e(b)?Qe(e,x,"whitespace")(b):x(b)}function x(b){return b===null||Ee(b)?(e.exit("definition"),l.parser.defined.push(a),t(b)):r(b)}}function zR(e,t,r){return l;function l(c){return ot(c)?Ro(e,a)(c):r(c)}function a(c){return rk(e,o,r,"definitionTitle","definitionTitleMarker","definitionTitleString")(c)}function o(c){return $e(c)?Qe(e,u,"whitespace")(c):u(c)}function u(c){return c===null||Ee(c)?t(c):r(c)}}const MR={name:"hardBreakEscape",tokenize:DR};function DR(e,t,r){return l;function l(o){return e.enter("hardBreakEscape"),e.consume(o),a}function a(o){return Ee(o)?(e.exit("hardBreakEscape"),t(o)):r(o)}}const RR={name:"headingAtx",resolve:OR,tokenize:LR};function OR(e,t){let r=e.length-2,l=3,a,o;return e[l][1].type==="whitespace"&&(l+=2),r-2>l&&e[r][1].type==="whitespace"&&(r-=2),e[r][1].type==="atxHeadingSequence"&&(l===r-1||r-4>l&&e[r-2][1].type==="whitespace")&&(r-=l+1===r?2:4),r>l&&(a={type:"atxHeadingText",start:e[l][1].start,end:e[r][1].end},o={type:"chunkText",start:e[l][1].start,end:e[r][1].end,contentType:"text"},_n(e,l,r-l+1,[["enter",a,t],["enter",o,t],["exit",o,t],["exit",a,t]])),e}function LR(e,t,r){let l=0;return a;function a(m){return e.enter("atxHeading"),o(m)}function o(m){return e.enter("atxHeadingSequence"),u(m)}function u(m){return m===35&&l++<6?(e.consume(m),u):m===null||ot(m)?(e.exit("atxHeadingSequence"),c(m)):r(m)}function c(m){return m===35?(e.enter("atxHeadingSequence"),d(m)):m===null||Ee(m)?(e.exit("atxHeading"),t(m)):$e(m)?Qe(e,c,"whitespace")(m):(e.enter("atxHeadingText"),h(m))}function d(m){return m===35?(e.consume(m),d):(e.exit("atxHeadingSequence"),c(m))}function h(m){return m===null||m===35||ot(m)?(e.exit("atxHeadingText"),c(m)):(e.consume(m),h)}}const HR=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],I1=["pre","script","style","textarea"],BR={concrete:!0,name:"htmlFlow",resolveTo:UR,tokenize:$R},IR={partial:!0,tokenize:PR},qR={partial:!0,tokenize:VR};function UR(e){let t=e.length;for(;t--&&!(e[t][0]==="enter"&&e[t][1].type==="htmlFlow"););return t>1&&e[t-2][1].type==="linePrefix"&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function $R(e,t,r){const l=this;let a,o,u,c,d;return h;function h(C){return m(C)}function m(C){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(C),p}function p(C){return C===33?(e.consume(C),x):C===47?(e.consume(C),o=!0,E):C===63?(e.consume(C),a=3,l.interrupt?t:D):Kt(C)?(e.consume(C),u=String.fromCharCode(C),S):r(C)}function x(C){return C===45?(e.consume(C),a=2,b):C===91?(e.consume(C),a=5,c=0,w):Kt(C)?(e.consume(C),a=4,l.interrupt?t:D):r(C)}function b(C){return C===45?(e.consume(C),l.interrupt?t:D):r(C)}function w(C){const P="CDATA[";return C===P.charCodeAt(c++)?(e.consume(C),c===P.length?l.interrupt?t:U:w):r(C)}function E(C){return Kt(C)?(e.consume(C),u=String.fromCharCode(C),S):r(C)}function S(C){if(C===null||C===47||C===62||ot(C)){const P=C===47,X=u.toLowerCase();return!P&&!o&&I1.includes(X)?(a=1,l.interrupt?t(C):U(C)):HR.includes(u.toLowerCase())?(a=6,P?(e.consume(C),_):l.interrupt?t(C):U(C)):(a=7,l.interrupt&&!l.parser.lazy[l.now().line]?r(C):o?N(C):k(C))}return C===45||Yt(C)?(e.consume(C),u+=String.fromCharCode(C),S):r(C)}function _(C){return C===62?(e.consume(C),l.interrupt?t:U):r(C)}function N(C){return $e(C)?(e.consume(C),N):H(C)}function k(C){return C===47?(e.consume(C),H):C===58||C===95||Kt(C)?(e.consume(C),A):$e(C)?(e.consume(C),k):H(C)}function A(C){return C===45||C===46||C===58||C===95||Yt(C)?(e.consume(C),A):M(C)}function M(C){return C===61?(e.consume(C),T):$e(C)?(e.consume(C),M):k(C)}function T(C){return C===null||C===60||C===61||C===62||C===96?r(C):C===34||C===39?(e.consume(C),d=C,L):$e(C)?(e.consume(C),T):R(C)}function L(C){return C===d?(e.consume(C),d=null,V):C===null||Ee(C)?r(C):(e.consume(C),L)}function R(C){return C===null||C===34||C===39||C===47||C===60||C===61||C===62||C===96||ot(C)?M(C):(e.consume(C),R)}function V(C){return C===47||C===62||$e(C)?k(C):r(C)}function H(C){return C===62?(e.consume(C),B):r(C)}function B(C){return C===null||Ee(C)?U(C):$e(C)?(e.consume(C),B):r(C)}function U(C){return C===45&&a===2?(e.consume(C),z):C===60&&a===1?(e.consume(C),G):C===62&&a===4?(e.consume(C),q):C===63&&a===3?(e.consume(C),D):C===93&&a===5?(e.consume(C),K):Ee(C)&&(a===6||a===7)?(e.exit("htmlFlowData"),e.check(IR,Y,ee)(C)):C===null||Ee(C)?(e.exit("htmlFlowData"),ee(C)):(e.consume(C),U)}function ee(C){return e.check(qR,I,Y)(C)}function I(C){return e.enter("lineEnding"),e.consume(C),e.exit("lineEnding"),F}function F(C){return C===null||Ee(C)?ee(C):(e.enter("htmlFlowData"),U(C))}function z(C){return C===45?(e.consume(C),D):U(C)}function G(C){return C===47?(e.consume(C),u="",Q):U(C)}function Q(C){if(C===62){const P=u.toLowerCase();return I1.includes(P)?(e.consume(C),q):U(C)}return Kt(C)&&u.length<8?(e.consume(C),u+=String.fromCharCode(C),Q):U(C)}function K(C){return C===93?(e.consume(C),D):U(C)}function D(C){return C===62?(e.consume(C),q):C===45&&a===2?(e.consume(C),D):U(C)}function q(C){return C===null||Ee(C)?(e.exit("htmlFlowData"),Y(C)):(e.consume(C),q)}function Y(C){return e.exit("htmlFlow"),t(C)}}function VR(e,t,r){const l=this;return a;function a(u){return Ee(u)?(e.enter("lineEnding"),e.consume(u),e.exit("lineEnding"),o):r(u)}function o(u){return l.parser.lazy[l.now().line]?r(u):t(u)}}function PR(e,t,r){return l;function l(a){return e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),e.attempt(as,t,r)}}const GR={name:"htmlText",tokenize:FR};function FR(e,t,r){const l=this;let a,o,u;return c;function c(D){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(D),d}function d(D){return D===33?(e.consume(D),h):D===47?(e.consume(D),M):D===63?(e.consume(D),k):Kt(D)?(e.consume(D),R):r(D)}function h(D){return D===45?(e.consume(D),m):D===91?(e.consume(D),o=0,w):Kt(D)?(e.consume(D),N):r(D)}function m(D){return D===45?(e.consume(D),b):r(D)}function p(D){return D===null?r(D):D===45?(e.consume(D),x):Ee(D)?(u=p,G(D)):(e.consume(D),p)}function x(D){return D===45?(e.consume(D),b):p(D)}function b(D){return D===62?z(D):D===45?x(D):p(D)}function w(D){const q="CDATA[";return D===q.charCodeAt(o++)?(e.consume(D),o===q.length?E:w):r(D)}function E(D){return D===null?r(D):D===93?(e.consume(D),S):Ee(D)?(u=E,G(D)):(e.consume(D),E)}function S(D){return D===93?(e.consume(D),_):E(D)}function _(D){return D===62?z(D):D===93?(e.consume(D),_):E(D)}function N(D){return D===null||D===62?z(D):Ee(D)?(u=N,G(D)):(e.consume(D),N)}function k(D){return D===null?r(D):D===63?(e.consume(D),A):Ee(D)?(u=k,G(D)):(e.consume(D),k)}function A(D){return D===62?z(D):k(D)}function M(D){return Kt(D)?(e.consume(D),T):r(D)}function T(D){return D===45||Yt(D)?(e.consume(D),T):L(D)}function L(D){return Ee(D)?(u=L,G(D)):$e(D)?(e.consume(D),L):z(D)}function R(D){return D===45||Yt(D)?(e.consume(D),R):D===47||D===62||ot(D)?V(D):r(D)}function V(D){return D===47?(e.consume(D),z):D===58||D===95||Kt(D)?(e.consume(D),H):Ee(D)?(u=V,G(D)):$e(D)?(e.consume(D),V):z(D)}function H(D){return D===45||D===46||D===58||D===95||Yt(D)?(e.consume(D),H):B(D)}function B(D){return D===61?(e.consume(D),U):Ee(D)?(u=B,G(D)):$e(D)?(e.consume(D),B):V(D)}function U(D){return D===null||D===60||D===61||D===62||D===96?r(D):D===34||D===39?(e.consume(D),a=D,ee):Ee(D)?(u=U,G(D)):$e(D)?(e.consume(D),U):(e.consume(D),I)}function ee(D){return D===a?(e.consume(D),a=void 0,F):D===null?r(D):Ee(D)?(u=ee,G(D)):(e.consume(D),ee)}function I(D){return D===null||D===34||D===39||D===60||D===61||D===96?r(D):D===47||D===62||ot(D)?V(D):(e.consume(D),I)}function F(D){return D===47||D===62||ot(D)?V(D):r(D)}function z(D){return D===62?(e.consume(D),e.exit("htmlTextData"),e.exit("htmlText"),t):r(D)}function G(D){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(D),e.exit("lineEnding"),Q}function Q(D){return $e(D)?Qe(e,K,"linePrefix",l.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(D):K(D)}function K(D){return e.enter("htmlTextData"),u(D)}}const Jm={name:"labelEnd",resolveAll:ZR,resolveTo:KR,tokenize:JR},YR={tokenize:WR},XR={tokenize:eO},QR={tokenize:tO};function ZR(e){let t=-1;const r=[];for(;++t=3&&(h===null||Ee(h))?(e.exit("thematicBreak"),t(h)):r(h)}function d(h){return h===a?(e.consume(h),l++,d):(e.exit("thematicBreakSequence"),$e(h)?Qe(e,c,"whitespace")(h):c(h))}}const sn={continuation:{tokenize:fO},exit:hO,name:"list",tokenize:cO},sO={partial:!0,tokenize:pO},uO={partial:!0,tokenize:dO};function cO(e,t,r){const l=this,a=l.events[l.events.length-1];let o=a&&a[1].type==="linePrefix"?a[2].sliceSerialize(a[1],!0).length:0,u=0;return c;function c(b){const w=l.containerState.type||(b===42||b===43||b===45?"listUnordered":"listOrdered");if(w==="listUnordered"?!l.containerState.marker||b===l.containerState.marker:fm(b)){if(l.containerState.type||(l.containerState.type=w,e.enter(w,{_container:!0})),w==="listUnordered")return e.enter("listItemPrefix"),b===42||b===45?e.check(nc,r,h)(b):h(b);if(!l.interrupt||b===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),d(b)}return r(b)}function d(b){return fm(b)&&++u<10?(e.consume(b),d):(!l.interrupt||u<2)&&(l.containerState.marker?b===l.containerState.marker:b===41||b===46)?(e.exit("listItemValue"),h(b)):r(b)}function h(b){return e.enter("listItemMarker"),e.consume(b),e.exit("listItemMarker"),l.containerState.marker=l.containerState.marker||b,e.check(as,l.interrupt?r:m,e.attempt(sO,x,p))}function m(b){return l.containerState.initialBlankLine=!0,o++,x(b)}function p(b){return $e(b)?(e.enter("listItemPrefixWhitespace"),e.consume(b),e.exit("listItemPrefixWhitespace"),x):r(b)}function x(b){return l.containerState.size=o+l.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(b)}}function fO(e,t,r){const l=this;return l.containerState._closeFlow=void 0,e.check(as,a,o);function a(c){return l.containerState.furtherBlankLines=l.containerState.furtherBlankLines||l.containerState.initialBlankLine,Qe(e,t,"listItemIndent",l.containerState.size+1)(c)}function o(c){return l.containerState.furtherBlankLines||!$e(c)?(l.containerState.furtherBlankLines=void 0,l.containerState.initialBlankLine=void 0,u(c)):(l.containerState.furtherBlankLines=void 0,l.containerState.initialBlankLine=void 0,e.attempt(uO,t,u)(c))}function u(c){return l.containerState._closeFlow=!0,l.interrupt=void 0,Qe(e,e.attempt(sn,t,r),"linePrefix",l.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(c)}}function dO(e,t,r){const l=this;return Qe(e,a,"listItemIndent",l.containerState.size+1);function a(o){const u=l.events[l.events.length-1];return u&&u[1].type==="listItemIndent"&&u[2].sliceSerialize(u[1],!0).length===l.containerState.size?t(o):r(o)}}function hO(e){e.exit(this.containerState.type)}function pO(e,t,r){const l=this;return Qe(e,a,"listItemPrefixWhitespace",l.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function a(o){const u=l.events[l.events.length-1];return!$e(o)&&u&&u[1].type==="listItemPrefixWhitespace"?t(o):r(o)}}const q1={name:"setextUnderline",resolveTo:mO,tokenize:gO};function mO(e,t){let r=e.length,l,a,o;for(;r--;)if(e[r][0]==="enter"){if(e[r][1].type==="content"){l=r;break}e[r][1].type==="paragraph"&&(a=r)}else e[r][1].type==="content"&&e.splice(r,1),!o&&e[r][1].type==="definition"&&(o=r);const u={type:"setextHeading",start:{...e[l][1].start},end:{...e[e.length-1][1].end}};return e[a][1].type="setextHeadingText",o?(e.splice(a,0,["enter",u,t]),e.splice(o+1,0,["exit",e[l][1],t]),e[l][1].end={...e[o][1].end}):e[l][1]=u,e.push(["exit",u,t]),e}function gO(e,t,r){const l=this;let a;return o;function o(h){let m=l.events.length,p;for(;m--;)if(l.events[m][1].type!=="lineEnding"&&l.events[m][1].type!=="linePrefix"&&l.events[m][1].type!=="content"){p=l.events[m][1].type==="paragraph";break}return!l.parser.lazy[l.now().line]&&(l.interrupt||p)?(e.enter("setextHeadingLine"),a=h,u(h)):r(h)}function u(h){return e.enter("setextHeadingLineSequence"),c(h)}function c(h){return h===a?(e.consume(h),c):(e.exit("setextHeadingLineSequence"),$e(h)?Qe(e,d,"lineSuffix")(h):d(h))}function d(h){return h===null||Ee(h)?(e.exit("setextHeadingLine"),t(h)):r(h)}}const xO={tokenize:yO};function yO(e){const t=this,r=e.attempt(as,l,e.attempt(this.parser.constructs.flowInitial,a,Qe(e,e.attempt(this.parser.constructs.flow,a,e.attempt(SR,a)),"linePrefix")));return r;function l(o){if(o===null){e.consume(o);return}return e.enter("lineEndingBlank"),e.consume(o),e.exit("lineEndingBlank"),t.currentConstruct=void 0,r}function a(o){if(o===null){e.consume(o);return}return e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),t.currentConstruct=void 0,r}}const vO={resolveAll:lk()},bO=ik("string"),wO=ik("text");function ik(e){return{resolveAll:lk(e==="text"?_O:void 0),tokenize:t};function t(r){const l=this,a=this.parser.constructs[e],o=r.attempt(a,u,c);return u;function u(m){return h(m)?o(m):c(m)}function c(m){if(m===null){r.consume(m);return}return r.enter("data"),r.consume(m),d}function d(m){return h(m)?(r.exit("data"),o(m)):(r.consume(m),d)}function h(m){if(m===null)return!0;const p=a[m];let x=-1;if(p)for(;++x-1){const c=u[0];typeof c=="string"?u[0]=c.slice(l):u.shift()}o>0&&u.push(e[a].slice(0,o))}return u}function OO(e,t){let r=-1;const l=[];let a;for(;++r0){const Qt=Ne.tokenStack[Ne.tokenStack.length-1];(Qt[1]||$1).call(Ne,void 0,Qt[0])}for(ge.position={start:mi(ce.length>0?ce[0][1].start:{line:1,column:1,offset:0}),end:mi(ce.length>0?ce[ce.length-2][1].end:{line:1,column:1,offset:0})},Xe=-1;++Xe0&&(l.className=["language-"+a[0]]);let o={type:"element",tagName:"code",properties:l,children:[{type:"text",value:r}]};return t.meta&&(o.data={meta:t.meta}),e.patch(t,o),o=e.applyData(t,o),o={type:"element",tagName:"pre",properties:{},children:[o]},e.patch(t,o),o}function QO(e,t){const r={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function ZO(e,t){const r={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function KO(e,t){const r=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",l=String(t.identifier).toUpperCase(),a=ba(l.toLowerCase()),o=e.footnoteOrder.indexOf(l);let u,c=e.footnoteCounts.get(l);c===void 0?(c=0,e.footnoteOrder.push(l),u=e.footnoteOrder.length):u=o+1,c+=1,e.footnoteCounts.set(l,c);const d={type:"element",tagName:"a",properties:{href:"#"+r+"fn-"+a,id:r+"fnref-"+a+(c>1?"-"+c:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(u)}]};e.patch(t,d);const h={type:"element",tagName:"sup",properties:{},children:[d]};return e.patch(t,h),e.applyData(t,h)}function JO(e,t){const r={type:"element",tagName:"h"+t.depth,properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function WO(e,t){if(e.options.allowDangerousHtml){const r={type:"raw",value:t.value};return e.patch(t,r),e.applyData(t,r)}}function sk(e,t){const r=t.referenceType;let l="]";if(r==="collapsed"?l+="[]":r==="full"&&(l+="["+(t.label||t.identifier)+"]"),t.type==="imageReference")return[{type:"text",value:"!["+t.alt+l}];const a=e.all(t),o=a[0];o&&o.type==="text"?o.value="["+o.value:a.unshift({type:"text",value:"["});const u=a[a.length-1];return u&&u.type==="text"?u.value+=l:a.push({type:"text",value:l}),a}function e6(e,t){const r=String(t.identifier).toUpperCase(),l=e.definitionById.get(r);if(!l)return sk(e,t);const a={src:ba(l.url||""),alt:t.alt};l.title!==null&&l.title!==void 0&&(a.title=l.title);const o={type:"element",tagName:"img",properties:a,children:[]};return e.patch(t,o),e.applyData(t,o)}function t6(e,t){const r={src:ba(t.url)};t.alt!==null&&t.alt!==void 0&&(r.alt=t.alt),t.title!==null&&t.title!==void 0&&(r.title=t.title);const l={type:"element",tagName:"img",properties:r,children:[]};return e.patch(t,l),e.applyData(t,l)}function n6(e,t){const r={type:"text",value:t.value.replace(/\r?\n|\r/g," ")};e.patch(t,r);const l={type:"element",tagName:"code",properties:{},children:[r]};return e.patch(t,l),e.applyData(t,l)}function r6(e,t){const r=String(t.identifier).toUpperCase(),l=e.definitionById.get(r);if(!l)return sk(e,t);const a={href:ba(l.url||"")};l.title!==null&&l.title!==void 0&&(a.title=l.title);const o={type:"element",tagName:"a",properties:a,children:e.all(t)};return e.patch(t,o),e.applyData(t,o)}function i6(e,t){const r={href:ba(t.url)};t.title!==null&&t.title!==void 0&&(r.title=t.title);const l={type:"element",tagName:"a",properties:r,children:e.all(t)};return e.patch(t,l),e.applyData(t,l)}function l6(e,t,r){const l=e.all(t),a=r?a6(r):uk(t),o={},u=[];if(typeof t.checked=="boolean"){const m=l[0];let p;m&&m.type==="element"&&m.tagName==="p"?p=m:(p={type:"element",tagName:"p",properties:{},children:[]},l.unshift(p)),p.children.length>0&&p.children.unshift({type:"text",value:" "}),p.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),o.className=["task-list-item"]}let c=-1;for(;++c1}function o6(e,t){const r={},l=e.all(t);let a=-1;for(typeof t.start=="number"&&t.start!==1&&(r.start=t.start);++a0){const u={type:"element",tagName:"tbody",properties:{},children:e.wrap(r,!0)},c=Fm(t.children[1]),d=$S(t.children[t.children.length-1]);c&&d&&(u.position={start:c,end:d}),a.push(u)}const o={type:"element",tagName:"table",properties:{},children:e.wrap(a,!0)};return e.patch(t,o),e.applyData(t,o)}function d6(e,t,r){const l=r?r.children:void 0,o=(l?l.indexOf(t):1)===0?"th":"td",u=r&&r.type==="table"?r.align:void 0,c=u?u.length:t.children.length;let d=-1;const h=[];for(;++d0,!0),l[0]),a=l.index+l[0].length,l=r.exec(t);return o.push(G1(t.slice(a),a>0,!1)),o.join("")}function G1(e,t,r){let l=0,a=e.length;if(t){let o=e.codePointAt(l);for(;o===V1||o===P1;)l++,o=e.codePointAt(l)}if(r){let o=e.codePointAt(a-1);for(;o===V1||o===P1;)a--,o=e.codePointAt(a-1)}return a>l?e.slice(l,a):""}function m6(e,t){const r={type:"text",value:p6(String(t.value))};return e.patch(t,r),e.applyData(t,r)}function g6(e,t){const r={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,r),e.applyData(t,r)}const x6={blockquote:FO,break:YO,code:XO,delete:QO,emphasis:ZO,footnoteReference:KO,heading:JO,html:WO,imageReference:e6,image:t6,inlineCode:n6,linkReference:r6,link:i6,listItem:l6,list:o6,paragraph:s6,root:u6,strong:c6,table:f6,tableCell:h6,tableRow:d6,text:m6,thematicBreak:g6,toml:Gu,yaml:Gu,definition:Gu,footnoteDefinition:Gu};function Gu(){}const ck=-1,Vc=0,Oo=1,bc=2,Wm=3,eg=4,tg=5,ng=6,fk=7,dk=8,F1=typeof self=="object"?self:globalThis,y6=(e,t)=>{const r=(a,o)=>(e.set(o,a),a),l=a=>{if(e.has(a))return e.get(a);const[o,u]=t[a];switch(o){case Vc:case ck:return r(u,a);case Oo:{const c=r([],a);for(const d of u)c.push(l(d));return c}case bc:{const c=r({},a);for(const[d,h]of u)c[l(d)]=l(h);return c}case Wm:return r(new Date(u),a);case eg:{const{source:c,flags:d}=u;return r(new RegExp(c,d),a)}case tg:{const c=r(new Map,a);for(const[d,h]of u)c.set(l(d),l(h));return c}case ng:{const c=r(new Set,a);for(const d of u)c.add(l(d));return c}case fk:{const{name:c,message:d}=u;return r(new F1[c](d),a)}case dk:return r(BigInt(u),a);case"BigInt":return r(Object(BigInt(u)),a);case"ArrayBuffer":return r(new Uint8Array(u).buffer,u);case"DataView":{const{buffer:c}=new Uint8Array(u);return r(new DataView(c),u)}}return r(new F1[o](u),a)};return l},Y1=e=>y6(new Map,e)(0),Jl="",{toString:v6}={},{keys:b6}=Object,ko=e=>{const t=typeof e;if(t!=="object"||!e)return[Vc,t];const r=v6.call(e).slice(8,-1);switch(r){case"Array":return[Oo,Jl];case"Object":return[bc,Jl];case"Date":return[Wm,Jl];case"RegExp":return[eg,Jl];case"Map":return[tg,Jl];case"Set":return[ng,Jl];case"DataView":return[Oo,r]}return r.includes("Array")?[Oo,r]:r.includes("Error")?[fk,r]:[bc,r]},Fu=([e,t])=>e===Vc&&(t==="function"||t==="symbol"),w6=(e,t,r,l)=>{const a=(u,c)=>{const d=l.push(u)-1;return r.set(c,d),d},o=u=>{if(r.has(u))return r.get(u);let[c,d]=ko(u);switch(c){case Vc:{let m=u;switch(d){case"bigint":c=dk,m=u.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+d);m=null;break;case"undefined":return a([ck],u)}return a([c,m],u)}case Oo:{if(d){let x=u;return d==="DataView"?x=new Uint8Array(u.buffer):d==="ArrayBuffer"&&(x=new Uint8Array(u)),a([d,[...x]],u)}const m=[],p=a([c,m],u);for(const x of u)m.push(o(x));return p}case bc:{if(d)switch(d){case"BigInt":return a([d,u.toString()],u);case"Boolean":case"Number":case"String":return a([d,u.valueOf()],u)}if(t&&"toJSON"in u)return o(u.toJSON());const m=[],p=a([c,m],u);for(const x of b6(u))(e||!Fu(ko(u[x])))&&m.push([o(x),o(u[x])]);return p}case Wm:return a([c,u.toISOString()],u);case eg:{const{source:m,flags:p}=u;return a([c,{source:m,flags:p}],u)}case tg:{const m=[],p=a([c,m],u);for(const[x,b]of u)(e||!(Fu(ko(x))||Fu(ko(b))))&&m.push([o(x),o(b)]);return p}case ng:{const m=[],p=a([c,m],u);for(const x of u)(e||!Fu(ko(x)))&&m.push(o(x));return p}}const{message:h}=u;return a([c,{name:d,message:h}],u)};return o},X1=(e,{json:t,lossy:r}={})=>{const l=[];return w6(!(t||r),!!t,new Map,l)(e),l},wc=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?Y1(X1(e,t)):structuredClone(e):(e,t)=>Y1(X1(e,t));function _6(e,t){const r=[{type:"text",value:"↩"}];return t>1&&r.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(t)}]}),r}function S6(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}function k6(e){const t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",r=e.options.footnoteBackContent||_6,l=e.options.footnoteBackLabel||S6,a=e.options.footnoteLabel||"Footnotes",o=e.options.footnoteLabelTagName||"h2",u=e.options.footnoteLabelProperties||{className:["sr-only"]},c=[];let d=-1;for(;++d0&&w.push({type:"text",value:" "});let N=typeof r=="string"?r:r(d,b);typeof N=="string"&&(N={type:"text",value:N}),w.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+x+(b>1?"-"+b:""),dataFootnoteBackref:"",ariaLabel:typeof l=="string"?l:l(d,b),className:["data-footnote-backref"]},children:Array.isArray(N)?N:[N]})}const S=m[m.length-1];if(S&&S.type==="element"&&S.tagName==="p"){const N=S.children[S.children.length-1];N&&N.type==="text"?N.value+=" ":S.children.push({type:"text",value:" "}),S.children.push(...w)}else m.push(...w);const _={type:"element",tagName:"li",properties:{id:t+"fn-"+x},children:e.wrap(m,!0)};e.patch(h,_),c.push(_)}if(c.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:o,properties:{...wc(u),id:"footnote-label"},children:[{type:"text",value:a}]},{type:"text",value:` -`},{type:"element",tagName:"ol",properties:{},children:e.wrap(c,!0)},{type:"text",value:` -`}]}}const Pc=(function(e){if(e==null)return j6;if(typeof e=="function")return Gc(e);if(typeof e=="object")return Array.isArray(e)?E6(e):N6(e);if(typeof e=="string")return C6(e);throw new Error("Expected function, string, or object as test")});function E6(e){const t=[];let r=-1;for(;++r":""))+")"})}return x;function x(){let b=hk,w,E,S;if((!t||o(d,h,m[m.length-1]||void 0))&&(b=M6(r(d,m)),b[0]===hm))return b;if("children"in d&&d.children){const _=d;if(_.children&&b[0]!==z6)for(E=(l?_.children.length:-1)+u,S=m.concat(_);E>-1&&E<_.children.length;){const N=_.children[E];if(w=c(N,E,S)(),w[0]===hm)return w;E=typeof w[1]=="number"?w[1]:E+u}}return b}}}function M6(e){return Array.isArray(e)?e:typeof e=="number"?[A6,e]:e==null?hk:[e]}function rg(e,t,r,l){let a,o,u;typeof t=="function"&&typeof r!="function"?(o=void 0,u=t,a=r):(o=t,u=r,a=l),pk(e,o,c,a);function c(d,h){const m=h[h.length-1],p=m?m.children.indexOf(d):void 0;return u(d,p,m)}}const pm={}.hasOwnProperty,D6={};function R6(e,t){const r=t||D6,l=new Map,a=new Map,o=new Map,u={...x6,...r.handlers},c={all:h,applyData:L6,definitionById:l,footnoteById:a,footnoteCounts:o,footnoteOrder:[],handlers:u,one:d,options:r,patch:O6,wrap:B6};return rg(e,function(m){if(m.type==="definition"||m.type==="footnoteDefinition"){const p=m.type==="definition"?l:a,x=String(m.identifier).toUpperCase();p.has(x)||p.set(x,m)}}),c;function d(m,p){const x=m.type,b=c.handlers[x];if(pm.call(c.handlers,x)&&b)return b(c,m,p);if(c.options.passThrough&&c.options.passThrough.includes(x)){if("children"in m){const{children:E,...S}=m,_=wc(S);return _.children=c.all(m),_}return wc(m)}return(c.options.unknownHandler||H6)(c,m,p)}function h(m){const p=[];if("children"in m){const x=m.children;let b=-1;for(;++b0&&r.push({type:"text",value:` -`}),r}function Q1(e){let t=0,r=e.charCodeAt(t);for(;r===9||r===32;)t++,r=e.charCodeAt(t);return e.slice(t)}function Z1(e,t){const r=R6(e,t),l=r.one(e,void 0),a=k6(r),o=Array.isArray(l)?{type:"root",children:l}:l||{type:"root",children:[]};return a&&o.children.push({type:"text",value:` -`},a),o}function I6(e,t){return e&&"run"in e?async function(r,l){const a=Z1(r,{file:l,...t});await e.run(a,l)}:function(r,l){return Z1(r,{file:l,...e||t})}}function K1(e){if(e)throw e}var Tp,J1;function q6(){if(J1)return Tp;J1=1;var e=Object.prototype.hasOwnProperty,t=Object.prototype.toString,r=Object.defineProperty,l=Object.getOwnPropertyDescriptor,a=function(h){return typeof Array.isArray=="function"?Array.isArray(h):t.call(h)==="[object Array]"},o=function(h){if(!h||t.call(h)!=="[object Object]")return!1;var m=e.call(h,"constructor"),p=h.constructor&&h.constructor.prototype&&e.call(h.constructor.prototype,"isPrototypeOf");if(h.constructor&&!m&&!p)return!1;var x;for(x in h);return typeof x>"u"||e.call(h,x)},u=function(h,m){r&&m.name==="__proto__"?r(h,m.name,{enumerable:!0,configurable:!0,value:m.newValue,writable:!0}):h[m.name]=m.newValue},c=function(h,m){if(m==="__proto__")if(e.call(h,m)){if(l)return l(h,m).value}else return;return h[m]};return Tp=function d(){var h,m,p,x,b,w,E=arguments[0],S=1,_=arguments.length,N=!1;for(typeof E=="boolean"&&(N=E,E=arguments[1]||{},S=2),(E==null||typeof E!="object"&&typeof E!="function")&&(E={});S<_;++S)if(h=arguments[S],h!=null)for(m in h)p=c(E,m),x=c(h,m),E!==x&&(N&&x&&(o(x)||(b=a(x)))?(b?(b=!1,w=p&&a(p)?p:[]):w=p&&o(p)?p:{},u(E,{name:m,newValue:d(N,w,x)})):typeof x<"u"&&u(E,{name:m,newValue:x}));return E},Tp}var U6=q6();const Ap=Qo(U6);function mm(e){if(typeof e!="object"||e===null)return!1;const t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function $6(){const e=[],t={run:r,use:l};return t;function r(...a){let o=-1;const u=a.pop();if(typeof u!="function")throw new TypeError("Expected function as last argument, not "+u);c(null,...a);function c(d,...h){const m=e[++o];let p=-1;if(d){u(d);return}for(;++pu.length;let d;c&&u.push(a);try{d=e.apply(this,u)}catch(h){const m=h;if(c&&r)throw m;return a(m)}c||(d&&d.then&&typeof d.then=="function"?d.then(o,a):d instanceof Error?a(d):o(d))}function a(u,...c){r||(r=!0,t(u,...c))}function o(u){a(null,u)}}const nr={basename:P6,dirname:G6,extname:F6,join:Y6,sep:"/"};function P6(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');os(e);let r=0,l=-1,a=e.length,o;if(t===void 0||t.length===0||t.length>e.length){for(;a--;)if(e.codePointAt(a)===47){if(o){r=a+1;break}}else l<0&&(o=!0,l=a+1);return l<0?"":e.slice(r,l)}if(t===e)return"";let u=-1,c=t.length-1;for(;a--;)if(e.codePointAt(a)===47){if(o){r=a+1;break}}else u<0&&(o=!0,u=a+1),c>-1&&(e.codePointAt(a)===t.codePointAt(c--)?c<0&&(l=a):(c=-1,l=u));return r===l?l=u:l<0&&(l=e.length),e.slice(r,l)}function G6(e){if(os(e),e.length===0)return".";let t=-1,r=e.length,l;for(;--r;)if(e.codePointAt(r)===47){if(l){t=r;break}}else l||(l=!0);return t<0?e.codePointAt(0)===47?"/":".":t===1&&e.codePointAt(0)===47?"//":e.slice(0,t)}function F6(e){os(e);let t=e.length,r=-1,l=0,a=-1,o=0,u;for(;t--;){const c=e.codePointAt(t);if(c===47){if(u){l=t+1;break}continue}r<0&&(u=!0,r=t+1),c===46?a<0?a=t:o!==1&&(o=1):a>-1&&(o=-1)}return a<0||r<0||o===0||o===1&&a===r-1&&a===l+1?"":e.slice(a,r)}function Y6(...e){let t=-1,r;for(;++t0&&e.codePointAt(e.length-1)===47&&(r+="/"),t?"/"+r:r}function Q6(e,t){let r="",l=0,a=-1,o=0,u=-1,c,d;for(;++u<=e.length;){if(u2){if(d=r.lastIndexOf("/"),d!==r.length-1){d<0?(r="",l=0):(r=r.slice(0,d),l=r.length-1-r.lastIndexOf("/")),a=u,o=0;continue}}else if(r.length>0){r="",l=0,a=u,o=0;continue}}t&&(r=r.length>0?r+"/..":"..",l=2)}else r.length>0?r+="/"+e.slice(a+1,u):r=e.slice(a+1,u),l=u-a-1;a=u,o=0}else c===46&&o>-1?o++:o=-1}return r}function os(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const Z6={cwd:K6};function K6(){return"/"}function gm(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function J6(e){if(typeof e=="string")e=new URL(e);else if(!gm(e)){const t=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code="ERR_INVALID_ARG_TYPE",t}if(e.protocol!=="file:"){const t=new TypeError("The URL must be of scheme file");throw t.code="ERR_INVALID_URL_SCHEME",t}return W6(e)}function W6(e){if(e.hostname!==""){const l=new TypeError('File URL host must be "localhost" or empty on darwin');throw l.code="ERR_INVALID_FILE_URL_HOST",l}const t=e.pathname;let r=-1;for(;++r0){let[b,...w]=m;const E=l[x][1];mm(E)&&mm(b)&&(b=Ap(!0,E,b)),l[x]=[h,b,...w]}}}}const rL=new ig().freeze();function Rp(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function Op(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function Lp(e,t){if(t)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function ew(e){if(!mm(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function tw(e,t,r){if(!r)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function Yu(e){return iL(e)?e:new mk(e)}function iL(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function lL(e){return typeof e=="string"||aL(e)}function aL(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const oL="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",nw=[],rw={allowDangerousHtml:!0},sL=/^(https?|ircs?|mailto|xmpp)$/i,uL=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"className",id:"remove-classname"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function Fc(e){const t=cL(e),r=fL(e);return dL(t.runSync(t.parse(r),r),e)}function cL(e){const t=e.rehypePlugins||nw,r=e.remarkPlugins||nw,l=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...rw}:rw;return rL().use(GO).use(r).use(I6,l).use(t)}function fL(e){const t=e.children||"",r=new mk;return typeof t=="string"&&(r.value=t),r}function dL(e,t){const r=t.allowedElements,l=t.allowElement,a=t.components,o=t.disallowedElements,u=t.skipHtml,c=t.unwrapDisallowed,d=t.urlTransform||hL;for(const m of uL)Object.hasOwn(t,m.from)&&(""+m.from+(m.to?"use `"+m.to+"` instead":"remove it")+oL+m.id,void 0);return rg(e,h),jD(e,{Fragment:y.Fragment,components:a,ignoreInvalidStyle:!0,jsx:y.jsx,jsxs:y.jsxs,passKeys:!0,passNode:!0});function h(m,p,x){if(m.type==="raw"&&x&&typeof p=="number")return u?x.children.splice(p,1):x.children[p]={type:"text",value:m.value},p;if(m.type==="element"){let b;for(b in Np)if(Object.hasOwn(Np,b)&&Object.hasOwn(m.properties,b)){const w=m.properties[b],E=Np[b];(E===null||E.includes(m.tagName))&&(m.properties[b]=d(String(w||""),b,m))}}if(m.type==="element"){let b=r?!r.includes(m.tagName):o?o.includes(m.tagName):!1;if(!b&&l&&typeof p=="number"&&(b=!l(m,p,x)),b&&x&&typeof p=="number")return c&&m.children?x.children.splice(p,1,...m.children):x.children.splice(p,1),p}}}function hL(e){const t=e.indexOf(":"),r=e.indexOf("?"),l=e.indexOf("#"),a=e.indexOf("/");return t===-1||a!==-1&&t>a||r!==-1&&t>r||l!==-1&&t>l||sL.test(e.slice(0,t))?e:""}function iw(e,t){const r=String(e);if(typeof t!="string")throw new TypeError("Expected character");let l=0,a=r.indexOf(t);for(;a!==-1;)l++,a=r.indexOf(t,a+t.length);return l}function pL(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function mL(e,t,r){const a=Pc((r||{}).ignore||[]),o=gL(t);let u=-1;for(;++u0?{type:"text",value:T}:void 0),T===!1?x.lastIndex=A+1:(w!==A&&N.push({type:"text",value:h.value.slice(w,A)}),Array.isArray(T)?N.push(...T):T&&N.push(T),w=A+k[0].length,_=!0),!x.global)break;k=x.exec(h.value)}return _?(w?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let r=t[0],l=r.indexOf(")");const a=iw(e,"(");let o=iw(e,")");for(;l!==-1&&a>o;)e+=r.slice(0,l+1),r=r.slice(l+1),l=r.indexOf(")"),o++;return[e,r]}function gk(e,t){const r=e.input.charCodeAt(e.index-1);return(e.index===0||rl(r)||Uc(r))&&(!t||r!==47)}xk.peek=IL;function zL(){this.buffer()}function ML(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function DL(){this.buffer()}function RL(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function OL(e){const t=this.resume(),r=this.stack[this.stack.length-1];r.type,r.identifier=Fn(this.sliceSerialize(e)).toLowerCase(),r.label=t}function LL(e){this.exit(e)}function HL(e){const t=this.resume(),r=this.stack[this.stack.length-1];r.type,r.identifier=Fn(this.sliceSerialize(e)).toLowerCase(),r.label=t}function BL(e){this.exit(e)}function IL(){return"["}function xk(e,t,r,l){const a=r.createTracker(l);let o=a.move("[^");const u=r.enter("footnoteReference"),c=r.enter("reference");return o+=a.move(r.safe(r.associationId(e),{after:"]",before:o})),c(),u(),o+=a.move("]"),o}function qL(){return{enter:{gfmFootnoteCallString:zL,gfmFootnoteCall:ML,gfmFootnoteDefinitionLabelString:DL,gfmFootnoteDefinition:RL},exit:{gfmFootnoteCallString:OL,gfmFootnoteCall:LL,gfmFootnoteDefinitionLabelString:HL,gfmFootnoteDefinition:BL}}}function UL(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:r,footnoteReference:xk},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function r(l,a,o,u){const c=o.createTracker(u);let d=c.move("[^");const h=o.enter("footnoteDefinition"),m=o.enter("label");return d+=c.move(o.safe(o.associationId(l),{before:d,after:"]"})),m(),d+=c.move("]:"),l.children&&l.children.length>0&&(c.shift(4),d+=c.move((t?` -`:" ")+o.indentLines(o.containerFlow(l,c.current()),t?yk:$L))),h(),d}}function $L(e,t,r){return t===0?e:yk(e,t,r)}function yk(e,t,r){return(r?"":" ")+e}const VL=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];vk.peek=XL;function PL(){return{canContainEols:["delete"],enter:{strikethrough:FL},exit:{strikethrough:YL}}}function GL(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:VL}],handlers:{delete:vk}}}function FL(e){this.enter({type:"delete",children:[]},e)}function YL(e){this.exit(e)}function vk(e,t,r,l){const a=r.createTracker(l),o=r.enter("strikethrough");let u=a.move("~~");return u+=r.containerPhrasing(e,{...a.current(),before:u,after:"~"}),u+=a.move("~~"),o(),u}function XL(){return"~"}function QL(e){return e.length}function ZL(e,t){const r=t||{},l=(r.align||[]).concat(),a=r.stringLength||QL,o=[],u=[],c=[],d=[];let h=0,m=-1;for(;++mh&&(h=e[m].length);++_d[_])&&(d[_]=k)}E.push(N)}u[m]=E,c[m]=S}let p=-1;if(typeof l=="object"&&"length"in l)for(;++pd[p]&&(d[p]=N),b[p]=N),x[p]=k}u.splice(1,0,x),c.splice(1,0,b),m=-1;const w=[];for(;++m "),o.shift(2);const u=r.indentLines(r.containerFlow(e,o.current()),WL);return a(),u}function WL(e,t,r){return">"+(r?"":" ")+e}function e8(e,t){return aw(e,t.inConstruct,!0)&&!aw(e,t.notInConstruct,!1)}function aw(e,t,r){if(typeof t=="string"&&(t=[t]),!t||t.length===0)return r;let l=-1;for(;++lu&&(u=o):o=1,a=l+t.length,l=r.indexOf(t,a);return u}function n8(e,t){return!!(t.options.fences===!1&&e.value&&!e.lang&&/[^ \r\n]/.test(e.value)&&!/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(e.value))}function r8(e){const t=e.options.fence||"`";if(t!=="`"&&t!=="~")throw new Error("Cannot serialize code with `"+t+"` for `options.fence`, expected `` ` `` or `~`");return t}function i8(e,t,r,l){const a=r8(r),o=e.value||"",u=a==="`"?"GraveAccent":"Tilde";if(n8(e,r)){const p=r.enter("codeIndented"),x=r.indentLines(o,l8);return p(),x}const c=r.createTracker(l),d=a.repeat(Math.max(t8(o,a)+1,3)),h=r.enter("codeFenced");let m=c.move(d);if(e.lang){const p=r.enter(`codeFencedLang${u}`);m+=c.move(r.safe(e.lang,{before:m,after:" ",encode:["`"],...c.current()})),p()}if(e.lang&&e.meta){const p=r.enter(`codeFencedMeta${u}`);m+=c.move(" "),m+=c.move(r.safe(e.meta,{before:m,after:` -`,encode:["`"],...c.current()})),p()}return m+=c.move(` -`),o&&(m+=c.move(o+` -`)),m+=c.move(d),h(),m}function l8(e,t,r){return(r?"":" ")+e}function lg(e){const t=e.options.quote||'"';if(t!=='"'&&t!=="'")throw new Error("Cannot serialize title with `"+t+"` for `options.quote`, expected `\"`, or `'`");return t}function a8(e,t,r,l){const a=lg(r),o=a==='"'?"Quote":"Apostrophe",u=r.enter("definition");let c=r.enter("label");const d=r.createTracker(l);let h=d.move("[");return h+=d.move(r.safe(r.associationId(e),{before:h,after:"]",...d.current()})),h+=d.move("]: "),c(),!e.url||/[\0- \u007F]/.test(e.url)?(c=r.enter("destinationLiteral"),h+=d.move("<"),h+=d.move(r.safe(e.url,{before:h,after:">",...d.current()})),h+=d.move(">")):(c=r.enter("destinationRaw"),h+=d.move(r.safe(e.url,{before:h,after:e.title?" ":` -`,...d.current()}))),c(),e.title&&(c=r.enter(`title${o}`),h+=d.move(" "+a),h+=d.move(r.safe(e.title,{before:h,after:a,...d.current()})),h+=d.move(a),c()),u(),h}function o8(e){const t=e.options.emphasis||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize emphasis with `"+t+"` for `options.emphasis`, expected `*`, or `_`");return t}function Xo(e){return"&#x"+e.toString(16).toUpperCase()+";"}function _c(e,t,r){const l=ya(e),a=ya(t);return l===void 0?a===void 0?r==="_"?{inside:!0,outside:!0}:{inside:!1,outside:!1}:a===1?{inside:!0,outside:!0}:{inside:!1,outside:!0}:l===1?a===void 0?{inside:!1,outside:!1}:a===1?{inside:!0,outside:!0}:{inside:!1,outside:!1}:a===void 0?{inside:!1,outside:!1}:a===1?{inside:!0,outside:!1}:{inside:!1,outside:!1}}bk.peek=s8;function bk(e,t,r,l){const a=o8(r),o=r.enter("emphasis"),u=r.createTracker(l),c=u.move(a);let d=u.move(r.containerPhrasing(e,{after:a,before:c,...u.current()}));const h=d.charCodeAt(0),m=_c(l.before.charCodeAt(l.before.length-1),h,a);m.inside&&(d=Xo(h)+d.slice(1));const p=d.charCodeAt(d.length-1),x=_c(l.after.charCodeAt(0),p,a);x.inside&&(d=d.slice(0,-1)+Xo(p));const b=u.move(a);return o(),r.attentionEncodeSurroundingInfo={after:x.outside,before:m.outside},c+d+b}function s8(e,t,r){return r.options.emphasis||"*"}function u8(e,t){let r=!1;return rg(e,function(l){if("value"in l&&/\r?\n|\r/.test(l.value)||l.type==="break")return r=!0,hm}),!!((!e.depth||e.depth<3)&&Zm(e)&&(t.options.setext||r))}function c8(e,t,r,l){const a=Math.max(Math.min(6,e.depth||1),1),o=r.createTracker(l);if(u8(e,r)){const m=r.enter("headingSetext"),p=r.enter("phrasing"),x=r.containerPhrasing(e,{...o.current(),before:` -`,after:` -`});return p(),m(),x+` -`+(a===1?"=":"-").repeat(x.length-(Math.max(x.lastIndexOf("\r"),x.lastIndexOf(` -`))+1))}const u="#".repeat(a),c=r.enter("headingAtx"),d=r.enter("phrasing");o.move(u+" ");let h=r.containerPhrasing(e,{before:"# ",after:` -`,...o.current()});return/^[\t ]/.test(h)&&(h=Xo(h.charCodeAt(0))+h.slice(1)),h=h?u+" "+h:u,r.options.closeAtx&&(h+=" "+u),d(),c(),h}wk.peek=f8;function wk(e){return e.value||""}function f8(){return"<"}_k.peek=d8;function _k(e,t,r,l){const a=lg(r),o=a==='"'?"Quote":"Apostrophe",u=r.enter("image");let c=r.enter("label");const d=r.createTracker(l);let h=d.move("![");return h+=d.move(r.safe(e.alt,{before:h,after:"]",...d.current()})),h+=d.move("]("),c(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(c=r.enter("destinationLiteral"),h+=d.move("<"),h+=d.move(r.safe(e.url,{before:h,after:">",...d.current()})),h+=d.move(">")):(c=r.enter("destinationRaw"),h+=d.move(r.safe(e.url,{before:h,after:e.title?" ":")",...d.current()}))),c(),e.title&&(c=r.enter(`title${o}`),h+=d.move(" "+a),h+=d.move(r.safe(e.title,{before:h,after:a,...d.current()})),h+=d.move(a),c()),h+=d.move(")"),u(),h}function d8(){return"!"}Sk.peek=h8;function Sk(e,t,r,l){const a=e.referenceType,o=r.enter("imageReference");let u=r.enter("label");const c=r.createTracker(l);let d=c.move("![");const h=r.safe(e.alt,{before:d,after:"]",...c.current()});d+=c.move(h+"]["),u();const m=r.stack;r.stack=[],u=r.enter("reference");const p=r.safe(r.associationId(e),{before:d,after:"]",...c.current()});return u(),r.stack=m,o(),a==="full"||!h||h!==p?d+=c.move(p+"]"):a==="shortcut"?d=d.slice(0,-1):d+=c.move("]"),d}function h8(){return"!"}kk.peek=p8;function kk(e,t,r){let l=e.value||"",a="`",o=-1;for(;new RegExp("(^|[^`])"+a+"([^`]|$)").test(l);)a+="`";for(/[^ \r\n]/.test(l)&&(/^[ \r\n]/.test(l)&&/[ \r\n]$/.test(l)||/^`|`$/.test(l))&&(l=" "+l+" ");++o\u007F]/.test(e.url))}Nk.peek=m8;function Nk(e,t,r,l){const a=lg(r),o=a==='"'?"Quote":"Apostrophe",u=r.createTracker(l);let c,d;if(Ek(e,r)){const m=r.stack;r.stack=[],c=r.enter("autolink");let p=u.move("<");return p+=u.move(r.containerPhrasing(e,{before:p,after:">",...u.current()})),p+=u.move(">"),c(),r.stack=m,p}c=r.enter("link"),d=r.enter("label");let h=u.move("[");return h+=u.move(r.containerPhrasing(e,{before:h,after:"](",...u.current()})),h+=u.move("]("),d(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(d=r.enter("destinationLiteral"),h+=u.move("<"),h+=u.move(r.safe(e.url,{before:h,after:">",...u.current()})),h+=u.move(">")):(d=r.enter("destinationRaw"),h+=u.move(r.safe(e.url,{before:h,after:e.title?" ":")",...u.current()}))),d(),e.title&&(d=r.enter(`title${o}`),h+=u.move(" "+a),h+=u.move(r.safe(e.title,{before:h,after:a,...u.current()})),h+=u.move(a),d()),h+=u.move(")"),c(),h}function m8(e,t,r){return Ek(e,r)?"<":"["}Ck.peek=g8;function Ck(e,t,r,l){const a=e.referenceType,o=r.enter("linkReference");let u=r.enter("label");const c=r.createTracker(l);let d=c.move("[");const h=r.containerPhrasing(e,{before:d,after:"]",...c.current()});d+=c.move(h+"]["),u();const m=r.stack;r.stack=[],u=r.enter("reference");const p=r.safe(r.associationId(e),{before:d,after:"]",...c.current()});return u(),r.stack=m,o(),a==="full"||!h||h!==p?d+=c.move(p+"]"):a==="shortcut"?d=d.slice(0,-1):d+=c.move("]"),d}function g8(){return"["}function ag(e){const t=e.options.bullet||"*";if(t!=="*"&&t!=="+"&&t!=="-")throw new Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function x8(e){const t=ag(e),r=e.options.bulletOther;if(!r)return t==="*"?"-":"*";if(r!=="*"&&r!=="+"&&r!=="-")throw new Error("Cannot serialize items with `"+r+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(r===t)throw new Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+r+"`) to be different");return r}function y8(e){const t=e.options.bulletOrdered||".";if(t!=="."&&t!==")")throw new Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function jk(e){const t=e.options.rule||"*";if(t!=="*"&&t!=="-"&&t!=="_")throw new Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function v8(e,t,r,l){const a=r.enter("list"),o=r.bulletCurrent;let u=e.ordered?y8(r):ag(r);const c=e.ordered?u==="."?")":".":x8(r);let d=t&&r.bulletLastUsed?u===r.bulletLastUsed:!1;if(!e.ordered){const m=e.children?e.children[0]:void 0;if((u==="*"||u==="-")&&m&&(!m.children||!m.children[0])&&r.stack[r.stack.length-1]==="list"&&r.stack[r.stack.length-2]==="listItem"&&r.stack[r.stack.length-3]==="list"&&r.stack[r.stack.length-4]==="listItem"&&r.indexStack[r.indexStack.length-1]===0&&r.indexStack[r.indexStack.length-2]===0&&r.indexStack[r.indexStack.length-3]===0&&(d=!0),jk(r)===u&&m){let p=-1;for(;++p-1?t.start:1)+(r.options.incrementListMarker===!1?0:t.children.indexOf(e))+o);let u=o.length+1;(a==="tab"||a==="mixed"&&(t&&t.type==="list"&&t.spread||e.spread))&&(u=Math.ceil(u/4)*4);const c=r.createTracker(l);c.move(o+" ".repeat(u-o.length)),c.shift(u);const d=r.enter("listItem"),h=r.indentLines(r.containerFlow(e,c.current()),m);return d(),h;function m(p,x,b){return x?(b?"":" ".repeat(u))+p:(b?o:o+" ".repeat(u-o.length))+p}}function _8(e,t,r,l){const a=r.enter("paragraph"),o=r.enter("phrasing"),u=r.containerPhrasing(e,l);return o(),a(),u}const S8=Pc(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function k8(e,t,r,l){return(e.children.some(function(u){return S8(u)})?r.containerPhrasing:r.containerFlow).call(r,e,l)}function E8(e){const t=e.options.strong||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}Tk.peek=N8;function Tk(e,t,r,l){const a=E8(r),o=r.enter("strong"),u=r.createTracker(l),c=u.move(a+a);let d=u.move(r.containerPhrasing(e,{after:a,before:c,...u.current()}));const h=d.charCodeAt(0),m=_c(l.before.charCodeAt(l.before.length-1),h,a);m.inside&&(d=Xo(h)+d.slice(1));const p=d.charCodeAt(d.length-1),x=_c(l.after.charCodeAt(0),p,a);x.inside&&(d=d.slice(0,-1)+Xo(p));const b=u.move(a+a);return o(),r.attentionEncodeSurroundingInfo={after:x.outside,before:m.outside},c+d+b}function N8(e,t,r){return r.options.strong||"*"}function C8(e,t,r,l){return r.safe(e.value,l)}function j8(e){const t=e.options.ruleRepetition||3;if(t<3)throw new Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}function T8(e,t,r){const l=(jk(r)+(r.options.ruleSpaces?" ":"")).repeat(j8(r));return r.options.ruleSpaces?l.slice(0,-1):l}const Ak={blockquote:JL,break:ow,code:i8,definition:a8,emphasis:bk,hardBreak:ow,heading:c8,html:wk,image:_k,imageReference:Sk,inlineCode:kk,link:Nk,linkReference:Ck,list:v8,listItem:w8,paragraph:_8,root:k8,strong:Tk,text:C8,thematicBreak:T8};function A8(){return{enter:{table:z8,tableData:sw,tableHeader:sw,tableRow:D8},exit:{codeText:R8,table:M8,tableData:qp,tableHeader:qp,tableRow:qp}}}function z8(e){const t=e._align;this.enter({type:"table",align:t.map(function(r){return r==="none"?null:r}),children:[]},e),this.data.inTable=!0}function M8(e){this.exit(e),this.data.inTable=void 0}function D8(e){this.enter({type:"tableRow",children:[]},e)}function qp(e){this.exit(e)}function sw(e){this.enter({type:"tableCell",children:[]},e)}function R8(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,O8));const r=this.stack[this.stack.length-1];r.type,r.value=t,this.exit(e)}function O8(e,t){return t==="|"?t:e}function L8(e){const t=e||{},r=t.tableCellPadding,l=t.tablePipeAlign,a=t.stringLength,o=r?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:` -`,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:x,table:u,tableCell:d,tableRow:c}};function u(b,w,E,S){return h(m(b,E,S),b.align)}function c(b,w,E,S){const _=p(b,E,S),N=h([_]);return N.slice(0,N.indexOf(` -`))}function d(b,w,E,S){const _=E.enter("tableCell"),N=E.enter("phrasing"),k=E.containerPhrasing(b,{...S,before:o,after:o});return N(),_(),k}function h(b,w){return ZL(b,{align:w,alignDelimiters:l,padding:r,stringLength:a})}function m(b,w,E){const S=b.children;let _=-1;const N=[],k=w.enter("table");for(;++_0&&!r&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),r}const e9={tokenize:s9,partial:!0};function t9(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:l9,continuation:{tokenize:a9},exit:o9}},text:{91:{name:"gfmFootnoteCall",tokenize:i9},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:n9,resolveTo:r9}}}}function n9(e,t,r){const l=this;let a=l.events.length;const o=l.parser.gfmFootnotes||(l.parser.gfmFootnotes=[]);let u;for(;a--;){const d=l.events[a][1];if(d.type==="labelImage"){u=d;break}if(d.type==="gfmFootnoteCall"||d.type==="labelLink"||d.type==="label"||d.type==="image"||d.type==="link")break}return c;function c(d){if(!u||!u._balanced)return r(d);const h=Fn(l.sliceSerialize({start:u.end,end:l.now()}));return h.codePointAt(0)!==94||!o.includes(h.slice(1))?r(d):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(d),e.exit("gfmFootnoteCallLabelMarker"),t(d))}}function r9(e,t){let r=e.length;for(;r--;)if(e[r][1].type==="labelImage"&&e[r][0]==="enter"){e[r][1];break}e[r+1][1].type="data",e[r+3][1].type="gfmFootnoteCallLabelMarker";const l={type:"gfmFootnoteCall",start:Object.assign({},e[r+3][1].start),end:Object.assign({},e[e.length-1][1].end)},a={type:"gfmFootnoteCallMarker",start:Object.assign({},e[r+3][1].end),end:Object.assign({},e[r+3][1].end)};a.end.column++,a.end.offset++,a.end._bufferIndex++;const o={type:"gfmFootnoteCallString",start:Object.assign({},a.end),end:Object.assign({},e[e.length-1][1].start)},u={type:"chunkString",contentType:"string",start:Object.assign({},o.start),end:Object.assign({},o.end)},c=[e[r+1],e[r+2],["enter",l,t],e[r+3],e[r+4],["enter",a,t],["exit",a,t],["enter",o,t],["enter",u,t],["exit",u,t],["exit",o,t],e[e.length-2],e[e.length-1],["exit",l,t]];return e.splice(r,e.length-r+1,...c),e}function i9(e,t,r){const l=this,a=l.parser.gfmFootnotes||(l.parser.gfmFootnotes=[]);let o=0,u;return c;function c(p){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(p),e.exit("gfmFootnoteCallLabelMarker"),d}function d(p){return p!==94?r(p):(e.enter("gfmFootnoteCallMarker"),e.consume(p),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",h)}function h(p){if(o>999||p===93&&!u||p===null||p===91||ot(p))return r(p);if(p===93){e.exit("chunkString");const x=e.exit("gfmFootnoteCallString");return a.includes(Fn(l.sliceSerialize(x)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(p),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):r(p)}return ot(p)||(u=!0),o++,e.consume(p),p===92?m:h}function m(p){return p===91||p===92||p===93?(e.consume(p),o++,h):h(p)}}function l9(e,t,r){const l=this,a=l.parser.gfmFootnotes||(l.parser.gfmFootnotes=[]);let o,u=0,c;return d;function d(w){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(w),e.exit("gfmFootnoteDefinitionLabelMarker"),h}function h(w){return w===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(w),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",m):r(w)}function m(w){if(u>999||w===93&&!c||w===null||w===91||ot(w))return r(w);if(w===93){e.exit("chunkString");const E=e.exit("gfmFootnoteDefinitionLabelString");return o=Fn(l.sliceSerialize(E)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(w),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),x}return ot(w)||(c=!0),u++,e.consume(w),w===92?p:m}function p(w){return w===91||w===92||w===93?(e.consume(w),u++,m):m(w)}function x(w){return w===58?(e.enter("definitionMarker"),e.consume(w),e.exit("definitionMarker"),a.includes(o)||a.push(o),Qe(e,b,"gfmFootnoteDefinitionWhitespace")):r(w)}function b(w){return t(w)}}function a9(e,t,r){return e.check(as,t,e.attempt(e9,t,r))}function o9(e){e.exit("gfmFootnoteDefinition")}function s9(e,t,r){const l=this;return Qe(e,a,"gfmFootnoteDefinitionIndent",5);function a(o){const u=l.events[l.events.length-1];return u&&u[1].type==="gfmFootnoteDefinitionIndent"&&u[2].sliceSerialize(u[1],!0).length===4?t(o):r(o)}}function u9(e){let r=(e||{}).singleTilde;const l={name:"strikethrough",tokenize:o,resolveAll:a};return r==null&&(r=!0),{text:{126:l},insideSpan:{null:[l]},attentionMarkers:{null:[126]}};function a(u,c){let d=-1;for(;++d1?d(w):(u.consume(w),p++,b);if(p<2&&!r)return d(w);const S=u.exit("strikethroughSequenceTemporary"),_=ya(w);return S._open=!_||_===2&&!!E,S._close=!E||E===2&&!!_,c(w)}}}class c9{constructor(){this.map=[]}add(t,r,l){f9(this,t,r,l)}consume(t){if(this.map.sort(function(o,u){return o[0]-u[0]}),this.map.length===0)return;let r=this.map.length;const l=[];for(;r>0;)r-=1,l.push(t.slice(this.map[r][0]+this.map[r][1]),this.map[r][2]),t.length=this.map[r][0];l.push(t.slice()),t.length=0;let a=l.pop();for(;a;){for(const o of a)t.push(o);a=l.pop()}this.map.length=0}}function f9(e,t,r,l){let a=0;if(!(r===0&&l.length===0)){for(;a-1;){const I=l.events[B][1].type;if(I==="lineEnding"||I==="linePrefix")B--;else break}const U=B>-1?l.events[B][1].type:null,ee=U==="tableHead"||U==="tableRow"?T:d;return ee===T&&l.parser.lazy[l.now().line]?r(H):ee(H)}function d(H){return e.enter("tableHead"),e.enter("tableRow"),h(H)}function h(H){return H===124||(u=!0,o+=1),m(H)}function m(H){return H===null?r(H):Ee(H)?o>1?(o=0,l.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(H),e.exit("lineEnding"),b):r(H):$e(H)?Qe(e,m,"whitespace")(H):(o+=1,u&&(u=!1,a+=1),H===124?(e.enter("tableCellDivider"),e.consume(H),e.exit("tableCellDivider"),u=!0,m):(e.enter("data"),p(H)))}function p(H){return H===null||H===124||ot(H)?(e.exit("data"),m(H)):(e.consume(H),H===92?x:p)}function x(H){return H===92||H===124?(e.consume(H),p):p(H)}function b(H){return l.interrupt=!1,l.parser.lazy[l.now().line]?r(H):(e.enter("tableDelimiterRow"),u=!1,$e(H)?Qe(e,w,"linePrefix",l.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(H):w(H))}function w(H){return H===45||H===58?S(H):H===124?(u=!0,e.enter("tableCellDivider"),e.consume(H),e.exit("tableCellDivider"),E):M(H)}function E(H){return $e(H)?Qe(e,S,"whitespace")(H):S(H)}function S(H){return H===58?(o+=1,u=!0,e.enter("tableDelimiterMarker"),e.consume(H),e.exit("tableDelimiterMarker"),_):H===45?(o+=1,_(H)):H===null||Ee(H)?A(H):M(H)}function _(H){return H===45?(e.enter("tableDelimiterFiller"),N(H)):M(H)}function N(H){return H===45?(e.consume(H),N):H===58?(u=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(H),e.exit("tableDelimiterMarker"),k):(e.exit("tableDelimiterFiller"),k(H))}function k(H){return $e(H)?Qe(e,A,"whitespace")(H):A(H)}function A(H){return H===124?w(H):H===null||Ee(H)?!u||a!==o?M(H):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(H)):M(H)}function M(H){return r(H)}function T(H){return e.enter("tableRow"),L(H)}function L(H){return H===124?(e.enter("tableCellDivider"),e.consume(H),e.exit("tableCellDivider"),L):H===null||Ee(H)?(e.exit("tableRow"),t(H)):$e(H)?Qe(e,L,"whitespace")(H):(e.enter("data"),R(H))}function R(H){return H===null||H===124||ot(H)?(e.exit("data"),L(H)):(e.consume(H),H===92?V:R)}function V(H){return H===92||H===124?(e.consume(H),R):R(H)}}function m9(e,t){let r=-1,l=!0,a=0,o=[0,0,0,0],u=[0,0,0,0],c=!1,d=0,h,m,p;const x=new c9;for(;++rr[2]+1){const w=r[2]+1,E=r[3]-r[2]-1;e.add(w,E,[])}}e.add(r[3]+1,0,[["exit",p,t]])}return a!==void 0&&(o.end=Object.assign({},ea(t.events,a)),e.add(a,0,[["exit",o,t]]),o=void 0),o}function cw(e,t,r,l,a){const o=[],u=ea(t.events,r);a&&(a.end=Object.assign({},u),o.push(["exit",a,t])),l.end=Object.assign({},u),o.push(["exit",l,t]),e.add(r+1,0,o)}function ea(e,t){const r=e[t],l=r[0]==="enter"?"start":"end";return r[1][l]}const g9={name:"tasklistCheck",tokenize:y9};function x9(){return{text:{91:g9}}}function y9(e,t,r){const l=this;return a;function a(d){return l.previous!==null||!l._gfmTasklistFirstContentOfListItem?r(d):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(d),e.exit("taskListCheckMarker"),o)}function o(d){return ot(d)?(e.enter("taskListCheckValueUnchecked"),e.consume(d),e.exit("taskListCheckValueUnchecked"),u):d===88||d===120?(e.enter("taskListCheckValueChecked"),e.consume(d),e.exit("taskListCheckValueChecked"),u):r(d)}function u(d){return d===93?(e.enter("taskListCheckMarker"),e.consume(d),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),c):r(d)}function c(d){return Ee(d)?t(d):$e(d)?e.check({tokenize:v9},t,r)(d):r(d)}}function v9(e,t,r){return Qe(e,l,"whitespace");function l(a){return a===null?r(a):t(a)}}function b9(e){return QS([G8(),t9(),u9(e),h9(),x9()])}const w9={};function Yc(e){const t=this,r=e||w9,l=t.data(),a=l.micromarkExtensions||(l.micromarkExtensions=[]),o=l.fromMarkdownExtensions||(l.fromMarkdownExtensions=[]),u=l.toMarkdownExtensions||(l.toMarkdownExtensions=[]);a.push(b9(r)),o.push(U8()),u.push($8(r))}const _9=new Set([".md",".markdown",".mdx"]);function S9({filePath:e,onClose:t}){const[r,l]=$.useState(null),[a,o]=$.useState(null),[u,c]=$.useState(!0),d=$.useCallback(async()=>{c(!0),o(null);try{const m=e.split("/").map(b=>encodeURIComponent(b)).join("/"),p=await fetch(`/api/files/${m}`);if(!p.ok){const b=await p.json().catch(()=>({}));o(b.error||`HTTP ${p.status}`);return}const x=await p.json();l(x)}catch(m){o(m instanceof Error?m.message:"Failed to load file")}finally{c(!1)}},[e]);$.useEffect(()=>{d()},[d]),$.useEffect(()=>{const m=p=>{p.key==="Escape"&&t()};return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[t]);const h=r?_9.has(r.extension):!1;return y.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",children:y.jsxs("div",{className:"relative flex flex-col w-[90vw] max-w-3xl max-h-[80vh] rounded-xl border border-[var(--border)] bg-[var(--surface)] shadow-2xl overflow-hidden",children:[y.jsxs("div",{className:"flex items-center gap-2 px-4 py-2.5 border-b border-[var(--border)] bg-[var(--surface-raised)] flex-shrink-0",children:[y.jsx(vw,{className:"w-4 h-4 text-[var(--text-muted)] flex-shrink-0"}),y.jsx("span",{className:"text-xs font-medium text-[var(--text)] truncate flex-1",title:e,children:e}),r&&y.jsx("span",{className:"text-[10px] text-[var(--text-muted)] flex-shrink-0 tabular-nums",children:E9(r.size)}),y.jsx("button",{onClick:t,className:"p-1 rounded-md text-[var(--text-muted)] hover:text-[var(--text)] hover:bg-[var(--surface-hover)] transition-colors flex-shrink-0",title:"Close (Esc)",children:y.jsx(ll,{className:"w-4 h-4"})})]}),y.jsxs("div",{className:"flex-1 overflow-auto px-5 py-4 min-h-0",children:[u&&y.jsx("div",{className:"flex items-center justify-center py-12",children:y.jsx(ca,{className:"w-5 h-5 text-[var(--text-muted)] animate-spin"})}),a&&y.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg bg-red-500/10 border border-red-500/30",children:[y.jsx(ic,{className:"w-4 h-4 text-red-400 flex-shrink-0"}),y.jsx("span",{className:"text-xs text-red-300",children:a})]}),r&&!a&&(h?y.jsx("div",{className:"file-viewer-markdown text-xs leading-relaxed text-[var(--text)]",children:y.jsx(k9,{content:r.content})}):y.jsx("pre",{className:"font-mono text-[11px] leading-[1.6] text-[var(--text)] whitespace-pre-wrap break-words",children:r.content}))]})]})})}function k9({content:e}){return y.jsx(Fc,{remarkPlugins:[Yc],components:{h1:({children:t})=>y.jsx("h1",{className:"text-base font-bold mb-3 mt-2 text-[var(--text)]",children:t}),h2:({children:t})=>y.jsx("h2",{className:"text-sm font-bold mb-2 mt-3 text-[var(--text)]",children:t}),h3:({children:t})=>y.jsx("h3",{className:"text-xs font-bold mb-1.5 mt-2 text-[var(--text)]",children:t}),p:({children:t})=>y.jsx("p",{className:"mb-2 last:mb-0",children:t}),ul:({children:t})=>y.jsx("ul",{className:"list-disc list-inside mb-2 space-y-1 ml-2",children:t}),ol:({children:t})=>y.jsx("ol",{className:"list-decimal list-inside mb-2 space-y-1 ml-2",children:t}),li:({children:t})=>y.jsx("li",{children:t}),code:({children:t,className:r})=>(r==null?void 0:r.includes("language-"))?y.jsx("code",{className:"block bg-[var(--bg)] border border-[var(--border)] rounded px-3 py-2 font-mono text-[11px] my-2 overflow-x-auto whitespace-pre",children:t}):y.jsx("code",{className:"bg-[var(--bg)] border border-[var(--border)] rounded px-1 py-0.5 font-mono text-[11px]",children:t}),pre:({children:t})=>y.jsx("pre",{className:"bg-[var(--bg)] border border-[var(--border)] rounded-md px-3 py-2.5 font-mono text-[11px] my-2 overflow-x-auto",children:t}),strong:({children:t})=>y.jsx("strong",{className:"font-semibold",children:t}),em:({children:t})=>y.jsx("em",{className:"italic",children:t}),a:({href:t,children:r})=>y.jsx("a",{href:t,target:"_blank",rel:"noopener noreferrer",className:"text-blue-400 hover:text-blue-300 underline underline-offset-2",children:r}),blockquote:({children:t})=>y.jsx("blockquote",{className:"border-l-2 border-[var(--border)] pl-3 my-2 opacity-80",children:t}),hr:()=>y.jsx("hr",{className:"border-[var(--border)] my-3"}),table:({children:t})=>y.jsx("div",{className:"overflow-x-auto my-2",children:y.jsx("table",{className:"text-[11px] border-collapse w-full",children:t})}),th:({children:t})=>y.jsx("th",{className:"border border-[var(--border)] px-2 py-1 text-left bg-[var(--bg)] font-semibold",children:t}),td:({children:t})=>y.jsx("td",{className:"border border-[var(--border)] px-2 py-1",children:t})},children:e})}function E9(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function N9({node:e}){const t=ue(M=>M.sendGateResponse),r=ue(M=>M.wsStatus),[l,a]=$.useState(null),[o,u]=$.useState(""),[c,d]=$.useState(null),[h,m]=$.useState(!1),[p,x]=$.useState(null),b=e.status==="waiting",w=e.status==="completed";$.useEffect(()=>{b&&(a(null),u(""),d(null),m(!1))},[b]);const E=b&&r==="connected"&&l===null,S=(M,T)=>{if(E){if(T){a(M),d(T);return}a(M),m(!0),t(e.name,M)}},_=()=>{if(l===null||c===null)return;const M={[c]:o};m(!0),t(e.name,l,M),d(null)},N=e.option_details,k=N==null?void 0:N.find(M=>M.value===e.selected_option),A=(k==null?void 0:k.label)||e.selected_option;return y.jsxs("div",{className:"space-y-3",children:[b&&y.jsxs(y.Fragment,{children:[y.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2 rounded-lg bg-amber-500/10 border border-amber-500/30",children:[y.jsxs("span",{className:"relative flex h-2.5 w-2.5 flex-shrink-0",children:[y.jsx("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full bg-amber-400 opacity-75"}),y.jsx("span",{className:"relative inline-flex rounded-full h-2.5 w-2.5 bg-amber-500"})]}),y.jsx("span",{className:"text-xs font-semibold text-amber-400 tracking-wide",children:"Decision Required"})]}),e.prompt&&y.jsx("div",{className:"border-l-2 border-amber-500/50 pl-3 py-0.5",children:y.jsx(Up,{text:e.prompt,muted:!1,onFileClick:x})}),N&&N.length>0&&y.jsxs("div",{className:"space-y-2",children:[y.jsx("div",{className:"flex flex-col gap-1.5",children:N.map(M=>{const T=l===M.value,L=l!==null&&!T;return y.jsx("button",{disabled:!E&&!T,onClick:()=>S(M.value,M.prompt_for),className:`w-full text-left px-3 py-2.5 rounded-lg border transition-all duration-150 ${T?"border-green-500/60 bg-green-500/10":L?"border-[var(--border)] opacity-40 cursor-default":"border-[var(--border)] bg-[var(--surface)] hover:border-amber-400/60 hover:bg-amber-500/5 cursor-pointer group"}`,children:y.jsxs("div",{className:"flex items-center gap-2.5",children:[y.jsx("div",{className:"flex-shrink-0",children:T?y.jsx("div",{className:"w-4 h-4 rounded-full bg-green-500 flex items-center justify-center",children:y.jsx(Yi,{className:"w-2.5 h-2.5 text-white",strokeWidth:3})}):y.jsx("div",{className:`w-4 h-4 rounded-full border-2 transition-colors ${L?"border-[var(--border)]":"border-[var(--border)] group-hover:border-amber-400"}`})}),y.jsx("div",{className:"flex-1 min-w-0",children:y.jsx("span",{className:`text-xs font-medium ${T?"text-green-400":"text-[var(--text)]"}`,children:M.label})}),M.route&&y.jsxs("span",{className:"text-[10px] text-[var(--text-muted)] flex-shrink-0",children:["→ ",M.route]})]})},M.value)})}),h&&!c&&y.jsxs("div",{className:"flex items-center gap-2 px-1",children:[y.jsx(ca,{className:"w-3 h-3 text-green-400 animate-spin"}),y.jsx("span",{className:"text-[10px] text-green-400",children:"Sending..."})]}),E&&y.jsx("p",{className:"text-[10px] text-[var(--text-muted)] px-1",children:"Select an option to continue the workflow"})]}),!N&&e.options&&e.options.length>0&&y.jsxs("div",{className:"space-y-1.5",children:[y.jsx("h4",{className:"text-[10px] uppercase tracking-wider text-[var(--text-muted)] font-semibold",children:"Options"}),y.jsx("div",{className:"flex flex-wrap gap-1.5",children:e.options.map(M=>y.jsx("span",{className:"text-[11px] px-2 py-0.5 rounded border border-[var(--border)] text-[var(--text-muted)]",children:M},M))})]}),c&&y.jsxs("div",{className:"rounded-lg border border-[var(--border)] bg-[var(--bg)] overflow-hidden",children:[y.jsx("div",{className:"px-3 py-2 border-b border-[var(--border)] bg-[var(--surface)]",children:y.jsx("h4",{className:"text-[10px] uppercase tracking-wider text-[var(--text-muted)] font-semibold",children:c})}),y.jsxs("div",{className:"p-3 space-y-2",children:[y.jsx("input",{type:"text",value:o,onChange:M=>u(M.target.value),onKeyDown:M=>M.key==="Enter"&&_(),placeholder:`Enter ${c}...`,className:"w-full text-xs px-3 py-2 rounded-lg border border-[var(--border)] bg-[var(--bg)] text-[var(--text)] outline-none focus:border-amber-400 transition-colors",autoFocus:!0}),y.jsxs("div",{className:"flex items-center justify-between",children:[y.jsx("span",{className:"text-[10px] text-[var(--text-muted)]",children:"Press Enter or click Submit"}),y.jsxs("button",{onClick:_,className:"flex items-center gap-1.5 text-xs px-3 py-1.5 rounded-lg bg-amber-500 text-white hover:bg-amber-600 transition-colors font-medium",children:[y.jsx(ww,{className:"w-3 h-3"}),"Submit"]})]})]})]})]}),w&&y.jsxs(y.Fragment,{children:[y.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2 rounded-lg bg-green-500/10 border border-green-500/30",children:[y.jsx(Yi,{className:"w-3.5 h-3.5 text-green-400 flex-shrink-0"}),y.jsx("span",{className:"text-xs font-semibold text-green-400 tracking-wide",children:"Decision Completed"})]}),e.prompt&&y.jsx("div",{className:"border-l-2 border-[var(--border)] pl-3 py-0.5",children:y.jsx(Up,{text:e.prompt,muted:!0,onFileClick:x})}),A&&y.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2.5 rounded-lg border border-green-500/30 bg-green-500/5",children:[y.jsx("div",{className:"w-4 h-4 rounded-full bg-green-500 flex items-center justify-center flex-shrink-0",children:y.jsx(Yi,{className:"w-2.5 h-2.5 text-white",strokeWidth:3})}),y.jsx("span",{className:"text-xs font-medium text-[var(--text)]",children:A}),e.route&&y.jsxs("span",{className:"ml-auto text-[10px] text-[var(--text-muted)]",children:["→ ",e.route]})]}),N&&N.length>1&&y.jsx("div",{className:"space-y-1",children:N.filter(M=>M.value!==e.selected_option).map(M=>y.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2 rounded-lg opacity-35",children:[y.jsx("div",{className:"w-4 h-4 rounded-full border-2 border-[var(--border)] flex-shrink-0"}),y.jsx("span",{className:"text-xs text-[var(--text-muted)]",children:M.label}),M.route&&y.jsxs("span",{className:"ml-auto text-[10px] text-[var(--text-muted)]",children:["→ ",M.route]})]},M.value))}),!N&&e.options&&e.options.length>0&&y.jsx("div",{className:"flex flex-wrap gap-1.5",children:e.options.map(M=>y.jsxs("span",{className:`text-[11px] px-2.5 py-1 rounded-lg border ${M===e.selected_option?"border-green-500/30 text-green-400 bg-green-500/5":"border-[var(--border)] text-[var(--text-muted)] opacity-40"}`,children:[M===e.selected_option&&"✓ ",M]},M))}),y.jsx(j9,{node:e})]}),!b&&!w&&y.jsxs(y.Fragment,{children:[y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx("span",{className:"text-xs text-[var(--text-muted)]",children:"Human Gate"}),y.jsxs("span",{className:"text-[10px] text-[var(--text-muted)] capitalize",children:["(",e.status,")"]})]}),e.prompt&&y.jsx("div",{className:"border-l-2 border-[var(--border)] pl-3 py-0.5",children:y.jsx(Up,{text:e.prompt,muted:!0,onFileClick:x})})]}),p&&y.jsx(S9,{filePath:p,onClose:()=>x(null)})]})}function C9(e){return!(!e||/^[a-z][a-z0-9+.-]*:/i.test(e)||e.startsWith("//")||e.startsWith("#")||e.startsWith("/")||e.startsWith("\\"))}function Up({text:e,muted:t,onFileClick:r}){const l=t?"text-[var(--text-muted)]":"text-[var(--text)]";return y.jsx("div",{className:`gate-markdown text-xs leading-relaxed ${l}`,children:y.jsx(Fc,{remarkPlugins:[Yc],components:{h1:({children:a})=>y.jsx("h1",{className:"text-sm font-bold mb-2 mt-1",children:a}),h2:({children:a})=>y.jsx("h2",{className:"text-xs font-bold mb-1.5 mt-1",children:a}),h3:({children:a})=>y.jsx("h3",{className:"text-xs font-semibold mb-1 mt-1",children:a}),p:({children:a})=>y.jsx("p",{className:"mb-1.5 last:mb-0",children:a}),ul:({children:a})=>y.jsx("ul",{className:"list-disc list-inside mb-1.5 space-y-0.5",children:a}),ol:({children:a})=>y.jsx("ol",{className:"list-decimal list-inside mb-1.5 space-y-0.5",children:a}),li:({children:a})=>y.jsx("li",{children:a}),code:({children:a,className:o})=>(o==null?void 0:o.includes("language-"))?y.jsx("code",{className:"block bg-[var(--bg)] border border-[var(--border)] rounded px-2 py-1.5 font-mono text-[11px] my-1 overflow-x-auto whitespace-pre",children:a}):y.jsx("code",{className:"bg-[var(--bg)] border border-[var(--border)] rounded px-1 py-0.5 font-mono text-[11px]",children:a}),pre:({children:a})=>y.jsx("pre",{className:"bg-[var(--bg)] border border-[var(--border)] rounded-md px-2.5 py-2 font-mono text-[11px] my-1.5 overflow-x-auto",children:a}),strong:({children:a})=>y.jsx("strong",{className:"font-semibold",children:a}),em:({children:a})=>y.jsx("em",{className:"italic",children:a}),a:({href:a,children:o})=>r&&C9(a)?y.jsxs("button",{onClick:u=>{u.preventDefault(),r(a)},className:"inline-flex items-center gap-0.5 text-blue-400 hover:text-blue-300 underline underline-offset-2 cursor-pointer",title:`Open ${a}`,children:[y.jsx(vw,{className:"w-3 h-3 inline flex-shrink-0"}),o]}):y.jsx("a",{href:a,target:"_blank",rel:"noopener noreferrer",className:"text-blue-400 hover:text-blue-300 underline underline-offset-2",children:o}),blockquote:({children:a})=>y.jsx("blockquote",{className:"border-l-2 border-[var(--border)] pl-2.5 my-1.5 opacity-80",children:a}),hr:()=>y.jsx("hr",{className:"border-[var(--border)] my-2"}),table:({children:a})=>y.jsx("div",{className:"overflow-x-auto my-2",children:y.jsx("table",{className:"text-[11px] border-collapse w-full",children:a})}),th:({children:a})=>y.jsx("th",{className:"border border-[var(--border)] px-2 py-1 text-left bg-[var(--bg)] font-semibold",children:a}),td:({children:a})=>y.jsx("td",{className:"border border-[var(--border)] px-2 py-1",children:a})},children:e})})}function j9({node:e}){const t=[];if(e.route&&t.push({label:"Route",value:`→ ${e.route}`}),e.additional_input){const r=typeof e.additional_input=="object"?JSON.stringify(e.additional_input):e.additional_input;t.push({label:"Additional Input",value:r})}return t.length===0?null:y.jsx(sl,{items:t})}function T9({node:e}){const t=e.status,r=Fe[t]||Fe.pending,a=C5()[e.name],o=e.type==="for_each_group",[u,c]=$.useState(!0),d=[];e.elapsed!=null&&d.push({label:"Elapsed",value:Jt(e.elapsed)}),a&&(d.push({label:"Total",value:a.total}),d.push({label:"Completed",value:a.completed}),a.failed>0&&d.push({label:"Failed",value:a.failed})),e.success_count!=null&&d.push({label:"Success",value:e.success_count}),e.failure_count!=null&&d.push({label:"Failures",value:e.failure_count});const h=e.for_each_items;return y.jsxs("div",{className:"space-y-4",children:[y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx("span",{className:"inline-flex items-center px-2 py-0.5 rounded text-[10px] font-bold uppercase tracking-wider",style:{backgroundColor:`${r}20`,color:r},children:t}),y.jsx("span",{className:"text-xs text-[var(--text-muted)]",children:o?"For-Each Group":"Parallel Group"})]}),a&&a.total>0&&y.jsxs("div",{className:"space-y-1",children:[y.jsxs("div",{className:"flex justify-between text-[10px] text-[var(--text-muted)]",children:[y.jsx("span",{children:"Progress"}),y.jsxs("span",{children:[a.completed+a.failed,"/",a.total]})]}),y.jsx("div",{className:"h-1.5 bg-[var(--bg)] rounded-full overflow-hidden",children:y.jsx("div",{className:"h-full rounded-full transition-all duration-500",style:{width:`${(a.completed+a.failed)/a.total*100}%`,background:a.failed>0?`linear-gradient(90deg, var(--completed) ${a.completed/(a.completed+a.failed)*100}%, var(--failed) 0%)`:"var(--completed)"}})})]}),y.jsx(sl,{items:d}),o&&h&&h.length>0&&y.jsxs("div",{className:"space-y-2",children:[y.jsxs("button",{onClick:()=>c(!u),className:"flex items-center gap-1.5 text-[10px] uppercase tracking-wider text-[var(--text-muted)] font-semibold hover:text-[var(--text)] transition-colors",children:[u?y.jsx(il,{className:"w-3 h-3"}):y.jsx(Rr,{className:"w-3 h-3"}),"Items (",h.length,")"]}),u&&y.jsx("div",{className:"space-y-1",children:h.map(m=>y.jsx(z9,{groupName:e.name,item:m},`${m.key}-${m.index}`))})]})]})}const A9={running:Fe.running,completed:Fe.completed,failed:Fe.failed};function z9({groupName:e,item:t}){const[r,l]=$.useState(t.status==="running"),a=A9[t.status],o=Um(),u=ue(x=>x.navigateIntoSubworkflow),c=`${e}[${t.key}]`,d=o.find(x=>x.slotKey===c),h=!!d,m=!!(t.prompt||t.output!=null||t.activity&&t.activity.length>0||t.error_type),p=[];return t.elapsed!=null&&p.push({label:"Elapsed",value:Jt(t.elapsed)}),t.tokens!=null&&p.push({label:"Tokens",value:Pn(t.tokens)}),t.cost_usd!=null&&p.push({label:"Cost",value:yi(t.cost_usd)}),y.jsxs("div",{className:"rounded-lg border border-[var(--border)] bg-[var(--surface)] overflow-hidden",children:[y.jsxs("button",{onClick:()=>m&&l(!r),className:"flex items-center gap-2 w-full px-3 py-2 text-left hover:bg-[var(--node-bg)] transition-colors",disabled:!m,children:[m?r?y.jsx(il,{className:"w-3 h-3 text-[var(--text-muted)] flex-shrink-0"}):y.jsx(Rr,{className:"w-3 h-3 text-[var(--text-muted)] flex-shrink-0"}):t.status==="running"?y.jsx(ca,{className:"w-3 h-3 animate-spin flex-shrink-0",style:{color:a}}):y.jsx("span",{className:"w-2 h-2 rounded-full flex-shrink-0 ml-0.5 mr-0.5",style:{backgroundColor:a}}),y.jsx("span",{className:"text-xs font-medium text-[var(--text)] truncate flex-1 min-w-0",children:t.key}),!r&&(t.elapsed!=null||t.tokens!=null||t.cost_usd!=null)&&y.jsxs("span",{className:"flex items-center gap-2 text-[10px] text-[var(--text-muted)] flex-shrink-0",children:[t.elapsed!=null&&y.jsx("span",{children:Jt(t.elapsed)}),t.tokens!=null&&y.jsx("span",{children:Pn(t.tokens)}),t.cost_usd!=null&&y.jsx("span",{children:yi(t.cost_usd)})]}),y.jsx("span",{className:"text-[10px] font-bold uppercase tracking-wider flex-shrink-0 px-1.5 py-0.5 rounded",style:{backgroundColor:`${a}20`,color:a},children:t.status}),h&&y.jsx("span",{role:"button",tabIndex:0,onClick:x=>{x.stopPropagation(),u(c)},onKeyDown:x=>{(x.key==="Enter"||x.key===" ")&&(x.stopPropagation(),x.preventDefault(),u(c))},title:`Dive into ${(d==null?void 0:d.workflowName)??c}`,className:"flex-shrink-0 p-1 rounded hover:bg-[var(--accent)]/20 hover:text-[var(--accent)] transition-colors text-[var(--text-muted)] cursor-pointer",children:y.jsx(Sc,{className:"w-3 h-3"})})]}),r&&m&&y.jsxs("div",{className:"px-3 py-3 space-y-3 border-t border-[var(--border)]",children:[p.length>0&&y.jsx(sl,{items:p}),t.prompt&&y.jsx(nl,{output:t.prompt,title:"Input / Prompt",defaultExpanded:!1}),t.activity&&t.activity.length>0&&y.jsx(Vm,{activity:t.activity,defaultExpanded:t.status!=="completed"}),t.output!=null&&y.jsx(nl,{output:t.output,title:"Output",defaultExpanded:!0}),t.status==="failed"&&(t.error_type||t.error_message)&&y.jsxs("div",{className:"text-xs text-red-400",children:[t.error_type&&y.jsx("span",{className:"font-semibold",children:t.error_type}),t.error_message&&y.jsxs("span",{className:"ml-1",children:["— ",t.error_message]})]})]})]})}function M9({node:e}){const t=ue(h=>h.engageDialog),r=ue(h=>h.sendDialogDecline),l=ue(h=>h.wsStatus),a=e.dialog_id||"",o=e.dialog_messages||[],u=l==="connected",c=o.find(h=>h.role==="agent"),d=()=>{u&&r(e.name,a)};return y.jsxs("div",{className:"flex flex-col gap-4",children:[y.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2 rounded-lg bg-fuchsia-500/10 border border-fuchsia-500/30",children:[y.jsxs("span",{className:"relative flex h-2.5 w-2.5 flex-shrink-0",children:[y.jsx("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full bg-fuchsia-400 opacity-75"}),y.jsx("span",{className:"relative inline-flex rounded-full h-2.5 w-2.5 bg-fuchsia-500"})]}),y.jsx("span",{className:"text-xs font-semibold text-fuchsia-400 tracking-wide",children:"Dialog Requested"})]}),c&&y.jsxs("div",{className:"rounded-lg px-3 py-2 bg-amber-500/10 border border-amber-500/30",children:[y.jsx("div",{className:"text-[10px] font-semibold mb-1 text-[var(--text-muted)]",children:e.name}),y.jsx("div",{className:"dialog-markdown text-xs leading-relaxed text-[var(--text)]",children:y.jsx(Fc,{remarkPlugins:[Yc],children:c.content})})]}),y.jsxs("div",{className:"space-y-2",children:[y.jsx("div",{className:"text-[10px] uppercase tracking-wider text-[var(--text-muted)] font-semibold",children:"How would you like to proceed?"}),y.jsxs("div",{className:"flex gap-2",children:[y.jsxs("button",{onClick:t,disabled:!u,className:"flex-1 flex items-center justify-center gap-1.5 text-xs px-3 py-2 rounded-lg border border-fuchsia-500/40 bg-fuchsia-500/10 text-fuchsia-300 hover:bg-fuchsia-500/20 transition-colors font-medium disabled:opacity-40 disabled:cursor-not-allowed",children:[y.jsx(ym,{className:"w-3 h-3"}),"💬 Discuss"]}),y.jsxs("button",{onClick:d,disabled:!u,className:"flex-1 flex items-center justify-center gap-1.5 text-xs px-3 py-2 rounded-lg border border-[var(--border)] bg-[var(--surface)] text-[var(--text-muted)] hover:bg-[var(--surface-hover)] transition-colors font-medium disabled:opacity-40 disabled:cursor-not-allowed",children:[y.jsx(ll,{className:"w-3 h-3"}),"✕ Skip & continue"]})]})]})]})}function D9({node:e}){const t=e.status,r=Fe[t]||Fe.pending,l=ue(c=>c.navigateIntoSubworkflow),o=Um().filter(c=>c.parentAgent===e.name),u=[];return e.elapsed!=null&&u.push({label:"Elapsed",value:Jt(e.elapsed)}),e.cost_usd!=null&&u.push({label:"Cost",value:yi(e.cost_usd)}),e.tokens!=null&&u.push({label:"Tokens",value:Pn(e.tokens)}),e.iteration!=null&&e.iteration>1&&u.push({label:"Iteration",value:e.iteration}),y.jsxs("div",{className:"space-y-4",children:[y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx("span",{className:"inline-flex items-center px-2 py-0.5 rounded text-[10px] font-bold uppercase tracking-wider",style:{backgroundColor:`${r}20`,color:r},children:t}),y.jsx("span",{className:"text-xs text-[var(--text-muted)]",children:"Subworkflow Agent"})]}),y.jsx(sl,{items:u}),o.length>0&&y.jsxs("div",{className:"space-y-2",children:[y.jsxs("div",{className:"text-[10px] uppercase tracking-wider text-[var(--text-muted)] font-semibold",children:["Subworkflow Runs (",o.length,")"]}),y.jsx("div",{className:"space-y-1",children:o.map((c,d)=>y.jsx(R9,{ctx:c,onClick:()=>l(c.slotKey)},`${c.slotKey}-${c.iteration}-${d}`))})]}),t==="failed"&&(e.error_type||e.error_message)&&y.jsxs("div",{className:"text-xs text-red-400",children:[e.error_type&&y.jsx("span",{className:"font-semibold",children:e.error_type}),e.error_message&&y.jsxs("span",{className:"ml-1",children:["— ",e.error_message]})]}),o.length===0&&t==="pending"&&y.jsx("div",{className:"text-xs text-[var(--text-muted)] italic",children:"Subworkflow has not started yet."})]})}function R9({ctx:e,onClick:t}){const r=Fe[e.status]||Fe.pending;return y.jsxs("button",{onClick:t,className:"flex items-center gap-2 w-full px-3 py-2 rounded-lg border border-[var(--border)] bg-[var(--surface)] hover:bg-[var(--node-bg)] transition-colors text-left",children:[y.jsx(Sc,{className:"w-3.5 h-3.5 flex-shrink-0",style:{color:r}}),y.jsxs("div",{className:"flex flex-col min-w-0 flex-1",children:[y.jsx("span",{className:"text-xs font-medium text-[var(--text)] truncate",children:e.workflowName||e.workflowFile||"Subworkflow"}),y.jsxs("div",{className:"flex items-center gap-2 text-[10px] text-[var(--text-muted)]",children:[e.agentsTotal>0&&y.jsxs("span",{className:"flex items-center gap-0.5",children:[y.jsx(bw,{className:"w-2.5 h-2.5"}),e.agentsCompleted,"/",e.agentsTotal," agents"]}),e.totalCost>0&&y.jsxs("span",{className:"flex items-center gap-0.5",children:[y.jsx(xw,{className:"w-2.5 h-2.5"}),yi(e.totalCost)]})]})]}),y.jsx("span",{className:"text-[10px] font-bold uppercase tracking-wider flex-shrink-0 px-1.5 py-0.5 rounded",style:{backgroundColor:`${r}20`,color:r},children:e.status}),y.jsx(Rr,{className:"w-3.5 h-3.5 flex-shrink-0 text-[var(--text-muted)]"})]})}function O9(){const e=ue(d=>d.selectedNode),t=ol(),r=ue(d=>d.selectNode),l=ue(d=>d.dialogEngaged),[a,o]=$.useState(!1);$.useEffect(()=>(requestAnimationFrame(()=>o(!0)),()=>o(!1)),[e]);const u=e?t[e]:null;if(!e||!u)return y.jsxs("div",{className:"h-full flex flex-col bg-[var(--surface)]",children:[y.jsx("div",{className:"flex items-center justify-between px-4 py-3 border-b border-[var(--border)]",children:y.jsx("h2",{className:"text-sm font-semibold text-[var(--text)]",children:"Detail"})}),y.jsx("div",{className:"flex-1 flex items-center justify-center",children:y.jsx("p",{className:"text-xs text-[var(--text-muted)]",children:"Click a node to view details"})})]});const c=(()=>{if(u.dialog_active&&!l)return M9;if(u.dialog_active&&l)return b1;switch(u.type){case"script":return W4;case"human_gate":return N9;case"parallel_group":case"for_each_group":return T9;case"workflow":return D9;default:return b1}})();return y.jsxs("div",{className:He("h-full flex flex-col bg-[var(--surface)] transition-all duration-150 ease-out",a?"translate-x-0 opacity-100":"translate-x-4 opacity-0"),children:[y.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-[var(--border)] flex-shrink-0",children:[y.jsx("h2",{className:"text-sm font-semibold text-[var(--text)] truncate",children:e}),y.jsx("button",{onClick:()=>r(null),className:"p-1 rounded hover:bg-[var(--surface-hover)] text-[var(--text-muted)] hover:text-[var(--text)] transition-colors",title:"Close panel",children:y.jsx(ll,{className:"w-4 h-4"})})]}),y.jsx("div",{className:"flex-1 overflow-y-auto px-4 py-3",children:y.jsx(c,{node:u})})]})}function rc(e){if(e==null)return"";if(typeof e=="string")return e;try{return JSON.stringify(e,null,2)}catch{return String(e)}}function L9(){const e=ue(S=>S.eventLog),t=ue(S=>S.activityLog),r=ue(S=>S.workflowOutput),l=ue(S=>S.workflowStatus),[a,o]=$.useState("log"),[u,c]=$.useState(!1),[d,h]=$.useState(0),[m,p]=$.useState(0),x=$.useCallback(S=>{o(S),S==="log"&&h(e.length),S==="activity"&&p(t.length)},[e.length,t.length]);$.useEffect(()=>{a==="log"&&h(e.length)},[a,e.length]),$.useEffect(()=>{a==="activity"&&p(t.length)},[a,t.length]),$.useEffect(()=>{l==="completed"&&r!=null&&o("output")},[l,r]);const b=r!=null,w=a!=="log"?Math.max(0,e.length-d):0,E=a!=="activity"?Math.max(0,t.length-m):0;return u?y.jsx("div",{className:"flex items-center bg-[var(--surface)] border-t border-[var(--border)] px-3 py-1",children:y.jsxs("button",{onClick:()=>c(!1),className:"flex items-center gap-1.5 text-xs text-[var(--text-muted)] hover:text-[var(--text)] transition-colors",children:[y.jsx(cN,{className:"w-3 h-3"}),y.jsx(ev,{className:"w-3 h-3"}),y.jsx("span",{children:"Output"}),t.length>0&&y.jsxs("span",{className:"text-[10px] text-[var(--text-muted)]",children:["(",t.length,")"]})]})}):y.jsxs("div",{className:"flex flex-col h-full bg-[var(--surface)] border-t border-[var(--border)]",children:[y.jsxs("div",{className:"flex items-center justify-between px-2 flex-shrink-0 border-b border-[var(--border)]",children:[y.jsxs("div",{className:"flex items-center gap-0.5",children:[y.jsx($p,{active:a==="log",onClick:()=>x("log"),icon:y.jsx(ev,{className:"w-3 h-3"}),label:"Log",count:e.length,unread:w}),y.jsx($p,{active:a==="activity",onClick:()=>x("activity"),icon:y.jsx(gw,{className:"w-3 h-3"}),label:"Activity",count:t.length,unread:E}),y.jsx($p,{active:a==="output",onClick:()=>x("output"),icon:y.jsx(xN,{className:"w-3 h-3"}),label:"Output",badge:b?l==="failed"?"error":"success":void 0})]}),y.jsx("button",{onClick:()=>c(!0),className:"p-1 rounded text-[var(--text-muted)] hover:text-[var(--text)] hover:bg-[var(--surface-hover)] transition-colors",title:"Collapse panel",children:y.jsx(il,{className:"w-3.5 h-3.5"})})]}),y.jsx("div",{className:"flex-1 overflow-hidden",children:a==="activity"?y.jsx(H9,{entries:t}):a==="log"?y.jsx(B9,{entries:e}):y.jsx(I9,{output:r,status:l})})]})}function $p({active:e,onClick:t,icon:r,label:l,count:a,badge:o,unread:u}){return y.jsxs("button",{onClick:t,className:He("relative flex items-center gap-1.5 px-3 py-1.5 text-xs transition-colors border-b-2 -mb-px",e?"text-[var(--text)] border-[var(--accent)]":"text-[var(--text-muted)] border-transparent hover:text-[var(--text-secondary)]"),children:[r,y.jsx("span",{children:l}),a!=null&&a>0&&y.jsx("span",{className:"text-[10px] text-[var(--text-muted)] tabular-nums",children:a}),o&&y.jsx("span",{className:He("w-1.5 h-1.5 rounded-full",o==="success"?"bg-[var(--completed)]":"bg-[var(--failed)]")}),!e&&u!=null&&u>0&&y.jsx("span",{className:"absolute -top-0.5 -right-0.5 flex h-3.5 min-w-[14px] items-center justify-center rounded-full bg-[var(--accent)] px-1",children:y.jsx("span",{className:"text-[8px] font-bold text-white leading-none tabular-nums",children:u>99?"99+":u})})]})}const fw={reasoning:{color:"text-indigo-400/70",label:"THINK",labelColor:"text-indigo-500"},"tool-start":{color:"text-blue-400",label:"TOOL →",labelColor:"text-blue-500"},"tool-complete":{color:"text-green-400",label:"TOOL ←",labelColor:"text-green-600"},turn:{color:"text-amber-400",label:"STEP",labelColor:"text-amber-500"},message:{color:"text-[var(--text)]",label:"MSG",labelColor:"text-[var(--text-muted)]"},prompt:{color:"text-cyan-400/70",label:"PROMPT",labelColor:"text-cyan-600"}};function H9({entries:e}){const t=$.useRef(null),r=$.useRef(!0),l=ue(d=>d.selectNode),[a,o]=$.useState(""),u=$.useCallback(()=>{const d=t.current;if(!d)return;const h=d.scrollHeight-d.scrollTop-d.clientHeight<30;r.current=h},[]),c=$.useMemo(()=>{if(!a)return e;const d=a.toLowerCase();return e.filter(h=>h.source.toLowerCase().includes(d)||rc(h.message).toLowerCase().includes(d))},[e,a]);return $.useEffect(()=>{t.current&&r.current&&(t.current.scrollTop=t.current.scrollHeight)},[c.length]),e.length===0?y.jsx("div",{className:"h-full flex items-center justify-center",children:y.jsx("p",{className:"text-xs text-[var(--text-muted)]",children:"Waiting for agent activity…"})}):y.jsxs("div",{className:"h-full flex flex-col",children:[y.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 border-b border-[var(--border-subtle)] flex-shrink-0",children:[y.jsx(_N,{className:"w-3 h-3 text-[var(--text-muted)] flex-shrink-0"}),y.jsx("input",{type:"text",value:a,onChange:d=>o(d.target.value),placeholder:"Filter by agent or message…",className:"flex-1 bg-transparent text-[11px] text-[var(--text)] placeholder:text-[var(--text-muted)] outline-none min-w-0"}),a&&y.jsxs(y.Fragment,{children:[y.jsxs("span",{className:"text-[10px] text-[var(--text-muted)] tabular-nums flex-shrink-0",children:[c.length," of ",e.length]}),y.jsx("button",{onClick:()=>o(""),className:"text-[var(--text-muted)] hover:text-[var(--text)] transition-colors flex-shrink-0",title:"Clear filter",children:y.jsx(ll,{className:"w-3 h-3"})})]})]}),y.jsxs("div",{ref:t,onScroll:u,className:"flex-1 overflow-y-auto font-mono text-[11px] leading-[1.6] px-3 py-2",children:[c.map((d,h)=>{const m=fw[d.type]||fw.message,p=Ik(d.timestamp);return y.jsxs("div",{className:"group",children:[y.jsxs("div",{className:"flex gap-1.5 hover:bg-[var(--surface-hover)] rounded px-1 -mx-1",children:[y.jsx("span",{className:"text-[var(--text-muted)] flex-shrink-0 select-none tabular-nums",children:p}),y.jsx("span",{className:He("flex-shrink-0 w-[5ch] text-[10px] font-semibold tabular-nums select-none",m.labelColor),children:m.label}),y.jsx("button",{onClick:()=>l(d.source),className:"text-[var(--text-secondary)] flex-shrink-0 min-w-[8ch] max-w-[16ch] truncate hover:text-[var(--accent)] hover:underline transition-colors text-left",title:`Select ${d.source}`,children:d.source}),y.jsx("span",{className:He("break-words min-w-0",m.color,d.type==="reasoning"&&"italic"),children:rc(d.message)})]}),d.detail&&y.jsx("div",{className:"ml-[calc(7ch+5ch+8ch+1rem)] px-2 py-1 my-0.5 bg-[var(--bg)] rounded text-[10px] text-[var(--text-muted)] whitespace-pre-wrap break-words max-h-24 overflow-y-auto border-l-2 border-[var(--border)]",children:rc(d.detail)})]},h)}),a&&c.length===0&&y.jsx("div",{className:"flex items-center justify-center py-4",children:y.jsxs("p",{className:"text-xs text-[var(--text-muted)]",children:['No matches for "',a,'"']})})]})]})}const dw={info:{color:"text-blue-400",icon:"›"},success:{color:"text-green-400",icon:"✓"},error:{color:"text-red-400",icon:"✗"},warning:{color:"text-amber-400",icon:"⚠"},debug:{color:"text-[var(--text-muted)]",icon:"·"}};function B9({entries:e}){const t=$.useRef(null),r=$.useRef(!0),l=ue(o=>o.selectNode),a=$.useCallback(()=>{const o=t.current;if(!o)return;const u=o.scrollHeight-o.scrollTop-o.clientHeight<30;r.current=u},[]);return $.useEffect(()=>{t.current&&r.current&&(t.current.scrollTop=t.current.scrollHeight)},[e.length]),e.length===0?y.jsx("div",{className:"h-full flex items-center justify-center",children:y.jsx("p",{className:"text-xs text-[var(--text-muted)]",children:"Waiting for events…"})}):y.jsx("div",{ref:t,onScroll:a,className:"h-full overflow-y-auto font-mono text-[11px] leading-[1.6] px-3 py-2",children:e.map((o,u)=>{const c=dw[o.level]||dw.info,d=Ik(o.timestamp);return y.jsxs("div",{className:"flex gap-2 hover:bg-[var(--surface-hover)] rounded px-1 -mx-1",children:[y.jsx("span",{className:"text-[var(--text-muted)] flex-shrink-0 select-none tabular-nums",children:d}),y.jsx("span",{className:He("flex-shrink-0 w-3 text-center select-none",c.color),children:c.icon}),y.jsx("button",{onClick:()=>l(o.source),className:"text-[var(--text-secondary)] flex-shrink-0 min-w-[8ch] max-w-[16ch] truncate hover:text-[var(--accent)] hover:underline transition-colors text-left",title:`Select ${o.source}`,children:o.source}),y.jsx("span",{className:He("break-words",o.level==="error"?"text-red-400":o.level==="success"?"text-green-400":"text-[var(--text)]"),children:rc(o.message)})]},u)})})}function Ik(e){const t=new Date(e*1e3),r=t.getHours().toString().padStart(2,"0"),l=t.getMinutes().toString().padStart(2,"0"),a=t.getSeconds().toString().padStart(2,"0");return`${r}:${l}:${a}`}function I9({output:e,status:t}){const[r,l]=$.useState(!1),a=Sw(e),o=async()=>{a&&(await navigator.clipboard.writeText(a),l(!0),setTimeout(()=>l(!1),2e3))};return e==null?y.jsx("div",{className:"h-full flex items-center justify-center",children:y.jsx("p",{className:"text-xs text-[var(--text-muted)]",children:t==="running"?"Workflow running — output will appear when complete…":t==="failed"?"Workflow failed — no output produced":"No output yet"})}):y.jsxs("div",{className:"h-full flex flex-col",children:[y.jsxs("div",{className:"flex items-center justify-between px-3 py-1 border-b border-[var(--border-subtle)] flex-shrink-0",children:[y.jsx("span",{className:"text-[10px] text-[var(--text-muted)] uppercase tracking-wider font-semibold",children:"Workflow Result"}),y.jsx("button",{onClick:o,className:"flex items-center gap-1 text-[10px] text-[var(--text-muted)] hover:text-[var(--text)] transition-colors px-1.5 py-0.5 rounded hover:bg-[var(--surface-hover)]",title:"Copy to clipboard",children:r?y.jsxs(y.Fragment,{children:[y.jsx(Yi,{className:"w-3 h-3 text-[var(--completed)]"}),y.jsx("span",{className:"text-[var(--completed)]",children:"Copied"})]}):y.jsxs(y.Fragment,{children:[y.jsx(yw,{className:"w-3 h-3"}),y.jsx("span",{children:"Copy"})]})})]}),y.jsx("div",{className:"flex-1 overflow-auto px-3 py-2",children:y.jsx("pre",{className:"font-mono text-[11px] leading-relaxed text-[var(--text)] whitespace-pre-wrap break-words",children:typeof e=="object"?y.jsx(q9,{text:a}):a})})]})}function q9({text:e}){const t=e.split(/("(?:[^"\\]|\\.)*")/g);return y.jsx(y.Fragment,{children:t.map((r,l)=>{if(l%2===1){const o=t.slice(l+1).join(""),u=/^\s*:/.test(o);return y.jsx("span",{className:u?"text-blue-400":"text-green-400",children:r},l)}const a=r.replace(/\b(true|false|null)\b|(-?\d+\.?\d*(?:e[+-]?\d+)?)/gi,(o,u,c)=>u?`${o}`:c?`${o}`:o);return y.jsx("span",{dangerouslySetInnerHTML:{__html:a}},l)})})}function U9({text:e}){return y.jsx("div",{className:"dialog-markdown text-xs leading-relaxed text-[var(--text)]",children:y.jsx(Fc,{remarkPlugins:[Yc],components:{h1:({children:t})=>y.jsx("h1",{className:"text-sm font-bold mb-2 mt-1",children:t}),h2:({children:t})=>y.jsx("h2",{className:"text-xs font-bold mb-1.5 mt-1",children:t}),h3:({children:t})=>y.jsx("h3",{className:"text-xs font-semibold mb-1 mt-1",children:t}),p:({children:t})=>y.jsx("p",{className:"mb-1.5 last:mb-0",children:t}),ul:({children:t})=>y.jsx("ul",{className:"list-disc list-inside mb-1.5 space-y-0.5",children:t}),ol:({children:t})=>y.jsx("ol",{className:"list-decimal list-inside mb-1.5 space-y-0.5",children:t}),li:({children:t})=>y.jsx("li",{children:t}),code:({children:t,className:r})=>(r==null?void 0:r.includes("language-"))?y.jsx("code",{className:"block bg-[var(--bg)] border border-[var(--border)] rounded px-2 py-1.5 font-mono text-[11px] my-1 overflow-x-auto whitespace-pre",children:t}):y.jsx("code",{className:"bg-[var(--bg)] border border-[var(--border)] rounded px-1 py-0.5 font-mono text-[11px]",children:t}),pre:({children:t})=>y.jsx("pre",{className:"bg-[var(--bg)] border border-[var(--border)] rounded-md px-2.5 py-2 font-mono text-[11px] my-1.5 overflow-x-auto",children:t}),strong:({children:t})=>y.jsx("strong",{className:"font-semibold",children:t}),em:({children:t})=>y.jsx("em",{className:"italic",children:t}),a:({href:t,children:r})=>y.jsx("a",{href:t,target:"_blank",rel:"noopener noreferrer",className:"text-blue-400 hover:text-blue-300 underline underline-offset-2",children:r}),blockquote:({children:t})=>y.jsx("blockquote",{className:"border-l-2 border-[var(--border)] pl-2.5 my-1.5 opacity-80",children:t}),hr:()=>y.jsx("hr",{className:"border-[var(--border)] my-2"}),table:({children:t})=>y.jsx("div",{className:"overflow-x-auto my-2",children:y.jsx("table",{className:"text-[11px] border-collapse w-full",children:t})}),th:({children:t})=>y.jsx("th",{className:"border border-[var(--border)] px-2 py-1 text-left bg-[var(--bg)] font-semibold",children:t}),td:({children:t})=>y.jsx("td",{className:"border border-[var(--border)] px-2 py-1",children:t})},children:e})})}function $9({node:e}){const t=ue(x=>x.sendDialogMessage),r=ue(x=>x.wsStatus),[l,a]=$.useState(""),o=$.useRef(null),u=e.dialog_active===!0,c=e.dialog_id||"",d=e.dialog_messages||[],h=u&&r==="connected";$.useEffect(()=>{var x;(x=o.current)==null||x.scrollIntoView({behavior:"smooth"})},[d.length,e.dialog_awaiting_response]);const m=()=>{!l.trim()||!h||(t(e.name,c,l.trim()),a(""))},p=x=>{x.key==="Enter"&&!x.shiftKey&&(x.preventDefault(),m())};return y.jsxs("div",{className:"flex flex-col h-full",children:[u?y.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2 rounded-lg bg-fuchsia-500/10 border border-fuchsia-500/30 mb-3 flex-shrink-0",children:[y.jsxs("span",{className:"relative flex h-2.5 w-2.5 flex-shrink-0",children:[y.jsx("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full bg-fuchsia-400 opacity-75"}),y.jsx("span",{className:"relative inline-flex rounded-full h-2.5 w-2.5 bg-fuchsia-500"})]}),y.jsx("span",{className:"text-xs font-semibold text-fuchsia-400 tracking-wide",children:"Dialog Mode"}),y.jsxs("span",{className:"ml-auto text-[10px] text-[var(--text-muted)]",children:[d.length," message",d.length!==1?"s":""]})]}):y.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2 rounded-lg bg-[var(--surface)] border border-[var(--border)] mb-3 flex-shrink-0",children:[y.jsx(ym,{className:"w-3.5 h-3.5 text-[var(--text-muted)]"}),y.jsx("span",{className:"text-xs font-semibold text-[var(--text-muted)] tracking-wide",children:"Dialog Completed"}),y.jsxs("span",{className:"ml-auto text-[10px] text-[var(--text-muted)]",children:[d.length," message",d.length!==1?"s":""]})]}),y.jsxs("div",{className:"flex-1 overflow-y-auto space-y-3 min-h-0 mb-3",children:[d.map((x,b)=>y.jsx("div",{className:`flex ${x.role==="user"?"justify-end":"justify-start"}`,children:y.jsxs("div",{className:`max-w-[85%] rounded-lg px-3 py-2 ${x.role==="agent"?"bg-amber-500/10 border border-amber-500/30":"bg-blue-500/10 border border-blue-500/30"}`,children:[y.jsx("div",{className:"text-[10px] font-semibold mb-1 text-[var(--text-muted)]",children:x.role==="agent"?e.name:"You"}),y.jsx(U9,{text:x.content})]})},b)),e.dialog_awaiting_response&&y.jsx("div",{className:"flex justify-start",children:y.jsxs("div",{className:"max-w-[85%] rounded-lg px-3 py-2 bg-amber-500/10 border border-amber-500/30",children:[y.jsx("div",{className:"text-[10px] font-semibold mb-1 text-[var(--text-muted)]",children:e.name}),y.jsxs("div",{className:"flex gap-1 items-center h-4",children:[y.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-400/60 animate-bounce [animation-delay:0ms]"}),y.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-400/60 animate-bounce [animation-delay:150ms]"}),y.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-400/60 animate-bounce [animation-delay:300ms]"})]})]})}),y.jsx("div",{ref:o})]}),u&&y.jsxs("div",{className:"flex-shrink-0 border-t border-[var(--border)] pt-3",children:[y.jsxs("div",{className:"flex gap-2",children:[y.jsx("input",{type:"text",value:l,onChange:x=>a(x.target.value),onKeyDown:p,placeholder:"Type your message...",className:"flex-1 text-xs px-3 py-2 rounded-lg border border-[var(--border)] bg-[var(--bg)] text-[var(--text)] outline-none focus:border-fuchsia-400 transition-colors",disabled:!h,autoFocus:!0}),y.jsxs("button",{onClick:m,disabled:!h||!l.trim(),className:"flex items-center justify-center gap-1.5 text-xs px-8 py-2 rounded-lg bg-fuchsia-500 text-white hover:bg-fuchsia-600 transition-colors font-medium disabled:opacity-40 disabled:cursor-not-allowed",children:[y.jsx(ww,{className:"w-3 h-3"}),"Send"]})]}),y.jsx("p",{className:"text-[10px] text-[var(--text-muted)] mt-1.5 px-1",children:'Press Enter to send · Type "done" to end dialog'})]})]})}function V9(){const e=ue(l=>l.activeDialog),t=ue(l=>l.nodes);if(!e)return null;const r=t[e.agentName];return r?y.jsxs("div",{className:"h-full flex flex-col bg-[var(--bg)] overflow-hidden",children:[y.jsxs("div",{className:"flex items-center gap-2.5 px-5 py-3 border-b border-[var(--border)] bg-[var(--surface)] flex-shrink-0",children:[y.jsx(ym,{className:"w-4 h-4 text-fuchsia-400"}),y.jsxs("h2",{className:"text-sm font-semibold text-[var(--text)]",children:["Dialog with ",e.agentName]})]}),y.jsx("div",{className:"flex-1 overflow-hidden px-5 py-4",children:y.jsx($9,{node:r})})]}):null}function P9(){const e=ue(l=>l.selectedNode),t=ue(l=>l.activeDialog),r=ue(l=>l.dialogEngaged);return y.jsxs(Pp,{direction:"vertical",className:"flex-1 overflow-hidden",children:[y.jsx(Eo,{defaultSize:70,minSize:30,children:y.jsxs(Pp,{direction:"horizontal",className:"h-full",children:[y.jsx(Eo,{defaultSize:e?65:100,minSize:40,children:t&&r?y.jsx(V9,{}):y.jsx(G4,{})}),e&&y.jsxs(y.Fragment,{children:[y.jsx(Gp,{className:"w-[3px] bg-[var(--border)] hover:bg-[var(--text-muted)] transition-colors cursor-col-resize"}),y.jsx(Eo,{defaultSize:35,minSize:20,maxSize:60,children:y.jsx(O9,{})})]})]})}),y.jsx(Gp,{className:"h-[3px] bg-[var(--border)] hover:bg-[var(--text-muted)] transition-colors cursor-row-resize"}),y.jsx(Eo,{defaultSize:30,minSize:5,maxSize:70,collapsible:!0,children:y.jsx(L9,{})})]})}const hw=10;function G9(){const e=ue(E=>E.iterationLimitGate),t=ue(E=>E.wsStatus),r=ue(E=>E.sendIterationLimitResponse),[l,a]=$.useState(String(hw)),[o,u]=$.useState(!1);$.useEffect(()=>{e!=null&&e.gate_id&&(a(String(hw)),u(!1))},[e==null?void 0:e.gate_id]);const c=$.useMemo(()=>{const E=Number(l);return!Number.isFinite(E)||E<0?null:Math.floor(E)},[l]);if(!e||e.skip_gates)return null;const d=e.agent_name??e.group_name??"workflow",h=t==="connected"&&!o,m=!h||c==null||c<=0,p=()=>e.agent_name!==void 0?{agent_name:e.agent_name}:{group_name:e.group_name},x=()=>{m||c==null||(u(!0),r(p(),e.gate_id,c))},b=()=>{h&&(u(!0),r(p(),e.gate_id,0))},w=E=>{E.key==="Enter"&&(E.preventDefault(),x())};return y.jsx("div",{role:"dialog","aria-modal":"true","aria-labelledby":"iteration-limit-title","data-testid":"iteration-limit-modal",className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",children:y.jsxs("div",{className:"relative flex flex-col w-[90vw] max-w-md rounded-xl border border-amber-500/40 bg-[var(--surface)] shadow-2xl overflow-hidden",children:[y.jsxs("div",{className:"flex items-center gap-2.5 px-4 py-3 border-b border-[var(--border)] bg-amber-500/10",children:[y.jsx(ic,{className:"w-4 h-4 text-amber-400 flex-shrink-0"}),y.jsx("h2",{id:"iteration-limit-title",className:"text-sm font-semibold text-[var(--text)]",children:"Max iterations reached"})]}),y.jsxs("div",{className:"px-4 py-4 space-y-3",children:[y.jsxs("p",{className:"text-xs text-[var(--text)]",children:[y.jsx("span",{className:"font-semibold",children:d})," reached"," ",y.jsxs("span",{className:"tabular-nums",children:[e.current_iteration,"/",e.max_iterations]})," ","iterations."]}),e.possible_loop&&y.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg bg-amber-500/5 border border-amber-500/30",children:[y.jsx(ic,{className:"w-3.5 h-3.5 text-amber-400 flex-shrink-0"}),y.jsx("span",{className:"text-[11px] text-amber-300",children:"The same agent has run repeatedly — this may indicate a loop."})]}),e.agent_history.length>0&&y.jsxs("div",{className:"space-y-1",children:[y.jsx("h3",{className:"text-[10px] uppercase tracking-wider text-[var(--text-muted)] font-semibold",children:"Recent agents"}),y.jsx("ol",{className:"text-[11px] text-[var(--text-muted)] list-decimal list-inside space-y-0.5",children:e.agent_history.map((E,S)=>y.jsx("li",{children:E},`${S}-${E}`))})]}),y.jsxs("div",{className:"space-y-1.5",children:[y.jsx("label",{htmlFor:"iteration-limit-additional",className:"block text-[10px] uppercase tracking-wider text-[var(--text-muted)] font-semibold",children:"Additional iterations"}),y.jsx("input",{id:"iteration-limit-additional","data-testid":"iteration-limit-input",type:"number",min:0,step:1,value:l,onChange:E=>a(E.target.value),onKeyDown:w,disabled:!h,autoFocus:!0,className:"w-full text-xs px-3 py-2 rounded-lg border border-[var(--border)] bg-[var(--bg)] text-[var(--text)] outline-none focus:border-amber-400 transition-colors disabled:opacity-50"}),y.jsx("p",{className:"text-[10px] text-[var(--text-muted)]",children:"Enter a positive number to continue, or press Stop to end the workflow."})]}),t!=="connected"&&y.jsx("div",{className:"text-[11px] text-red-300",children:"Disconnected from server — reconnect to resolve this gate."})]}),y.jsxs("div",{className:"flex items-center justify-end gap-2 px-4 py-3 border-t border-[var(--border)] bg-[var(--surface-raised)]",children:[y.jsxs("button",{type:"button","data-testid":"iteration-limit-stop",onClick:b,disabled:!h,className:"flex items-center gap-1.5 text-xs px-3 py-1.5 rounded-lg border border-[var(--border)] text-[var(--text)] hover:bg-[var(--surface-hover)] disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:[y.jsx(dN,{className:"w-3.5 h-3.5"}),"Stop"]}),y.jsxs("button",{type:"button","data-testid":"iteration-limit-continue",onClick:x,disabled:m,className:"flex items-center gap-1.5 text-xs px-3 py-1.5 rounded-lg bg-amber-500 text-white hover:bg-amber-600 disabled:opacity-50 disabled:cursor-not-allowed transition-colors font-medium",children:[y.jsx(kc,{className:"w-3.5 h-3.5"}),"Continue"]})]})]})})}const F9=3e4;function Y9(){const e=ue(p=>p.processEvent),t=ue(p=>p.replayState),r=ue(p=>p.setWsStatus),l=ue(p=>p.setWsSend),a=$.useRef(null),o=$.useRef(1e3),u=$.useRef(null),c=$.useRef(null),d=$.useRef(()=>{}),h=$.useCallback(()=>{r("reconnecting"),u.current=setTimeout(()=>{o.current=Math.min(o.current*2,F9),d.current()},o.current)},[r]),m=$.useCallback(()=>{r("connecting"),c.current&&c.current.abort();const p=new AbortController;c.current=p,fetch("/api/state",{signal:p.signal}).then(x=>x.json()).then(x=>{x&&x.length>0&&t(x);const w=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/ws`;try{const E=new WebSocket(w);a.current=E,E.onopen=()=>{o.current=1e3,r("connected"),l(S=>{E.readyState===WebSocket.OPEN&&E.send(JSON.stringify(S))})},E.onmessage=S=>{try{const _=JSON.parse(S.data);e(_)}catch(_){console.error("Failed to parse WebSocket message:",_)}},E.onclose=()=>{r("disconnected"),l(null),a.current=null,h()},E.onerror=()=>{}}catch{h()}}).catch(x=>{p.signal.aborted||(console.error("Failed to fetch state:",x),h())})},[e,t,r,l,h]);d.current=m,$.useEffect(()=>(m(),()=>{c.current&&c.current.abort(),u.current&&clearTimeout(u.current),a.current&&a.current.close(),l(null)}),[m,l])}function X9(){const e=ue(h=>h.setReplayMode),t=ue(h=>h.setWsStatus),r=ue(h=>h.replayPlaying),l=ue(h=>h.replayPosition),a=ue(h=>h.replayTotalEvents),o=ue(h=>h.replaySpeed),u=ue(h=>h.replayEvents),c=ue(h=>h.setReplayPosition);$.useEffect(()=>{t("connecting"),fetch("/api/state").then(h=>h.json()).then(h=>{e(h),t("connected")}).catch(h=>{console.error("Failed to load replay events:",h),t("disconnected")})},[e,t]);const d=$.useRef(null);$.useEffect(()=>{if(!r||l>=a){d.current&&clearTimeout(d.current),r&&l>=a&&ue.getState().setReplayPlaying(!1);return}const h=u[l-1],m=u[l];let p=100;if(h&&m){const x=(m.timestamp-h.timestamp)*1e3;p=Math.max(16,Math.min(x/o,2e3))}return d.current=setTimeout(()=>{c(l+1)},p),()=>{d.current&&clearTimeout(d.current)}},[r,l,a,o,u,c])}function Q9(){return Y9(),null}function Z9(){return X9(),null}function K9(){const[e,t]=$.useState(null),r=ue(o=>o.replayMode),l=ue(o=>o.selectNode),a=ue(o=>o.workflowName);return $.useEffect(()=>{fetch("/api/replay/info").then(o=>{o.ok?t(!0):t(!1)}).catch(()=>t(!1))},[]),$.useEffect(()=>{document.title=a?`Conductor — ${a}`:"Conductor Dashboard"},[a]),$.useEffect(()=>{const o=u=>{u.key==="Escape"&&l(null)};return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[l]),e===null?null:y.jsxs("div",{className:"h-full flex flex-col bg-[var(--bg)]",children:[e?y.jsx(Z9,{}):y.jsx(Q9,{}),y.jsx(HN,{}),y.jsx(BN,{}),y.jsx(P9,{}),r?y.jsx(VN,{}):y.jsx(qN,{}),!r&&y.jsx(G9,{})]})}rN.createRoot(document.getElementById("root")).render(y.jsx($.StrictMode,{children:y.jsx(K9,{})})); diff --git a/src/conductor/web/static/index.html b/src/conductor/web/static/index.html index 40d33eb3..3d9cd197 100644 --- a/src/conductor/web/static/index.html +++ b/src/conductor/web/static/index.html @@ -5,7 +5,7 @@ Conductor Dashboard - + diff --git a/tests/test_config/test_wait_schema.py b/tests/test_config/test_wait_schema.py new file mode 100644 index 00000000..400f037b --- /dev/null +++ b/tests/test_config/test_wait_schema.py @@ -0,0 +1,256 @@ +"""Tests for ``type: wait`` schema validation. + +Covers: +- Valid wait agent definitions (literal and templated durations). +- Required ``duration`` field. +- Forbidden fields on wait agents. +- Duration bounds (> 0 and <= 24h). +- Boolean duration rejection (pre-coercion). +- Reject wait inside parallel groups and as for-each inline agents. +- Reject ``duration`` and ``reason`` on non-wait agents. +""" + +from __future__ import annotations + +import pytest +from pydantic import ValidationError as PydanticValidationError + +from conductor.config.schema import ( + AgentDef, + ForEachDef, + GateOption, + OutputField, + ParallelGroup, + RouteDef, + RuntimeConfig, + WorkflowConfig, + WorkflowDef, +) +from conductor.config.validator import validate_workflow_config +from conductor.exceptions import ConfigurationError + + +def _make_workflow( + *agents: AgentDef, + parallel: list[ParallelGroup] | None = None, + for_each: list[ForEachDef] | None = None, +) -> WorkflowConfig: + """Build a minimal WorkflowConfig for validator tests.""" + return WorkflowConfig( + workflow=WorkflowDef( + name="wait-test", + description="test", + version="1.0.0", + entry_point=agents[0].name, + runtime=RuntimeConfig(provider="copilot"), + ), + agents=list(agents), + parallel=parallel or [], + for_each=for_each or [], + ) + + +class TestValidWait: + """Wait agents accept duration as int/float/string or Jinja template.""" + + def test_int_seconds(self) -> None: + a = AgentDef(name="w", type="wait", duration=60) + assert a.type == "wait" + assert a.duration == 60 + + def test_float_seconds(self) -> None: + a = AgentDef(name="w", type="wait", duration=1.5) + assert a.duration == 1.5 + + def test_string_seconds(self) -> None: + a = AgentDef(name="w", type="wait", duration="60s") + assert a.duration == "60s" + + def test_string_minutes(self) -> None: + AgentDef(name="w", type="wait", duration="5m") + + def test_string_milliseconds(self) -> None: + AgentDef(name="w", type="wait", duration="500ms") + + def test_string_hours(self) -> None: + AgentDef(name="w", type="wait", duration="1h") + + def test_24h_cap_inclusive(self) -> None: + # Exactly 24h is allowed. + AgentDef(name="w", type="wait", duration="24h") + + def test_templated_duration_deferred(self) -> None: + # Templates are not parsed at schema time. + a = AgentDef(name="w", type="wait", duration="{{ workflow.input.x }}s") + assert a.duration == "{{ workflow.input.x }}s" + + def test_templated_garbage_deferred(self) -> None: + # Even nonsense after the template is OK at schema time. + AgentDef(name="w", type="wait", duration="{{ x }}-not-a-duration") + + def test_optional_reason(self) -> None: + a = AgentDef(name="w", type="wait", duration="1s", reason="hello") + assert a.reason == "hello" + + +class TestWaitRequiresDuration: + def test_missing_duration(self) -> None: + with pytest.raises(PydanticValidationError, match="require 'duration'"): + AgentDef(name="w", type="wait") + + +class TestWaitDurationBounds: + def test_zero_rejected(self) -> None: + with pytest.raises(PydanticValidationError, match="must be > 0"): + AgentDef(name="w", type="wait", duration=0) + + def test_negative_rejected(self) -> None: + with pytest.raises(PydanticValidationError): + AgentDef(name="w", type="wait", duration=-1) + + def test_over_24h_rejected(self) -> None: + with pytest.raises(PydanticValidationError, match="24h cap"): + AgentDef(name="w", type="wait", duration="25h") + + def test_just_over_24h_rejected(self) -> None: + with pytest.raises(PydanticValidationError, match="24h cap"): + AgentDef(name="w", type="wait", duration=86401) + + +class TestWaitDurationBool: + def test_true_rejected(self) -> None: + # Booleans must be rejected pre-coercion. Pydantic v2 would + # otherwise accept True as int 1. + with pytest.raises(PydanticValidationError, match="boolean"): + AgentDef(name="w", type="wait", duration=True) + + def test_false_rejected(self) -> None: + with pytest.raises(PydanticValidationError, match="boolean"): + AgentDef(name="w", type="wait", duration=False) + + +class TestWaitForbiddenFields: + """Fields that don't make sense for wait must be rejected.""" + + @pytest.mark.parametrize( + "field,value,match", + [ + ("prompt", "x", "'prompt'"), + ("provider", "copilot", "'provider'"), + ("model", "claude-haiku-4.5", "'model'"), + ("system_prompt", "x", "'system_prompt'"), + ("command", "ls", "'command'"), + ("working_dir", "/tmp", "'working_dir'"), + ("timeout", 5, "'timeout'"), + ("workflow", "./sub.yaml", "'workflow'"), + ("max_session_seconds", 30.0, "'max_session_seconds'"), + ("max_agent_iterations", 5, "'max_agent_iterations'"), + ("timeout_seconds", 10.0, "'timeout_seconds'"), + ], + ) + def test_forbidden(self, field: str, value: object, match: str) -> None: + kwargs = {"name": "w", "type": "wait", "duration": "1s", field: value} + with pytest.raises(PydanticValidationError, match=match): + AgentDef(**kwargs) # type: ignore[arg-type] + + def test_tools_list_rejected(self) -> None: + with pytest.raises(PydanticValidationError, match="'tools'"): + AgentDef(name="w", type="wait", duration="1s", tools=["foo"]) + + def test_options_rejected(self) -> None: + with pytest.raises(PydanticValidationError, match="'options'"): + AgentDef( + name="w", + type="wait", + duration="1s", + options=[GateOption(label="x", value="x", route="$end")], + ) + + def test_args_rejected(self) -> None: + with pytest.raises(PydanticValidationError, match="'args'"): + AgentDef(name="w", type="wait", duration="1s", args=["x"]) + + def test_env_rejected(self) -> None: + with pytest.raises(PydanticValidationError, match="'env'"): + AgentDef(name="w", type="wait", duration="1s", env={"FOO": "bar"}) + + def test_input_mapping_rejected(self) -> None: + with pytest.raises(PydanticValidationError, match="'input_mapping'"): + AgentDef(name="w", type="wait", duration="1s", input_mapping={"x": "y"}) + + def test_max_depth_rejected(self) -> None: + with pytest.raises(PydanticValidationError, match="'max_depth'"): + AgentDef(name="w", type="wait", duration="1s", max_depth=2) + + def test_output_rejected(self) -> None: + with pytest.raises(PydanticValidationError, match="'output'"): + AgentDef( + name="w", + type="wait", + duration="1s", + output={"x": {"type": "string"}}, + ) + + +class TestWaitFieldsOnOtherTypes: + """duration/reason are wait-only — other types must reject them.""" + + def test_duration_on_plain_agent(self) -> None: + with pytest.raises(PydanticValidationError, match="'duration'"): + AgentDef(name="a", duration="1s", prompt="hi", model="x") + + def test_reason_on_plain_agent(self) -> None: + with pytest.raises(PydanticValidationError, match="'reason'"): + AgentDef(name="a", reason="x", prompt="hi", model="x") + + def test_duration_on_script(self) -> None: + with pytest.raises(PydanticValidationError, match="'duration'"): + AgentDef(name="s", type="script", command="ls", duration="1s") + + +class TestWaitInParallelOrForEach: + """Wait steps cannot be used in parallel groups or for-each groups.""" + + def test_reject_wait_in_parallel(self) -> None: + wait = AgentDef(name="w", type="wait", duration="1s", routes=[RouteDef(to="$end")]) + other = AgentDef(name="o", type="wait", duration="1s", routes=[RouteDef(to="$end")]) + config = _make_workflow( + wait, + other, + parallel=[ParallelGroup(name="pg", agents=["w", "o"], routes=[RouteDef(to="$end")])], + ) + with pytest.raises(ConfigurationError, match="Wait steps cannot be used in parallel"): + validate_workflow_config(config) + + def test_reject_wait_in_for_each(self) -> None: + wait = AgentDef(name="w", type="wait", duration="1s", routes=[RouteDef(to="$end")]) + # An entry-point agent + a producer agent (so the for-each + # source resolves to a real agent reference). + entry = AgentDef( + name="entry", + prompt="x", + model="m", + output={"items": OutputField(type="array", items={"type": "string"})}, + routes=[RouteDef(to="fe")], + ) + for_each = ForEachDef( + name="fe", + type="for_each", + source="entry.output.items", + **{"as": "item"}, + agent=wait, + routes=[RouteDef(to="$end")], + ) + config = _make_workflow(entry, for_each=[for_each]) + with pytest.raises(ConfigurationError, match="Wait steps cannot be used in for_each"): + validate_workflow_config(config) + + +class TestWaitValidationViaWorkflow: + """Smoke test: a workflow containing only a wait step validates.""" + + def test_minimal_wait_workflow(self) -> None: + wait = AgentDef(name="w", type="wait", duration="100ms", routes=[RouteDef(to="$end")]) + config = _make_workflow(wait) + # Should not raise. + validate_workflow_config(config) diff --git a/tests/test_engine/test_duration.py b/tests/test_engine/test_duration.py new file mode 100644 index 00000000..ce0038c8 --- /dev/null +++ b/tests/test_engine/test_duration.py @@ -0,0 +1,120 @@ +"""Tests for the duration parser used by the wait step. + +Covers plain numeric inputs, all supported unit suffixes, whitespace +tolerance, and rejection of malformed / unsupported values. +""" + +from __future__ import annotations + +import pytest + +from conductor.duration import parse_duration + + +class TestParseDurationNumeric: + """Plain numeric durations are interpreted as seconds.""" + + def test_int(self) -> None: + assert parse_duration(60) == 60.0 + + def test_zero(self) -> None: + assert parse_duration(0) == 0.0 + + def test_float(self) -> None: + assert parse_duration(1.5) == 1.5 + + def test_returns_float(self) -> None: + assert isinstance(parse_duration(1), float) + + +class TestParseDurationStrings: + """String durations support ms/s/m/h suffixes and bare numbers.""" + + def test_bare_number(self) -> None: + assert parse_duration("60") == 60.0 + + def test_bare_float(self) -> None: + assert parse_duration("2.5") == 2.5 + + def test_seconds_suffix(self) -> None: + assert parse_duration("60s") == 60.0 + + def test_milliseconds(self) -> None: + assert parse_duration("500ms") == 0.5 + + def test_minutes(self) -> None: + assert parse_duration("5m") == 300.0 + + def test_fractional_minutes(self) -> None: + assert parse_duration("2.5m") == 150.0 + + def test_hours(self) -> None: + assert parse_duration("1h") == 3600.0 + + def test_fractional_hours(self) -> None: + assert parse_duration("0.5h") == 1800.0 + + +class TestParseDurationWhitespace: + """Surrounding and intra-token whitespace is tolerated.""" + + def test_leading_trailing(self) -> None: + assert parse_duration(" 60s ") == 60.0 + + def test_between_value_and_unit(self) -> None: + assert parse_duration("60 s") == 60.0 + + def test_lots_of_whitespace(self) -> None: + assert parse_duration("\t 5 m \n") == 300.0 + + +class TestParseDurationRejects: + """Malformed and unsupported inputs raise ValueError.""" + + def test_bool_true(self) -> None: + with pytest.raises(ValueError, match="boolean"): + parse_duration(True) # type: ignore[arg-type] + + def test_bool_false(self) -> None: + with pytest.raises(ValueError, match="boolean"): + parse_duration(False) # type: ignore[arg-type] + + def test_empty_string(self) -> None: + with pytest.raises(ValueError): + parse_duration("") + + def test_whitespace_only(self) -> None: + with pytest.raises(ValueError): + parse_duration(" ") + + def test_unsupported_unit_d(self) -> None: + with pytest.raises(ValueError): + parse_duration("1d") + + def test_unsupported_unit_us(self) -> None: + with pytest.raises(ValueError): + parse_duration("100us") + + def test_garbage(self) -> None: + with pytest.raises(ValueError): + parse_duration("forever") + + def test_negative_number(self) -> None: + # Bare negatives are not matched by the parser. (Out-of-range + # checks are the caller's responsibility, but we don't accept + # negative literals because the grammar reads as "[unit]" + # with non-negative numbers.) + with pytest.raises(ValueError): + parse_duration("-5s") + + def test_none(self) -> None: + with pytest.raises(ValueError): + parse_duration(None) # type: ignore[arg-type] + + def test_list(self) -> None: + with pytest.raises(ValueError): + parse_duration([60]) # type: ignore[arg-type] + + def test_number_then_garbage(self) -> None: + with pytest.raises(ValueError): + parse_duration("5 minutes") diff --git a/tests/test_engine/test_wait_workflow.py b/tests/test_engine/test_wait_workflow.py new file mode 100644 index 00000000..9f9aa57c --- /dev/null +++ b/tests/test_engine/test_wait_workflow.py @@ -0,0 +1,249 @@ +"""Integration tests for ``type: wait`` steps in :class:`WorkflowEngine`. + +Tests cover: +- Linear workflow with a wait step that routes to ``$end``. +- Wait output (``{"waited_seconds": float}``) accessible in downstream + agent context. +- Workflow-level ``limits.timeout_seconds`` cancels an in-flight wait + via :class:`ConductorTimeoutError`. +- Interrupt event during a wait surfaces in events and stops execution. +- Emits expected ``agent_started`` (with ``agent_type: "wait"``), + ``wait_started``, and ``wait_completed`` events. +""" + +from __future__ import annotations + +import asyncio +import contextlib +from unittest.mock import MagicMock + +import pytest + +from conductor.config.schema import ( + AgentDef, + ContextConfig, + LimitsConfig, + RouteDef, + RuntimeConfig, + WorkflowConfig, + WorkflowDef, +) +from conductor.engine.workflow import WorkflowEngine +from conductor.events import WorkflowEvent, WorkflowEventEmitter +from conductor.exceptions import TimeoutError as ConductorTimeoutError + + +def _make_config( + agents: list[AgentDef], + *, + entry: str, + timeout_seconds: int | None = None, + output: dict[str, str] | None = None, +) -> WorkflowConfig: + return WorkflowConfig( + workflow=WorkflowDef( + name="wait-test", + description="wait test", + version="1.0.0", + entry_point=entry, + runtime=RuntimeConfig(provider="copilot"), + context=ContextConfig(mode="accumulate"), + limits=LimitsConfig(max_iterations=10, timeout_seconds=timeout_seconds), + ), + agents=agents, + output=output or {}, + ) + + +class TestWaitWorkflowLinear: + @pytest.mark.asyncio + async def test_wait_runs_to_end(self) -> None: + config = _make_config( + [ + AgentDef( + name="pause", + type="wait", + duration="50ms", + routes=[RouteDef(to="$end")], + ), + ], + entry="pause", + output={"slept": "{{ pause.output.waited_seconds }}"}, + ) + engine = WorkflowEngine(config, MagicMock()) + result = await engine.run({}) + assert "slept" in result + # Output is rendered to a string by the workflow output template. + assert float(result["slept"]) >= 0.04 + + @pytest.mark.asyncio + async def test_wait_output_only_has_waited_seconds(self) -> None: + """Per issue #218, the wait output contract is strict: only + ``waited_seconds`` is exposed in workflow context.""" + config = _make_config( + [ + AgentDef( + name="pause", + type="wait", + duration="20ms", + reason="should not leak into context", + routes=[RouteDef(to="$end")], + ), + ], + entry="pause", + ) + engine = WorkflowEngine(config, MagicMock()) + await engine.run({}) + # Stored under pause.output — must contain ONLY waited_seconds. + stored = engine.context.get_for_template().get("pause", {}).get("output", {}) + assert set(stored.keys()) == {"waited_seconds"} + assert stored["waited_seconds"] >= 0.01 + + +class TestWaitWorkflowTimeout: + @pytest.mark.asyncio + async def test_workflow_timeout_cancels_wait(self) -> None: + """A long wait must be cancelled by the workflow-level timeout.""" + config = _make_config( + [ + AgentDef( + name="long_pause", + type="wait", + duration="60s", + routes=[RouteDef(to="$end")], + ), + ], + entry="long_pause", + timeout_seconds=1, + ) + engine = WorkflowEngine(config, MagicMock()) + with pytest.raises(ConductorTimeoutError): + await engine.run({}) + + +class TestWaitWorkflowEvents: + @pytest.mark.asyncio + async def test_emits_wait_lifecycle(self) -> None: + emitter = WorkflowEventEmitter() + events: list[WorkflowEvent] = [] + emitter.subscribe(events.append) + + config = _make_config( + [ + AgentDef( + name="pause", + type="wait", + duration="20ms", + reason="quick", + routes=[RouteDef(to="$end")], + ), + ], + entry="pause", + ) + engine = WorkflowEngine(config, MagicMock(), event_emitter=emitter) + await engine.run({}) + + types = [e.type for e in events] + assert "agent_started" in types + assert "wait_started" in types + assert "wait_completed" in types + + # agent_started carries the agent_type discriminator. + started = next(e for e in events if e.type == "agent_started") + assert started.data.get("agent_type") == "wait" + + ws = next(e for e in events if e.type == "wait_started") + assert ws.data["agent_name"] == "pause" + assert ws.data["duration_seconds"] == pytest.approx(0.02) + assert ws.data["reason"] == "quick" + + wc = next(e for e in events if e.type == "wait_completed") + assert wc.data["agent_name"] == "pause" + assert wc.data["waited_seconds"] >= 0.01 + assert wc.data["requested_seconds"] == pytest.approx(0.02) + assert wc.data["interrupted"] is False + + +class TestWaitWorkflowTemplatedDuration: + @pytest.mark.asyncio + async def test_templated_duration_from_workflow_input(self) -> None: + config = WorkflowConfig( + workflow=WorkflowDef( + name="wait-templated", + entry_point="pause", + runtime=RuntimeConfig(provider="copilot"), + context=ContextConfig(mode="accumulate"), + limits=LimitsConfig(max_iterations=5), + input={ + "interval_ms": { # type: ignore[dict-item] + "type": "number", + "default": 30, + } + }, + ), + agents=[ + AgentDef( + name="pause", + type="wait", + duration="{{ workflow.input.interval_ms }}ms", + routes=[RouteDef(to="$end")], + ), + ], + ) + engine = WorkflowEngine(config, MagicMock()) + await engine.run({"interval_ms": 25}) + stored = engine.context.get_for_template().get("pause", {}).get("output", {}) + assert stored["waited_seconds"] >= 0.02 + + +class TestWaitWorkflowInterrupt: + @pytest.mark.asyncio + async def test_interrupt_event_cuts_wait_short(self) -> None: + """When the interrupt event fires mid-wait, the wait completes + early with ``interrupted=True`` and the next agent receives + control as soon as the between-step interrupt check returns. + + We use ``skip_gates=True`` so the interrupt handler auto-stops + without trying to prompt the user, and assert on the emitted + ``wait_completed`` payload rather than the engine's outcome + (which is governed by the generic interrupt path, not by wait). + """ + emitter = WorkflowEventEmitter() + events: list[WorkflowEvent] = [] + emitter.subscribe(events.append) + + interrupt_event = asyncio.Event() + config = _make_config( + [ + AgentDef( + name="long_pause", + type="wait", + duration="30s", + routes=[RouteDef(to="$end")], + ), + ], + entry="long_pause", + ) + engine = WorkflowEngine( + config, + MagicMock(), + event_emitter=emitter, + interrupt_event=interrupt_event, + skip_gates=True, + ) + + async def kick() -> None: + await asyncio.sleep(0.1) + interrupt_event.set() + + # We don't care what the engine ultimately raises — it depends + # on the interactive interrupt path. We only care that the wait + # itself was cut short. + with contextlib.suppress(BaseException): + await asyncio.gather(engine.run({}), kick()) + + wait_completed = [e for e in events if e.type == "wait_completed"] + assert wait_completed, "expected a wait_completed event" + payload = wait_completed[0].data + assert payload["interrupted"] is True + assert payload["waited_seconds"] < 5.0 # nowhere near 30s diff --git a/tests/test_executor/test_wait.py b/tests/test_executor/test_wait.py new file mode 100644 index 00000000..e0e51218 --- /dev/null +++ b/tests/test_executor/test_wait.py @@ -0,0 +1,131 @@ +"""Tests for :class:`WaitExecutor`. + +Covers: +- Plain numeric and suffixed-string durations. +- Templated durations rendered from context. +- Interrupt event cancels sleep early; ``interrupted=True`` and + elapsed < requested. +- Runtime validation errors for unparseable / out-of-range durations. +""" + +from __future__ import annotations + +import asyncio + +import pytest + +from conductor.config.schema import AgentDef +from conductor.exceptions import ValidationError +from conductor.executor.wait import WaitExecutor, WaitOutput + + +@pytest.fixture +def executor() -> WaitExecutor: + return WaitExecutor() + + +class TestWaitOutput: + def test_fields(self) -> None: + out = WaitOutput(waited_seconds=0.1, requested_seconds=0.1, reason=None, interrupted=False) + assert out.waited_seconds == 0.1 + assert out.interrupted is False + + +class TestWaitExecutorBasic: + @pytest.mark.asyncio + async def test_short_sleep(self, executor: WaitExecutor) -> None: + agent = AgentDef(name="w", type="wait", duration="100ms") + out = await executor.execute(agent, {}) + assert 0.09 <= out.waited_seconds < 1.0 + assert out.requested_seconds == 0.1 + assert out.interrupted is False + assert out.reason is None + + @pytest.mark.asyncio + async def test_numeric_duration(self, executor: WaitExecutor) -> None: + agent = AgentDef(name="w", type="wait", duration=0.05) + out = await executor.execute(agent, {}) + assert out.requested_seconds == 0.05 + assert out.waited_seconds >= 0.04 + + @pytest.mark.asyncio + async def test_reason_rendered(self, executor: WaitExecutor) -> None: + agent = AgentDef(name="w", type="wait", duration="50ms", reason="hi {{ name }}") + out = await executor.execute(agent, {"name": "there"}) + assert out.reason == "hi there" + + @pytest.mark.asyncio + async def test_templated_duration(self, executor: WaitExecutor) -> None: + agent = AgentDef( + name="w", + type="wait", + duration="{{ workflow.input.interval }}ms", + ) + out = await executor.execute(agent, {"workflow": {"input": {"interval": 50}}}) + assert out.requested_seconds == 0.05 + + +class TestWaitExecutorInterrupt: + @pytest.mark.asyncio + async def test_interrupt_cancels_early(self, executor: WaitExecutor) -> None: + agent = AgentDef(name="w", type="wait", duration="10s") + ev = asyncio.Event() + task = asyncio.create_task(executor.execute(agent, {}, interrupt_event=ev)) + await asyncio.sleep(0.05) + ev.set() + out = await task + assert out.interrupted is True + assert out.waited_seconds < 1.0 + # The event MUST remain set so the engine's between-step + # _check_interrupt can consume it and trigger the user menu. + assert ev.is_set() + + @pytest.mark.asyncio + async def test_no_interrupt_runs_to_completion(self, executor: WaitExecutor) -> None: + agent = AgentDef(name="w", type="wait", duration="50ms") + ev = asyncio.Event() + out = await executor.execute(agent, {}, interrupt_event=ev) + assert out.interrupted is False + assert out.waited_seconds >= 0.04 + + @pytest.mark.asyncio + async def test_outer_cancellation_propagates(self, executor: WaitExecutor) -> None: + agent = AgentDef(name="w", type="wait", duration="10s") + ev = asyncio.Event() + task = asyncio.create_task(executor.execute(agent, {}, interrupt_event=ev)) + await asyncio.sleep(0.05) + task.cancel() + with pytest.raises(asyncio.CancelledError): + await task + + +class TestWaitExecutorRuntimeValidation: + """Bounds and parse errors that can arise from templated durations.""" + + @pytest.mark.asyncio + async def test_unparseable_duration(self, executor: WaitExecutor) -> None: + # Bypass the schema by constructing via model_construct (skips + # validation), then trip the runtime parser. + agent = AgentDef.model_construct(name="w", type="wait", duration="forever") + with pytest.raises(ValidationError, match="Wait 'w'"): + await executor.execute(agent, {}) + + @pytest.mark.asyncio + async def test_zero_duration_via_template(self, executor: WaitExecutor) -> None: + agent = AgentDef( + name="w", + type="wait", + duration="{{ workflow.input.interval }}s", + ) + with pytest.raises(ValidationError, match="must be > 0"): + await executor.execute(agent, {"workflow": {"input": {"interval": 0}}}) + + @pytest.mark.asyncio + async def test_over_cap_via_template(self, executor: WaitExecutor) -> None: + agent = AgentDef( + name="w", + type="wait", + duration="{{ workflow.input.interval }}h", + ) + with pytest.raises(ValidationError, match="24h cap"): + await executor.execute(agent, {"workflow": {"input": {"interval": 25}}}) From 54f54e779dee010c0d38bf570192dfdf64215b32 Mon Sep 17 00:00:00 2001 From: Jason Robert Date: Thu, 21 May 2026 15:17:49 -0400 Subject: [PATCH 2/3] chore(wait): address PR #224 review findings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Follow-up to feat(engine): add type: wait step (#218) addressing findings from the pr-review-toolkit pass. Code fixes: - schema.py: drop the duplicate isinstance(value, bool) guard inside _validate_wait_duration. The reject_bool_duration field validator (mode="before") already catches booleans pre-coercion in normal construction; the duplicate was unreachable. Replace with a docstring note pointing at the field validator. (Flagged by dead-code-finder, type-design-analyzer, and comment-analyzer.) - engine/workflow.py wait dispatch preview block: * Replace the redundant `except (ValueError, Exception)` tuple with a bare `except Exception` (ValueError is a subclass). * Add a `logger.debug` line on preview render failure so the path is no longer silent. * For preview_reason, fall back to None instead of the raw template string — the dashboard previously displayed literal Jinja markup like `{{ x }}` until wait_failed fired; None is the correct "absent" signal. (Flagged by silent-failure-hunter and code-reviewer.) - executor/wait.py _sleep_with_interrupt cleanup: narrow `contextlib.suppress(CancelledError, Exception)` to `suppress(CancelledError)` to match the success-path cleanup. Genuine errors from future, non- trivial awaitables should not be silently swallowed during cleanup. (Flagged by silent-failure-hunter.) Test additions / improvements: - test_web/test_server.py: new test_emits_wait_events_for_wait_type pins the _synth_agent_or_script wait branch contract (event names, synthetic flag, duration_seconds/reason/interrupted fields). This was the largest coverage gap — resume replay had no test. - test_engine/test_wait_workflow.py: new test_emits_wait_failed_on_runtime_validation verifies a wait_failed event is emitted with error_type="ValidationError" and the expected message before the exception unwinds. Closes the gap where a refactor dropping the try/except in the dispatch branch would leave the dashboard with a hanging "started but never completed" node. - test_executor/test_wait.py + test_engine/test_wait_workflow.py: loosen wall-clock lower bounds (>= 0.09 / >= 0.04 / >= 0.01 / etc.) that risked CI flakes on loaded runners. The executor's contract is "sleep at least roughly this long unless interrupted", and the interrupted=False check is the real invariant — the precise elapsed value is not what these tests are pinning. All 1463 tests in tests/test_config + tests/test_engine + tests/test_executor + tests/test_web pass. `make lint` is clean. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- src/conductor/config/schema.py | 14 +++--- src/conductor/engine/workflow.py | 31 ++++++++++--- src/conductor/executor/wait.py | 7 ++- tests/test_engine/test_wait_workflow.py | 59 +++++++++++++++++++++++-- tests/test_executor/test_wait.py | 10 ++++- tests/test_web/test_server.py | 33 +++++++++++++- 6 files changed, 131 insertions(+), 23 deletions(-) diff --git a/src/conductor/config/schema.py b/src/conductor/config/schema.py index 8a048dc0..9232da87 100644 --- a/src/conductor/config/schema.py +++ b/src/conductor/config/schema.py @@ -874,15 +874,15 @@ def validate_agent_type(self) -> AgentDef: def _validate_wait_duration(self) -> None: """Validate ``duration`` for a ``wait`` agent. - Booleans are rejected outright. Templated durations (containing - ``{{``) defer all literal validation to runtime; for everything - else we parse the value and enforce ``0 < d <= 24h``. + Templated durations (containing ``{{``) defer all literal + validation to runtime; for everything else we parse the value + and enforce ``0 < d <= MAX_WAIT_DURATION_SECONDS``. + + Note: Booleans are already rejected pre-coercion by the + :meth:`reject_bool_duration` ``mode="before"`` field validator, + so this method never sees ``True``/``False``. """ value = self.duration - if isinstance(value, bool): - raise ValueError( - f"wait duration must be a number or duration string, not boolean: {value!r}" - ) if isinstance(value, str) and "{{" in value: return diff --git a/src/conductor/engine/workflow.py b/src/conductor/engine/workflow.py index c9c833ae..9658c4fc 100644 --- a/src/conductor/engine/workflow.py +++ b/src/conductor/engine/workflow.py @@ -2434,10 +2434,12 @@ async def _execute_loop(self, current_agent_name: str) -> dict[str, Any]: # Resolve the duration up-front so the # ``wait_started`` event includes the parsed # value (the dashboard renders a sleeping - # pill keyed off this). Templated durations - # that can't be rendered will raise inside - # ``_execute_wait`` below; emit ``None`` here - # so the event still fires for debuggability. + # pill keyed off this). Failures here are + # preview-only — the canonical render+parse + # runs inside ``_execute_wait`` below and + # will surface the real error via + # ``wait_failed``. Log at debug so the + # preview path is still observable. try: rendered_duration = self.renderer.render( str(agent.duration), agent_context @@ -2445,7 +2447,12 @@ async def _execute_loop(self, current_agent_name: str) -> dict[str, Any]: preview_duration_seconds: float | None = parse_duration( rendered_duration ) - except (ValueError, Exception): # noqa: BLE001 — defensive + except Exception as exc: # noqa: BLE001 — defensive preview + logger.debug( + "wait_started preview duration render failed for %s: %s", + agent.name, + exc, + ) preview_duration_seconds = None preview_reason: str | None = None if agent.reason is not None: @@ -2453,8 +2460,18 @@ async def _execute_loop(self, current_agent_name: str) -> dict[str, Any]: preview_reason = self.renderer.render( agent.reason, agent_context ) - except Exception: # noqa: BLE001 — defensive - preview_reason = agent.reason + except Exception as exc: # noqa: BLE001 — defensive preview + # Do NOT fall back to the raw + # template string — the dashboard + # would then display literal + # ``{{ ... }}`` markup. ``None`` is + # the correct "absent" signal. + logger.debug( + "wait_started preview reason render failed for %s: %s", + agent.name, + exc, + ) + preview_reason = None self._emit( "wait_started", diff --git a/src/conductor/executor/wait.py b/src/conductor/executor/wait.py index ed12fabb..0e65e3f1 100644 --- a/src/conductor/executor/wait.py +++ b/src/conductor/executor/wait.py @@ -179,11 +179,14 @@ async def _sleep_with_interrupt(seconds: float, interrupt_event: asyncio.Event | except BaseException: # Cancellation from outside (e.g., workflow timeout) — clean # up both tasks and re-raise so wait_for / outer cancellation - # handlers see the original exception. + # handlers see the original exception. Only suppress + # CancelledError during cleanup (matches the success path + # above); a genuine exception from a future, non-trivial + # awaitable should not be silently swallowed. for t in (sleep_task, interrupt_task): if not t.done(): t.cancel() - with contextlib.suppress(asyncio.CancelledError, Exception): + with contextlib.suppress(asyncio.CancelledError): await t raise diff --git a/tests/test_engine/test_wait_workflow.py b/tests/test_engine/test_wait_workflow.py index 9f9aa57c..3bb2eac7 100644 --- a/tests/test_engine/test_wait_workflow.py +++ b/tests/test_engine/test_wait_workflow.py @@ -74,7 +74,10 @@ async def test_wait_runs_to_end(self) -> None: result = await engine.run({}) assert "slept" in result # Output is rendered to a string by the workflow output template. - assert float(result["slept"]) >= 0.04 + # Avoid a tight lower bound — CI scheduling jitter can land the + # measured value slightly under the requested duration. + assert float(result["slept"]) >= 0.0 + assert float(result["slept"]) < 5.0 @pytest.mark.asyncio async def test_wait_output_only_has_waited_seconds(self) -> None: @@ -97,7 +100,7 @@ async def test_wait_output_only_has_waited_seconds(self) -> None: # Stored under pause.output — must contain ONLY waited_seconds. stored = engine.context.get_for_template().get("pause", {}).get("output", {}) assert set(stored.keys()) == {"waited_seconds"} - assert stored["waited_seconds"] >= 0.01 + assert stored["waited_seconds"] >= 0.0 class TestWaitWorkflowTimeout: @@ -159,10 +162,58 @@ async def test_emits_wait_lifecycle(self) -> None: wc = next(e for e in events if e.type == "wait_completed") assert wc.data["agent_name"] == "pause" - assert wc.data["waited_seconds"] >= 0.01 + assert wc.data["waited_seconds"] >= 0.0 assert wc.data["requested_seconds"] == pytest.approx(0.02) assert wc.data["interrupted"] is False + @pytest.mark.asyncio + async def test_emits_wait_failed_on_runtime_validation(self) -> None: + """Runtime validation errors (e.g. a templated duration that + evaluates to a value over the 24h cap) must emit a + ``wait_failed`` event before the exception unwinds. Without + this, the dashboard would show a hanging "started but never + completed" wait node on any failure.""" + from conductor.exceptions import ValidationError + + emitter = WorkflowEventEmitter() + events: list[WorkflowEvent] = [] + emitter.subscribe(events.append) + + config = WorkflowConfig( + workflow=WorkflowDef( + name="wait-failed", + entry_point="pause", + runtime=RuntimeConfig(provider="copilot"), + context=ContextConfig(mode="accumulate"), + limits=LimitsConfig(max_iterations=5), + input={ + "hours": { # type: ignore[dict-item] + "type": "number", + "default": 25, + } + }, + ), + agents=[ + AgentDef( + name="pause", + type="wait", + duration="{{ workflow.input.hours }}h", + routes=[RouteDef(to="$end")], + ), + ], + ) + engine = WorkflowEngine(config, MagicMock(), event_emitter=emitter) + with pytest.raises(ValidationError): + await engine.run({"hours": 25}) + + failed = [e for e in events if e.type == "wait_failed"] + assert failed, "expected a wait_failed event" + data = failed[0].data + assert data["agent_name"] == "pause" + assert data["error_type"] == "ValidationError" + assert "24h cap" in data["message"] + assert "elapsed" in data + class TestWaitWorkflowTemplatedDuration: @pytest.mark.asyncio @@ -193,7 +244,7 @@ async def test_templated_duration_from_workflow_input(self) -> None: engine = WorkflowEngine(config, MagicMock()) await engine.run({"interval_ms": 25}) stored = engine.context.get_for_template().get("pause", {}).get("output", {}) - assert stored["waited_seconds"] >= 0.02 + assert stored["waited_seconds"] >= 0.0 class TestWaitWorkflowInterrupt: diff --git a/tests/test_executor/test_wait.py b/tests/test_executor/test_wait.py index e0e51218..952d2951 100644 --- a/tests/test_executor/test_wait.py +++ b/tests/test_executor/test_wait.py @@ -36,7 +36,12 @@ class TestWaitExecutorBasic: async def test_short_sleep(self, executor: WaitExecutor) -> None: agent = AgentDef(name="w", type="wait", duration="100ms") out = await executor.execute(agent, {}) - assert 0.09 <= out.waited_seconds < 1.0 + # Don't assert a tight lower bound — event-loop scheduling jitter + # on loaded CI can make the monotonic elapsed slightly under the + # requested duration. The contract is "sleep at least roughly + # this long unless interrupted", and ``not interrupted`` is the + # actual invariant. + assert out.waited_seconds < 1.0 assert out.requested_seconds == 0.1 assert out.interrupted is False assert out.reason is None @@ -46,7 +51,8 @@ async def test_numeric_duration(self, executor: WaitExecutor) -> None: agent = AgentDef(name="w", type="wait", duration=0.05) out = await executor.execute(agent, {}) assert out.requested_seconds == 0.05 - assert out.waited_seconds >= 0.04 + assert out.waited_seconds < 1.0 + assert out.interrupted is False @pytest.mark.asyncio async def test_reason_rendered(self, executor: WaitExecutor) -> None: diff --git a/tests/test_web/test_server.py b/tests/test_web/test_server.py index d31386f2..db769d48 100644 --- a/tests/test_web/test_server.py +++ b/tests/test_web/test_server.py @@ -1110,7 +1110,7 @@ class TestReplaySyntheticFromContext: """Tests for WebDashboard.replay_synthetic_from_context (issue #167 fallback).""" def _build_config(self): - """Build a minimal WorkflowConfig with one agent + one script for tests.""" + """Build a minimal WorkflowConfig with one agent + one script + one wait for tests.""" from conductor.config.schema import AgentDef, RuntimeConfig, WorkflowConfig, WorkflowDef return WorkflowConfig( @@ -1122,6 +1122,7 @@ def _build_config(self): agents=[ AgentDef(name="a", prompt="x", routes=[]), AgentDef(name="s", type="script", command="echo hi", routes=[]), + AgentDef(name="w", type="wait", duration="5s", reason="cooldown", routes=[]), ], ) @@ -1156,6 +1157,36 @@ def test_emits_script_events_for_script_type(self) -> None: assert types == ["script_started", "script_completed"] assert dashboard._event_history[1]["data"]["stdout"] == "hi" + def test_emits_wait_events_for_wait_type(self) -> None: + """Wait steps replay via _synth_agent_or_script's wait branch + (issue #218). The synthetic event pair must use the + wait_started/wait_completed names, propagate the persisted + waited_seconds, carry the AgentDef's reason, and mark + ``synthetic: True`` so the UI can identify replayed state.""" + from conductor.engine.context import WorkflowContext + + emitter, dashboard = _make_dashboard() + ctx = WorkflowContext() + ctx.store("w", {"waited_seconds": 3.5}) + + count = dashboard.replay_synthetic_from_context(ctx, self._build_config()) + + assert count == 2 + types = [ev["type"] for ev in dashboard._event_history] + assert types == ["wait_started", "wait_completed"] + started = dashboard._event_history[0]["data"] + completed = dashboard._event_history[1]["data"] + assert started["agent_name"] == "w" + assert started["duration_seconds"] == 3.5 + assert started["reason"] == "cooldown" + assert started["synthetic"] is True + assert completed["agent_name"] == "w" + assert completed["waited_seconds"] == 3.5 + assert completed["requested_seconds"] == 3.5 + assert completed["reason"] == "cooldown" + assert completed["interrupted"] is False + assert completed["synthetic"] is True + def test_empty_history_returns_zero(self) -> None: from conductor.engine.context import WorkflowContext From c03dc57a52257e17665687cff3929d47f6a9330d Mon Sep 17 00:00:00 2001 From: Jason Robert Date: Thu, 21 May 2026 15:48:53 -0400 Subject: [PATCH 3/3] docs(wait): document type: wait step across user docs and skill references MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Follow-up to PR #224 — propagate the new `type: wait` step into all user-facing documentation and the bundled conductor skill so authors and AI assistants discover it. User docs: - docs/workflow-syntax.md: add full Wait Steps section after Script Steps (duration formats, output contract, polling loop-back pattern, cancellation semantics, restrictions, example link). Update the type literal comment to include `wait`. Note that wait steps count toward `max_iterations`. Update the dialog-mode forbidden-type list. - docs/configuration.md: add `wait` to the list of agent types where `reasoning.effort` is rejected (don't call a model). - README.md: add wait-step.yaml to the examples table. - AGENTS.md: document `executor/wait.py` and the new top-level `conductor/duration.py` helper module. Update the workflow execution flow steps to include wait. - examples/README.md: add a "Step Types" section documenting both script-step.yaml (previously undocumented) and the new wait-step.yaml. Skill references (plugins/conductor/skills/conductor/): - SKILL.md: add wait entry to the Key Concepts table. - references/yaml-schema.md: extend the type-literal enumeration; add a full Wait Agent Schema section (duration format, output, full forbidden-field list, cancellation); update parallel-group and for-each validation rules to mention wait; extend the reasoning/retry/timeout_seconds forbidden-type comments. - references/authoring.md: extend the type-literal comment; add a full Wait Steps (`type: wait`) section (duration format, output, polling loop-back pattern, cancellation, restrictions); extend the reasoning/retry/timeout_seconds/dialog forbidden-type lists. CHANGELOG.md: - Add an Unreleased entry summarizing the wait step feature, with PR/issue references. Verification: - `make validate-examples` passes (including wait-step.yaml). - All cross-references to step-type restrictions are now consistent across user docs and skill references. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- AGENTS.md | 10 ++- CHANGELOG.md | 28 +++++++ README.md | 1 + docs/configuration.md | 4 +- docs/workflow-syntax.md | 70 ++++++++++++++++- examples/README.md | 28 +++++++ plugins/conductor/skills/conductor/SKILL.md | 1 + .../skills/conductor/references/authoring.md | 76 +++++++++++++++++-- .../conductor/references/yaml-schema.md | 55 ++++++++++++-- 9 files changed, 256 insertions(+), 17 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index ae893226..71aa4165 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -86,9 +86,12 @@ make validate-examples # validate all examples - **executor/**: Agent execution - `agent.py` - `AgentExecutor` handles prompt rendering, tool resolution, and output validation for single agents - `script.py` - `ScriptExecutor` runs shell commands as workflow steps, capturing stdout/stderr/exit_code + - `wait.py` - `WaitExecutor` pauses workflow execution for a parsed duration via `asyncio.sleep`. Races the sleep against the engine's `interrupt_event` so Esc/Ctrl+G cancels in-flight waits immediately; the workflow-level `limits.timeout_seconds` also cancels it via `LimitEnforcer.wait_for_with_timeout`. Output contract is strictly `{"waited_seconds": float}` per issue #218. - `template.py` - Jinja2 template rendering - `output.py` - JSON output parsing and schema validation +- **duration.py**: `parse_duration(value)` shared helper. Accepts plain `int`/`float` seconds, or strings with `ms`/`s`/`m`/`h` suffix. Raises `ValueError` (nests cleanly inside Pydantic `ValidationError`). Rejects booleans. Bounds enforcement (e.g. > 0, 24h cap) lives in callers so the parser can be reused. + - **providers/**: SDK provider abstraction - `base.py` - `AgentProvider` ABC defining `execute()`, `validate_connection()`, `close()` - `copilot.py` - GitHub Copilot SDK implementation @@ -113,12 +116,13 @@ make validate-examples # validate all examples 1. CLI parses YAML via `config/loader.py` → `WorkflowConfig` 2. `WorkflowEngine` initializes with config and provider -3. Engine loops: find agent/parallel/for-each/script → execute → evaluate routes → next +3. Engine loops: find agent/parallel/for-each/script/wait → execute → evaluate routes → next 4. Parallel groups execute agents concurrently with context isolation (deep copy snapshot) 5. For-each groups resolve source arrays at runtime, inject loop variables (`{{ item }}`, `{{ _index }}`, `{{ _key }}`) 6. Script steps run shell commands via asyncio subprocess, expose stdout/stderr/exit_code to context -7. Routes evaluated via `Router` using Jinja2 or simpleeval expressions -8. Final output built from templates in `output:` section +7. Wait steps pause via `asyncio.sleep` (cancellable by interrupt or workflow timeout); expose `{"waited_seconds": float}` to context +8. Routes evaluated via `Router` using Jinja2 or simpleeval expressions +9. Final output built from templates in `output:` section ### Key Patterns diff --git a/CHANGELOG.md b/CHANGELOG.md index 101f89c5..487a98a7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,34 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased](https://github.com/microsoft/conductor/compare/v0.1.17...HEAD) +### Added +- New `type: wait` workflow step that pauses execution for a parsed + duration via in-process `asyncio.sleep`. Cross-platform — no shell + `sleep` dependency. Use for rate-limit cooldowns, polling intervals, + external-system catch-up, and demos. The `duration:` field accepts + plain numbers (seconds), suffixed strings (`"500ms"`, `"60s"`, + `"2.5m"`, `"1h"`), or a Jinja2 template that renders to one of + those (e.g. `"{{ workflow.input.poll_interval }}s"`). Schema enforces + `0 < duration <= 24h` and rejects boolean values pre-coercion. + `Esc` / `Ctrl+G` cancels in-progress waits immediately (the engine + races the sleep against the interrupt event), and the workflow-level + `limits.timeout_seconds` also cancels them. Wait steps emit + `wait_started` / `wait_completed` / `wait_failed` events alongside + the generic `agent_started` (with `agent_type: "wait"`), so existing + dashboards keyed on agent lifecycle pick them up automatically. The + dashboard adds a dedicated `WaitNode` (clock icon) and `WaitDetail` + panel that show the requested duration, actual elapsed time, reason, + and an "interrupted" indicator. The public output contract is strict + — only `{"waited_seconds": float}` is exposed to workflow context; + extra metadata lives in event payloads. Wait steps count toward + `limits.max_iterations` (each pause is one step) but are not subject + to `max_agent_iterations` (per-LLM-agent tool counter). Wait cannot + be used inside `parallel` or `for_each` groups. New `examples/wait-step.yaml` + demonstrates a polling pattern with a templated poll interval and + route loop-back + ([#224](https://github.com/microsoft/conductor/pull/224), + closes [#218](https://github.com/microsoft/conductor/issues/218)). + ## [0.1.17](https://github.com/microsoft/conductor/compare/v0.1.16...v0.1.17) - 2026-05-21 ### Added diff --git a/README.md b/README.md index 6175ffb8..a36b17d9 100644 --- a/README.md +++ b/README.md @@ -300,6 +300,7 @@ See the [`examples/`](./examples/) directory for complete workflows: | [parallel-research.yaml](./examples/parallel-research.yaml) | Static parallel execution | | [design-review.yaml](./examples/design-review.yaml) | Human gate with loop pattern | | [script-step.yaml](./examples/script-step.yaml) | Script step with exit_code routing | +| [wait-step.yaml](./examples/wait-step.yaml) | Wait step + script for a polling loop-back pattern | **More examples and running instructions:** [examples/README.md](./examples/README.md) diff --git a/docs/configuration.md b/docs/configuration.md index 679469b4..4a0cecab 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -159,8 +159,8 @@ agents: Per-agent overrides always win over the workflow-wide default. The `reasoning.effort` field is **only** valid on standard `agent`-type agents; it -is rejected on `script`, `human_gate`, and `workflow` agents (which do not call -a model). +is rejected on `script`, `human_gate`, `workflow`, and `wait` agents (which do +not call a model). ### Per-provider translation diff --git a/docs/workflow-syntax.md b/docs/workflow-syntax.md index a713243e..93425aba 100644 --- a/docs/workflow-syntax.md +++ b/docs/workflow-syntax.md @@ -75,7 +75,7 @@ Agents are defined in the `agents` list. Each agent represents a unit of work. agents: - name: string # Required: Unique agent identifier description: string # Optional: Purpose description - type: agent # agent | human_gate | script | workflow (default: agent) + type: agent # agent | human_gate | script | workflow | wait (default: agent) model: string # Optional: Model identifier (e.g., 'claude-sonnet-4.5') prompt: | # Required for type=agent: Agent instructions @@ -281,6 +281,71 @@ routes: **Environment variable note** — values in `env` are passed as-is to the subprocess (they are not rendered as Jinja2 templates). Use `${VAR}` syntax in the workflow YAML loader if you need environment variable substitution in env values. +### Wait Steps + +Wait steps pause workflow execution for a parsed duration via in-process `asyncio.sleep`. Use them for rate-limit cooldowns, polling intervals, and external-system catch-up — cross-platform, no shell `sleep` dependency. + +```yaml +agents: + - name: cooldown + type: wait + description: "Cool down between API bursts" # Optional + duration: 60s # Required: see "Duration format" below + reason: "Avoiding rate limit" # Optional: shown in dashboard + routes: + - to: next_step +``` + +**Duration format** — `duration` accepts: + +- A plain `int` or `float` (seconds): `duration: 60`, `duration: 1.5`. +- A string with a unit suffix: `ms` (milliseconds), `s` (seconds), `m` (minutes), `h` (hours). Examples: `"500ms"`, `"60s"`, `"2.5m"`, `"1h"`. +- A Jinja2 template that renders to one of the above. Templated durations defer literal validation to runtime: + + ```yaml + duration: "{{ workflow.input.poll_interval_seconds }}s" + ``` + +The resolved duration must be **greater than 0 and no more than 24 hours** (`86400s`). Longer pauses should reconsider `workflow.limits.timeout_seconds` first. + +**Output structure** — wait step output is strict — only `waited_seconds` is exposed: + +| Field | Type | Description | +|-------|------|-------------| +| `waited_seconds` | `number` | Wall-clock seconds actually slept (may be less than requested on interrupt) | + +Access in templates: `{{ cooldown.output.waited_seconds }}`. + +**Polling pattern** — wait composes with routing loop-backs to build polling workflows without writing any Python: + +```yaml +agents: + - name: check_status + type: script + command: ./poll-status.sh + routes: + - to: process_result + when: "status == 'ready'" + - to: wait_then_retry + + - name: wait_then_retry + type: wait + duration: "{{ workflow.input.poll_interval_seconds }}s" + routes: + - to: check_status # loop back + + - name: process_result + # ... +``` + +**Cancellation** — `Esc` / `Ctrl+G` cancels an in-progress wait immediately (the engine races the sleep against the interrupt event). The workflow-level `limits.timeout_seconds` also cancels in-flight waits via the standard timeout path. + +**Iteration counting** — wait steps count toward `workflow.limits.max_iterations` (each pause is one step). They are not subject to `max_agent_iterations`, which counts per-LLM-agent tool iterations. + +**Restrictions** — wait steps cannot have `prompt`, `model`, `provider`, `tools`, `system_prompt`, `options`, `command`, `args`, `env`, `working_dir`, `timeout`, `workflow`, `input_mapping`, `max_depth`, `max_session_seconds`, `max_agent_iterations`, `retry`, `dialog`, `reasoning`, `timeout_seconds`, or `output`. Wait steps also cannot be used inside `parallel` groups or `for_each` groups. + +See [`examples/wait-step.yaml`](../examples/wait-step.yaml) for a complete polling workflow. + ### Sub-Workflow Steps Sub-workflow steps reference external workflow YAML files, enabling composable and reusable workflow building blocks. The sub-workflow runs as a black box — its internal agents are not visible to the parent. @@ -401,7 +466,7 @@ After the conversation, the agent re-executes with the dialog transcript as addi | `dialog.trigger_prompt` | string | Yes | Criteria for the LLM evaluator to decide when dialog is needed | **Behavior notes:** -- Dialog is supported on regular `agent` type only (not `human_gate`, `script`, or `workflow`) +- Dialog is supported on regular `agent` type only (not `human_gate`, `script`, `workflow`, or `wait`) - In web dashboard mode, the dialog temporarily replaces the graph area with a chat interface - When `--skip-gates` is set (e.g., CI/automation), dialogs are automatically skipped - The evaluator prompt should describe *when* to trigger dialog, not *what* to ask — the evaluator generates the opening question from the agent's output context @@ -695,6 +760,7 @@ workflow: - Each agent execution counts as 1 iteration - Parallel agents count individually (3 parallel agents = 3 iterations) - Loop-back patterns increment the counter on each iteration +- Script steps and wait steps each count as 1 iteration ### Timeout Behavior diff --git a/examples/README.md b/examples/README.md index 254a9cc7..ff011333 100644 --- a/examples/README.md +++ b/examples/README.md @@ -128,6 +128,34 @@ Research workflow demonstrating multi-provider patterns. Demonstrates: conductor run examples/multi-provider-research.yaml --input topic="Cloud computing" ``` +## Step Types + +### script-step.yaml + +Script step with shell command, JSON output parsing, and `exit_code`-based routing. +Demonstrates: +- `type: script` agents (cross-platform shell command execution) +- Capturing stdout/stderr/exit_code +- Routing on `exit_code` (`when: "exit_code == 0"`) +- Passing script output to downstream LLM agents + +```bash +conductor run examples/script-step.yaml +``` + +### wait-step.yaml + +Polling pattern with a wait step and a routing loop-back. Demonstrates: +- `type: wait` agents (pure `asyncio.sleep`, cross-platform — no shell `sleep` dependency) +- Templated `duration` (`"{{ workflow.input.poll_interval_seconds }}s"`) +- Loop-back from wait → script for polling +- `reason` field surfaced in the dashboard + +```bash +conductor run examples/wait-step.yaml \ + --input poll_interval_seconds=2 --input max_attempts=3 +``` + ## Planning and Implementation ### plan.yaml diff --git a/plugins/conductor/skills/conductor/SKILL.md b/plugins/conductor/skills/conductor/SKILL.md index 76ee09fb..adc2ae33 100644 --- a/plugins/conductor/skills/conductor/SKILL.md +++ b/plugins/conductor/skills/conductor/SKILL.md @@ -99,6 +99,7 @@ For runtime config, context modes, limits, and cost tracking, see [references/au | `entry_point` | First agent/group to execute | | `routes` | Where agent goes next (`$end` to finish, `self` to loop) | | `type: script` | Shell command step (captures stdout, stderr, exit_code; JSON stdout is auto-merged) | +| `type: wait` | Pause via `asyncio.sleep` (cross-platform); duration accepts `Ns/Nm/Nh/Nms` or Jinja2; composes with route loop-backs for polling | | `type: workflow` | Sub-workflow agent — runs another YAML file as a black box (supports `input_mapping`, `max_depth`) | | `parallel` | Static parallel groups (fixed agent list) | | `for_each` | Dynamic parallel groups (runtime-determined array; supports `type: workflow` agents) | diff --git a/plugins/conductor/skills/conductor/references/authoring.md b/plugins/conductor/skills/conductor/references/authoring.md index 7ab76aaf..40fd8926 100644 --- a/plugins/conductor/skills/conductor/references/authoring.md +++ b/plugins/conductor/skills/conductor/references/authoring.md @@ -67,7 +67,7 @@ workflow: ```yaml agents: - name: my_agent # Required: unique identifier - type: agent # agent (default), human_gate, script, or workflow + type: agent # agent (default), human_gate, script, workflow, or wait description: What it does model: gpt-5.2 # Override workflow default provider: claude # Optional: per-agent provider override @@ -97,9 +97,9 @@ agents: timeout_seconds: 120 # Hard wall-clock cancellation for this agent (provider-backed only). # Engine wraps execution in asyncio.wait_for(); raises AgentTimeoutError. # Effective limit = min(timeout_seconds, remaining_workflow_timeout). - # Non-retryable. Forbidden on script/human_gate/workflow types. + # Non-retryable. Forbidden on script/human_gate/workflow/wait types. - retry: # Per-agent retry policy (optional, not allowed on script/human_gate/workflow) + retry: # Per-agent retry policy (optional, not allowed on script/human_gate/workflow/wait) max_attempts: 3 # 1-10, default 1 (no retry) backoff: exponential # exponential (default) or fixed delay_seconds: 2.0 # Base delay (0-300, default 2.0) @@ -127,7 +127,7 @@ agents: - **Copilot**: forwarded as `reasoning_effort` on the session. Validated against the model's advertised `supported_reasoning_efforts`; raises `ValidationError` for unsupported combinations (skipped in mock-handler mode or when capability metadata is absent). - **Claude**: enables extended thinking via `thinking={"type": "enabled", "budget_tokens": N}` with mapping `low=2048`, `medium=8192`, `high=16384`, `xhigh=32768`. Auto-coerces `temperature` to `1.0` (logged at INFO) and bumps `max_tokens` to fit `budget + 4096` (capped at 64000, logged at INFO when clamped). Only valid on thinking-capable models (`claude-3-7-*`, `claude-opus-4*`, `claude-sonnet-4*`, `claude-haiku-4*`); raises `ValidationError` otherwise. -Both providers surface reasoning content via `agent_reasoning` events visible in the dashboard, JSONL logs, and the console at `-vv`. Not allowed on `script`, `human_gate`, or `workflow` agent types. +Both providers surface reasoning content via `agent_reasoning` events visible in the dashboard, JSONL logs, and the console at `-vv`. Not allowed on `script`, `human_gate`, `workflow`, or `wait` agent types. ```yaml runtime: @@ -253,6 +253,72 @@ routes: Script agents **cannot** have: `prompt`, `provider`, `model`, `tools`, `output`, `system_prompt`, `options`, `retry`, `reasoning`, `dialog`, `max_session_seconds`, `max_agent_iterations`, `timeout_seconds` (use `timeout:` instead), `input_mapping`, or `max_depth`. Command and args support Jinja2 templating for dynamic values. +## Wait Steps (`type: wait`) + +Pause workflow execution for a parsed duration via in-process `asyncio.sleep`. Cross-platform — no shell `sleep` dependency. Use for rate-limit cooldowns, polling intervals, and external-system catch-up. + +```yaml +agents: + - name: cooldown + type: wait + description: Cool down between API bursts # Optional + duration: 60s # Required (see "Duration format") + reason: Avoiding rate limit # Optional, shown in dashboard + routes: + - to: next_call +``` + +### Duration Format + +- Plain `int`/`float` → seconds (e.g. `60`, `1.5`). +- Suffixed string: `ms`, `s`, `m`, `h` (e.g. `"500ms"`, `"60s"`, `"2.5m"`, `"1h"`). +- Jinja2 template rendering to one of the above (templates defer literal validation to runtime): + ```yaml + duration: "{{ workflow.input.poll_interval_seconds }}s" + ``` +- Must resolve to `> 0` and `≤ 86400s` (24h). Booleans are rejected. + +### Wait Output + +Strict — only one field: + +```jinja2 +{{ wait_name.output.waited_seconds }} # Actual seconds slept (may be < requested on interrupt) +``` + +### Polling Loop-back Pattern + +```yaml +agents: + - name: check_status + type: script + command: ./poll-status.sh + routes: + - to: process_result + when: "status == 'ready'" + - to: wait_then_retry + + - name: wait_then_retry + type: wait + duration: "{{ workflow.input.poll_interval_seconds }}s" + routes: + - to: check_status # loop back + + - name: process_result + # ... +``` + +### Wait Cancellation + +- `Esc` / `Ctrl+G` cancels in-progress waits immediately (the engine races the sleep against the interrupt event). +- Workflow-level `limits.timeout_seconds` cancels in-flight waits via the standard timeout path. + +### Wait Restrictions + +Wait agents **cannot** have: `prompt`, `model`, `provider`, `tools`, `system_prompt`, `options`, `command`, `args`, `env`, `working_dir`, `timeout`, `workflow`, `input_mapping`, `max_depth`, `max_session_seconds`, `max_agent_iterations`, `retry`, `dialog`, `reasoning`, `timeout_seconds`, or `output`. They also cannot be used inside `parallel` groups or `for_each` groups. + +See `examples/wait-step.yaml` for a complete polling workflow. + ## Sub-Workflow Agents (`type: workflow`) Reference an external workflow YAML file as a black-box step. The sub-workflow runs with its own engine and inherits the parent's provider configuration. @@ -323,7 +389,7 @@ agents: - to: writer ``` -Only valid on provider-backed agents (not `script`, `human_gate`, or `workflow`). See `examples/dialog-mode.yaml` for a complete example. +Only valid on provider-backed agents (not `script`, `human_gate`, `workflow`, or `wait`). See `examples/dialog-mode.yaml` for a complete example. ## Workflow Metadata and Workspace Instructions diff --git a/plugins/conductor/skills/conductor/references/yaml-schema.md b/plugins/conductor/skills/conductor/references/yaml-schema.md index a2be3bf2..a00ea82e 100644 --- a/plugins/conductor/skills/conductor/references/yaml-schema.md +++ b/plugins/conductor/skills/conductor/references/yaml-schema.md @@ -103,7 +103,7 @@ agents: name: string # Unique agent identifier # Optional fields - type: string # "agent" (default), "human_gate", "script", or "workflow" + type: string # "agent" (default), "human_gate", "script", "workflow", or "wait" description: string # What this agent does model: string # Override default_model provider: string # Per-agent provider override ("copilot" or "claude") @@ -145,14 +145,14 @@ agents: timeout_seconds: float # Hard wall-clock timeout (>=1.0); engine wraps in asyncio.wait_for(). # Effective limit = min(timeout_seconds, remaining_workflow_timeout). # Raises AgentTimeoutError; non-retryable. - # Forbidden on script (use 'timeout' instead), human_gate, workflow. + # Forbidden on script (use 'timeout' instead), human_gate, workflow, wait. # Per-agent reasoning effort (overrides runtime.default_reasoning_effort) - # Not allowed for script, human_gate, or workflow agent types. + # Not allowed for script, human_gate, workflow, or wait agent types. reasoning: effort: string # low, medium, high, or xhigh - # Per-agent retry policy (optional, not allowed for script, human_gate, or workflow agents) + # Per-agent retry policy (optional, not allowed for script, human_gate, workflow, or wait agents) retry: max_attempts: integer # Max attempts including first (1-10, default: 1 = no retry) backoff: string # "exponential" (default) or "fixed" @@ -190,7 +190,7 @@ agents: Both providers continue to surface reasoning content via `agent_reasoning` events visible in the dashboard, JSONL logs, and console at `-vv`. -Forbidden on agent types: `script`, `human_gate`, `workflow`. +Forbidden on agent types: `script`, `human_gate`, `workflow`, `wait`. ## Script Agent Schema @@ -222,6 +222,48 @@ Script agents always produce: {{ script_name.output.exit_code }} # Process exit code (0 = success) ``` +## Wait Agent Schema + +Wait agents pause workflow execution for a parsed duration via in-process `asyncio.sleep`. Cross-platform — no shell `sleep` dependency. Use for rate-limit cooldowns, polling intervals, and external-system catch-up. + +```yaml +agents: + - name: string + type: wait # Required + description: string # Optional + duration: string | number # Required: see "Duration format" below + reason: string # Optional: human-readable reason (shown in dashboard) + input: [string] # Optional: context dependencies + routes: # Required: routing rules + - to: string + when: string # May reference waited_seconds +``` + +### Duration Format + +`duration` accepts: + +- A plain `int` or `float` (interpreted as seconds): `duration: 60`, `duration: 1.5` +- A string with a unit suffix — `ms`, `s`, `m`, `h`: `"500ms"`, `"60s"`, `"2.5m"`, `"1h"` +- A Jinja2 template rendering to one of the above: `"{{ workflow.input.interval }}s"` + (templates defer literal validation to runtime) + +The resolved duration must be **> 0 and ≤ 24h** (`86400s`). Booleans are rejected. + +### Wait Output + +Wait agents produce a single, strict field: + +```jinja2 +{{ wait_name.output.waited_seconds }} # Actual seconds slept (may be < requested on interrupt) +``` + +### Wait Restrictions + +Forbidden fields: `prompt`, `model`, `provider`, `tools`, `system_prompt`, `options`, `command`, `args`, `env`, `working_dir`, `timeout`, `workflow`, `input_mapping`, `max_depth`, `max_session_seconds`, `max_agent_iterations`, `retry`, `dialog`, `reasoning`, `timeout_seconds`, `output`. Wait steps cannot be used inside `parallel` or `for_each` groups. + +`Esc` / `Ctrl+G` cancels in-progress waits. Workflow-level `limits.timeout_seconds` also cancels them. + ## File Includes (`!file` Tag) Include external file content anywhere in YAML: @@ -551,12 +593,14 @@ runtime: - All route targets must be valid agent names, group names, `$end`, or `self` - `when` conditions must be valid Jinja2 expressions - `human_gate` agents require `options` and `prompt` +- `wait` agents require `duration`; literal values must be `> 0` and `≤ 86400s` (24h) ### Parallel Group Validation - Must contain at least 2 agents - All referenced agents must exist - Route targets must be valid +- `script`, `workflow`, and `wait` steps cannot be used inside parallel groups ### For-Each Validation @@ -564,6 +608,7 @@ runtime: - `as` must be a valid Python identifier, not a reserved name - `max_concurrent` must be 1-100 - Nested for-each groups are not allowed +- `script` and `wait` steps cannot be used as inline agents in for-each groups ### Routing Validation